@@ -5,11 +5,10 @@ import classnames from "classnames";
55import path from "path";
66import MenuTray from "../components/MenuTray";
77import Section from "../components/Section";
8+import { capitalize } from "../lib/lib";
89
9−function ActiveLink({ children, href, className }) {
10− const router = useRouter();
11−
12− const firstCrumb = router.asPath.split("/")[1];
10+function ActiveLink({ children, href, className, currentPath }) {
11+ const firstCrumb = currentPath.split("/")[1];
1312
1413 const activeClassName = classnames({
1514 "text-black": "/" + firstCrumb === href,
@@ -26,25 +25,53 @@ function ActiveLink({ children, href, className }) {
2625export default function Header(props) {
2726 const [isOpen, toggleTray] = useState(false);
2827
28+ const currentPath = useRouter().asPath;
29+
30+ const routeDepth = currentPath.split("/").length;
31+
32+ const firstCrumb = currentPath.split("/")[1];
33+
2934 return (
3035 <header className="w-full px-4 md:px-8 md:w-10/12 flex flex-row justify-between items-center pt-8 md:pt-10 lg:pt-12 pb-10 md:pb-12 lg:pb-24">
31− <Link href="/">
32− <a className="type-ui">Urbit</a>
33− </Link>
36+ <div>
37+ <Link href="/">
38+ <a className="type-ui">Urbit</a>
39+ </Link>
40+ {routeDepth > 2 ? (
41+ <Link href={`/${firstCrumb}`}>
42+ <a className="inline md:hidden type-ui text-gray ml-2">
43+ {capitalize(firstCrumb)}
44+ </a>
45+ </Link>
46+ ) : null}
47+ </div>
3448 {
3549 // Large screen header
3650 }
3751 <nav className="items-center hidden md:flex">
38− <ActiveLink className="mr-5 type-ui" href="/docs">
52+ <ActiveLink
53+ currentPath={currentPath}
54+ className="mr-5 type-ui"
55+ href="/docs"
56+ >
3957 Docs
4058 </ActiveLink>
41− <ActiveLink className="mr-5 type-ui" href="/blog">
59+ <ActiveLink
60+ currentPath={currentPath}
61+ className="mr-5 type-ui"
62+ href="/blog"
63+ >
4264 Blog
4365 </ActiveLink>
44− <ActiveLink className="mr-5 type-ui" href="/events">
66+ <ActiveLink
67+ currentPath={currentPath}
68+ className="mr-5 type-ui"
69+ href="/events"
70+ >
4571 Events
4672 </ActiveLink>
4773 <ActiveLink
74+ currentPath={currentPath}
4875 className="mr-5 text-green type-ui button-text"
4976 href="/getting-started"
5077 >
@@ -68,16 +95,32 @@ export default function Header(props) {
6895 <Link href="/">
6996 <a className="type-ui mb-12">Urbit</a>
7097 </Link>
71− <ActiveLink className="mr-5 mb-4 type-h3" href="/docs">
98+ <ActiveLink
99+ currentPath={currentPath}
100+ className="mr-5 mb-4 type-h3"
101+ href="/docs"
102+ >
72103 Docs
73104 </ActiveLink>
74− <ActiveLink className="mr-5 mb-4 type-h3" href="/blog">
105+ <ActiveLink
106+ currentPath={currentPath}
107+ className="mr-5 mb-4 type-h3"
108+ href="/blog"
109+ >
75110 Blog
76111 </ActiveLink>
77− <ActiveLink className="mr-5 mb-4 type-h3" href="/events">
112+ <ActiveLink
113+ currentPath={currentPath}
114+ className="mr-5 mb-4 type-h3"
115+ href="/events"
116+ >
78117 Events
79118 </ActiveLink>
80− <ActiveLink className="mr-5 mb-4 type-h3" href="/grants">
119+ <ActiveLink
120+ currentPath={currentPath}
121+ className="mr-5 mb-4 type-h3"
122+ href="/grants"
123+ >
81124 Grants
82125 </ActiveLink>
83126 </MenuTray>