1import Link from "next/link";
2import { useRouter } from "next/router";
3import { useState, useEffect } from "react";
4import classnames from "classnames";
5import MenuTray from "../components/MenuTray";
6import { capitalize } from "../lib/lib";
8function ActiveLink({ children, href, className, currentPath }) {
9 const firstCrumb = currentPath.split("/")[1];
11 const activeClassName = classnames({
12 "text-wall-600": "/" + firstCrumb === href,
13 "text-wall-500": "/" + firstCrumb !== href,
17 <Link href={href} passHref>
18 <a className={`${className} ${activeClassName}`}>{children}</a>
23export default function Header(props) {
24 const [isOpen, setTray] = useState(false);
26 const currentPath = useRouter().asPath;
28 const routeDepth = currentPath.split("/").length;
30 const firstCrumb = currentPath.split("/")[1];
33 <header className="layout px-4 md:px-8 flex justify-between items-center pt-8 md:pt-10 lg:pt-12 pb-10 md:pb-12 lg:pb-24">
35 <Link href="/" passHref>
36 <a className="font-semibold text-lg">Urbit</a>
39 <Link href={`/${firstCrumb}`} passHref>
40 <a className="inline md:hidden type-ui text-wall-500 ml-2">
41 {capitalize(firstCrumb)}
47 // Large screen header
49 <nav className="items-center hidden md:flex">
51 currentPath={currentPath}
52 className="mr-5 text-green-400 type-ui button-text"
53 href="/getting-started"
59 currentPath={currentPath}
60 className="mr-5 type-ui"
67 currentPath={currentPath}
68 className="mr-5 type-ui"
75 currentPath={currentPath}
76 className="mr-5 type-ui"
83 currentPath={currentPath}
84 className="mr-5 type-ui"
91 currentPath={currentPath}
92 className="mr-5 type-ui"
100 // Small screen header
102 <MenuTray isOpen={isOpen} setTray={setTray} search={props.search}>
103 <Link href="/" passHref>
104 <a className="font-semibold mb-4">Urbit</a>
106 <Link href="https://urbit.org" passHref>
107 <a className="font-semibold mt-2">Urbit.org</a>
109 <Link href="https://operators.urbit.org" passHref>
110 <a className="mt-2">Operators</a>
112 <Link href="https://developers.urbit.org" passHref>
113 <a className="mt-2 mb-4">Developers</a>
115 <hr className="border-wall-200" />
118 currentPath={currentPath}
119 className="mr-5 mt-4 mb-4 text-green-400"
120 href="/getting-started"
126 currentPath={currentPath}
127 className="mr-5 mb-4"
134 currentPath={currentPath}
135 className="mr-5 mb-4"
142 currentPath={currentPath}
143 className="mr-5 mb-4"
150 currentPath={currentPath}
151 className="mr-5 mb-4"
158 currentPath={currentPath}
159 className="mr-5 mb-4"
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list