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"
|
2025-02-14 10:46:02 +01:00
|
|
|
|
2025-02-13 17:28:49 +01:00
|
|
|
async function getGuideContent(slug: string) {
|
2025-02-15 12:56:14 +01:00
|
|
|
const guidePath = path.join(process.cwd(), "..", "guides", `${slug}.md`)
|
|
|
|
const fileContents = fs.readFileSync(guidePath, "utf8")
|
2025-02-13 17:28:49 +01:00
|
|
|
|
2025-02-15 12:56:14 +01:00
|
|
|
const result = await remark().use(html).process(fileContents)
|
|
|
|
return result.toString()
|
2025-02-13 17:28:49 +01:00
|
|
|
}
|
|
|
|
|
2025-02-15 12:56:14 +01:00
|
|
|
export async function generateStaticParams() {
|
|
|
|
const guideFiles = fs.readdirSync(path.join(process.cwd(), "..", "guides"))
|
|
|
|
return guideFiles.map((file) => ({
|
|
|
|
slug: file.replace(/\.md$/, ""),
|
|
|
|
}))
|
2025-02-15 12:40:28 +01:00
|
|
|
}
|
|
|
|
|
2025-02-15 11:54:33 +01:00
|
|
|
export default async function GuidePage({ params }: { params: { slug: string } }) {
|
2025-02-15 12:56:14 +01:00
|
|
|
const guideContent = await getGuideContent(params.slug)
|
2025-02-13 23:04:40 +01:00
|
|
|
|
2025-02-14 11:05:58 +01:00
|
|
|
return (
|
2025-02-15 13:11:44 +01:00
|
|
|
<div className="min-h-screen bg-white text-gray-900">
|
|
|
|
<div className="container mx-auto px-4 py-16 max-w-3xl">
|
|
|
|
<div
|
|
|
|
className="prose prose-lg max-w-none prose-pre:bg-gray-100 prose-pre:text-gray-900 prose-headings:text-gray-900 prose-p:text-gray-800"
|
|
|
|
dangerouslySetInnerHTML={{ __html: guideContent }}
|
|
|
|
/>
|
|
|
|
</div>
|
2025-02-14 11:05:58 +01:00
|
|
|
</div>
|
|
|
|
)
|
2025-02-15 12:22:29 +01:00
|
|
|
}
|
|
|
|
|