1import Link from "next/link";
2import { useRouter } from "next/router";
3import { useState, useEffect } from "react";
4import classnames from "classnames";
5import path from "path";
6import MenuTray from "../components/MenuTray";
7import Section from "../components/Section";
8import { capitalize } from "../lib/lib";
10function ActiveLink({ children, href, className, currentPath }) {
11 const firstCrumb = currentPath.split("/")[1];
13 const activeClassName = classnames({
14 "text-wall-600": "/" + firstCrumb === href,
15 "text-wall-500": "/" + firstCrumb !== href,
20 <a className={`${className} ${activeClassName}`}>{children}</a>
25export default function Header(props) {
26 const [isOpen, setTray] = useState(false);
27 const [shortcut, setShortcut] = useState("");
29 const currentPath = useRouter().asPath;
31 const routeDepth = currentPath.split("/").length;
33 const firstCrumb = currentPath.split("/")[1];
35 const detectOS = () => {
36 const agent = window.navigator.appVersion;
37 if (agent.includes("Win")) {
39 } else if (agent.includes("Mac")) {
41 } else if (agent.includes("Linux")) {
47 setShortcut(detectOS());
51 <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">
54 <a className="type-ui">Urbit</a>
57 <Link href={`/${firstCrumb}`}>
58 <a className="inline md:hidden type-ui text-wall-500 ml-2">
59 {capitalize(firstCrumb)}
65 // Large screen header
67 <nav className="items-center hidden md:flex">
69 currentPath={currentPath}
70 className="mr-5 type-ui"
76 currentPath={currentPath}
77 className="mr-5 type-ui"
83 currentPath={currentPath}
84 className="mr-5 type-ui"
90 currentPath={currentPath}
91 className="mr-5 type-ui"
97 currentPath={currentPath}
98 className="mr-5 text-green-400 type-ui button-text"
99 href="/getting-started"
104 currentPath={currentPath}
105 className="mr-5 type-ui"
113 props.search.toggleSearch(e);
115 className="bg-wall-100 text-wall-500 flex px-4 py-1 rounded-lg type-ui"
118 <div className="ml-4 text-wall-400">{shortcut}</div>
123 // Small screen header
125 <MenuTray isOpen={isOpen} setTray={setTray} search={props.search}>
127 <a className="type-ui mb-12">Urbit</a>
130 currentPath={currentPath}
131 className="mr-5 mb-4 type-h3"
137 currentPath={currentPath}
138 className="mr-5 mb-4 type-h3"
144 currentPath={currentPath}
145 className="mr-5 mb-4 type-h3"
151 currentPath={currentPath}
152 className="mr-5 mb-4 type-h3"
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