I’ve got about 8 categories of detail pages, half of which are detail pages, the other half are editorial pages. The data for these 2 page types is entirely different, and nesting one route in a subfolder is not an option.
pages/[detailPageCategory]/[slug].js
pages/[editorialPageCategory]/[slug].js
Ideally I’d create separate page components for both to separate concerns but Nextjs cannot handle two dynamic routes one the same level.
pages/[pageType]/[slug].js
Would the best idea be to handle both routes in a single dynamic route? This feels unclean, since both pages are bundled together, and I'll need to pass a prop to the page pageType={layout1|layout2} and handle both cases within the page component, not separating concerns.
const DynamicRoutePage = ({ pageType, data }) => {
if (pageType === "detail") {
return (
<DetailPage {...data} />
)
}
if (pageType === "editorial") {
return (
<EditorialPage {...data} />
)
}
return null
}
Are there best practices of how to approach this? Perhaps Next’s ‘getLayout’ function?