fridays / next-routes

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

Routes with params not load correctly #196

Closed elissaioskon closed 6 years ago

elissaioskon commented 6 years ago

Hello, "next-routes": "^1.1.0",

On my project Under pages folder there is a file named post.

On routes i have: routes.add('post', '/postForMe/:slug')

On index.js file on pages folder i have a link

<Link route='/postForMe' params={{ slug: post.title }}>
      <a>
       Navigate me to a random post
      </a>
    </Link>

When i do this it does not take the params on the url. if i do <Link route='post' params={{ slug: post.title }}> it works but i want to pass the route path on the route props on Link not the file name. Can anyone help?

fridays commented 6 years ago

You can either use the route name post and pass the params like you do. Or you can use a full path that matches the pattern like so:

<Link route={`/postForMe/${post.title}`}>