Update page.tsx

This commit is contained in:
MacRimi 2025-02-14 18:11:45 +01:00 committed by GitHub
parent a50af2f493
commit b43b0ae19b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3,11 +3,29 @@ import path from "path"
import { remark } from "remark"
import html from "remark-html"
function markdownToHtml(markdown) {
return markdown
.replace(/^### (.*$)/gim, "<h3>$1</h3>") // Convertir ### en <h3>
.replace(/^## (.*$)/gim, "<h2>$1</h2>") // Convertir ## en <h2>
.replace(/^# (.*$)/gim, "<h1>$1</h1>") // Convertir # en <h1>
.replace(/\*\*(.*?)\*\*/gim, "<b>$1</b>") // Convertir **negrita** en <b>
.replace(/\*(.*?)\*/gim, "<i>$1</i>") // Convertir *cursiva* en <i>
.replace(/`(.*?)`/gim, "<code>$1</code>") // Convertir `código` en <code>
.replace(/^- (.*$)/gim, "<ul><li>$1</li></ul>") // Convertir listas en <ul>
.replace(/\n/g, "<br />") // Mantener los saltos de línea
}
async function getChangelog() {
const changelogPath = path.join(process.cwd(), "..", "CHANGELOG.md")
try {
const fileContents = fs.readFileSync(changelogPath, "utf8")
const result = await remark().use(html).process(fileContents)
// Convertimos Markdown a HTML manualmente
const formattedContent = markdownToHtml(fileContents)
// Usamos remark-html como último paso
const result = await remark().use(html).process(formattedContent)
return result.toString()
} catch (error) {
console.error("Error reading changelog file:", error)
@ -22,7 +40,7 @@ export default async function ChangelogPage() {
<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>
<div className="prose prose-lg" dangerouslySetInnerHTML={{ __html: changelogContent }} />
<div className="prose prose-lg max-w-none" dangerouslySetInnerHTML={{ __html: changelogContent }} />
</div>
</div>
)