fridays / next-routes

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

Confusion in the routes.add example #100

Closed chhuang closed 7 years ago

chhuang commented 7 years ago

In the first example: routes.add('blog', '/blog/:slug'), the first argument is the page and the second is the pattern.

But then under API:: routes.add(pattern, page), should that be routes.add(page, pattern) instead?

nuttikung commented 7 years ago

I think it's correct but I the information which I understand.

Choices :

  1. routes.add(name, pattern = /name, page = name)
  2. routes.add(pattern, page)

Case :

  1. routes.add('blog', '/blog/:slug')
    • will be mapped to the 1st choice and page = name by default.
  2. routes.add('user', '/user/:id', 'profile') will be mapped to choice 1
    • will be mapped to the 1st choice and page = profile
  3. routes.add('/:noname/:lang(en|es)/:wow+', 'complex')
    • will be mapped to the 2nd choice and page = complex

If any wrong, Let's discuss!

fridays commented 7 years ago

Thanks @nuttikung that's all correct!