This commit is contained in:
MacRimi
2025-02-13 23:04:40 +01:00
parent a9a89b5b46
commit 990b2bf7de
137 changed files with 7536 additions and 219 deletions

View File

@@ -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>
)
}