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-black": "/" + firstCrumb === href,
15 "text-gray": "/" + 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="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">
54 <a className="type-ui">Urbit</a>
57 <Link href={`/${firstCrumb}`}>
58 <a className="inline md:hidden type-ui text-gray 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 text-green type-ui button-text"
92 href="/getting-started"
99 props.search.toggleSearch(e);
101 className="button-sm bg-wall text-gray"
103 Search<div className="ml-4 text-lightGray">{shortcut}</div>
108 // Small screen header
110 <MenuTray isOpen={isOpen} setTray={setTray} search={props.search}>
112 <a className="type-ui mb-12">Urbit</a>
115 currentPath={currentPath}
116 className="mr-5 mb-4 type-h3"
122 currentPath={currentPath}
123 className="mr-5 mb-4 type-h3"
129 currentPath={currentPath}
130 className="mr-5 mb-4 type-h3"
136 currentPath={currentPath}
137 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