dentonzh/Eggspress

Cannot load posts where source Markdown file is in a subdirectory

Closed this issue · 1 comments

There is an issue that prevents Markdown files stored in a subdirectory of @/posts/ from building.

@/posts/this-post.md will build
@/posts/some-directory/nested-post.md will not

This results in a 500 error when navigating to a page for nested-post.md.

The culprit is likely a call made to getPostSlugs() from the generateStaticParams() function in our dynamic route for blog pages.

Changing the line:
const files = fs.readdirSync(dir)

to:
const files = await getFilesRecursively(dir)

And refactoring the rest of this function to make use conventions in getFilesRecursively should fix this issue.