@@ -1,121 +0,0 @@
1−import Head from "next/head";
2−import Link from "next/link";
3−import { useRouter } from "next/router";
4−import classnames from "classnames";
5−import { join } from "path";
6−import Meta from "../../components/Meta";
7−import { Markdown, getPage } from "@urbit/foundation-design-system";
8−import ContentArea from "../../components/ContentArea";
9−import Sidebar from "../../components/DocsSidebar";
10−import communityTree from "../../cache/community.json";
11−
12−const breadcrumbs = (posts, paths) => {
13− const results = [
14− <Link href="/">Urbit</Link>,
15− <span className="px-1">/</span>,
16− <Link href="/community">Community</Link>,
17− ];
18− let thisLink = "/community";
19− for (const path of paths) {
20− posts = posts.children[path];
21− thisLink = join(thisLink, path);
22− results.push(
23− <span className="px-1">/</span>,
24− <Link href={thisLink}>{posts.title}</Link>
25− );
26− }
27− return results;
28−};
29−
30−const childPages = (thisLink, children, level = 0) => (
31− <ul className="pl-1">
32− {children?.map((child) => (
33− <li>{pageTree(join(thisLink, child.slug), child, level)}</li>
34− ))}
35− </ul>
36−);
37−
38−const pageTree = (thisLink, tree, level = 0) => {
39− const router = useRouter();
40−
41− const isThisPage = router.asPath === thisLink;
42−
43− const pageItemClasses = classnames({
44− "pl-4 text-wall-600 text-base hover:text-green-400": level === 0,
45− "pl-8 text-wall-600 text-base hover:text-green-400": level === 1,
46− "pl-12 text-wall-600 text-base hover:text-green-400": level === 2,
47− "dot relative": isThisPage,
48− "text-green-400": isThisPage,
49− });
50−
51− return (
52− <>
53− <Link href={thisLink}>
54− <a className={`${pageItemClasses} cursor-pointer`}>{tree.title}</a>
55− </Link>
56− </>
57− );
58−};
59−
60−export default function UsingLayout({ posts, data, markdown, params, search }) {
61− return (
62− <>
63− <Head>
64− <title>{data.title} • Community</title>
65− {Meta(data)}
66− </Head>
67− <div className="flex h-screen min-h-screen w-screen sidebar">
68− <Sidebar search={search}>
69− {childPages("/community", posts.pages)}
70− </Sidebar>
71− <ContentArea
72− breadcrumbs={breadcrumbs(posts, params.slug?.slice(0, -1) || "")}
73− title={data.title}
74− search={search}
75− section={"Community"}
76− params={params}
77− >
78− <div className="markdown">
79− <Markdown.render content={JSON.parse(markdown)} />
80− </div>
81− </ContentArea>
82− </div>
83− </>
84− );
85−}
86−
87−export async function getStaticProps({ params }) {
88− const posts = communityTree;
89−
90− const { data, content } = getPage(
91− join(process.cwd(), "content/community", params.slug?.join("/") || "/")
92− );
93−
94− const markdown = JSON.stringify(Markdown.parse({ post: { content } }));
95−
96− return { props: { posts, data, markdown, params } };
97−}
98−
99−export async function getStaticPaths() {
100− const posts = communityTree;
101−
102− const slugs = [];
103−
104− const allHrefs = (thisLink, tree) => {
105− slugs.push(thisLink, ...tree.pages.map((e) => join(thisLink, e.slug)));
106− allHrefsChildren(thisLink, tree.children);
107− };
108−
109− const allHrefsChildren = (thisLink, children) => {
110− Object.entries(children).map(([childSlug, child]) => {
111− allHrefs(join(thisLink, childSlug), child);
112− });
113− };
114−
115− allHrefs("/community", posts);
116−
117− return {
118− paths: slugs,
119− fallback: false,
120− };
121−}