fridays / next-routes

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

Named index route issues #83

Closed jaydenseric closed 7 years ago

jaydenseric commented 7 years ago

How do you make a named route for the homepage?

I have tried:

routes.add('home', '/')

But that results in Client pings, but there's no entry for page: /home.

In some situations you want a index route with the name the same as an existing page file.

// When pages/sellers.js exists
routes.add('sellers', '/')

It automatically renders pages/sellers.js instead of pages/index.js.

Are these bugs? Is there a way to use all the parameters somehow to workaround the issues?

fridays commented 7 years ago

If no page is given as the third argument, it uses the name from the first argument as the page to render. So if you name it index, it will render that page. If you use a different name and it should render index, do this:

routes.add('sellers', '/', 'index')
jaydenseric commented 7 years ago

Thanks, your tip worked.