mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-08-25 13:51:15 +00:00
start web
This commit is contained in:
30
web/app/guides/[slug]/page.tsx
Normal file
30
web/app/guides/[slug]/page.tsx
Normal file
@@ -0,0 +1,30 @@
|
||||
import fs from "fs"
|
||||
import path from "path"
|
||||
import { remark } from "remark"
|
||||
import html from "remark-html"
|
||||
|
||||
async function getGuideContent(slug: string) {
|
||||
const guidePath = path.join(process.cwd(), "guides", `${slug}.md`)
|
||||
const fileContents = fs.readFileSync(guidePath, "utf8")
|
||||
|
||||
const result = await remark().use(html).process(fileContents)
|
||||
return result.toString()
|
||||
}
|
||||
|
||||
export async function generateStaticParams() {
|
||||
const guideFiles = fs.readdirSync(path.join(process.cwd(), "guides"))
|
||||
return guideFiles.map((file) => ({
|
||||
slug: file.replace(/\.md$/, ""),
|
||||
}))
|
||||
}
|
||||
|
||||
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">
|
||||
<div className="prose prose-lg dark:prose-invert" dangerouslySetInnerHTML={{ __html: guideContent }} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
Reference in New Issue
Block a user