mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-08-25 13:51:15 +00:00
update
This commit is contained in:
@@ -3,30 +3,21 @@ import path from "path"
|
||||
import { remark } from "remark"
|
||||
import html from "remark-html"
|
||||
|
||||
// Function to retrieve the guide content based on the slug
|
||||
async function getGuideContent(slug: string) {
|
||||
// Adjusted to look inside the correct 'guides' folder at the root level of the project
|
||||
const guidePath = path.join(process.cwd(), "..", "guides", slug, "index.md") // Corrected to look in the root directory
|
||||
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()
|
||||
}
|
||||
|
||||
// Function to generate static paths for all available guides
|
||||
export async function generateStaticParams() {
|
||||
// Adjusted to look in the correct 'guides' folder at the root level of the project
|
||||
const guidesPath = path.join(process.cwd(), "..", "guides")
|
||||
const guideFolders = fs.readdirSync(guidesPath, { withFileTypes: true }) // Read only directories
|
||||
|
||||
return guideFolders
|
||||
.filter((folder) => folder.isDirectory()) // Ensure it's a directory
|
||||
.map((folder) => ({
|
||||
slug: folder.name, // Use the folder name as slug
|
||||
}))
|
||||
const guideFiles = fs.readdirSync(path.join(process.cwd(), "guides"))
|
||||
return guideFiles.map((file) => ({
|
||||
slug: file.replace(/\.md$/, ""),
|
||||
}))
|
||||
}
|
||||
|
||||
// Page component to render a guide based on its slug
|
||||
export default async function GuidePage({ params }: { params: { slug: string } }) {
|
||||
const guideContent = await getGuideContent(params.slug)
|
||||
|
||||
@@ -36,3 +27,4 @@ export default async function GuidePage({ params }: { params: { slug: string } }
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user