Content doesn't renders statically when using Catch all routes
combining with lazy imports
#221
Replies: 2 comments 4 replies
-
Hey, |
Beta Was this translation helpful? Give feedback.
-
I think we can actually mimic the desired functionality. |
Beta Was this translation helpful? Give feedback.
-
Hello there,
I'm migrating a blog that uses Jekyll as the SSG to Flareact. I'm having difficulties handling dynamic routes when applying
catch-all routes
to keep the same url structure we have now.For example, now we have the current structures:
The issue comes from handling the
post
andcategory
pages. For what I understood reading the documentation when I have multiple routes the correct way is to create a[...cathAll].tsx
file. So my folder structure is/pages/[lang]/blog/[...slug].tsx
.category
andpost
pages use different components, so when the functiongetEdgeProps
runs, I have to first check whether the route is category or post and then fetch its content.For handling the render of the components, I thought about using the
react.lazy
import (https://reactjs.org/docs/code-splitting.html). But I notice that after implementing it, the page stopped rendering the HTML statically but started to bring only a JSON script in its source code.Is there a way to have this kind of dynamic routing splitting the code and keeping the content rendered server-side?
This is just a sample test I was developing as a proof of concept. If the route has
/blog
, it should renderFooter
component.And the page source looks as follows:
Beta Was this translation helpful? Give feedback.
All reactions