Update page.tsx

This commit is contained in:
MacRimi 2025-02-13 21:50:19 +01:00 committed by GitHub
parent ec29e76dbb
commit 7affb5f4e8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5,7 +5,8 @@ import html from "remark-html"
// Function to retrieve the guide content based on the slug
async function getGuideContent(slug: string) {
const guidePath = path.join(process.cwd(), "guides", slug, "index.md") // Adjusted to look inside a folder
// 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 fileContents = fs.readFileSync(guidePath, "utf8")
const result = await remark().use(html).process(fileContents)
@ -14,7 +15,8 @@ async function getGuideContent(slug: string) {
// Function to generate static paths for all available guides
export async function generateStaticParams() {
const guidesPath = path.join(process.cwd(), "guides")
// 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
@ -34,5 +36,3 @@ export default async function GuidePage({ params }: { params: { slug: string } }
</div>
)
}