@@ -1,6 +1,8 @@
1import Head from "next/head";
1import Head from "next/head";
2import Link from "next/link";
2import Link from "next/link";
3import { useRouter } from "next/router";
3import { useRouter } from "next/router";
4+import { useState } from "react";
5+import classnames from "classnames";
4import { join } from "path";
6import { join } from "path";
5import { getDocs, formatDate, buildPageTree, getPage } from "../../lib/lib";
7import { getDocs, formatDate, buildPageTree, getPage } from "../../lib/lib";
6import Markdown from "../../components/Markdown";
8import Markdown from "../../components/Markdown";
@@ -23,38 +25,60 @@ const breadcrumbs = (posts, paths) => {
23 return results;
25 return results;
26−const childPages = (thisLink, children) => (
28+const childPages = (thisLink, children, level = 0) => (
27 <ul className="pl-1">
29 <ul className="pl-1">
28 {Object.entries(children).map(([childSlug, child]) => (
30 {Object.entries(children).map(([childSlug, child]) => (
29− <li>{pageTree(join(thisLink, childSlug), child)}</li>
31+ <li>{pageTree(join(thisLink, childSlug), child, level)}</li>
34−const pageTree = (thisLink, tree) => (
36+const pageTree = (thisLink, tree, level = 0) => {
35− <div>
37+ const router = useRouter();
36− <Link href={thisLink}>
38+ const firstCrumb = "/" + router.asPath.split("/").slice(1).join("/");
40+ const thisPage = firstCrumb.includes(thisLink);
41+ const [isOpen, toggleTree] = useState(thisPage);
43+ const activeClasses = classnames({
47+ const headerClass = classnames({
48+ "text-gray": !thisPage,
37− <span className="font-medium text-lg cursor-pointer">{tree.title}</span>
54+ "font-medium text-lg cursor-pointer hover:text-black " + headerClass
56+ onClick={() => toggleTree(!isOpen)}
60+ <div className={activeClasses}>
39− <ul className="pl-1">
61+ <ul className={"pl-1"}>
40− {tree.pages
62+ {tree.pages
41− .sort((a, b) => a.weight - b.weight)
63+ .sort((a, b) => a.weight - b.weight)
42− .map(({ title, slug }) => (
64+ .map(({ title, slug }) => (
43− <li className="font-thin py-1">
65+ <li className="font-thin py-1">
44− <Link href={join(thisLink, slug)}>{title}</Link>
66+ <Link href={join(thisLink, slug)}>{title}</Link>
48− {childPages(thisLink, tree.children)}
70+ {childPages(thisLink, tree.children, level + 1)}
52function Sidebar(props) {
76function Sidebar(props) {
54 <div className="flex flex-col w-72 bg-wall max-h-screen h-screen">
78 <div className="flex flex-col w-72 bg-wall max-h-screen h-screen">
55− <header className="flex justify-between items-center pl-12 pt-8 pb-8">
79+ <header className="flex flex-shrink-0 justify-between items-center pl-12 pt-12 pb-8">
56 <Link href="/">
80 <Link href="/">
57− <a className="type-ui">Urbit</a>
81+ <a className="type-ui text-gray">Urbit.org</a>
60 <div className="overflow-y-scroll p-12 pt-16">
84 <div className="overflow-y-scroll p-12 pt-16">
@@ -68,8 +92,11 @@ function Sidebar(props) {
68function ContentArea(props) {
92function ContentArea(props) {
70 <div className="w-full">
94 <div className="w-full">
71− <header className="flex justify-between items-center px-24 pt-8 pb-8">
95+ <header className="flex justify-between items-center px-24 pt-12 pb-8">
72− <div className="type-ui">Install Urbit</div>
96+ <div className="type-ui">Urbit Documentation</div>
97+ <button className="button-sm bg-wall text-gray">
98+ Search Urbit.org<div className="ml-4 text-lightGray">⌘K</div>
73 </header>
100 </header>
74 <div className="px-24 pb-24 pt-16 flex flex-col w-full max-h-screen h-screen overflow-y-scroll">
101 <div className="px-24 pb-24 pt-16 flex flex-col w-full max-h-screen h-screen overflow-y-scroll">
75 <div className="type-ui text-lightGray">{props.breadcrumbs}</div>
102 <div className="type-ui text-lightGray">{props.breadcrumbs}</div>