@@ -5,11 +5,10 @@ import classnames from "classnames";
5import path from "path";
5import path from "path";
6import MenuTray from "../components/MenuTray";
6import MenuTray from "../components/MenuTray";
7import Section from "../components/Section";
7import Section from "../components/Section";
8+import { capitalize } from "../lib/lib";
9−function ActiveLink({ children, href, className }) {
10+function ActiveLink({ children, href, className, currentPath }) {
10− const router = useRouter();
12− const firstCrumb = router.asPath.split("/")[1];
11+ const firstCrumb = currentPath.split("/")[1];
14 const activeClassName = classnames({
13 const activeClassName = classnames({
15 "text-black": "/" + firstCrumb === href,
14 "text-black": "/" + firstCrumb === href,
@@ -26,25 +25,53 @@ function ActiveLink({ children, href, className }) {
26export default function Header(props) {
25export default function Header(props) {
27 const [isOpen, toggleTray] = useState(false);
26 const [isOpen, toggleTray] = useState(false);
28+ const currentPath = useRouter().asPath;
30+ const routeDepth = currentPath.split("/").length;
32+ const firstCrumb = currentPath.split("/")[1];
30 <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">
35 <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="/">
37+ <Link href="/">
32− <a className="type-ui">Urbit</a>
38+ <a className="type-ui">Urbit</a>
41+ <Link href={`/${firstCrumb}`}>
42+ <a className="inline md:hidden type-ui text-gray ml-2">
43+ {capitalize(firstCrumb)}
35 // Large screen header
49 // Large screen header
37 <nav className="items-center hidden md:flex">
51 <nav className="items-center hidden md:flex">
53+ currentPath={currentPath}
38− <ActiveLink className="mr-5 type-ui" href="/docs">
54+ className="mr-5 type-ui"
40 </ActiveLink>
58 </ActiveLink>
60+ currentPath={currentPath}
41− <ActiveLink className="mr-5 type-ui" href="/blog">
61+ className="mr-5 type-ui"
43 </ActiveLink>
65 </ActiveLink>
67+ currentPath={currentPath}
44− <ActiveLink className="mr-5 type-ui" href="/events">
68+ className="mr-5 type-ui"
46 </ActiveLink>
72 </ActiveLink>
47 <ActiveLink
73 <ActiveLink
74+ currentPath={currentPath}
48 className="mr-5 text-green type-ui button-text"
75 className="mr-5 text-green type-ui button-text"
49 href="/getting-started"
76 href="/getting-started"
@@ -68,16 +95,32 @@ export default function Header(props) {
68 <Link href="/">
95 <Link href="/">
69 <a className="type-ui mb-12">Urbit</a>
96 <a className="type-ui mb-12">Urbit</a>
99+ currentPath={currentPath}
71− <ActiveLink className="mr-5 mb-4 type-h3" href="/docs">
100+ className="mr-5 mb-4 type-h3"
73 </ActiveLink>
104 </ActiveLink>
106+ currentPath={currentPath}
74− <ActiveLink className="mr-5 mb-4 type-h3" href="/blog">
107+ className="mr-5 mb-4 type-h3"
76 </ActiveLink>
111 </ActiveLink>
113+ currentPath={currentPath}
77− <ActiveLink className="mr-5 mb-4 type-h3" href="/events">
114+ className="mr-5 mb-4 type-h3"
79 </ActiveLink>
118 </ActiveLink>
120+ currentPath={currentPath}
80− <ActiveLink className="mr-5 mb-4 type-h3" href="/grants">
121+ className="mr-5 mb-4 type-h3"
82 </ActiveLink>
125 </ActiveLink>
83 </MenuTray>
126 </MenuTray>