Skip to content

merge index and slug routes into one file #12

@dohomi

Description

@dohomi

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 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions