Skip to content

Commit

Permalink
Dynamic routes clarification (#8110)
Browse files Browse the repository at this point in the history
As talked in #8101 dynamic routing documentation could be confusing. This PR tries to clarify it a bit.
  • Loading branch information
sgmonda authored and kodiakhq[bot] committed Jul 25, 2019
1 parent 8b0a93b commit eae1f6b
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions packages/next/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,20 @@ A `<Link>` for `/post/abc` looks like so:
</Link>
```

- `href`: the path inside `pages` directory
- `as`: the path that will be rendered in the browser URL bar
- `href`: the path inside `pages` directory.
- `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).
Expand Down

0 comments on commit eae1f6b

Please sign in to comment.