Commit eae1f6b7 authored by Sergio Garcia Mondaray's avatar Sergio Garcia Mondaray Committed by kodiakhq[bot]

Dynamic routes clarification (#8110)

As talked in https://github.com/zeit/next.js/issues/8101 dynamic routing documentation could be confusing. This PR tries to clarify it a bit.
parent 8b0a93b0
...@@ -311,8 +311,20 @@ A `<Link>` for `/post/abc` looks like so: ...@@ -311,8 +311,20 @@ A `<Link>` for `/post/abc` looks like so:
</Link> </Link>
``` ```
- `href`: the path inside `pages` directory - `href`: the path inside `pages` directory.
- `as`: the path that will be rendered in the browser URL bar - `as`: the path that will be rendered in the browser URL bar.
As `href` is a filesystem path, it shouldn't change at runtime, instead, you will probably need to change `as`
dynamically according to your needs. Here's an example to create a list of links:
```jsx
const pids = ['id1', 'id2', 'id3'];
{pids.map(pid => (
<Link href="/post/[pid]" as={`/post/${pid}`}>
<a>Post {pid}</a>
</Link>
))}
```
> You can [read more about `<Link>` here](#with-link). > You can [read more about `<Link>` here](#with-link).
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment