48 lines
1.5 KiB
TypeScript
Raw Normal View History

2025-02-13 23:04:40 +01:00
import fs from "fs"
import path from "path"
import { remark } from "remark"
import html from "remark-html"
2025-02-14 18:14:16 +01:00
function markdownToHtml(markdown: string): string {
2025-02-14 18:11:45 +01:00
return markdown
2025-02-14 18:14:16 +01:00
.replace(/^### (.*$)/gim, "<h3>$1</h3>")
.replace(/^## (.*$)/gim, "<h2>$1</h2>")
.replace(/^# (.*$)/gim, "<h1>$1</h1>")
.replace(/\*\*(.*?)\*\*/gim, "<b>$1</b>")
.replace(/\*(.*?)\*/gim, "<i>$1</i>")
.replace(/`(.*?)`/gim, "<code>$1</code>")
.replace(/^- (.*$)/gim, "<ul><li>$1</li></ul>")
.replace(/\n/g, "<br />");
2025-02-14 18:11:45 +01:00
}
2025-02-13 23:04:40 +01:00
async function getChangelog() {
2025-02-14 17:31:44 +01:00
const changelogPath = path.join(process.cwd(), "..", "CHANGELOG.md")
2025-02-14 17:54:52 +01:00
try {
const fileContents = fs.readFileSync(changelogPath, "utf8")
2025-02-14 18:11:45 +01:00
// Convertimos Markdown a HTML manualmente
const formattedContent = markdownToHtml(fileContents)
// Usamos remark-html como último paso
const result = await remark().use(html).process(formattedContent)
2025-02-14 17:54:52 +01:00
return result.toString()
} catch (error) {
console.error("Error reading changelog file:", error)
return "<p>Changelog content not found.</p>"
}
2025-02-13 23:04:40 +01:00
}
export default async function ChangelogPage() {
const changelogContent = await getChangelog()
2025-02-14 12:24:18 +01:00
return (
2025-02-14 17:54:52 +01:00
<div className="bg-white text-gray-900">
<div className="container mx-auto px-4 py-16 max-w-4xl">
<h1 className="text-4xl font-bold mb-8">Changelog</h1>
2025-02-14 18:11:45 +01:00
<div className="prose prose-lg max-w-none" dangerouslySetInnerHTML={{ __html: changelogContent }} />
2025-02-14 17:54:52 +01:00
</div>
2025-02-13 23:04:40 +01:00
</div>
)
2025-02-14 17:09:21 +01:00
}