Next.js Discord

Discord Forum

Dynamic routing with empty slug

Unanswered
American Sable posted this in #help-forum
Open in Discord
American SableOP
Generate paths with one of the slug being empty so it matches /

3 Replies

American SableOP
I want basically do this:
export async function generateStaticParams() {
    return [{ lang: "en" }, { lang: "fr" }, { lang: undefined }];


My structure is
app
- [lang]
- second

I want to create
- /
- /second
- /en
- /en/second
- /fr
- /fr/second

Note this is a static export (output: export)
But building results in:

I'm missing / and /second
Tried catch all and optional catch all, but you have to have it as the last item :/