fridays / next-routes

Universal dynamic routes for Next.js
MIT License
2.47k stars 230 forks source link

Question about .pushRouter() #55

Closed khorolets closed 7 years ago

khorolets commented 7 years ago

Hi! Thanks for your work!

I have a question about .pushRouter() method.

In my routes I have something like:

routes.add('users', '/people/:username/:page', 'index')

And when I do

Router.pushRouter("users", {username: 'nick', page: 'bio'})

I actually go to the necessary page, but url looks like /people/nick?page=bio instead of /people/nick/bio

Am I doing something wrong or .pushRouter doesn't have to do what I expect?

Thanks in advance and sorry if it is too silly question.

UPDATE

<Link /> does the same.

fridays commented 7 years ago

Hey, I can't reproduce. But maybe you have another route with a pattern /people/:username that is defined earlier? If yes, move that below the users route.

khorolets commented 7 years ago

Hi @fridays! Thanks for answering so fast. So I have to place more detailed routes higher than less detailed, right?

Something like:

:username/:page :username

I'll write you back once I try your suggestion. Thanks!

khorolets commented 7 years ago

Thanks @fridays, I came up with:

routes.add('users', '/people/:username/:page?', 'index')

Appeared that I don't need to have additional route without :page.

Good luck!