Unverified Commit baf0b287 authored by Karl Horky's avatar Karl Horky Committed by GitHub

Add routing example with dynamic `as` prop (#11114)

parent 23d71ff1
...@@ -84,6 +84,24 @@ function Home() { ...@@ -84,6 +84,24 @@ function Home() {
export default Home export default Home
``` ```
The `as` prop can also be generated dynamically. For example, to show a list of posts which have been passed to the page as a prop:
```jsx
function Home({ posts }) {
return (
<ul>
{posts.map(post => (
<li key={post.id}>
<Link href="/blog/[slug]" as={`/blog/${post.slug}`}>
<a>{post.title}</a>
</Link>
</li>
))}
</ul>
)
}
```
## Injecting the router ## Injecting the router
<details> <details>
......
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