fridays / next-routes

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

Is it possible to point to the same path but differ which component to render #109

Closed JonatanSalas closed 7 years ago

JonatanSalas commented 7 years ago

Hi!

I have two types of routes in my app: /some-url /some-url_withId

If I express them as a pattern, I got the following:

/:id

The trouble is that the components that render those urls are different. There's a way to get the same url pattern but differ the component to render?

fridays commented 7 years ago

Is this what you're looking for?

routes.add('/:slug([a-z]+)_:id', 'detailpage')
routes.add('/:slug', 'otherpage')

More patterns info here: https://github.com/pillarjs/path-to-regexp

JonatanSalas commented 7 years ago

Yes! That was exactly what I was looking for! Thank you very much!