1import { useState, useEffect, useRef } from "react";
2import { useRouter } from "next/router";
3import { TableOfContents } from "@urbit/foundation-design-system";
5export default function ContentArea(props) {
6 const [shortcut, setShortcut] = useState("");
8 const detectOS = () => {
9 const agent = window.navigator.appVersion;
10 if (agent.includes("Win")) {
12 } else if (agent.includes("Mac")) {
14 } else if (agent.includes("Linux")) {
20 setShortcut(detectOS());
23 const scrollBox = useRef();
25 const router = useRouter();
28 const handleRouteChange = () => {
29 if (scrollBox.current === null) return;
30 scrollBox.current.scrollTop = 0;
33 router.events.on("routeChangeComplete", handleRouteChange);
35 // If the component is unmounted, unsubscribe
36 // from the event with the `off` method:
38 router.events.off("routeChangeStart", handleRouteChange);
43 <div className="w-full min-w-0 flex flex-col items-center bg-white">
46 className="px-4 md:px-12 lg:px-24 pt-8 md:pt-10 lg:pt-16 flex flex-col w-full max-w-screen-xl max-h-screen h-screen overflow-y-scroll"
48 <div className="flex justify-between w-full items-center shrink-0">
49 <div className="font-semibold antialiased text-lg text-black">
52 <div className="hidden md:block">
56 props.search.toggleSearch();
58 className="bg-wall-100 text-wall-500 flex px-4 py-1 rounded-lg type-ui"
60 Search<div className="ml-4 text-wall-400">{shortcut}</div>
64 <div className="flex justify-between">
65 <div className="min-w-0 max-w-screen-md">
66 <div className="mb-16">
67 <h2 className="mt-24">{props.title}</h2>
68 {props?.description && (
69 <p className="text-wall-400 font-regular mt-2 text-xl">
75 <div className="pb-24" />
77 {!props?.disableToC && (
79 key={props.params.slug?.join("/") || Math.random()}
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