Update page.tsx

This commit is contained in:
MacRimi 2025-02-14 10:42:55 +01:00 committed by GitHub
parent 9d27944fbb
commit 82568dfa11
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4,7 +4,7 @@ import { remark } from "remark"
import html from "remark-html" import html from "remark-html"
async function getGuideContent(slug: string) { async function getGuideContent(slug: string) {
const guidePath = path.join(process.cwd(), "guides", `${slug}.md`) const guidePath = path.join(process.cwd(), "..", "..", "guides", `${slug}.md`)
const fileContents = fs.readFileSync(guidePath, "utf8") const fileContents = fs.readFileSync(guidePath, "utf8")
const result = await remark().use(html).process(fileContents) const result = await remark().use(html).process(fileContents)
@ -12,7 +12,8 @@ async function getGuideContent(slug: string) {
} }
export async function generateStaticParams() { export async function generateStaticParams() {
const guideFiles = fs.readdirSync(path.join(process.cwd(), "guides")) const guidesPath = path.join(process.cwd(), "..", "..", "guides")
const guideFiles = fs.readdirSync(guidesPath)
return guideFiles.map((file) => ({ return guideFiles.map((file) => ({
slug: file.replace(/\.md$/, ""), slug: file.replace(/\.md$/, ""),
})) }))
@ -23,7 +24,7 @@ export default async function GuidePage({ params }: { params: { slug: string } }
return ( return (
<div className="container mx-auto px-4 py-16 max-w-3xl"> <div className="container mx-auto px-4 py-16 max-w-3xl">
<div className="prose prose-lg dark:prose-invert" dangerouslySetInnerHTML={{ __html: guideContent }} /> <div className="prose prose-lg" dangerouslySetInnerHTML={{ __html: guideContent }} />
</div> </div>
) )
} }