How to dynamically prerender blog post routes from MDX files? #13849
Unanswered
nikolailehbrink
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there,
I’m building a blog with React Router 7 and using MDX files for my posts. I want to prerender all my blog post routes, but I don’t want to manually update the
prerender
array in my config every time I add a new post.Currently, my posts are loaded dynamically at runtime using the following
getPosts()
function:But for prerendering, I need to list all the routes in the
prerender
array in myreact-router.config.ts
:I tried importing the post slugs dynamically using the same
getPosts()
function:However I get the following error:
I understand this is because the config runs before the virtual modules are available, but my question is:
Is there a way to dynamically generate the
prerender
array from my MDX files, or do I have to keep this list in sync manually?Beta Was this translation helpful? Give feedback.
All reactions