-
Notifications
You must be signed in to change notification settings - Fork 592
/
DocsSidebar.tsx
55 lines (47 loc) · 1.31 KB
/
DocsSidebar.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import {
CATEGORIES,
TableOfContentsCategory,
TableOfContentsCategoryEntry,
} from "../data/docs.ts";
export default function DocsSidebar(props: { path: string }) {
return (
<ol class="list-decimal list-inside font-semibold nested">
{CATEGORIES.map((category) => (
<SidebarCategory path={props.path} category={category} />
))}
</ol>
);
}
const link = "text(gray-900 hover:gray-600)";
const linkActive = "text(green-600 hover:green-500)";
export function SidebarCategory(props: {
path: string;
category: TableOfContentsCategory;
}) {
const { title, href, entries } = props.category;
const outerLink = `${href == props.path ? linkActive : link} font-bold`;
return (
<li class="my-2 block">
<a href={href} class={outerLink}>{title}</a>
{entries.length > 0 && (
<ol class="pl-4 list-decimal nested">
{entries.map((entry) => (
<SidebarEntry path={props.path} entry={entry} />
))}
</ol>
)}
</li>
);
}
export function SidebarEntry(props: {
path: string;
entry: TableOfContentsCategoryEntry;
}) {
const { title, href } = props.entry;
const innerLink = `${href == props.path ? linkActive : link} font-normal`;
return (
<li class="my-0.5">
<a href={href} class={innerLink}>{title}</a>
</li>
);
}