Open dohomi opened 3 years ago
Hello,
I think for micro optimization it would be better to merge index, [slug] and [...slug] into one file:
[[...index]].jsx // or [[...index]].tsx
NextJS handles double square brackets as catch all route and you can merge all content into one file rather than keeping 3 separate files
Now the only adjustment to make is inside getStaticProps
export getStaticProps: GetStaticProps<AppPageProps> = async (props) => { const { params, preview, previewData, locale, locales, defaultLocale } = props const slug = params?.index?.length ? params.index !== 'index' ? params.index : 'home' : 'home' (...) // all other content
Thanks, I merged [slug] into [...slug]. But will keep index.js for now, to have a static page example that is not using catch-all routes.
index.js
Hello,
I think for micro optimization it would be better to merge index, [slug] and [...slug] into one file:
NextJS handles double square brackets as catch all route and you can merge all content into one file rather than keeping 3 separate files
Now the only adjustment to make is inside getStaticProps