Skip to content

Commit c13ab67

Browse files
committed
done
1 parent 08ff11a commit c13ab67

File tree

3 files changed

+38
-3
lines changed

3 files changed

+38
-3
lines changed

pages/index.jsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
11
import React from 'react'
2+
import Link from 'next/link'
23

3-
export default () => <h1>Index Page</h1>
4+
export default () => (
5+
<div>
6+
<h1>Index page</h1>
7+
8+
<Link href="/notes">
9+
<a>Notes</a>
10+
</Link>
11+
</div>
12+
)

pages/notes/[id].jsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
import React from 'react'
22
import { useRouter } from 'next/router'
3+
import Link from 'next/link'
34

45
export default () => {
56
const router = useRouter()
67
const { id }= router.query
78

89
return (
9-
<h1>Note: {id} </h1>
10+
<div>
11+
<h1>Note: {id} </h1>
12+
13+
<Link href="/notes">
14+
<a>Notes</a>
15+
</Link>
16+
</div>
1017
)
1118
}

pages/notes/index.jsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
11
import React from 'react'
2+
import Link from 'next/link'
23

3-
export default () => <h1>Notes</h1>
4+
export default () => {
5+
const notes = new Array(15).fill(1).map((e, i) => ({id: i, title: `Note: ${i}`}))
6+
7+
return (
8+
<div>
9+
<h1>Notes</h1>
10+
11+
{notes.map(note => (
12+
<div>
13+
<Link key={note.id} href="/notes/[id]" as={`/notes/${note.id}`}>
14+
<a>
15+
<strong>{note.title}</strong>
16+
</a>
17+
</Link>
18+
</div>
19+
))}
20+
</div>
21+
)
22+
}

0 commit comments

Comments
 (0)