File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change 1
1
import Link from "next/link" ;
2
2
import { useRouter } from "next/router" ;
3
+ import styles from "./NavBar.module.css" ;
3
4
4
5
export default function NavBar ( ) {
5
6
const router = useRouter ( ) ;
6
7
return (
7
8
< nav >
8
9
< Link href = "/" >
9
- < a style = { { color : router . pathname === "/" ? "red" : "blue" } } > Home</ a >
10
+ < a
11
+ className = { `${ styles . link } ${
12
+ router . pathname === "/" ? styles . active : ""
13
+ } `}
14
+ >
15
+ Home
16
+ </ a >
10
17
</ Link >
11
18
< Link href = "/about" >
12
- < a style = { { color : router . pathname === "/about" ? "red" : "blue" } } >
19
+ < a
20
+ className = { [
21
+ styles . link ,
22
+ router . pathname === "/about" ? styles . active : "" ,
23
+ ] . join ( " " ) }
24
+ >
13
25
About
14
26
</ a >
15
27
</ Link >
Original file line number Diff line number Diff line change
1
+ .link {
2
+ text-decoration : none;
3
+ }
4
+
5
+ .active {
6
+ color : tomato;
7
+ }
You can’t perform that action at this time.
0 commit comments