Problem of unknown routing #12899
-
Hey, Lets say I use a CMS for resolving slugs before I know the pagetype that should be rendered. For example if a user comes it to /en/newspage, and I fetch my CMS for the slug and it returns a pageType property that I need to render like below:
There is no way for me to build up a parameterized routingtable at runtime before resolving a route. So my general question is if NextJS has a feature for this or what the best approach would be. One approach that comes to my mind is to only use the index page and fetch the slug from there and conditionally render my pagecomponent myself, is there a better way? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
I'm not sure that architecture is the best approach. Could you have a specific API for the newspage instead of looping multiple pages into the same API endpoint? For example, |
Beta Was this translation helpful? Give feedback.
I'm not sure that architecture is the best approach. Could you have a specific API for the newspage instead of looping multiple pages into the same API endpoint?
For example,
pages/en/newspage/[page].js
would render all of the news pages and would be able to share that samenewsapge
layout. Then, it could fetch information from your CMS ingetStaticProps
/getStaticPaths
to build out all of the individual news pages.