2025-02-13 17:28:49 +01:00
|
|
|
import fs from "fs"
|
|
|
|
import path from "path"
|
|
|
|
import { remark } from "remark"
|
|
|
|
import html from "remark-html"
|
|
|
|
|
|
|
|
async function getGuideContent(slug: string) {
|
2025-02-14 10:42:55 +01:00
|
|
|
const guidePath = path.join(process.cwd(), "..", "..", "guides", `${slug}.md`)
|
2025-02-13 17:28:49 +01:00
|
|
|
const fileContents = fs.readFileSync(guidePath, "utf8")
|
|
|
|
|
|
|
|
const result = await remark().use(html).process(fileContents)
|
|
|
|
return result.toString()
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function generateStaticParams() {
|
2025-02-14 10:42:55 +01:00
|
|
|
const guidesPath = path.join(process.cwd(), "..", "..", "guides")
|
|
|
|
const guideFiles = fs.readdirSync(guidesPath)
|
2025-02-13 23:04:40 +01:00
|
|
|
return guideFiles.map((file) => ({
|
|
|
|
slug: file.replace(/\.md$/, ""),
|
|
|
|
}))
|
2025-02-13 17:28:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export default async function GuidePage({ params }: { params: { slug: string } }) {
|
|
|
|
const guideContent = await getGuideContent(params.slug)
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="container mx-auto px-4 py-16 max-w-3xl">
|
2025-02-14 10:42:55 +01:00
|
|
|
<div className="prose prose-lg" dangerouslySetInnerHTML={{ __html: guideContent }} />
|
2025-02-13 17:28:49 +01:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
2025-02-13 23:04:40 +01:00
|
|
|
|