@ox-content/vite-plugin 3.0.0-alpha.8 → 3.0.0-beta.0
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/dist/index.cjs +8898 -2585
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2050 -221
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2050 -221
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +8839 -2531
- package/dist/index.mjs.map +1 -1
- package/dist/markdown-tables.cjs +70 -0
- package/dist/markdown-tables.cjs.map +1 -0
- package/dist/markdown-tables.d.cts +22 -0
- package/dist/markdown-tables.d.cts.map +1 -0
- package/dist/markdown-tables.d.mts +22 -0
- package/dist/markdown-tables.d.mts.map +1 -0
- package/dist/markdown-tables.mjs +66 -0
- package/dist/markdown-tables.mjs.map +1 -0
- package/dist/napi.cjs +44 -0
- package/dist/napi.cjs.map +1 -0
- package/dist/napi.mjs +34 -0
- package/dist/napi.mjs.map +1 -0
- package/dist/reader-chrome-client.cjs +103 -0
- package/dist/reader-chrome-client.d.cts +2 -0
- package/dist/reader-chrome-client.d.mts +2 -0
- package/dist/reader-chrome-client.mjs +102 -0
- package/dist/reader-chrome.cjs +109 -0
- package/dist/reader-chrome.cjs.map +1 -0
- package/dist/reader-chrome.d.cts +103 -0
- package/dist/reader-chrome.d.mts +103 -0
- package/dist/reader-chrome.mjs +98 -0
- package/dist/reader-chrome.mjs.map +1 -0
- package/dist/styles/all.css +15 -0
- package/dist/styles/citations.css +62 -0
- package/dist/styles/core.css +2261 -0
- package/dist/styles/github.css +262 -0
- package/dist/styles/graphviz.css +34 -0
- package/dist/styles/magic-links.css +33 -0
- package/dist/styles/markdown-tables.css +16 -0
- package/dist/styles/mermaid.css +151 -0
- package/dist/styles/not-by-ai.css +43 -0
- package/dist/styles/ogp.css +170 -0
- package/dist/styles/reader-chrome.css +163 -0
- package/dist/styles/social.css +678 -0
- package/dist/styles/tabs.css +210 -0
- package/dist/styles/theme-transition.css +37 -0
- package/dist/styles/twitter-full.css +598 -0
- package/dist/styles/youtube.css +87 -0
- package/dist/theme-tokens.cjs +95 -0
- package/dist/theme-tokens.cjs.map +1 -0
- package/dist/theme-tokens.d.cts +72 -0
- package/dist/theme-tokens.d.cts.map +1 -0
- package/dist/theme-tokens.d.mts +72 -0
- package/dist/theme-tokens.d.mts.map +1 -0
- package/dist/theme-tokens.mjs +91 -0
- package/dist/theme-tokens.mjs.map +1 -0
- package/dist/theme-transition-client.cjs +161 -0
- package/dist/theme-transition-client.d.cts +21 -0
- package/dist/theme-transition-client.d.mts +21 -0
- package/dist/theme-transition-client.mjs +160 -0
- package/dist/twitter-client.cjs +84 -0
- package/dist/twitter-client.d.cts +11 -0
- package/dist/twitter-client.d.mts +11 -0
- package/dist/twitter-client.mjs +83 -0
- package/dist/vitepress.cjs +614 -77
- package/dist/vitepress.cjs.map +1 -1
- package/dist/vitepress.mjs +588 -65
- package/dist/vitepress.mjs.map +1 -1
- package/package.json +89 -4
- package/dist/api.cjs +0 -6563
- package/dist/api.cjs.map +0 -1
- package/dist/api.mjs +0 -6456
- package/dist/api.mjs.map +0 -1
- package/dist/interop.cjs +0 -31
- package/dist/interop.cjs.map +0 -1
- package/dist/interop.mjs +0 -26
- package/dist/interop.mjs.map +0 -1
- package/dist/tabs.cjs +0 -98
- package/dist/tabs.cjs.map +0 -1
- package/dist/tabs.mjs +0 -99
- package/dist/tabs.mjs.map +0 -1
package/dist/vitepress.mjs
CHANGED
|
@@ -1,32 +1,585 @@
|
|
|
1
|
+
import { n as importNapiModuleSync } from "./napi.mjs";
|
|
2
|
+
import { renderThemeTokenCss } from "./theme-tokens.mjs";
|
|
1
3
|
import { createRequire } from "node:module";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
4
|
+
import { existsSync } from "node:fs";
|
|
5
|
+
import { isAbsolute, join, resolve } from "node:path";
|
|
6
|
+
import { createHash } from "node:crypto";
|
|
7
|
+
import { mkdir, readFile, readdir, stat, writeFile } from "node:fs/promises";
|
|
8
|
+
import { glob } from "glob";
|
|
9
|
+
//#region src/theme-fonts-acquire.ts
|
|
10
|
+
/**
|
|
11
|
+
* Resolve self-hosted faces from a local file / `@fontsource` directory or
|
|
12
|
+
* Google Fonts. Downloads are cached; tests inject `fetch` so CI never hits
|
|
13
|
+
* the network.
|
|
14
|
+
*/
|
|
15
|
+
const GOOGLE_CSS = "https://fonts.googleapis.com/css2";
|
|
16
|
+
const GOOGLE_UA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36";
|
|
17
|
+
const ALLOWED_HOSTS = /* @__PURE__ */ new Set(["fonts.googleapis.com", "fonts.gstatic.com"]);
|
|
18
|
+
function fontMime(fileName) {
|
|
19
|
+
if (fileName.endsWith(".woff")) return "font/woff";
|
|
20
|
+
if (fileName.endsWith(".ttf")) return "font/ttf";
|
|
21
|
+
if (fileName.endsWith(".otf")) return "font/otf";
|
|
22
|
+
return "font/woff2";
|
|
23
|
+
}
|
|
24
|
+
function renderFontFaceCss(faces) {
|
|
25
|
+
return faces.map((face) => {
|
|
26
|
+
const range = face.unicodeRange ? `\n unicode-range: ${face.unicodeRange};` : "";
|
|
27
|
+
const fileName = face.fileName;
|
|
28
|
+
const format = fileName.endsWith(".woff") ? "woff" : fileName.endsWith(".ttf") ? "truetype" : fileName.endsWith(".otf") ? "opentype" : "woff2";
|
|
29
|
+
return `@font-face {
|
|
30
|
+
font-family: ${/^[a-zA-Z_-][\w-]*$/.test(face.family) ? face.family : `"${face.family.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"`};
|
|
31
|
+
font-style: ${face.style};
|
|
32
|
+
font-weight: ${face.weight};
|
|
33
|
+
font-display: ${face.display};
|
|
34
|
+
src: url(./${fileName}) format("${format}");${range}
|
|
35
|
+
}`;
|
|
36
|
+
}).join("\n\n");
|
|
37
|
+
}
|
|
38
|
+
function resolveFontCacheDir(root, cacheDir) {
|
|
39
|
+
return cacheDir ?? join(root, "node_modules", ".cache", "ox-content", "fonts");
|
|
40
|
+
}
|
|
41
|
+
async function acquireSelfHostedFaces(faces, options) {
|
|
42
|
+
const cacheDir = resolveFontCacheDir(options.root, options.cacheDir);
|
|
43
|
+
const acquired = [];
|
|
44
|
+
for (const face of faces) acquired.push(face.provider === "local" ? await acquireLocalFace(face, options.root) : await acquireGoogleFace(face, cacheDir, options.fetch ?? fetch));
|
|
45
|
+
return acquired;
|
|
46
|
+
}
|
|
47
|
+
async function acquireLocalFace(face, root) {
|
|
48
|
+
if (!face.path) throw new Error(`Theme font "${face.family}" uses provider "local" but has no path.`);
|
|
49
|
+
if (face.path.includes("\0")) throw new Error(`Theme font "${face.family}" path must not contain NUL.`);
|
|
50
|
+
const resolved = resolveLocalPath(root, face.path);
|
|
51
|
+
const info = await stat(resolved).catch(() => void 0);
|
|
52
|
+
if (!info) throw new Error(`Theme font "${face.family}" was not found at ${resolved}.`);
|
|
53
|
+
const file = info.isDirectory() ? await findDirectoryFont(resolved, face) : resolved;
|
|
54
|
+
return {
|
|
55
|
+
...face,
|
|
56
|
+
bytes: await readFile(file)
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function resolveLocalPath(root, spec) {
|
|
60
|
+
if (isAbsolute(spec)) return spec;
|
|
61
|
+
if (spec.startsWith("@") || !spec.startsWith(".")) return resolve(root, "node_modules", spec);
|
|
62
|
+
return resolve(root, spec);
|
|
63
|
+
}
|
|
64
|
+
async function findDirectoryFont(dir, face) {
|
|
65
|
+
const filesDir = existsSync(join(dir, "files")) ? join(dir, "files") : dir;
|
|
66
|
+
const names = (await readdir(filesDir)).filter((name) => /\.(woff2|woff|ttf|otf)$/i.test(name));
|
|
67
|
+
const weight = String(face.weight);
|
|
68
|
+
const wantItalic = face.style === "italic";
|
|
69
|
+
const match = names.find((name) => {
|
|
70
|
+
const lower = name.toLowerCase();
|
|
71
|
+
const hasWeight = lower.includes(weight);
|
|
72
|
+
const italic = lower.includes("italic");
|
|
73
|
+
const subset = face.subset === "all" || lower.includes(face.subset.toLowerCase());
|
|
74
|
+
return hasWeight && subset && italic === wantItalic;
|
|
75
|
+
});
|
|
76
|
+
const fallback = names[0];
|
|
77
|
+
const chosen = match ?? (names.length === 1 ? fallback : void 0);
|
|
78
|
+
if (!chosen) throw new Error(`Theme font "${face.family}" has no ${face.weight} ${face.style} ${face.subset} file in ${filesDir}.`);
|
|
79
|
+
return join(filesDir, chosen);
|
|
80
|
+
}
|
|
81
|
+
async function acquireGoogleFace(face, cacheDir, fetchFn) {
|
|
82
|
+
const parsed = parseGoogleCss(await cachedText(googleCssUrl(face), cacheDir, fetchFn, ".css")).find((entry) => entry.weight === face.weight && entry.style === face.style && (entry.subset === face.subset || !entry.subset));
|
|
83
|
+
if (!parsed) throw new Error(`Google Fonts CSS for "${face.family}" has no ${face.weight} ${face.style} ${face.subset} face.`);
|
|
84
|
+
const bytes = await cachedBytes(parsed.url, cacheDir, fetchFn, ".woff2");
|
|
85
|
+
return {
|
|
86
|
+
...face,
|
|
87
|
+
bytes,
|
|
88
|
+
unicodeRange: face.unicodeRange ?? parsed.unicodeRange
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function googleCssUrl(face) {
|
|
92
|
+
const italic = face.style === "italic";
|
|
93
|
+
const axis = italic ? "ital,wght" : "wght";
|
|
94
|
+
const spec = italic ? `1,${face.weight}` : `${face.weight}`;
|
|
95
|
+
const family = `${face.family.replace(/ /g, "+")}:${axis}@${spec}`;
|
|
96
|
+
return `${GOOGLE_CSS}?family=${family}&display=${encodeURIComponent(face.display)}`;
|
|
97
|
+
}
|
|
98
|
+
function parseGoogleCss(css) {
|
|
99
|
+
const faces = [];
|
|
100
|
+
const blocks = css.matchAll(/\/\*\s*([a-z0-9-]+)\s*\*\/\s*@font-face\s*\{([^}]+)\}/gi);
|
|
101
|
+
for (const match of blocks) {
|
|
102
|
+
const parsed = parseGoogleBlock(match[2] ?? "", match[1]?.toLowerCase() ?? "");
|
|
103
|
+
if (parsed) faces.push(parsed);
|
|
104
|
+
}
|
|
105
|
+
if (faces.length === 0) for (const match of css.matchAll(/@font-face\s*\{([^}]+)\}/gi)) {
|
|
106
|
+
const parsed = parseGoogleBlock(match[1] ?? "", "");
|
|
107
|
+
if (parsed) faces.push(parsed);
|
|
108
|
+
}
|
|
109
|
+
return faces;
|
|
110
|
+
}
|
|
111
|
+
function parseGoogleBlock(body, subset) {
|
|
112
|
+
const url = body.match(/url\((['"]?)(https?:\/\/[^'")]+)\1\)/)?.[2];
|
|
113
|
+
if (!url || !isAllowedFontUrl(url)) return;
|
|
114
|
+
return {
|
|
115
|
+
subset,
|
|
116
|
+
weight: Number(body.match(/font-weight:\s*(\d+)/i)?.[1] ?? 400),
|
|
117
|
+
style: /font-style:\s*italic/i.test(body) ? "italic" : "normal",
|
|
118
|
+
url,
|
|
119
|
+
unicodeRange: body.match(/unicode-range:\s*([^;]+)/i)?.[1]?.trim()
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function isAllowedFontUrl(url) {
|
|
23
123
|
try {
|
|
24
|
-
|
|
25
|
-
return
|
|
124
|
+
const parsed = new URL(url);
|
|
125
|
+
return parsed.protocol === "https:" && ALLOWED_HOSTS.has(parsed.hostname);
|
|
26
126
|
} catch {
|
|
27
|
-
|
|
28
|
-
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
async function cachedText(url, cacheDir, fetchFn, ext) {
|
|
131
|
+
const bytes = await cachedBytes(url, cacheDir, fetchFn, ext);
|
|
132
|
+
return new TextDecoder().decode(bytes);
|
|
133
|
+
}
|
|
134
|
+
async function cachedBytes(url, cacheDir, fetchFn, ext) {
|
|
135
|
+
if (!isAllowedFontUrl(url)) throw new Error(`Refusing to download font from ${url}.`);
|
|
136
|
+
await mkdir(cacheDir, { recursive: true });
|
|
137
|
+
const dest = join(cacheDir, `${createHash("sha256").update(url).digest("hex").slice(0, 16)}${ext}`);
|
|
138
|
+
if (existsSync(dest)) return readFile(dest);
|
|
139
|
+
const response = await fetchFn(url, { headers: { "User-Agent": GOOGLE_UA } });
|
|
140
|
+
if (!response.ok) throw new Error(`Failed to download ${url}: ${response.status}`);
|
|
141
|
+
const bytes = new Uint8Array(await response.arrayBuffer());
|
|
142
|
+
await writeFile(dest, bytes);
|
|
143
|
+
return bytes;
|
|
144
|
+
}
|
|
145
|
+
//#endregion
|
|
146
|
+
//#region src/theme-fonts.ts
|
|
147
|
+
/**
|
|
148
|
+
* Opt-in web-font objects for `theme.fonts`, plus SSG self-host emission.
|
|
149
|
+
*
|
|
150
|
+
* NAPI still receives flattened CSS stacks (`JsThemeFonts`). File acquisition
|
|
151
|
+
* and `@font-face` generation stay in TypeScript so other PRs can keep landing
|
|
152
|
+
* NAPI theme-type changes independently.
|
|
153
|
+
*/
|
|
154
|
+
const FONT_ASSET_DIR = "__ox_fonts__";
|
|
155
|
+
const FONT_CSS_NAME = "fonts.css";
|
|
156
|
+
const NAMED_FONT_PATTERN = /^[a-z][a-z0-9-]*$/;
|
|
157
|
+
const GENERIC_FOR = {
|
|
158
|
+
sans: "sans-serif",
|
|
159
|
+
mono: "monospace",
|
|
160
|
+
named: "sans-serif"
|
|
161
|
+
};
|
|
162
|
+
function isThemeWebFont(value) {
|
|
163
|
+
return typeof value === "object" && value !== null && typeof value.family === "string";
|
|
164
|
+
}
|
|
165
|
+
/** CSS `font-family` identifier; quotes names that are not a single ident. */
|
|
166
|
+
function cssFamilyName(family) {
|
|
167
|
+
const trimmed = family.trim();
|
|
168
|
+
if (trimmed.startsWith("\"") && trimmed.endsWith("\"") || trimmed.startsWith("'") && trimmed.endsWith("'")) return trimmed;
|
|
169
|
+
if (/^[a-zA-Z_-][\w-]*$/.test(trimmed)) return trimmed;
|
|
170
|
+
return `"${trimmed.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"`;
|
|
171
|
+
}
|
|
172
|
+
function flattenThemeFont(value, generic) {
|
|
173
|
+
if (value === void 0) return;
|
|
174
|
+
if (typeof value === "string") return value;
|
|
175
|
+
const fallbacks = value.fallbacks?.length ? value.fallbacks.join(", ") : generic;
|
|
176
|
+
return `${cssFamilyName(value.family)}, ${fallbacks}`;
|
|
177
|
+
}
|
|
178
|
+
/** Flatten object fonts so `JsThemeFonts` stays `{ sans?: string; mono?: string }`. */
|
|
179
|
+
function flattenThemeFonts(fonts) {
|
|
180
|
+
const sans = flattenThemeFont(fonts.sans, GENERIC_FOR.sans);
|
|
181
|
+
const mono = flattenThemeFont(fonts.mono, GENERIC_FOR.mono);
|
|
182
|
+
if (!sans && !mono) return;
|
|
183
|
+
return {
|
|
184
|
+
sans,
|
|
185
|
+
mono
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
function namedFontToken(name) {
|
|
189
|
+
if (!NAMED_FONT_PATTERN.test(name)) throw new Error(`Invalid theme font name: ${JSON.stringify(name)}. Named fonts are lowercase kebab-case (e.g. "code").`);
|
|
190
|
+
return name;
|
|
191
|
+
}
|
|
192
|
+
/** Extra `--octc-font-*` variables for `fonts.named`. Roles stay in Rust theme CSS. */
|
|
193
|
+
function namedFontVarsCss(fonts) {
|
|
194
|
+
const entries = Object.entries(fonts.named ?? {});
|
|
195
|
+
if (entries.length === 0) return "";
|
|
196
|
+
return `:root {\n${entries.map(([name, value]) => {
|
|
197
|
+
const stack = flattenThemeFont(value, GENERIC_FOR.named);
|
|
198
|
+
return ` --octc-font-${namedFontToken(name)}: ${stack};`;
|
|
199
|
+
}).join("\n")}\n}`;
|
|
200
|
+
}
|
|
201
|
+
function normalizeBasePath(base) {
|
|
202
|
+
if (!base || base === "/") return "/";
|
|
203
|
+
return base.endsWith("/") ? base : `${base}/`;
|
|
204
|
+
}
|
|
205
|
+
function plannedFontFileName(family, weight, style, subset, extension) {
|
|
206
|
+
const ext = extension.startsWith(".") ? extension : `.${extension}`;
|
|
207
|
+
return `${slugify(family)}-${weight}-${style}-${slugify(subset)}${ext}`;
|
|
208
|
+
}
|
|
209
|
+
function plannedFontExtension(font) {
|
|
210
|
+
if (font.provider === "local" && font.path && /\.\w+$/.test(font.path) && !font.path.endsWith("/")) return font.path.match(/(\.\w+)$/)?.[1] ?? ".woff2";
|
|
211
|
+
return ".woff2";
|
|
212
|
+
}
|
|
213
|
+
function planSelfHostedFaces(fonts) {
|
|
214
|
+
const faces = [];
|
|
215
|
+
for (const value of themeFontValues(fonts)) {
|
|
216
|
+
if (!isThemeWebFont(value) || !value.selfHost) continue;
|
|
217
|
+
const font = normalizeWebFont(value);
|
|
218
|
+
const extension = plannedFontExtension(font);
|
|
219
|
+
for (const weight of font.weights) for (const style of font.styles) for (const subset of font.subsets) faces.push({
|
|
220
|
+
family: font.family,
|
|
221
|
+
weight,
|
|
222
|
+
style,
|
|
223
|
+
subset,
|
|
224
|
+
display: font.display,
|
|
225
|
+
preload: shouldPreload(font.preload, weight),
|
|
226
|
+
provider: font.provider,
|
|
227
|
+
path: font.path,
|
|
228
|
+
fileName: plannedFontFileName(font.family, weight, style, subset, extension),
|
|
229
|
+
unicodeRange: font.unicodeRange
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
const unique = /* @__PURE__ */ new Map();
|
|
233
|
+
for (const face of faces) {
|
|
234
|
+
const existing = unique.get(face.fileName);
|
|
235
|
+
if (existing) existing.preload ||= face.preload;
|
|
236
|
+
else unique.set(face.fileName, face);
|
|
237
|
+
}
|
|
238
|
+
return [...unique.values()];
|
|
239
|
+
}
|
|
240
|
+
function themeFontHeadHtml(fonts, base) {
|
|
241
|
+
const faces = planSelfHostedFaces(fonts);
|
|
242
|
+
if (faces.length === 0) return "";
|
|
243
|
+
const root = normalizeBasePath(base);
|
|
244
|
+
const tags = [`<link rel="stylesheet" href="${root}${FONT_ASSET_DIR}/${FONT_CSS_NAME}">`];
|
|
245
|
+
for (const face of faces) {
|
|
246
|
+
if (!face.preload) continue;
|
|
247
|
+
tags.push(`<link rel="preload" href="${root}${FONT_ASSET_DIR}/${face.fileName}" as="font" type="${fontMime(face.fileName)}" crossorigin>`);
|
|
248
|
+
}
|
|
249
|
+
return tags.join("\n");
|
|
250
|
+
}
|
|
251
|
+
function withSelfHostedFontHead(embed, fonts, base) {
|
|
252
|
+
const extra = themeFontHeadHtml(fonts, base);
|
|
253
|
+
const keys = Object.keys(embed);
|
|
254
|
+
if (!extra && keys.length === 0) return;
|
|
255
|
+
if (!extra) return embed;
|
|
256
|
+
return {
|
|
257
|
+
...embed,
|
|
258
|
+
head: embed.head ? `${extra}\n${embed.head}` : extra
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
/** Copy self-hosted faces into `outDir` and write `@font-face` CSS. */
|
|
262
|
+
async function writeSelfHostedThemeFonts(options) {
|
|
263
|
+
const faces = planSelfHostedFaces(options.fonts);
|
|
264
|
+
if (faces.length === 0) return [];
|
|
265
|
+
const acquired = await acquireSelfHostedFaces(faces, options);
|
|
266
|
+
const destDir = join(options.outDir, FONT_ASSET_DIR);
|
|
267
|
+
await mkdir(destDir, { recursive: true });
|
|
268
|
+
const written = [];
|
|
269
|
+
for (const face of acquired) {
|
|
270
|
+
const dest = join(destDir, face.fileName);
|
|
271
|
+
await writeFile(dest, face.bytes);
|
|
272
|
+
written.push(dest);
|
|
29
273
|
}
|
|
274
|
+
const cssPath = join(destDir, FONT_CSS_NAME);
|
|
275
|
+
await writeFile(cssPath, renderFontFaceCss(acquired), "utf8");
|
|
276
|
+
written.push(cssPath);
|
|
277
|
+
return written;
|
|
278
|
+
}
|
|
279
|
+
function themeFontValues(fonts) {
|
|
280
|
+
return [
|
|
281
|
+
fonts.sans,
|
|
282
|
+
fonts.mono,
|
|
283
|
+
...Object.values(fonts.named ?? {})
|
|
284
|
+
].filter((value) => value !== void 0);
|
|
285
|
+
}
|
|
286
|
+
function normalizeWebFont(font) {
|
|
287
|
+
const provider = font.provider ?? (font.path ? "local" : "google");
|
|
288
|
+
if (provider === "local" && !font.path) throw new Error(`Theme font "${font.family}" uses provider "local" but has no path.`);
|
|
289
|
+
return {
|
|
290
|
+
...font,
|
|
291
|
+
family: font.family.trim(),
|
|
292
|
+
provider,
|
|
293
|
+
weights: font.weights?.length ? font.weights : [400],
|
|
294
|
+
styles: font.styles?.length ? font.styles : ["normal"],
|
|
295
|
+
subsets: font.subsets?.length ? font.subsets : ["latin"],
|
|
296
|
+
display: font.display ?? "swap"
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
function shouldPreload(preload, weight) {
|
|
300
|
+
if (preload === true) return true;
|
|
301
|
+
return Array.isArray(preload) && preload.includes(weight);
|
|
302
|
+
}
|
|
303
|
+
function slugify(value) {
|
|
304
|
+
return value.trim().toLowerCase().replace(/['"]/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "") || "font";
|
|
305
|
+
}
|
|
306
|
+
//#endregion
|
|
307
|
+
//#region src/icons-css.ts
|
|
308
|
+
/**
|
|
309
|
+
* Resolve Iconify JSON collections and emit CSS-mask rules.
|
|
310
|
+
*
|
|
311
|
+
* Collections come from installed `@iconify-json/*` or `@iconify/json`.
|
|
312
|
+
* Tests supply fixture JSON under the project `root` — no network.
|
|
313
|
+
*/
|
|
314
|
+
function iconCssSelector(prefix, name) {
|
|
315
|
+
return `.icon-\\[${prefix}--${name}\\]`;
|
|
316
|
+
}
|
|
317
|
+
function resolveIconCollectionPath(prefix, root) {
|
|
318
|
+
const files = [join(root, "node_modules", "@iconify-json", prefix, "icons.json"), join(root, "node_modules", "@iconify", "json", "json", `${prefix}.json`)];
|
|
319
|
+
for (const file of files) if (existsSync(file)) return file;
|
|
320
|
+
return resolveViaNode(prefix, root);
|
|
321
|
+
}
|
|
322
|
+
function resolveViaNode(prefix, root) {
|
|
323
|
+
try {
|
|
324
|
+
return createRequire(join(root, "package.json")).resolve(`@iconify-json/${prefix}/icons.json`);
|
|
325
|
+
} catch {
|
|
326
|
+
try {
|
|
327
|
+
return createRequire(join(root, "package.json")).resolve(`@iconify/json/json/${prefix}.json`);
|
|
328
|
+
} catch {
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
async function loadIconCollection(prefix, root) {
|
|
334
|
+
const path = resolveIconCollectionPath(prefix, root);
|
|
335
|
+
if (!path) return;
|
|
336
|
+
const raw = await readFile(path, "utf8");
|
|
337
|
+
return JSON.parse(raw);
|
|
338
|
+
}
|
|
339
|
+
function lookupIcon(collection, name) {
|
|
340
|
+
const fallback = collection.width ?? 16;
|
|
341
|
+
const fallbackH = collection.height ?? fallback;
|
|
342
|
+
const direct = collection.icons[name];
|
|
343
|
+
if (direct) return {
|
|
344
|
+
body: direct.body,
|
|
345
|
+
width: direct.width ?? fallback,
|
|
346
|
+
height: direct.height ?? fallbackH
|
|
347
|
+
};
|
|
348
|
+
const alias = collection.aliases?.[name];
|
|
349
|
+
if (!alias) return;
|
|
350
|
+
const parent = collection.icons[alias.parent];
|
|
351
|
+
if (!parent) return;
|
|
352
|
+
return {
|
|
353
|
+
body: parent.body,
|
|
354
|
+
width: alias.width ?? parent.width ?? fallback,
|
|
355
|
+
height: alias.height ?? parent.height ?? fallbackH
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
function isMulticolorIcon(body) {
|
|
359
|
+
return /(?:fill|stroke)=["'](?!currentColor|none)[^"']+["']/i.test(body);
|
|
360
|
+
}
|
|
361
|
+
function renderIconsCss(icons) {
|
|
362
|
+
return `/* ox-content self-hosted Iconify icons */\n${icons.map(renderOneIconCss).join("\n")}\n`;
|
|
363
|
+
}
|
|
364
|
+
function renderOneIconCss(icon) {
|
|
365
|
+
const selector = iconCssSelector(icon.prefix, icon.name);
|
|
366
|
+
const url = svgToDataUrl(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${icon.width} ${icon.height}">${maskBody(icon)}</svg>`);
|
|
367
|
+
if (icon.multicolor) return `${selector}{display:inline-block;width:1em;height:1em;background-color:transparent;background-image:${url};background-repeat:no-repeat;background-size:100% 100%}`;
|
|
368
|
+
return `${selector}{display:inline-block;width:1em;height:1em;background-color:currentColor;-webkit-mask-image:${url};mask-image:${url};-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-size:100% 100%;mask-size:100% 100%}`;
|
|
369
|
+
}
|
|
370
|
+
function maskBody(icon) {
|
|
371
|
+
return icon.multicolor ? icon.body : icon.body.replace(/currentColor/g, "black");
|
|
372
|
+
}
|
|
373
|
+
function svgToDataUrl(svg) {
|
|
374
|
+
return `url("data:image/svg+xml,${svg.replace(/"/g, "'").replace(/%/g, "%25").replace(/#/g, "%23").replace(/</g, "%3C").replace(/>/g, "%3E").replace(/\s+/g, " ")}")`;
|
|
375
|
+
}
|
|
376
|
+
//#endregion
|
|
377
|
+
//#region src/icons.ts
|
|
378
|
+
/**
|
|
379
|
+
* Opt-in self-hosted Iconify CSS for used and safelisted icons.
|
|
380
|
+
*
|
|
381
|
+
* Collection lookup stays on disk (`@iconify-json/*` / `@iconify/json`).
|
|
382
|
+
* Theme embed injection composes with self-hosted font `<link>` tags.
|
|
383
|
+
*/
|
|
384
|
+
const ICON_ASSET_DIR = "__ox_icons__";
|
|
385
|
+
const ICON_CSS_NAME = "icons.css";
|
|
386
|
+
const URL_SCHEMES = /* @__PURE__ */ new Set([
|
|
387
|
+
"http",
|
|
388
|
+
"https",
|
|
389
|
+
"data",
|
|
390
|
+
"mailto",
|
|
391
|
+
"file",
|
|
392
|
+
"javascript",
|
|
393
|
+
"vscode",
|
|
394
|
+
"tel",
|
|
395
|
+
"blob"
|
|
396
|
+
]);
|
|
397
|
+
const COLON_ICON = /(?<![A-Za-z0-9_-])([a-z][a-z0-9-]*):([a-z0-9][a-z0-9-]*)/gi;
|
|
398
|
+
const CLASS_ICON = /icon-\[([a-z][a-z0-9-]*)--([a-z0-9][a-z0-9-]*)\]/gi;
|
|
399
|
+
const ICON_FIELD = /(?:^|[\s,{])icon\s*:\s*["']([^"']+)["']/g;
|
|
400
|
+
function resolveIconsOptions(value) {
|
|
401
|
+
if (!value) return {
|
|
402
|
+
enabled: false,
|
|
403
|
+
mode: "css-mask",
|
|
404
|
+
syntax: "unocss",
|
|
405
|
+
include: [],
|
|
406
|
+
safelist: []
|
|
407
|
+
};
|
|
408
|
+
if (value === true) return {
|
|
409
|
+
enabled: true,
|
|
410
|
+
mode: "css-mask",
|
|
411
|
+
syntax: "unocss",
|
|
412
|
+
include: [],
|
|
413
|
+
safelist: []
|
|
414
|
+
};
|
|
415
|
+
return {
|
|
416
|
+
enabled: true,
|
|
417
|
+
mode: value.mode ?? "css-mask",
|
|
418
|
+
syntax: value.syntax ?? "unocss",
|
|
419
|
+
include: value.include ?? [],
|
|
420
|
+
safelist: value.safelist ?? []
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
function parseIconName(value) {
|
|
424
|
+
const trimmed = value.trim();
|
|
425
|
+
const classMatch = /^icon-\[(.+)\]$/.exec(trimmed);
|
|
426
|
+
if (classMatch?.[1]) {
|
|
427
|
+
const inner = classMatch[1];
|
|
428
|
+
const sep = inner.indexOf("--");
|
|
429
|
+
if (sep <= 0) return;
|
|
430
|
+
return tokenPair(inner.slice(0, sep), inner.slice(sep + 2));
|
|
431
|
+
}
|
|
432
|
+
const sep = trimmed.indexOf(":");
|
|
433
|
+
if (sep <= 0) return;
|
|
434
|
+
return tokenPair(trimmed.slice(0, sep), trimmed.slice(sep + 1));
|
|
435
|
+
}
|
|
436
|
+
function normalizeIconName(value) {
|
|
437
|
+
const parsed = parseIconName(value);
|
|
438
|
+
return parsed ? `${parsed.prefix}:${parsed.name}` : value;
|
|
439
|
+
}
|
|
440
|
+
function tokenPair(prefix, name) {
|
|
441
|
+
if (!/^[a-z][a-z0-9-]*$/i.test(prefix) || !/^[a-z0-9][a-z0-9-]*$/i.test(name)) return;
|
|
442
|
+
if (URL_SCHEMES.has(prefix.toLowerCase())) return;
|
|
443
|
+
return {
|
|
444
|
+
prefix,
|
|
445
|
+
name
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
function collectIconNamesFromText(text, into = /* @__PURE__ */ new Set()) {
|
|
449
|
+
COLON_ICON.lastIndex = 0;
|
|
450
|
+
for (const match of text.matchAll(COLON_ICON)) addParsed(into, match[1], match[2]);
|
|
451
|
+
CLASS_ICON.lastIndex = 0;
|
|
452
|
+
for (const match of text.matchAll(CLASS_ICON)) addParsed(into, match[1], match[2]);
|
|
453
|
+
return into;
|
|
454
|
+
}
|
|
455
|
+
function collectIconFieldNames(text, into = /* @__PURE__ */ new Set()) {
|
|
456
|
+
ICON_FIELD.lastIndex = 0;
|
|
457
|
+
for (const match of text.matchAll(ICON_FIELD)) {
|
|
458
|
+
const parsed = match[1] ? parseIconName(match[1]) : void 0;
|
|
459
|
+
if (parsed) into.add(`${parsed.prefix}:${parsed.name}`);
|
|
460
|
+
}
|
|
461
|
+
return into;
|
|
462
|
+
}
|
|
463
|
+
function collectThemeIconNames(socialLinks) {
|
|
464
|
+
if (!Array.isArray(socialLinks)) return [];
|
|
465
|
+
const names = [];
|
|
466
|
+
for (const link of socialLinks) {
|
|
467
|
+
if (!link || typeof link !== "object") continue;
|
|
468
|
+
const icon = link.icon;
|
|
469
|
+
if (typeof icon === "string" && parseIconName(icon)) names.push(normalizeIconName(icon));
|
|
470
|
+
}
|
|
471
|
+
return names;
|
|
472
|
+
}
|
|
473
|
+
function addParsed(into, prefix, name) {
|
|
474
|
+
if (!prefix || !name) return;
|
|
475
|
+
const parsed = tokenPair(prefix, name);
|
|
476
|
+
if (parsed) into.add(`${parsed.prefix}:${parsed.name}`);
|
|
477
|
+
}
|
|
478
|
+
function iconStylesheetHref(base) {
|
|
479
|
+
return `${normalizeBasePath(base)}${ICON_ASSET_DIR}/${ICON_CSS_NAME}`;
|
|
480
|
+
}
|
|
481
|
+
function iconStylesheetLink(base) {
|
|
482
|
+
return `<link rel="stylesheet" href="${iconStylesheetHref(base)}">`;
|
|
483
|
+
}
|
|
484
|
+
function withSelfHostedIconHead(embed, enabled, base) {
|
|
485
|
+
if (!enabled) return embed;
|
|
486
|
+
const extra = iconStylesheetLink(base);
|
|
487
|
+
if (!embed) return { head: extra };
|
|
488
|
+
return {
|
|
489
|
+
...embed,
|
|
490
|
+
head: embed.head ? `${extra}\n${embed.head}` : extra
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
/** Copy resolved icon CSS into `outDir`. Missing collections or names become errors. */
|
|
494
|
+
async function writeSelfHostedIcons(input) {
|
|
495
|
+
if (!input.options.enabled) return {
|
|
496
|
+
files: [],
|
|
497
|
+
errors: [],
|
|
498
|
+
names: []
|
|
499
|
+
};
|
|
500
|
+
const names = await collectResolvedIconNames(input);
|
|
501
|
+
const { icons, errors } = await resolveIconBodies(names, input.root);
|
|
502
|
+
const destDir = join(input.outDir, ICON_ASSET_DIR);
|
|
503
|
+
await mkdir(destDir, { recursive: true });
|
|
504
|
+
const cssPath = join(destDir, ICON_CSS_NAME);
|
|
505
|
+
await writeFile(cssPath, renderIconsCss(icons), "utf8");
|
|
506
|
+
return {
|
|
507
|
+
files: [cssPath],
|
|
508
|
+
errors,
|
|
509
|
+
names
|
|
510
|
+
};
|
|
511
|
+
}
|
|
512
|
+
async function collectResolvedIconNames(input) {
|
|
513
|
+
const names = /* @__PURE__ */ new Set();
|
|
514
|
+
for (const item of input.options.safelist) addName(names, item);
|
|
515
|
+
for (const item of collectThemeIconNames(input.socialLinks)) names.add(item);
|
|
516
|
+
const { names: includeNames, globs } = partitionInclude(input.options.include);
|
|
517
|
+
for (const item of includeNames) names.add(item);
|
|
518
|
+
for (const pattern of globs) {
|
|
519
|
+
const files = await glob(pattern, {
|
|
520
|
+
cwd: input.root,
|
|
521
|
+
nodir: true,
|
|
522
|
+
absolute: true,
|
|
523
|
+
ignore: ["**/node_modules/**"]
|
|
524
|
+
});
|
|
525
|
+
for (const file of files) collectIconNamesFromText(await readFile(file, "utf8"), names);
|
|
526
|
+
}
|
|
527
|
+
if (input.srcDir) {
|
|
528
|
+
const files = await glob("**/*.{md,mdx,markdown}", {
|
|
529
|
+
cwd: input.srcDir,
|
|
530
|
+
nodir: true,
|
|
531
|
+
absolute: true,
|
|
532
|
+
ignore: ["**/node_modules/**"]
|
|
533
|
+
});
|
|
534
|
+
for (const file of files) collectIconFieldNames(await readFile(file, "utf8"), names);
|
|
535
|
+
}
|
|
536
|
+
return [...names].sort();
|
|
537
|
+
}
|
|
538
|
+
function partitionInclude(include) {
|
|
539
|
+
const names = [];
|
|
540
|
+
const globs = [];
|
|
541
|
+
for (const entry of include) if (parseIconName(entry)) names.push(normalizeIconName(entry));
|
|
542
|
+
else globs.push(entry);
|
|
543
|
+
return {
|
|
544
|
+
names,
|
|
545
|
+
globs
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
function addName(into, value) {
|
|
549
|
+
const parsed = parseIconName(value);
|
|
550
|
+
if (parsed) into.add(`${parsed.prefix}:${parsed.name}`);
|
|
551
|
+
}
|
|
552
|
+
async function resolveIconBodies(names, root) {
|
|
553
|
+
const icons = [];
|
|
554
|
+
const errors = [];
|
|
555
|
+
const collections = /* @__PURE__ */ new Map();
|
|
556
|
+
for (const id of names) {
|
|
557
|
+
const parsed = parseIconName(id);
|
|
558
|
+
if (!parsed) continue;
|
|
559
|
+
if (!collections.has(parsed.prefix)) collections.set(parsed.prefix, await loadIconCollection(parsed.prefix, root));
|
|
560
|
+
const collection = collections.get(parsed.prefix);
|
|
561
|
+
if (!collection) {
|
|
562
|
+
errors.push(`[ox-content] icons: missing Iconify collection "${parsed.prefix}". Install @iconify-json/${parsed.prefix} or @iconify/json.`);
|
|
563
|
+
continue;
|
|
564
|
+
}
|
|
565
|
+
const found = lookupIcon(collection, parsed.name);
|
|
566
|
+
if (!found) {
|
|
567
|
+
errors.push(`[ox-content] icons: missing icon "${parsed.prefix}:${parsed.name}" in collection "${parsed.prefix}".`);
|
|
568
|
+
continue;
|
|
569
|
+
}
|
|
570
|
+
icons.push({
|
|
571
|
+
prefix: parsed.prefix,
|
|
572
|
+
name: parsed.name,
|
|
573
|
+
body: found.body,
|
|
574
|
+
width: found.width,
|
|
575
|
+
height: found.height,
|
|
576
|
+
multicolor: isMulticolorIcon(found.body)
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
return {
|
|
580
|
+
icons,
|
|
581
|
+
errors
|
|
582
|
+
};
|
|
30
583
|
}
|
|
31
584
|
//#endregion
|
|
32
585
|
//#region src/header-chrome.ts
|
|
@@ -79,36 +632,6 @@ function resolveHeaderNavItems(items, locale, defaultLocale) {
|
|
|
79
632
|
}));
|
|
80
633
|
}
|
|
81
634
|
//#endregion
|
|
82
|
-
//#region src/theme-tokens.ts
|
|
83
|
-
const TOKEN_PREFIX = "--octc-";
|
|
84
|
-
const TOKEN_NAME_PATTERN = /^[a-z][a-z0-9-]*$/;
|
|
85
|
-
/**
|
|
86
|
-
* Renders light and dark token records as the three selectors the SSG runtime
|
|
87
|
-
* switches between: an explicit `[data-theme="dark"]` opt-in, the OS
|
|
88
|
-
* `prefers-color-scheme` fallback, and the `:root` base.
|
|
89
|
-
*
|
|
90
|
-
* Emitted after the typed color variables and before the theme's own `css`, so
|
|
91
|
-
* a token can override a typed color and raw `css` can override a token.
|
|
92
|
-
*/
|
|
93
|
-
function tokensToCss(light, dark) {
|
|
94
|
-
const lightBody = declarations(light, " ");
|
|
95
|
-
const darkBody = declarations(dark, " ");
|
|
96
|
-
const blocks = [];
|
|
97
|
-
if (lightBody) blocks.push(`:root {\n${lightBody}\n}`);
|
|
98
|
-
if (darkBody) {
|
|
99
|
-
blocks.push(`[data-theme="dark"] {\n${darkBody}\n}`);
|
|
100
|
-
blocks.push(`@media (prefers-color-scheme: dark) {\n :root:not([data-theme="light"]) {\n${declarations(dark, " ")}\n }\n}`);
|
|
101
|
-
}
|
|
102
|
-
return blocks.join("\n");
|
|
103
|
-
}
|
|
104
|
-
function declarations(tokens, indent) {
|
|
105
|
-
return Object.entries(tokens).filter(([, value]) => value !== void 0 && value !== "").map(([name, value]) => `${indent}${TOKEN_PREFIX}${assertTokenName(name)}: ${value};`).join("\n");
|
|
106
|
-
}
|
|
107
|
-
function assertTokenName(name) {
|
|
108
|
-
if (!TOKEN_NAME_PATTERN.test(name)) throw new Error(`Invalid theme token name: ${JSON.stringify(name)}. Token names are lowercase kebab-case without the "${TOKEN_PREFIX}" prefix (e.g. "surface-glass").`);
|
|
109
|
-
return name;
|
|
110
|
-
}
|
|
111
|
-
//#endregion
|
|
112
635
|
//#region src/theme.ts
|
|
113
636
|
/**
|
|
114
637
|
* Default theme configuration.
|
|
@@ -117,6 +640,7 @@ function assertTokenName(name) {
|
|
|
117
640
|
const defaultTheme = {
|
|
118
641
|
name: "default",
|
|
119
642
|
viewTransitions: true,
|
|
643
|
+
toggleTransition: false,
|
|
120
644
|
aside: false,
|
|
121
645
|
breadcrumbs: false,
|
|
122
646
|
headingPermalink: "hover",
|
|
@@ -258,6 +782,7 @@ function resolveTheme(config) {
|
|
|
258
782
|
return {
|
|
259
783
|
name: merged.name ?? "custom",
|
|
260
784
|
viewTransitions: merged.viewTransitions ?? defaultTheme.viewTransitions ?? true,
|
|
785
|
+
toggleTransition: merged.toggleTransition === "circle" ? "circle" : false,
|
|
261
786
|
aside: merged.aside ?? defaultTheme.aside ?? false,
|
|
262
787
|
breadcrumbs: resolveThemeFlag(merged.breadcrumbs),
|
|
263
788
|
headingPermalink: merged.headingPermalink === "always" ? "always" : "hover",
|
|
@@ -313,10 +838,11 @@ function withDerivedCodeBackgroundTop(theme) {
|
|
|
313
838
|
/**
|
|
314
839
|
* Converts resolved theme to the format expected by Rust NAPI.
|
|
315
840
|
*/
|
|
316
|
-
function themeToNapi(theme, locale) {
|
|
841
|
+
function themeToNapi(theme, locale, base, iconsEnabled = false) {
|
|
317
842
|
const socialLinks = socialLinksToNapi(theme.socialLinks);
|
|
318
843
|
return {
|
|
319
844
|
viewTransitions: theme.viewTransitions,
|
|
845
|
+
toggleTransition: theme.toggleTransition === "circle" ? "circle" : void 0,
|
|
320
846
|
aside: theme.aside,
|
|
321
847
|
breadcrumbs: theme.breadcrumbs,
|
|
322
848
|
headingPermalink: theme.headingPermalink,
|
|
@@ -344,10 +870,7 @@ function themeToNapi(theme, locale) {
|
|
|
344
870
|
codeBackgroundTop: theme.darkColors.codeBackgroundTop,
|
|
345
871
|
codeText: theme.darkColors.codeText
|
|
346
872
|
} : void 0,
|
|
347
|
-
fonts: theme.fonts
|
|
348
|
-
sans: theme.fonts.sans,
|
|
349
|
-
mono: theme.fonts.mono
|
|
350
|
-
} : void 0,
|
|
873
|
+
fonts: flattenThemeFonts(theme.fonts),
|
|
351
874
|
entryPage: theme.entryPage.mode ? { mode: theme.entryPage.mode } : void 0,
|
|
352
875
|
layout: theme.layout.sidebarWidth ? {
|
|
353
876
|
sidebarWidth: theme.layout.sidebarWidth,
|
|
@@ -369,7 +892,7 @@ function themeToNapi(theme, locale) {
|
|
|
369
892
|
copyright: theme.footer.copyright
|
|
370
893
|
} : void 0,
|
|
371
894
|
socialLinks,
|
|
372
|
-
embed:
|
|
895
|
+
embed: withSelfHostedIconHead(withSelfHostedFontHead(theme.embed, theme.fonts, base), iconsEnabled, base),
|
|
373
896
|
css: themeCss(theme) || void 0,
|
|
374
897
|
js: theme.js || void 0
|
|
375
898
|
};
|
|
@@ -379,9 +902,9 @@ function themeToNapi(theme, locale) {
|
|
|
379
902
|
* land after the typed color variables the Rust renderer emits.
|
|
380
903
|
*/
|
|
381
904
|
function themeCss(theme) {
|
|
382
|
-
const
|
|
383
|
-
if (!
|
|
384
|
-
return theme.css ? `${
|
|
905
|
+
const prefix = [renderThemeTokenCss(theme), namedFontVarsCss(theme.fonts)].filter(Boolean).join("\n");
|
|
906
|
+
if (!prefix) return theme.css;
|
|
907
|
+
return theme.css ? `${prefix}\n${theme.css}` : prefix;
|
|
385
908
|
}
|
|
386
909
|
function socialLinksToNapi(links) {
|
|
387
910
|
if (Array.isArray(links)) {
|
|
@@ -659,6 +1182,6 @@ function normalizeVitePressFrontmatter(frontmatter) {
|
|
|
659
1182
|
return importNapiModuleSync().normalizeVitePressFrontmatter(frontmatter);
|
|
660
1183
|
}
|
|
661
1184
|
//#endregion
|
|
662
|
-
export { normalizeVitePressFrontmatter as a, mergeThemes as c, parsePageChromeFlags as d, resolveHeaderNavItems as f,
|
|
1185
|
+
export { writeSelfHostedIcons as _, normalizeVitePressFrontmatter as a, mergeThemes as c, parsePageChromeFlags as d, resolveHeaderNavItems as f, withSelfHostedIconHead as g, resolveIconsOptions as h, generateVitePressMigrationConfig as i, resolveTheme as l, resolvePageChromeOption as m, convertVitePressSidebar as n, defaultTheme as o, resolveLocaleLabel as p, fromVitePressConfig as r, defineTheme as s, convertVitePressNav as t, themeToNapi as u, writeSelfHostedThemeFonts as v };
|
|
663
1186
|
|
|
664
1187
|
//# sourceMappingURL=vitepress.mjs.map
|