Compley dynamic routes?
Unanswered
Singapura posted this in #help-forum
SingapuraOP
When we began building our website, it was expected that it would always be a
site.com/category_slug/product_slug
and our current routing looks like this:
However now we have to support an arbitrary number of dynamic routes
Eg. it might be site.com/europe/germany/berlin
or site.com/europe/germany/berlin/cycling-around-berlin
etc. with each of those routes having their own content which would display products.
but then if you click on a product it would go back to the old URL structure: site.com/cycling/berling-cycling
How do you even go about this? I am aware of [..slug] but then what is a clean way of handling and differentiating all of the different types of content that could be on the same route?
is having one [..slug]/layout.tsx
and then in it
if (type==product_page)
return /[..slug]/(product_layout)/layout.tsx page.tsx
the way to go?
site.com/category_slug/product_slug
and our current routing looks like this:
├── [category]
│ ├── (no_layout)
│ │ └── [product]
│ │ ├── layout.tsx
│ │ └── page.tsx
│ └── (with_layout)
│ ├── layout.tsx
│ └── page.tsx
├── layout.tsx
└── page.tsxHowever now we have to support an arbitrary number of dynamic routes
Eg. it might be site.com/europe/germany/berlin
or site.com/europe/germany/berlin/cycling-around-berlin
etc. with each of those routes having their own content which would display products.
but then if you click on a product it would go back to the old URL structure: site.com/cycling/berling-cycling
How do you even go about this? I am aware of [..slug] but then what is a clean way of handling and differentiating all of the different types of content that could be on the same route?
is having one [..slug]/layout.tsx
and then in it
if (type==product_page)
return /[..slug]/(product_layout)/layout.tsx page.tsx
the way to go?