@@ -1,236 +0,0 @@
1−import Head from "next/head";
2−import Link from "next/link";
3−import { useRouter } from "next/router";
4−import { useState } from "react";
5−import classnames from "classnames";
6−import { join } from "path";
7−import { getPreviousPost, getNextPost, getPage } from "../../lib/lib";
8−import Meta from "../../components/Meta";
9−import Pagination from "../../components/Pagination";
10−import { Markdown } from "foundation-design-system";
11−import ContentArea from "../../components/ContentArea";
12−import Sidebar from "../../components/Sidebar";
13−import docsPageTree from "../../cache/docs.json";
15−const breadcrumbs = (posts, paths) => {
17− <Link href="/">Urbit</Link>,
18− <span className="px-1">/</span>,
19− <Link href="/docs">Documentation</Link>,
21− let thisLink = "/docs";
22− for (const path of paths) {
23− posts = posts.children[path];
24− thisLink = join(thisLink, path);
26− <span className="px-1">/</span>,
27− <Link href={thisLink}>{posts.title}</Link>
33−const childPages = (thisLink, children, level = 0) => (
34− <ul className="pl-0">
35− {Object.entries(children).map(([childSlug, child]) => (
36− <li>{pageTree(join(thisLink, childSlug), child, level)}</li>
41−const pageTree = (thisLink, tree, level = 0) => {
42− const router = useRouter();
43− const firstCrumb = "/" + router.asPath.split("/").slice(1, -1).join("/");
45− const includesThisPage = firstCrumb.includes(thisLink);
46− const isThisPage = router.asPath === thisLink;
47− const [isOpen, toggleTree] = useState(includesThisPage);
49− const activeClasses = classnames({
53− const headingItemClasses = classnames({
54− "pl-0 text-wall-600 text-base font-semibold hover:text-green-400 leading-relaxed":
56− "pl-4 text-wall-600 text-base font-semibold hover:text-green-400":
58− "pl-8 text-wall-600 text-base hover:text-green-400": level === 2,
61− const pageItemClasses = classnames({
62− "pl-4 text-base hover:text-green-400": level === 0,
63− "pl-8 text-base hover:text-green-400": level === 1,
64− "pl-12 text-base hover:text-green-400": level === 2,
69− <span onClick={() => toggleTree(!isOpen)}>
70− <p className={`${headingItemClasses} cursor-pointer`}>{tree.title}</p>
72− <div className={activeClasses}>
74− {tree.pages.map(({ title, slug }) => {
75− const href = join(thisLink, slug);
76− const isSelected = router.asPath === href;
77− const selectedClasses = classnames({
79− "text-green-400": isSelected,
80− "text-wall-600": !isSelected,
84− <Link href={href} passHref>
86− className={`relative inline-block ${selectedClasses} ${pageItemClasses} `}
95− {childPages(thisLink, tree.children, level + 1)}
101−export default function DocsLayout({
110− const router = useRouter();
112− const isSelected = "/docs".includes(router.asPath);
113− const selectedClasses = classnames({
115− "text-green-400": isSelected,
116− "text-wall-600": !isSelected,
118− const rootClasses = "pl-0 text-base hover:text-green-400";
123− <title>{data.title} • Documentation • urbit.org</title>
126− <div className="flex h-screen min-h-screen w-screen sidebar">
127− <Sidebar search={search}>
130− <Link href="/docs" passHref>
131− <a className={`relative ${selectedClasses} ${rootClasses}`}>
137− {childPages("/docs", posts.children)}
140− breadcrumbs={breadcrumbs(posts, params.slug?.slice(0, -1) || "")}
143− section="Urbit Documentation"
146− <div className="markdown technical">
147− <Markdown.render content={JSON.parse(markdown)} />
149− <div className="flex justify-between mt-16">
150− {previousPost === null ? (
151− <div className={""} />
155− title="Previous Post"
158− section={join("docs", params.slug?.slice(0, -1).join("/"))}
161− {nextPost === null ? (
162− <div className={""} />
169− section={join("docs", params.slug?.slice(0, -1).join("/"))}
174− className="font-semibold rounded-xl block p-2 text-wall-400 hover:text-green-400 mt-16"
176− href={`https://github.com/urbit/urbit.org/blob/master/content/docs/${
177− params.slug?.join("/") || "_index"
180− Edit this page on GitHub
188−export async function getStaticProps({ params }) {
189− const posts = docsPageTree;
191− const { data, content } = getPage(
192− join(process.cwd(), "content/docs", params.slug?.join("/") || "/")
195− const previousPost =
197− params.slug?.slice(-1).join("") || "docs",
198− ["title", "slug", "weight"],
199− join("docs", params.slug?.slice(0, -1).join("/") || "/"),
205− params.slug?.slice(-1).join("") || "docs",
206− ["title", "slug", "weight"],
207− join("docs", params.slug?.slice(0, -1).join("/") || "/"),
211− const markdown = JSON.stringify(Markdown.parse({ post: { content } }));
212− return { props: { posts, data, markdown, previousPost, nextPost, params } };
215−export async function getStaticPaths() {
216− const posts = docsPageTree;
219− const allHrefs = (thisLink, tree) => {
220− slugs.push(thisLink, ...tree.pages.map((e) => join(thisLink, e.slug)));
221− allHrefsChildren(thisLink, tree.children);
224− const allHrefsChildren = (thisLink, children) => {
225− Object.entries(children).map(([childSlug, child]) => {
226− allHrefs(join(thisLink, childSlug), child);
230− allHrefs("/docs", posts);