()
| 2 | import { useRouter } from "next/router" |
| 3 | |
| 4 | const Header = () => { |
| 5 | const router = useRouter() |
| 6 | |
| 7 | function isActive(pathname: string) { |
| 8 | return router.pathname === pathname |
| 9 | } |
| 10 | |
| 11 | return ( |
| 12 | <nav> |
| 13 | <div className="left"> |
| 14 | <Link href="/" legacyBehavior> |
| 15 | <a className="bold" data-active={isActive("/")}> |
| 16 | Blog |
| 17 | </a> |
| 18 | </Link> |
| 19 | <Link href="/drafts" legacyBehavior> |
| 20 | <a data-active={isActive("/drafts")}>Drafts</a> |
| 21 | </Link> |
| 22 | </div> |
| 23 | <div className="right"> |
| 24 | <Link href="/signup" legacyBehavior> |
| 25 | <a data-active={isActive("/signup")}>Signup</a> |
| 26 | </Link> |
| 27 | <Link href="/create" legacyBehavior> |
| 28 | <a data-active={isActive("/create")}>+ Create draft</a> |
| 29 | </Link> |
| 30 | </div> |
| 31 | <style jsx>{` |
| 32 | nav { |
| 33 | display: flex; |
| 34 | padding: 2rem; |
| 35 | align-items: center; |
| 36 | } |
| 37 | |
| 38 | .bold { |
| 39 | font-weight: bold; |
| 40 | } |
| 41 | |
| 42 | a { |
| 43 | text-decoration: none; |
| 44 | color: #000; |
| 45 | display: inline-block; |
| 46 | } |
| 47 | |
| 48 | .left a[data-active="true"] { |
| 49 | color: gray; |
| 50 | } |
| 51 | |
| 52 | a + a { |
| 53 | margin-left: 1rem; |
| 54 | } |
| 55 | |
| 56 | .right { |
| 57 | margin-left: auto; |
| 58 | } |
| 59 | |
| 60 | .right a { |
| 61 | border: 1px solid black; |
nothing calls this directly
no test coverage detected