-1

i am working dynamic routing in next j s,and folder structure is like

pages:
_app.j s
index.j s

main_Page:
  cart:
    [...cart_Component.j s]
  about:
    [...about_Component.j s]
  [[...index]].j s

and here my [[...index]].j s file is dynamic and i need to show all countries data until any country selected from header drop down and after need to show the data based on selected country in [[...index]].j s,so have taken it as dynamic from index.j s =>[[...index]].j s

but my problem is when i want to go to cart from home,i am writing like this

Router.push(`/main_Page/${this.state.country_Name}/cart/${cart_Name}`)

it is not navigating to cart page stayed in [[...index]].j s,so i have renamed cart as [cart] then i was able to go to cart,but my problem is when i want navigate to about page i have renamed it also like [about] it throws an error like

error: you cannot use different slug names for the same dynamic path

when i am routing to any page it's going to [cart] page,please help

  • 1
    The folder structure you have would expect a URL like `/main_Page/cart/${cart_Name}` to match the `cart` route. If you want the country name in there you need to account for it in the folder structure. – juliomalves Jan 04 '22 at 09:19

1 Answers1

-1

i have changed my folder structure to

pages:
_app.j s
index.j s

[main_Page]:
  cart:
    [...cart_Component.j s]
  about:
    [...about_Component.j s]
  [[...index]].j s

with country:

Router.push(`/${this.state.country_Name}/cart/${cart_Name}`)

without country:

Router.push(`/main_Page/cart/${cart_Name}`)