fridays / next-routes

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

Confusing documentation for add overloads #197

Closed DullReferenceException closed 6 years ago

DullReferenceException commented 6 years ago

Maybe this is a simple typo, but in the documentation, the overloads for .add(...) are listed as:

routes.add(name, pattern = /name, page = name)
routes.add(pattern, page)
routes.add(object)

...but the sample are given as:

routes
.add('about')
.add('blog', '/blog/:slug')
.add('user', '/user/:id', 'profile')
.add('/:noname/:lang(en|es)/:wow+', 'complex')
.add({name: 'beta', pattern: '/v3', page: 'v3'})

...and these two samples seem to be conflicting on whether the name or the pattern comes first in the case of the two-argument overload:

.add('blog', '/blog/:slug')
.add('/:noname/:lang(en|es)/:wow+', 'complex')
fridays commented 6 years ago

The first sample has a route name blog which can be used to link to it. It will render the page component with the same name. It could use a different page component if that was given as a third argument.

The second sample has no name, it can only be linked to using the pattern. It will render the page complex

I agree the docs could explain this better, pull requests very welcome!

DullReferenceException commented 6 years ago

Thanks for the explanation. Here's a possible way to make things clearer: https://github.com/fridays/next-routes/pull/200

fridays commented 6 years ago

Thanks!