File tree Expand file tree Collapse file tree 3 files changed +29
-5
lines changed Expand file tree Collapse file tree 3 files changed +29
-5
lines changed Original file line number Diff line number Diff line change
1
+ import Link from "next/link" ;
2
+ import { useRouter } from "next/router" ;
3
+
4
+ export default function NavBar ( ) {
5
+ const router = useRouter ( ) ;
6
+ return (
7
+ < nav >
8
+ < Link href = "/" >
9
+ < a style = { { color : router . pathname === "/" ? "red" : "blue" } } > Home</ a >
10
+ </ Link >
11
+ < Link href = "/about" >
12
+ < a style = { { color : router . pathname === "/about" ? "red" : "blue" } } >
13
+ About
14
+ </ a >
15
+ </ Link >
16
+ </ nav >
17
+ ) ;
18
+ }
Original file line number Diff line number Diff line change
1
+ import NavBar from "../components/NavBar" ;
2
+
1
3
export default function Potato ( ) {
2
- return "about us" ;
4
+ return (
5
+ < div >
6
+ < NavBar />
7
+ < h1 > About</ h1 >
8
+ </ div >
9
+ ) ;
3
10
}
Original file line number Diff line number Diff line change 1
- import { useState } from "react " ;
1
+ import NavBar from "../components/NavBar " ;
2
2
3
3
export default function Home ( ) {
4
- const [ counter , setCounter ] = useState ( 0 ) ;
5
4
return (
6
5
< div >
7
- < h1 > Hello { counter } </ h1 >
8
- < button onClick = { ( ) => setCounter ( ( prev ) => prev + 1 ) } > + </ button >
6
+ < NavBar / >
7
+ < h1 > Hello </ h1 >
9
8
</ div >
10
9
) ;
11
10
}
You can’t perform that action at this time.
0 commit comments