@risinghq/folio 0.0.0-stage → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +45 -2
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +123 -0
- package/dist/client/index.d.ts +6 -0
- package/dist/client/index.js +147 -0
- package/dist/highlight.d.ts +2 -0
- package/dist/highlight.js +82 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +3 -0
- package/dist/layout.d.ts +39 -0
- package/dist/layout.js +203 -0
- package/dist/manual.d.ts +11 -0
- package/dist/manual.js +23 -0
- package/dist/markdown.d.ts +43 -0
- package/dist/markdown.js +144 -0
- package/dist/og.d.ts +19 -0
- package/dist/og.js +94 -0
- package/dist/options.d.ts +67 -0
- package/dist/options.js +50 -0
- package/dist/plugin.d.ts +20 -0
- package/dist/plugin.js +255 -0
- package/dist/site.d.ts +14 -0
- package/dist/site.js +53 -0
- package/package.json +74 -4
- package/theme/base.css +66 -0
- package/theme/components/code-block.css +53 -0
- package/theme/components/doc.css +61 -0
- package/theme/components/footer.css +18 -0
- package/theme/components/header.css +89 -0
- package/theme/components/home.css +14 -0
- package/theme/components/not-found.css +13 -0
- package/theme/components/pager.css +39 -0
- package/theme/components/prose.css +104 -0
- package/theme/components/sidebar.css +173 -0
- package/theme/components/toc.css +102 -0
- package/theme/controls.css +110 -0
- package/theme/fonts.css +24 -0
- package/theme/index.css +14 -0
- package/theme/tokens.css +83 -0
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Plugin } from "vite";
|
|
2
|
+
import { type FolioOptions, type PackageInfo, type ResolvedOptions } from "./options.ts";
|
|
3
|
+
export declare function entryModule(root: string, options: ResolvedOptions): string;
|
|
4
|
+
/** The nearest `package.json` at or above `dir`, or none. */
|
|
5
|
+
export declare function readPackage(dir: string): PackageInfo;
|
|
6
|
+
type Route = {
|
|
7
|
+
kind: "home";
|
|
8
|
+
} | {
|
|
9
|
+
kind: "page";
|
|
10
|
+
slug: string;
|
|
11
|
+
} | {
|
|
12
|
+
kind: "file";
|
|
13
|
+
path: string;
|
|
14
|
+
} | {
|
|
15
|
+
kind: "missing";
|
|
16
|
+
};
|
|
17
|
+
/** Matches a request path below `base` to a route; null means not a page request. */
|
|
18
|
+
export declare function matchRoute(path: string, base: string): Route | null;
|
|
19
|
+
export declare function folio(input?: FolioOptions): Plugin;
|
|
20
|
+
export {};
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
import { dirname, extname, isAbsolute, join, resolve } from "node:path";
|
|
5
|
+
import { homePage, manualPage, notFoundPage, routesFor, } from "./layout.js";
|
|
6
|
+
import { docsFile, escapeHtml } from "./markdown.js";
|
|
7
|
+
import { renderCard } from "./og.js";
|
|
8
|
+
import { resolveOptions, } from "./options.js";
|
|
9
|
+
import { loadSite } from "./site.js";
|
|
10
|
+
const entryId = "virtual:folio/entry";
|
|
11
|
+
const resolvedEntryId = `\0${entryId}`;
|
|
12
|
+
const require = createRequire(import.meta.url);
|
|
13
|
+
export function entryModule(root, options) {
|
|
14
|
+
const islands = options.islands
|
|
15
|
+
? `import islands from ${JSON.stringify(isAbsolute(options.islands) ? options.islands : resolve(root, options.islands))};`
|
|
16
|
+
: "const islands = {};";
|
|
17
|
+
const font = (name) => `import ${JSON.stringify(require.resolve(name))};`;
|
|
18
|
+
return [
|
|
19
|
+
font("@fontsource-variable/figtree"),
|
|
20
|
+
font("@fontsource-variable/geist-mono"),
|
|
21
|
+
`import "@risinghq/folio/theme.css";`,
|
|
22
|
+
`import { start } from "@risinghq/folio/client";`,
|
|
23
|
+
islands,
|
|
24
|
+
`start(islands);`,
|
|
25
|
+
].join("\n");
|
|
26
|
+
}
|
|
27
|
+
/** The nearest `package.json` at or above `dir`, or none. */
|
|
28
|
+
export function readPackage(dir) {
|
|
29
|
+
for (let current = dir;; current = dirname(current)) {
|
|
30
|
+
const file = join(current, "package.json");
|
|
31
|
+
if (existsSync(file))
|
|
32
|
+
return JSON.parse(readFileSync(file, "utf8"));
|
|
33
|
+
if (dirname(current) === current)
|
|
34
|
+
return {};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/** Matches a request path below `base` to a route; null means not a page request. */
|
|
38
|
+
export function matchRoute(path, base) {
|
|
39
|
+
if (!path.startsWith(base))
|
|
40
|
+
return null;
|
|
41
|
+
const rest = path.slice(base.length).replace(/\/$/, "");
|
|
42
|
+
if (rest === "" || rest === "index.html")
|
|
43
|
+
return { kind: "home" };
|
|
44
|
+
const page = /^docs\/([a-z0-9-]+)(?:\.html|\/index\.html)?$/.exec(rest);
|
|
45
|
+
if (page)
|
|
46
|
+
return { kind: "page", slug: page[1] ?? "" };
|
|
47
|
+
const file = docsFile.exec(rest.slice("docs/".length));
|
|
48
|
+
if (rest.startsWith("docs/") && file)
|
|
49
|
+
return { kind: "file", path: file[1] ?? "" };
|
|
50
|
+
if (rest.startsWith("docs/") || rest === "docs")
|
|
51
|
+
return { kind: "missing" };
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
const mediaTypes = {
|
|
55
|
+
png: "image/png",
|
|
56
|
+
jpg: "image/jpeg",
|
|
57
|
+
jpeg: "image/jpeg",
|
|
58
|
+
gif: "image/gif",
|
|
59
|
+
svg: "image/svg+xml",
|
|
60
|
+
webp: "image/webp",
|
|
61
|
+
avif: "image/avif",
|
|
62
|
+
};
|
|
63
|
+
/** Preloads the Latin text and code faces, which every page paints with first. */
|
|
64
|
+
function fontPreloads(bundle, base) {
|
|
65
|
+
return Object.values(bundle)
|
|
66
|
+
.filter((file) => file.type === "asset" &&
|
|
67
|
+
/\/(?:figtree|geist-mono)-latin-wght-normal-[\w-]+\.woff2$/.test(file.fileName))
|
|
68
|
+
.map((file) => `<link rel="preload" href="${base}${file.fileName}" as="font" type="font/woff2" crossorigin>`);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Prerenders a page of the site when the reader hovers or presses its link,
|
|
72
|
+
* so the click shows it at once. Browsers without speculation rules ignore it.
|
|
73
|
+
*/
|
|
74
|
+
function speculationRules(base) {
|
|
75
|
+
const rules = {
|
|
76
|
+
prerender: [{ where: { href_matches: `${base}*` }, eagerness: "moderate" }],
|
|
77
|
+
};
|
|
78
|
+
return `<script type="speculationrules">${JSON.stringify(rules)}</script>`;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Cloudflare and Netlify read `_headers`. Hashed assets never change, so a
|
|
82
|
+
* browser keeps them instead of revalidating each one on every page.
|
|
83
|
+
*/
|
|
84
|
+
function cacheHeaders(base, assetsDir) {
|
|
85
|
+
return `${base}${assetsDir}/*\n Cache-Control: public, max-age=31536000, immutable\n`;
|
|
86
|
+
}
|
|
87
|
+
/** The home page and every manual page, for search engines. */
|
|
88
|
+
function sitemap(routes, site) {
|
|
89
|
+
const urls = [routes.home, ...site.pages.map((p) => routes.page(p.slug))]
|
|
90
|
+
.map((path) => `<url><loc>${escapeHtml(routes.absolute(path) ?? path)}</loc></url>`)
|
|
91
|
+
.join("\n");
|
|
92
|
+
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
93
|
+
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
94
|
+
${urls}
|
|
95
|
+
</urlset>
|
|
96
|
+
`;
|
|
97
|
+
}
|
|
98
|
+
function robots(routes) {
|
|
99
|
+
return `User-agent: *\nAllow: /\n\nSitemap: ${routes.absolute(`${routes.home}sitemap.xml`)}\n`;
|
|
100
|
+
}
|
|
101
|
+
/** The social card of the home page and of each manual page. */
|
|
102
|
+
function cards(options, routes, site) {
|
|
103
|
+
const host = options.url ? new URL(options.url).host : undefined;
|
|
104
|
+
const home = {
|
|
105
|
+
path: routes.card(),
|
|
106
|
+
card: {
|
|
107
|
+
title: options.title,
|
|
108
|
+
summary: options.description || site.home?.summary || "",
|
|
109
|
+
host,
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
const pages = site.pages.map((page) => ({
|
|
113
|
+
path: routes.card(page.slug),
|
|
114
|
+
card: {
|
|
115
|
+
site: options.title,
|
|
116
|
+
title: page.title,
|
|
117
|
+
summary: site.rendered.get(page.slug)?.summary ?? "",
|
|
118
|
+
host,
|
|
119
|
+
},
|
|
120
|
+
}));
|
|
121
|
+
return [home, ...pages];
|
|
122
|
+
}
|
|
123
|
+
function renderRoute(route, site, options, base, assets) {
|
|
124
|
+
const routes = routesFor(base, options.url);
|
|
125
|
+
const shared = { options, routes, pages: site.pages, assets };
|
|
126
|
+
if (route.kind === "home")
|
|
127
|
+
return { status: 200, html: homePage({ ...shared, home: site.home }) };
|
|
128
|
+
const page = route.kind === "page" ? site.rendered.get(route.slug) : undefined;
|
|
129
|
+
if (route.kind === "page" && page) {
|
|
130
|
+
return {
|
|
131
|
+
status: 200,
|
|
132
|
+
html: manualPage({ ...shared, slug: route.slug, page }),
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
return { status: 404, html: notFoundPage(shared) };
|
|
136
|
+
}
|
|
137
|
+
export function folio(input = {}) {
|
|
138
|
+
let options;
|
|
139
|
+
let config;
|
|
140
|
+
async function serve(server, url) {
|
|
141
|
+
const path = decodeURIComponent(url.split(/[?#]/)[0] ?? "");
|
|
142
|
+
const route = matchRoute(path, config.base);
|
|
143
|
+
if (!route)
|
|
144
|
+
return null;
|
|
145
|
+
const site = await loadSite(config.root, options, routesFor(config.base, options.url));
|
|
146
|
+
if (route.kind === "file") {
|
|
147
|
+
if (!site.files.includes(route.path))
|
|
148
|
+
return null;
|
|
149
|
+
return {
|
|
150
|
+
status: 200,
|
|
151
|
+
type: mediaTypes[extname(route.path).slice(1)] ?? "",
|
|
152
|
+
body: await readFile(join(config.root, options.docs, route.path)),
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
// transformIndexHtml adds the base to this path.
|
|
156
|
+
const assets = {
|
|
157
|
+
head: `<script type="module" src="/@id/${entryId}"></script>`,
|
|
158
|
+
};
|
|
159
|
+
const { status, html } = renderRoute(route, site, options, config.base, assets);
|
|
160
|
+
return {
|
|
161
|
+
status,
|
|
162
|
+
type: "text/html; charset=utf-8",
|
|
163
|
+
body: await server.transformIndexHtml(url, html),
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
return {
|
|
167
|
+
name: "folio",
|
|
168
|
+
config() {
|
|
169
|
+
return {
|
|
170
|
+
// MPA lets `vite preview` serve the emitted pages the way GitHub
|
|
171
|
+
// Pages does: `docs/x/index.html`, `docs/x.html`, else a 404.
|
|
172
|
+
appType: "mpa",
|
|
173
|
+
build: { rolldownOptions: { input: { folio: entryId } } },
|
|
174
|
+
};
|
|
175
|
+
},
|
|
176
|
+
configResolved(resolved) {
|
|
177
|
+
config = resolved;
|
|
178
|
+
options = resolveOptions(input, readPackage(resolved.root));
|
|
179
|
+
},
|
|
180
|
+
resolveId(id) {
|
|
181
|
+
return id === entryId ? resolvedEntryId : null;
|
|
182
|
+
},
|
|
183
|
+
load(id) {
|
|
184
|
+
return id === resolvedEntryId ? entryModule(config.root, options) : null;
|
|
185
|
+
},
|
|
186
|
+
configureServer(server) {
|
|
187
|
+
const docs = join(config.root, options.docs);
|
|
188
|
+
server.watcher.add(docs);
|
|
189
|
+
server.watcher.on("change", (file) => {
|
|
190
|
+
if (file.startsWith(docs))
|
|
191
|
+
server.ws.send({ type: "full-reload" });
|
|
192
|
+
});
|
|
193
|
+
server.middlewares.use(async (req, res, next) => {
|
|
194
|
+
if (req.method !== "GET" || !req.url)
|
|
195
|
+
return next();
|
|
196
|
+
let response;
|
|
197
|
+
try {
|
|
198
|
+
response = await serve(server, req.url);
|
|
199
|
+
}
|
|
200
|
+
catch (error) {
|
|
201
|
+
return next(error);
|
|
202
|
+
}
|
|
203
|
+
if (!response)
|
|
204
|
+
return next();
|
|
205
|
+
res.statusCode = response.status;
|
|
206
|
+
res.setHeader("Content-Type", response.type);
|
|
207
|
+
res.end(response.body);
|
|
208
|
+
});
|
|
209
|
+
},
|
|
210
|
+
async generateBundle(_, bundle) {
|
|
211
|
+
const entry = Object.values(bundle).find((chunk) => chunk.type === "chunk" &&
|
|
212
|
+
chunk.isEntry &&
|
|
213
|
+
chunk.facadeModuleId === resolvedEntryId);
|
|
214
|
+
if (!entry || entry.type !== "chunk")
|
|
215
|
+
throw new Error("folio: the client entry was not built");
|
|
216
|
+
const css = [...(entry.viteMetadata?.importedCss ?? [])];
|
|
217
|
+
const head = [
|
|
218
|
+
...fontPreloads(bundle, config.base),
|
|
219
|
+
...css.map((file) => `<link rel="stylesheet" href="${config.base}${file}">`),
|
|
220
|
+
`<script type="module" src="${config.base}${entry.fileName}"></script>`,
|
|
221
|
+
speculationRules(config.base),
|
|
222
|
+
].join("\n");
|
|
223
|
+
const routes = routesFor(config.base, options.url);
|
|
224
|
+
const site = await loadSite(config.root, options, routes);
|
|
225
|
+
const emit = (fileName, source) => this.emitFile({ type: "asset", fileName, source });
|
|
226
|
+
const own = (file) => Boolean(config.publicDir && existsSync(join(config.publicDir, file)));
|
|
227
|
+
if (options.url) {
|
|
228
|
+
if (!own("sitemap.xml"))
|
|
229
|
+
emit("sitemap.xml", sitemap(routes, site));
|
|
230
|
+
// Crawlers read robots.txt only at the host's root.
|
|
231
|
+
if (config.base === "/" && !own("robots.txt"))
|
|
232
|
+
emit("robots.txt", robots(routes));
|
|
233
|
+
if (options.ogImage === undefined) {
|
|
234
|
+
const drawn = cards(options, routes, site);
|
|
235
|
+
const images = await Promise.all(drawn.map(({ card }) => renderCard(card)));
|
|
236
|
+
drawn.forEach(({ path }, i) => emit(path.slice(routes.home.length), images[i]));
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
const sources = await Promise.all(site.files.map((file) => readFile(join(config.root, options.docs, file))));
|
|
240
|
+
site.files.forEach((file, i) => emit(`docs/${file}`, sources[i]));
|
|
241
|
+
if (config.base.startsWith("/") && !own("_headers")) {
|
|
242
|
+
emit("_headers", cacheHeaders(config.base, config.build.assetsDir));
|
|
243
|
+
}
|
|
244
|
+
const assets = { head };
|
|
245
|
+
emit("index.html", renderRoute({ kind: "home" }, site, options, config.base, assets).html);
|
|
246
|
+
emit("404.html", renderRoute({ kind: "missing" }, site, options, config.base, assets)
|
|
247
|
+
.html);
|
|
248
|
+
for (const page of site.pages) {
|
|
249
|
+
const { html } = renderRoute({ kind: "page", slug: page.slug }, site, options, config.base, assets);
|
|
250
|
+
emit(`docs/${page.slug}/index.html`, html);
|
|
251
|
+
emit(`docs/${page.slug}.html`, html);
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
};
|
|
255
|
+
}
|
package/dist/site.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Routes } from "./layout.ts";
|
|
2
|
+
import { type PageEntry } from "./manual.ts";
|
|
3
|
+
import { type RenderedPage } from "./markdown.ts";
|
|
4
|
+
import type { ResolvedOptions } from "./options.ts";
|
|
5
|
+
export interface Site {
|
|
6
|
+
pages: PageEntry[];
|
|
7
|
+
rendered: Map<string, RenderedPage>;
|
|
8
|
+
/** `index.md` of the docs folder: the home page, when it exists. */
|
|
9
|
+
home?: RenderedPage;
|
|
10
|
+
/** Every docs folder file a page or the home page shows. */
|
|
11
|
+
files: string[];
|
|
12
|
+
}
|
|
13
|
+
/** Reads the docs folder's index and renders every page it lists, and the home page. */
|
|
14
|
+
export declare function loadSite(root: string, options: ResolvedOptions, routes: Routes): Promise<Site>;
|
package/dist/site.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { imageSize } from "image-size";
|
|
5
|
+
import { readManual } from "./manual.js";
|
|
6
|
+
import { renderPage } from "./markdown.js";
|
|
7
|
+
async function readOptional(path) {
|
|
8
|
+
try {
|
|
9
|
+
return await readFile(path, "utf8");
|
|
10
|
+
}
|
|
11
|
+
catch (error) {
|
|
12
|
+
if (error.code === "ENOENT")
|
|
13
|
+
return undefined;
|
|
14
|
+
throw error;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function readImageSize(dir, file) {
|
|
18
|
+
let source;
|
|
19
|
+
try {
|
|
20
|
+
source = readFileSync(join(dir, file));
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
throw new Error(`folio: the image ${file} is not in ${dir}`);
|
|
24
|
+
}
|
|
25
|
+
const { width, height } = imageSize(source);
|
|
26
|
+
return { width, height };
|
|
27
|
+
}
|
|
28
|
+
/** Reads the docs folder's index and renders every page it lists, and the home page. */
|
|
29
|
+
export async function loadSite(root, options, routes) {
|
|
30
|
+
const dir = join(root, options.docs);
|
|
31
|
+
const indexPath = join(options.docs, "README.md");
|
|
32
|
+
const pages = readManual(await readFile(join(dir, "README.md"), "utf8"), indexPath);
|
|
33
|
+
const sourceUrl = (file) => options.repository
|
|
34
|
+
? `${options.repository}/blob/${options.branch}/${options.docsPath}/${file}`
|
|
35
|
+
: file;
|
|
36
|
+
const context = {
|
|
37
|
+
pages,
|
|
38
|
+
pageUrl: routes.page,
|
|
39
|
+
sourceUrl,
|
|
40
|
+
fileUrl: routes.file,
|
|
41
|
+
imageSize: (file) => readImageSize(dir, file),
|
|
42
|
+
};
|
|
43
|
+
const sources = await Promise.all(pages.map((page) => readFile(join(dir, `${page.slug}.md`), "utf8")));
|
|
44
|
+
const rendered = new Map(pages.map((page, i) => [page.slug, renderPage(sources[i] ?? "", context)]));
|
|
45
|
+
const homeSource = await readOptional(join(dir, "index.md"));
|
|
46
|
+
const home = homeSource === undefined
|
|
47
|
+
? undefined
|
|
48
|
+
: renderPage(homeSource, { ...context, actions: true });
|
|
49
|
+
const files = [
|
|
50
|
+
...new Set([...rendered.values(), ...(home ? [home] : [])].flatMap((page) => page.files)),
|
|
51
|
+
];
|
|
52
|
+
return { pages, rendered, home, files };
|
|
53
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,76 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@risinghq/folio",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "A documentation site from a repository's docs folder, built with Vite and Solid.",
|
|
5
|
+
"homepage": "https://folio.rising.sh",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/risinghq/folio.git"
|
|
10
|
+
},
|
|
11
|
+
"bin": {
|
|
12
|
+
"folio": "dist/cli.js"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"theme"
|
|
17
|
+
],
|
|
18
|
+
"type": "module",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"default": "./dist/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./client": {
|
|
25
|
+
"types": "./dist/client/index.d.ts",
|
|
26
|
+
"default": "./dist/client/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./highlight": {
|
|
29
|
+
"types": "./dist/highlight.d.ts",
|
|
30
|
+
"default": "./dist/highlight.js"
|
|
31
|
+
},
|
|
32
|
+
"./theme.css": "./theme/index.css"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "tsc -p tsconfig.build.json",
|
|
36
|
+
"prepare": "bun run build",
|
|
37
|
+
"check": "bun run lint && bun run typecheck && bun run build && bun run test",
|
|
38
|
+
"fix": "oxlint --fix && oxfmt",
|
|
39
|
+
"lint": "oxlint --deny-warnings && oxfmt --check",
|
|
40
|
+
"test": "vitest run",
|
|
41
|
+
"typecheck": "tsc --noEmit",
|
|
42
|
+
"site": "vite site",
|
|
43
|
+
"build:site": "bun run build && vite build site",
|
|
44
|
+
"deploy:site": "wrangler deploy -c site/wrangler.jsonc"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@fontsource-variable/figtree": "^5.3.0",
|
|
48
|
+
"@fontsource-variable/geist-mono": "^5.3.0",
|
|
49
|
+
"@fontsource/figtree": "^5.3.0",
|
|
50
|
+
"@resvg/resvg-js": "^2.6.2",
|
|
51
|
+
"@shikijs/langs": "^4.6.0",
|
|
52
|
+
"image-size": "^2.1.0",
|
|
53
|
+
"marked": "^18.2.0",
|
|
54
|
+
"satori": "^0.63.2",
|
|
55
|
+
"shiki": "^4.6.0"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@solidjs/web": "^2.0.0-rc.21",
|
|
59
|
+
"@types/jsdom": "^30.0.0",
|
|
60
|
+
"@types/node": "^26.6.7",
|
|
61
|
+
"jsdom": "^31.0.1",
|
|
62
|
+
"oxfmt": "^0.78.0",
|
|
63
|
+
"oxlint": "^1.93.0",
|
|
64
|
+
"playwright": "^1.65.0",
|
|
65
|
+
"solid-js": "^2.0.0-rc.21",
|
|
66
|
+
"typescript": "^7.0.2",
|
|
67
|
+
"vite": "^8.3.8",
|
|
68
|
+
"vitest": "^5.1.0",
|
|
69
|
+
"wrangler": "^4.168.0"
|
|
70
|
+
},
|
|
71
|
+
"peerDependencies": {
|
|
72
|
+
"@solidjs/web": "^2.0.0-rc.21",
|
|
73
|
+
"solid-js": "^2.0.0-rc.21",
|
|
74
|
+
"vite": "^8.3.8"
|
|
75
|
+
}
|
|
76
|
+
}
|
package/theme/base.css
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
* {
|
|
2
|
+
box-sizing: border-box;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
6
|
+
@view-transition {
|
|
7
|
+
navigation: auto;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
html {
|
|
12
|
+
scroll-padding-top: calc(var(--header) + 24px);
|
|
13
|
+
-webkit-text-size-adjust: 100%;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
body {
|
|
17
|
+
margin: 0;
|
|
18
|
+
background: var(--bg);
|
|
19
|
+
color: var(--text);
|
|
20
|
+
font: 400 16px/1.7 var(--font);
|
|
21
|
+
-webkit-font-smoothing: antialiased;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
a {
|
|
25
|
+
color: inherit;
|
|
26
|
+
text-decoration: none;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
button,
|
|
30
|
+
select,
|
|
31
|
+
input {
|
|
32
|
+
font: inherit;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
:focus-visible {
|
|
36
|
+
outline: 2px solid var(--accent);
|
|
37
|
+
outline-offset: 2px;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
code,
|
|
41
|
+
pre,
|
|
42
|
+
kbd,
|
|
43
|
+
output {
|
|
44
|
+
font-family: var(--mono);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.skip {
|
|
48
|
+
position: absolute;
|
|
49
|
+
left: 16px;
|
|
50
|
+
top: -64px;
|
|
51
|
+
z-index: 40;
|
|
52
|
+
padding: 8px 12px;
|
|
53
|
+
background: var(--raised);
|
|
54
|
+
border-radius: var(--r-md);
|
|
55
|
+
}
|
|
56
|
+
.skip:focus {
|
|
57
|
+
top: 12px;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@media (prefers-reduced-motion: reduce) {
|
|
61
|
+
*,
|
|
62
|
+
*::before,
|
|
63
|
+
*::after {
|
|
64
|
+
transition-duration: 0.01ms !important;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
.code {
|
|
2
|
+
margin: 0 0 24px;
|
|
3
|
+
background: var(--bg-sunken);
|
|
4
|
+
border: 1px solid var(--line-subtle);
|
|
5
|
+
border-radius: var(--r-lg);
|
|
6
|
+
overflow: hidden;
|
|
7
|
+
}
|
|
8
|
+
.code figcaption {
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
justify-content: space-between;
|
|
12
|
+
height: 40px;
|
|
13
|
+
padding: 0 8px 0 16px;
|
|
14
|
+
font: 12px var(--mono);
|
|
15
|
+
color: var(--faint);
|
|
16
|
+
border-bottom: 1px solid var(--line-subtle);
|
|
17
|
+
}
|
|
18
|
+
/*
|
|
19
|
+
* Shiki writes its theme's background inline; the block's own surface wins.
|
|
20
|
+
* No right padding: browsers count it as scrollable overflow, so a line that
|
|
21
|
+
* fits the box would still show a scrollbar.
|
|
22
|
+
*/
|
|
23
|
+
.code pre {
|
|
24
|
+
margin: 0;
|
|
25
|
+
padding: 18px 0 18px 20px;
|
|
26
|
+
overflow-x: auto;
|
|
27
|
+
scrollbar-width: thin;
|
|
28
|
+
scrollbar-color: var(--line) transparent;
|
|
29
|
+
font: 13.5px/1.75 var(--mono);
|
|
30
|
+
tab-size: 2;
|
|
31
|
+
background: transparent !important;
|
|
32
|
+
}
|
|
33
|
+
.copy {
|
|
34
|
+
height: 28px;
|
|
35
|
+
padding: 0 10px;
|
|
36
|
+
font: 500 13px/1 var(--font);
|
|
37
|
+
color: var(--muted);
|
|
38
|
+
background: var(--raised);
|
|
39
|
+
border: 1px solid var(--line);
|
|
40
|
+
border-radius: var(--r-sm);
|
|
41
|
+
cursor: pointer;
|
|
42
|
+
}
|
|
43
|
+
.copy:hover {
|
|
44
|
+
color: var(--text);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@media (max-width: 820px) {
|
|
48
|
+
.prose .code {
|
|
49
|
+
margin-inline: calc(-1 * var(--gutter));
|
|
50
|
+
border-inline: 0;
|
|
51
|
+
border-radius: 0;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/* A manual page: the sidebar, the content column and the rail. */
|
|
2
|
+
|
|
3
|
+
.doc-layout {
|
|
4
|
+
display: grid;
|
|
5
|
+
grid-template-columns: 280px minmax(0, 1fr) 240px;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.doc {
|
|
9
|
+
min-width: 0;
|
|
10
|
+
max-width: 812px;
|
|
11
|
+
padding: 48px 72px 96px;
|
|
12
|
+
}
|
|
13
|
+
.crumb {
|
|
14
|
+
margin: 0 0 12px;
|
|
15
|
+
font: 12.5px var(--mono);
|
|
16
|
+
color: var(--faint);
|
|
17
|
+
}
|
|
18
|
+
.crumb a:hover {
|
|
19
|
+
color: var(--text);
|
|
20
|
+
}
|
|
21
|
+
.doc h1 {
|
|
22
|
+
margin: 0 0 20px;
|
|
23
|
+
font-size: 48px;
|
|
24
|
+
line-height: 1.05;
|
|
25
|
+
letter-spacing: -0.035em;
|
|
26
|
+
font-weight: 600;
|
|
27
|
+
text-wrap: balance;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.doc-footer {
|
|
31
|
+
margin-top: 64px;
|
|
32
|
+
font-size: 14px;
|
|
33
|
+
color: var(--muted);
|
|
34
|
+
}
|
|
35
|
+
.doc-footer > a:hover {
|
|
36
|
+
color: var(--text);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@media (max-width: 1180px) {
|
|
40
|
+
.doc-layout {
|
|
41
|
+
grid-template-columns: 260px minmax(0, 1fr);
|
|
42
|
+
}
|
|
43
|
+
.doc {
|
|
44
|
+
padding-inline: 48px;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@media (max-width: 820px) {
|
|
49
|
+
.doc-layout {
|
|
50
|
+
display: block;
|
|
51
|
+
}
|
|
52
|
+
.doc {
|
|
53
|
+
padding: 24px var(--gutter) 64px;
|
|
54
|
+
}
|
|
55
|
+
.crumb {
|
|
56
|
+
display: none;
|
|
57
|
+
}
|
|
58
|
+
.doc h1 {
|
|
59
|
+
font-size: 36px;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
.site-footer {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-wrap: wrap;
|
|
4
|
+
align-items: center;
|
|
5
|
+
justify-content: space-between;
|
|
6
|
+
gap: 12px 24px;
|
|
7
|
+
padding: 28px var(--gutter);
|
|
8
|
+
font-size: 13.5px;
|
|
9
|
+
color: var(--muted);
|
|
10
|
+
border-top: 1px solid var(--line-subtle);
|
|
11
|
+
}
|
|
12
|
+
.site-footer a:hover {
|
|
13
|
+
color: var(--text);
|
|
14
|
+
}
|
|
15
|
+
.site-footer nav {
|
|
16
|
+
display: flex;
|
|
17
|
+
gap: 24px;
|
|
18
|
+
}
|