fridays / next-routes

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

Issue with Multi-params #80

Closed erickeno closed 7 years ago

erickeno commented 7 years ago

I am having an issue setting up multiple params

routes.add('/:category/:slug', 'post');

and in the link in one of the pages I have

<Link params={{ category: 'example', slug: 'some-slug' }}>...</Link>

and I keep getting this error Parameter 'url' must be a string, not undefined.

lfades commented 7 years ago

Mmm, try using this:

<Link route='/:category/:slug' params={{ category: 'example', slug: 'some-slug' }}>...</Link>

or with a route name

routes.add(yourRouteName, '/:category/:slug', 'post');

<Link route={yourRouteName} params={{ category: 'example', slug: 'some-slug' }}>...</Link>
fridays commented 7 years ago

Without a route name, you can only link by URL:

<Link route='/example/some-slug'>

With a route name, you can generate it:

routes.add('post', '/:category/:slug')
<Link route='post' params={{category: 'example', slug: 'some-slug'}}>

Hope it helps!

erickeno commented 7 years ago

thanks for the help, it worked.