forked from solidjs/solid-start
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docs.root.tsx
317 lines (298 loc) · 12.2 KB
/
docs.root.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
// @refresh reload
import { createMemo, For, Show, Suspense } from "solid-js";
import { MDXProvider } from "solid-mdx";
import {
Body,
FileRoutes,
Head,
Html,
Link,
Meta,
Routes,
Scripts,
Stylesheet,
Title,
unstable_island
} from "solid-start";
import { ErrorBoundary } from "solid-start/error-boundary";
import "./components/index.css";
const IslandA = unstable_island(() => import("./components/A"));
const TableOfContents = unstable_island(() => import("./components/TableOfContents"));
export const mods = /*#__PURE__*/ import.meta.glob<
true,
any,
{
getHeadings: () => {
depth: number;
text: string;
slug: string;
}[];
getFrontMatter: () => {
title?: string;
sectionTitle?: string;
order?: number;
section?: string;
sectionOrder?: number;
subsection?: string;
};
}
>("./docs/**/*.{md,mdx}", {
eager: true,
query: {
meta: ""
}
});
const socials = [
{
href: "https://github.com/solidjs/solid",
alt: "GitHub",
icon: "M12 .3a12 12 0 00-3.8 23.38c.6.12.83-.26.83-.57L9 21.07c-3.34.72-4.04-1.61-4.04-1.61-.55-1.39-1.34-1.76-1.34-1.76-1.08-.74.09-.73.09-.73 1.2.09 1.83 1.24 1.83 1.24 1.07 1.83 2.81 1.3 3.5 1 .1-.78.42-1.31.76-1.61-2.67-.3-5.47-1.33-5.47-5.93 0-1.31.47-2.38 1.24-3.22-.14-.3-.54-1.52.1-3.18 0 0 1-.32 3.3 1.23a11.5 11.5 0 016 0c2.28-1.55 3.29-1.23 3.29-1.23.64 1.66.24 2.88.12 3.18a4.65 4.65 0 011.23 3.22c0 4.61-2.8 5.63-5.48 5.92.42.36.81 1.1.81 2.22l-.01 3.29c0 .31.2.69.82.57A12 12 0 0012 .3"
},
{
href: "https://www.reddit.com/r/solidjs/",
alt: "Reddit",
icon: "M12 0A12 12 0 000 12a12 12 0 0012 12 12 12 0 0012-12A12 12 0 0012 0zm5.01 4.74c.69 0 1.25.56 1.25 1.25a1.25 1.25 0 01-2.5.06l-2.6-.55-.8 3.75c1.83.07 3.48.63 4.68 1.49.3-.31.73-.5 1.2-.5.97 0 1.76.8 1.76 1.76 0 .72-.43 1.33-1.01 1.61a3.11 3.11 0 01.04.52c0 2.7-3.13 4.87-7 4.87-3.88 0-7-2.17-7-4.87 0-.18 0-.36.04-.53A1.75 1.75 0 014.03 12a1.75 1.75 0 012.96-1.26 8.52 8.52 0 014.74-1.5l.89-4.17a.34.34 0 01.14-.2.35.35 0 01.24-.04l2.9.62a1.21 1.21 0 011.11-.7zM9.25 12a1.25 1.25 0 101.25 1.25c0-.69-.56-1.25-1.25-1.25zm5.5 0a1.25 1.25 0 000 2.5 1.25 1.25 0 000-2.5zm-5.47 3.99a.33.33 0 00-.23.1.33.33 0 000 .46c.84.84 2.49.91 2.96.91.48 0 2.1-.06 2.96-.91a.36.36 0 00.03-.47.33.33 0 00-.46 0c-.55.54-1.68.73-2.51.73-.83 0-1.98-.2-2.51-.73a.33.33 0 00-.24-.1z"
},
{
href: "https://discord.com/invite/solidjs",
alt: "Discord",
icon: "M12 0C5.3 0 0 5.3 0 12s5.3 12 12 12 12-5.4 12-12S18.6 0 12 0zM9.7 5.9a.05.05 0 0 1 .06.03 8.43 8.43 0 0 1 .41.83 12.2 12.2 0 0 1 3.66 0 9.19 9.19 0 0 1 .4-.83.05.05 0 0 1 .06-.03 13.2 13.2 0 0 1 3.26 1.01.04.04 0 0 1 .02.02c1.8 2.66 2.7 5.66 2.37 9.11a.05.05 0 0 1-.02.04 13.24 13.24 0 0 1-4 2.02.05.05 0 0 1-.06-.02 10.65 10.65 0 0 1-.82-1.33.05.05 0 0 1 .02-.07 8.2 8.2 0 0 0 1.25-.6.05.05 0 0 0 .01-.08 6.47 6.47 0 0 1-.25-.2.05.05 0 0 0-.05 0 9.47 9.47 0 0 1-8.05 0 .05.05 0 0 0-.05 0l-.25.2a.05.05 0 0 0 0 .08 8.75 8.75 0 0 0 1.26.6.05.05 0 0 1 .02.07 9.48 9.48 0 0 1-.82 1.33.05.05 0 0 1-.05.02 13.28 13.28 0 0 1-4-2.02.05.05 0 0 1-.02-.04c-.28-2.99.29-6.01 2.37-9.11a.05.05 0 0 1 .02-.02A13.17 13.17 0 0 1 9.7 5.9zM9.35 11c-.8 0-1.43.72-1.43 1.6 0 .9.64 1.62 1.43 1.62.8 0 1.44-.72 1.44-1.61.02-.88-.63-1.61-1.44-1.61zm5.33 0c-.8 0-1.44.72-1.44 1.6 0 .9.65 1.62 1.44 1.62.8 0 1.43-.72 1.43-1.61.02-.88-.63-1.61-1.43-1.61z"
},
{
href: "https://twitter.com/solid_js",
alt: "Twitter",
icon: "M12,0.1c-6.7,0-12,5.3-12,12s5.3,12,12,12s12-5.4,12-12S18.6,0.1,12,0.1z M17,9.4v0.4c0,3.8-2.6,8-7.5,8 c-1.5,0-2.9-0.5-4.1-1.3c0.2,0,0.4,0,0.7,0c1.2,0,2.3-0.5,3.3-1.2c-1.1,0-2.1-0.8-2.4-2c0.2,0.1,0.3,0.1,0.5,0.1 c0.2,0,0.5-0.1,0.7-0.1C6.9,13,6,11.9,6,10.5v-0.1c0.3,0.2,0.8,0.4,1.2,0.4c-0.7-0.5-1.2-1.4-1.2-2.3c0-0.5,0.1-1.1,0.3-1.4 c1.3,1.7,3.2,2.8,5.4,2.9c-0.1-0.2-0.1-0.4-0.1-0.6c0-1.6,1.2-2.8,2.7-2.8c0.8,0,1.4,0.3,1.9,0.9C17,7.3,17.6,7,18.1,6.7 c-0.2,0.7-0.6,1.2-1.1,1.6c0.5-0.1,1-0.2,1.5-0.4C18.1,8.4,17.6,8.9,17,9.4z"
}
];
function SocialIcon(props) {
return (
<li class="mx-2">
<a href={props.href} rel="noopener" target="_blank">
<span class="sr-only">{props.alt}</span>
<svg viewBox="0 0 24 24" class="h-8 transition hover:opacity-50 opacity-60">
<path fill="currentColor" d={props.icon} />
</svg>
</a>
</li>
);
}
function Header() {
return (
<header class="flex px-8 py-2 shadow-md z-10 relative">
<div class="flex justify-between w-full">
<div class="flex space-x-3">
<img src="/logo.svg" class="w-9 h-9" />
<div class="text-xl mt-2 uppercase">
<span>Solid</span>
<span class="font-semibold ml-1 text-solid-medium">Start</span>
</div>
</div>
<div class="flex space-x-10">
<div class="flex items-center">
<a href="https://www.solidjs.com" target="_blank" class="flex items-center space-x-5">
SocialJS.com
<svg
class="h-5 z-50 -mt-1 ltr:ml-1 rtl:mr-1 opacity-30"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"
/>
</svg>
</a>
</div>
<ul class="flex">
<For each={socials} children={social => <SocialIcon {...social} />} />
</ul>
</div>
</div>
</header>
);
}
function Nav() {
const data = createMemo(() => {
let sections: {
[key: string]: {
title: string;
path: string;
order: number;
subsection: string;
href: string;
}[] & { subsection?: Set<string>; title?: string; order?: number };
} = {};
Object.keys(mods).forEach(key => {
let frontMatter = mods[key].getFrontMatter();
let {
title = mods[key].getHeadings().find(h => h.depth === 1)?.text ?? "",
section = "",
order = 100
} = frontMatter ?? {};
if (!sections[section]) {
sections[section] = [];
}
if (frontMatter?.subsection) {
if (!sections[section].subsection) {
sections[section].subsection = new Set();
}
sections[section].subsection.add(frontMatter.subsection);
}
if (frontMatter?.sectionTitle) {
sections[section].title = frontMatter.sectionTitle;
}
if (frontMatter?.sectionOrder) {
sections[section].order = frontMatter.sectionOrder;
}
sections[section].push({
title,
path: key,
order,
frontMatter: frontMatter,
subsection: frontMatter?.subsection,
href: key.slice(6).replace(/\.mdx?$/, "")
});
});
Object.keys(sections).forEach(key => {
sections[key].sort((a, b) => a.order - b.order);
});
return Object.values(sections).sort((a, b) => (a.order ?? 100) - (b.order ?? 100));
});
return (
<nav class="min-w-[300px] px-8 py-8 space-y-4 h-[calc(100vh-3.5rem)] md:block hidden overflow-scroll bg-slate-100">
<div id="docsearch" />
<For each={data()}>
{r => (
<ul>
<span class="text-left w-full dark:text-white border-b border-gray-200 dark:border-gray-500 hover:text-gray-400 transition flex flex-wrap content-center justify-between space-x-2 text-xl p-2 py-2 mb-8">
{r.title}
</span>
<Show
when={!r.subsection}
fallback={
<>
<For each={[...r.subsection.values()]}>
{s => (
<ul class="ml-2 mt-3">
<span class="font-bold text-gray-400 text-md mb-4">{s}</span>
<For each={r.filter(i => i.subsection === s)}>
{({ title, path, href, frontMatter }) => (
<li class="ml-2" classList={{ "text-slate-300": !frontMatter.active }}>
<IslandA activeClass="text-blue-700" href={href}>
<span>{title}</span>
</IslandA>
</li>
)}
</For>
</ul>
)}
</For>
<For each={r.filter(i => !i.subsection)}>
{({ title, path, href, frontMatter }) => (
<li class="ml-2" classList={{ "text-slate-300": !frontMatter.active }}>
<IslandA activeClass="text-blue-700" href={href}>
<span>{title}</span>
</IslandA>
</li>
)}
</For>
</>
}
>
<For each={r}>
{({ title, path, href, frontMatter }) => (
<li class="ml-2" classList={{ "text-slate-300": !frontMatter.active }}>
<IslandA activeClass="text-blue-700" href={href}>
<span>{title}</span>
</IslandA>
</li>
)}
</For>
</Show>
</ul>
)}
</For>
</nav>
);
}
import { components } from "./components/components";
import { useTableOfContents } from "./components/TableOfContents";
export default function Root() {
return (
<Html lang="en">
<Head>
<Title>SolidStart</Title>
<Meta charset="utf-8" />
<Meta name="viewport" content="width=device-width, initial-scale=1" />
<Link rel="icon" href="/favicon.ico" />
<Stylesheet href="https://cdn.jsdelivr.net/npm/@docsearch/css@3" />
</Head>
<Body>
<Header />
<div class="flex md:flex-row flex-col justify-around">
<Nav />
<div class="px-8 py-4 h-[calc(100vh-3.5rem)] overflow-scroll container">
<ErrorBoundary>
<Suspense>
<main class="prose prose-md max-w-none w-full pt-0 lg:px-10">
<MDXProvider
components={{
...components,
"table-of-contents": () => {
const headings = useTableOfContents();
return (
<>
<div class="xl:hidden space-y-4 overflow-hidden">
<ul class="space-y-2 text-[1rem]">
<Suspense>
<For each={headings()}>
{h => (
<li
classList={{
"ml-2": h.depth === 2,
"ml-4": h.depth === 3
}}
>
<IslandA class="border-0 no-underline" href={`#${h.slug}`}>
{h.text}
</IslandA>
</li>
)}
</For>
</Suspense>
</ul>
</div>
<hr class="xl:hidden" />
</>
);
}
}}
>
<Routes>
<FileRoutes />
</Routes>
</MDXProvider>
</main>
</Suspense>
</ErrorBoundary>
</div>
<TableOfContents />
</div>
<script src="https://cdn.jsdelivr.net/npm/@docsearch/js@3"></script>
<script>
{`docsearch({
appId: "VTVVKZ36GX",
apiKey: "f520312c8dccf1309453764ee2fed27e",
indexName: "solidjs",
container: "#docsearch",
debug: false
});`}
</script>
<Scripts />
</Body>
</Html>
);
}