@unterberg/nivel 0.2.0 → 0.2.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/dist/{chunk-MPERUGQD.js → chunk-AQJQDMKW.js} +77 -55
- package/dist/chunk-AQJQDMKW.js.map +1 -0
- package/dist/{chunk-SOVTSE5J.js → chunk-AT4O3RRN.js} +8 -2
- package/dist/chunk-AT4O3RRN.js.map +1 -0
- package/dist/{chunk-VGBPF5O7.js → chunk-C724XH47.js} +3 -5
- package/dist/chunk-C724XH47.js.map +1 -0
- package/dist/{chunk-G6PC37P5.js → chunk-GFZ3P4F4.js} +515 -8
- package/dist/chunk-GFZ3P4F4.js.map +1 -0
- package/dist/{chunk-WEGYZIYX.js → chunk-I75ALNG2.js} +2 -2
- package/dist/chunk-WMHFKLPG.js +124 -0
- package/dist/chunk-WMHFKLPG.js.map +1 -0
- package/dist/cli.js +2 -3
- package/dist/cli.js.map +1 -1
- package/dist/client.js +3 -4
- package/dist/icons.d.ts +1 -1
- package/dist/icons.js +11637 -2
- package/dist/icons.js.map +1 -1
- package/dist/index.js +2 -3
- package/dist/mdx.js +2 -3
- package/dist/mdx.js.map +1 -1
- package/dist/runtime/client.js +3 -4
- package/dist/runtime/node.js +6 -8
- package/dist/vike.js +5 -7
- package/dist/vike.js.map +1 -1
- package/package.json +6 -5
- package/dist/chunk-G6PC37P5.js.map +0 -1
- package/dist/chunk-L6ZVB6XH.js +0 -36
- package/dist/chunk-L6ZVB6XH.js.map +0 -1
- package/dist/chunk-MPERUGQD.js.map +0 -1
- package/dist/chunk-SOVTSE5J.js.map +0 -1
- package/dist/chunk-UMH7S7OB.js +0 -445
- package/dist/chunk-UMH7S7OB.js.map +0 -1
- package/dist/chunk-VGBPF5O7.js.map +0 -1
- /package/dist/{chunk-WEGYZIYX.js.map → chunk-I75ALNG2.js.map} +0 -0
|
@@ -1,16 +1,421 @@
|
|
|
1
1
|
import {
|
|
2
|
-
extractDocHeadings
|
|
3
|
-
|
|
2
|
+
extractDocHeadings,
|
|
3
|
+
getDocsIconMapKey
|
|
4
|
+
} from "./chunk-AT4O3RRN.js";
|
|
4
5
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} from "./chunk-
|
|
6
|
+
nivelAssetUrl,
|
|
7
|
+
resolvePublicAssetUrl,
|
|
8
|
+
withSiteBaseUrl
|
|
9
|
+
} from "./chunk-PYYPYIBD.js";
|
|
10
|
+
|
|
11
|
+
// src/docs/icons.ts
|
|
12
|
+
import * as lucideIcons from "lucide-react";
|
|
13
|
+
var excludedLucideExports = /* @__PURE__ */ new Set(["createLucideIcon", "Icon", "icons", "LucideProvider", "useLucideContext"]);
|
|
14
|
+
var isLucideIconExport = (value) => {
|
|
15
|
+
if (typeof value !== "object" || value === null) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
return "$$typeof" in value && "render" in value;
|
|
19
|
+
};
|
|
20
|
+
var docsIconNames = Object.freeze(
|
|
21
|
+
Object.entries(lucideIcons).filter(([name, value]) => !excludedLucideExports.has(name) && isLucideIconExport(value)).map(([name]) => name).sort()
|
|
22
|
+
);
|
|
23
|
+
var docsIconNameSet = new Set(docsIconNames);
|
|
24
|
+
var isDocsIconName = (value) => {
|
|
25
|
+
return docsIconNameSet.has(value);
|
|
26
|
+
};
|
|
27
|
+
var assertDocsIconName = (value, context) => {
|
|
28
|
+
if (isDocsIconName(value)) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
throw new Error(
|
|
32
|
+
`${context} must be a valid lucide-react icon export. Received "${value}". See https://lucide.dev/icons/`
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// src/docs/resolveDocsConfig.ts
|
|
37
|
+
var isExternalHref = (value) => {
|
|
38
|
+
return /^(?:[a-z]+:)?\/\//i.test(value) || value.startsWith("mailto:") || value.startsWith("tel:");
|
|
39
|
+
};
|
|
40
|
+
var normalizeBasePath = (value) => {
|
|
41
|
+
const normalized = value.trim();
|
|
42
|
+
if (!normalized) {
|
|
43
|
+
throw new Error("Docs basePath must be a non-empty absolute path.");
|
|
44
|
+
}
|
|
45
|
+
if (!normalized.startsWith("/") || normalized.startsWith("//")) {
|
|
46
|
+
throw new Error(`Docs basePath must start with "/". Received ${JSON.stringify(value)}.`);
|
|
47
|
+
}
|
|
48
|
+
if (normalized.includes("?") || normalized.includes("#")) {
|
|
49
|
+
throw new Error(`Docs basePath cannot include query strings or hashes. Received ${JSON.stringify(value)}.`);
|
|
50
|
+
}
|
|
51
|
+
const collapsed = normalized.replace(/\/+/g, "/").replace(/\/+$/g, "");
|
|
52
|
+
return collapsed === "" ? "/" : collapsed;
|
|
53
|
+
};
|
|
54
|
+
var normalizeContentDir = (value) => {
|
|
55
|
+
const normalized = (value ?? "docs").trim();
|
|
56
|
+
if (!normalized) {
|
|
57
|
+
throw new Error("Docs contentDir must be a non-empty project-relative path.");
|
|
58
|
+
}
|
|
59
|
+
if (normalized.startsWith("/") || normalized.startsWith("\\")) {
|
|
60
|
+
throw new Error(`Docs contentDir must be project-relative. Received ${JSON.stringify(value)}.`);
|
|
61
|
+
}
|
|
62
|
+
if (/^[a-zA-Z]:[\\/]/.test(normalized)) {
|
|
63
|
+
throw new Error(`Docs contentDir must be project-relative. Received ${JSON.stringify(value)}.`);
|
|
64
|
+
}
|
|
65
|
+
const segments = normalized.replaceAll("\\", "/").split("/");
|
|
66
|
+
const resolvedSegments = [];
|
|
67
|
+
for (const segment of segments) {
|
|
68
|
+
if (segment === "" || segment === ".") {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (segment === "..") {
|
|
72
|
+
throw new Error(`Docs contentDir cannot escape the project root. Received ${JSON.stringify(value)}.`);
|
|
73
|
+
}
|
|
74
|
+
resolvedSegments.push(segment);
|
|
75
|
+
}
|
|
76
|
+
if (resolvedSegments.length === 0) {
|
|
77
|
+
throw new Error(`Docs contentDir must contain at least one path segment. Received ${JSON.stringify(value)}.`);
|
|
78
|
+
}
|
|
79
|
+
return resolvedSegments.join("/");
|
|
80
|
+
};
|
|
81
|
+
var normalizeSlug = (value) => value.replace(/^\/+|\/+$/g, "");
|
|
82
|
+
var joinDocsHref = (basePath, slug) => {
|
|
83
|
+
const normalizedBasePath = normalizeBasePath(basePath);
|
|
84
|
+
const normalizedSlug = normalizeSlug(slug);
|
|
85
|
+
if (!normalizedSlug) {
|
|
86
|
+
return normalizedBasePath === "/" ? "/" : `${normalizedBasePath}/`;
|
|
87
|
+
}
|
|
88
|
+
return normalizedBasePath === "/" ? `/${normalizedSlug}/` : `${normalizedBasePath}/${normalizedSlug}/`;
|
|
89
|
+
};
|
|
90
|
+
var normalizePathname = (value) => {
|
|
91
|
+
const pathname = value.split("?")[0]?.split("#")[0] ?? value;
|
|
92
|
+
const normalized = pathname.trim().replace(/\/+$/g, "");
|
|
93
|
+
return normalized === "" ? "/" : `${normalized}/`.replace(/\/+/g, "/");
|
|
94
|
+
};
|
|
95
|
+
var resolveDocsHref = (basePath, href) => {
|
|
96
|
+
const normalized = href.trim();
|
|
97
|
+
if (!normalized || normalized.startsWith("#") || isExternalHref(normalized)) {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
const pathname = normalized.split("?")[0]?.split("#")[0] ?? normalized;
|
|
101
|
+
if (!pathname) {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
if (pathname.startsWith("/")) {
|
|
105
|
+
const normalizedPathname = normalizePathname(pathname);
|
|
106
|
+
const normalizedBasePath = normalizeBasePath(basePath);
|
|
107
|
+
if (normalizedBasePath === "/") {
|
|
108
|
+
return normalizedPathname;
|
|
109
|
+
}
|
|
110
|
+
return normalizedPathname === `${normalizedBasePath}/` || normalizedPathname.startsWith(`${normalizedBasePath}/`) ? normalizedPathname : null;
|
|
111
|
+
}
|
|
112
|
+
if (pathname.startsWith("./") || pathname.startsWith("../")) {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
return joinDocsHref(basePath, pathname);
|
|
116
|
+
};
|
|
117
|
+
var normalizeSourcePath = (value) => {
|
|
118
|
+
const segments = value.replaceAll("\\", "/").split("/");
|
|
119
|
+
const normalizedSegments = [];
|
|
120
|
+
for (const segment of segments) {
|
|
121
|
+
if (segment === "" || segment === ".") {
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
if (segment === "..") {
|
|
125
|
+
normalizedSegments.pop();
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
normalizedSegments.push(segment);
|
|
129
|
+
}
|
|
130
|
+
return normalizedSegments.join("/");
|
|
131
|
+
};
|
|
132
|
+
var getSectionHref = (items, visibleOnly = false) => {
|
|
133
|
+
for (const item of items) {
|
|
134
|
+
if (item.kind === "page") {
|
|
135
|
+
if (visibleOnly && !item.showInNav) {
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
return item.href;
|
|
139
|
+
}
|
|
140
|
+
if (item.kind === "group") {
|
|
141
|
+
if (visibleOnly && !item.showInNav) {
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
const href = getSectionHref(item.items, visibleOnly);
|
|
145
|
+
if (href) {
|
|
146
|
+
return href;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return null;
|
|
151
|
+
};
|
|
152
|
+
var resolveNavigationHref = (value, fieldName, basePath) => {
|
|
153
|
+
const normalized = value.trim();
|
|
154
|
+
if (!normalized) {
|
|
155
|
+
throw new Error(`Docs ${fieldName} must be a non-empty string.`);
|
|
156
|
+
}
|
|
157
|
+
if (normalized.startsWith("#") || isExternalHref(normalized)) {
|
|
158
|
+
return normalized;
|
|
159
|
+
}
|
|
160
|
+
if (!normalized.startsWith("/")) {
|
|
161
|
+
return joinDocsHref(basePath, normalized);
|
|
162
|
+
}
|
|
163
|
+
return normalizePathname(normalized);
|
|
164
|
+
};
|
|
165
|
+
var resolveThemeConfig = (theme) => {
|
|
166
|
+
return {
|
|
167
|
+
light: theme?.light ?? "consumer-light",
|
|
168
|
+
dark: theme?.dark ?? "consumer-dark",
|
|
169
|
+
defaultPreference: theme?.defaultPreference ?? "light"
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
var resolveFooterConfig = (footer) => {
|
|
173
|
+
return {
|
|
174
|
+
pagination: footer?.pagination ?? false
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
var resolveBrandConfig = (brand, siteTitle) => {
|
|
178
|
+
const text = brand?.text ?? siteTitle;
|
|
179
|
+
return {
|
|
180
|
+
text,
|
|
181
|
+
href: withSiteBaseUrl(brand?.href ?? "/"),
|
|
182
|
+
logoLight: resolvePublicAssetUrl(brand?.logoLight),
|
|
183
|
+
logoDark: resolvePublicAssetUrl(brand?.logoDark),
|
|
184
|
+
logoAlt: brand?.logoAlt ?? `${text} logo`
|
|
185
|
+
};
|
|
186
|
+
};
|
|
187
|
+
var resolveHeadConfig = (head) => {
|
|
188
|
+
const fontPreset = head?.fontPreset ?? "inter";
|
|
189
|
+
const defaultFontStylesheetHref = fontPreset === "inter" ? nivelAssetUrl("fonts/fonts-inter.css") : void 0;
|
|
190
|
+
const defaultFontPreloadHrefs = fontPreset === "inter" ? [
|
|
191
|
+
nivelAssetUrl("fonts/inter-v20-latin-regular.woff2"),
|
|
192
|
+
nivelAssetUrl("fonts/inter-v20-latin-600.woff2"),
|
|
193
|
+
nivelAssetUrl("fonts/inter-v20-latin-800.woff2")
|
|
194
|
+
] : [];
|
|
195
|
+
return {
|
|
196
|
+
faviconSvg: resolvePublicAssetUrl(head?.faviconSvg),
|
|
197
|
+
faviconIco: resolvePublicAssetUrl(head?.faviconIco),
|
|
198
|
+
appleTouchIcon: resolvePublicAssetUrl(head?.appleTouchIcon),
|
|
199
|
+
fontPreset,
|
|
200
|
+
fontStylesheetHref: head?.fontStylesheetHref ?? defaultFontStylesheetHref,
|
|
201
|
+
fontPreloadHrefs: head?.fontPreloadHrefs ?? defaultFontPreloadHrefs
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
var resolvePartnerAssetUrl = (value) => {
|
|
205
|
+
if (!value) {
|
|
206
|
+
return void 0;
|
|
207
|
+
}
|
|
208
|
+
return resolvePublicAssetUrl(value);
|
|
209
|
+
};
|
|
210
|
+
var resolvePartner = (partner) => {
|
|
211
|
+
return {
|
|
212
|
+
name: partner.name,
|
|
213
|
+
href: withSiteBaseUrl(partner.href),
|
|
214
|
+
logoLight: resolvePartnerAssetUrl(partner.logoLight) ?? partner.logoLight,
|
|
215
|
+
logoDark: resolvePartnerAssetUrl(partner.logoDark),
|
|
216
|
+
logoAlt: partner.logoAlt ?? `${partner.name} logo`
|
|
217
|
+
};
|
|
218
|
+
};
|
|
219
|
+
var resolveSocialConfig = (social) => {
|
|
220
|
+
return {
|
|
221
|
+
...social
|
|
222
|
+
};
|
|
223
|
+
};
|
|
224
|
+
var resolvePartnersConfig = (partners) => {
|
|
225
|
+
return {
|
|
226
|
+
primary: (partners?.primary ?? []).map(resolvePartner),
|
|
227
|
+
gold: (partners?.gold ?? []).map(resolvePartner)
|
|
228
|
+
};
|
|
229
|
+
};
|
|
230
|
+
var requireTrimmedString = (value, fieldName) => {
|
|
231
|
+
const normalized = value.trim();
|
|
232
|
+
if (!normalized) {
|
|
233
|
+
throw new Error(`Docs algolia config "${fieldName}" must be a non-empty string.`);
|
|
234
|
+
}
|
|
235
|
+
return normalized;
|
|
236
|
+
};
|
|
237
|
+
var resolveAlgoliaConfig = (algolia) => {
|
|
238
|
+
if (!algolia) {
|
|
239
|
+
return null;
|
|
240
|
+
}
|
|
241
|
+
return {
|
|
242
|
+
appId: requireTrimmedString(algolia.appId, "appId"),
|
|
243
|
+
apiKey: requireTrimmedString(algolia.apiKey, "apiKey"),
|
|
244
|
+
indexName: requireTrimmedString(algolia.indexName, "indexName"),
|
|
245
|
+
fields: {
|
|
246
|
+
href: algolia.fields?.href?.trim() || "href",
|
|
247
|
+
title: algolia.fields?.title?.trim() || "title",
|
|
248
|
+
excerpt: algolia.fields?.excerpt?.trim() || "excerpt",
|
|
249
|
+
sectionTitle: algolia.fields?.sectionTitle?.trim() || "sectionTitle"
|
|
250
|
+
},
|
|
251
|
+
searchParams: algolia.searchParams ?? {}
|
|
252
|
+
};
|
|
253
|
+
};
|
|
254
|
+
var normalizeAliases = (aliases, slug) => {
|
|
255
|
+
const normalizedAliases = /* @__PURE__ */ new Set();
|
|
256
|
+
for (const alias of aliases ?? []) {
|
|
257
|
+
const normalizedAlias = normalizeSlug(alias);
|
|
258
|
+
if (!normalizedAlias || normalizedAlias === slug) {
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
normalizedAliases.add(normalizedAlias);
|
|
262
|
+
}
|
|
263
|
+
return [...normalizedAliases];
|
|
264
|
+
};
|
|
265
|
+
var resolveDocsConfig = (config) => {
|
|
266
|
+
const normalizedBasePath = normalizeBasePath(config.basePath);
|
|
267
|
+
const normalizedContentDir = normalizeContentDir(config.contentDir);
|
|
268
|
+
const pageIds = /* @__PURE__ */ new Set();
|
|
269
|
+
const pageSlugs = /* @__PURE__ */ new Set();
|
|
270
|
+
const pageAliases = /* @__PURE__ */ new Set();
|
|
271
|
+
const groupIds = /* @__PURE__ */ new Set();
|
|
272
|
+
const sectionIds = /* @__PURE__ */ new Set();
|
|
273
|
+
const pages = [];
|
|
274
|
+
const navbarItems = [];
|
|
275
|
+
const resolveSidebarNodes = (nodes, sectionId) => {
|
|
276
|
+
return nodes.map((node) => {
|
|
277
|
+
if (node.kind === "group") {
|
|
278
|
+
if (groupIds.has(node.id)) {
|
|
279
|
+
throw new Error(`Duplicate docs group id "${node.id}".`);
|
|
280
|
+
}
|
|
281
|
+
if (node.icon) {
|
|
282
|
+
assertDocsIconName(node.icon, `Docs group "${node.id}" icon`);
|
|
283
|
+
}
|
|
284
|
+
groupIds.add(node.id);
|
|
285
|
+
return {
|
|
286
|
+
kind: "group",
|
|
287
|
+
id: node.id,
|
|
288
|
+
title: node.title,
|
|
289
|
+
href: node.href ? resolveNavigationHref(node.href, `group "${node.id}" href`, normalizedBasePath) : void 0,
|
|
290
|
+
showInNav: node.showInNav ?? true,
|
|
291
|
+
collapsible: node.collapsible,
|
|
292
|
+
items: resolveSidebarNodes(node.items, sectionId),
|
|
293
|
+
icon: node.icon
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
if (node.kind !== "page") {
|
|
297
|
+
throw new Error(`Invalid docs sidebar node: ${JSON.stringify(node)}`);
|
|
298
|
+
}
|
|
299
|
+
const pageNode = node;
|
|
300
|
+
const slug = normalizeSlug(pageNode.slug);
|
|
301
|
+
const aliases = normalizeAliases(pageNode.aliases, slug);
|
|
302
|
+
if (pageNode.icon) {
|
|
303
|
+
assertDocsIconName(pageNode.icon, `Docs page "${pageNode.id}" icon`);
|
|
304
|
+
}
|
|
305
|
+
if (!slug) {
|
|
306
|
+
throw new Error(`Docs page "${pageNode.id}" must define a non-empty slug.`);
|
|
307
|
+
}
|
|
308
|
+
if (pageIds.has(pageNode.id)) {
|
|
309
|
+
throw new Error(`Duplicate docs page id "${pageNode.id}".`);
|
|
310
|
+
}
|
|
311
|
+
if (pageSlugs.has(slug)) {
|
|
312
|
+
throw new Error(`Duplicate docs page slug "${slug}".`);
|
|
313
|
+
}
|
|
314
|
+
for (const alias of aliases) {
|
|
315
|
+
if (pageSlugs.has(alias) || pageAliases.has(alias)) {
|
|
316
|
+
throw new Error(`Duplicate docs page alias "${alias}".`);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
pageIds.add(pageNode.id);
|
|
320
|
+
pageSlugs.add(slug);
|
|
321
|
+
for (const alias of aliases) {
|
|
322
|
+
pageAliases.add(alias);
|
|
323
|
+
}
|
|
324
|
+
const href = joinDocsHref(normalizedBasePath, slug);
|
|
325
|
+
const page = {
|
|
326
|
+
...pageNode,
|
|
327
|
+
slug,
|
|
328
|
+
aliases,
|
|
329
|
+
href,
|
|
330
|
+
aliasHrefs: aliases.map((alias) => joinDocsHref(normalizedBasePath, alias)),
|
|
331
|
+
tableOfContents: pageNode.tableOfContents ?? true,
|
|
332
|
+
sectionId,
|
|
333
|
+
documentTitle: `${pageNode.title} | ${config.siteTitle}`,
|
|
334
|
+
source: normalizeSourcePath(pageNode.source)
|
|
335
|
+
};
|
|
336
|
+
pages.push(page);
|
|
337
|
+
return {
|
|
338
|
+
kind: "page",
|
|
339
|
+
id: pageNode.id,
|
|
340
|
+
title: pageNode.title,
|
|
341
|
+
navTitle: pageNode.navTitle ?? pageNode.title,
|
|
342
|
+
href,
|
|
343
|
+
showInNav: pageNode.showInNav ?? true,
|
|
344
|
+
icon: pageNode.icon
|
|
345
|
+
};
|
|
346
|
+
});
|
|
347
|
+
};
|
|
348
|
+
const sections = config.graph.items.map((section) => {
|
|
349
|
+
if (section.kind !== "section") {
|
|
350
|
+
throw new Error(`Top-level docs graph items must be sections. Received ${JSON.stringify(section)}`);
|
|
351
|
+
}
|
|
352
|
+
if (sectionIds.has(section.id)) {
|
|
353
|
+
throw new Error(`Duplicate docs section id "${section.id}".`);
|
|
354
|
+
}
|
|
355
|
+
if (section.icon) {
|
|
356
|
+
assertDocsIconName(section.icon, `Docs section "${section.id}" icon`);
|
|
357
|
+
}
|
|
358
|
+
sectionIds.add(section.id);
|
|
359
|
+
const items = resolveSidebarNodes(section.items, section.id);
|
|
360
|
+
const firstVisibleHref = getSectionHref(items, true);
|
|
361
|
+
const href = section.href ? resolveNavigationHref(section.href, `section "${section.id}" href`, normalizedBasePath) : firstVisibleHref ?? getSectionHref(items);
|
|
362
|
+
if (!href) {
|
|
363
|
+
throw new Error(`Docs section "${section.id}" must contain at least one page.`);
|
|
364
|
+
}
|
|
365
|
+
const resolvedSection = {
|
|
366
|
+
id: section.id,
|
|
367
|
+
title: section.title,
|
|
368
|
+
navTitle: section.navTitle ?? section.title,
|
|
369
|
+
href,
|
|
370
|
+
items,
|
|
371
|
+
icon: section.icon
|
|
372
|
+
};
|
|
373
|
+
navbarItems.push({
|
|
374
|
+
id: section.id,
|
|
375
|
+
title: resolvedSection.navTitle,
|
|
376
|
+
href: resolvedSection.href
|
|
377
|
+
});
|
|
378
|
+
return resolvedSection;
|
|
379
|
+
});
|
|
380
|
+
if (pages.length === 0) {
|
|
381
|
+
throw new Error("Docs graph must contain at least one page.");
|
|
382
|
+
}
|
|
383
|
+
return {
|
|
384
|
+
siteTitle: config.siteTitle,
|
|
385
|
+
siteDescription: config.siteDescription ?? null,
|
|
386
|
+
basePath: normalizedBasePath,
|
|
387
|
+
contentDir: normalizedContentDir,
|
|
388
|
+
theme: resolveThemeConfig(config.theme),
|
|
389
|
+
footer: resolveFooterConfig(config.footer),
|
|
390
|
+
brand: resolveBrandConfig(config.brand, config.siteTitle),
|
|
391
|
+
head: resolveHeadConfig(config.head),
|
|
392
|
+
partners: resolvePartnersConfig(config.partners),
|
|
393
|
+
social: resolveSocialConfig(config.social),
|
|
394
|
+
algolia: resolveAlgoliaConfig(config.algolia),
|
|
395
|
+
pages,
|
|
396
|
+
sections,
|
|
397
|
+
navbarItems
|
|
398
|
+
};
|
|
399
|
+
};
|
|
400
|
+
var getResolvedPageById = (config, pageId) => {
|
|
401
|
+
const page = config.pages.find((candidate) => candidate.id === pageId);
|
|
402
|
+
if (!page) {
|
|
403
|
+
throw new Error(`Unknown docs page id "${pageId}".`);
|
|
404
|
+
}
|
|
405
|
+
return page;
|
|
406
|
+
};
|
|
9
407
|
|
|
10
408
|
// src/runtime/node/codegen.ts
|
|
11
409
|
import fs from "fs";
|
|
410
|
+
import { createRequire } from "module";
|
|
12
411
|
import path from "path";
|
|
13
412
|
var GENERATED_DIRNAME = "(nivel-generated)";
|
|
413
|
+
var require2 = createRequire(import.meta.url);
|
|
414
|
+
var lucidePackageRoot = path.dirname(require2.resolve("lucide-react/package.json"));
|
|
415
|
+
var lucideEsmEntryPath = path.join(lucidePackageRoot, "dist", "esm", "lucide-react.js");
|
|
416
|
+
var lucideEsmIconsDirectoryPath = path.join(lucidePackageRoot, "dist", "esm", "icons");
|
|
417
|
+
var lucideIconModuleNameByExportName = null;
|
|
418
|
+
var lucideIconNodeByName = /* @__PURE__ */ new Map();
|
|
14
419
|
var writeFileIfChanged = (filePath, source) => {
|
|
15
420
|
const current = fs.existsSync(filePath) ? fs.readFileSync(filePath, "utf8") : null;
|
|
16
421
|
if (current === source) {
|
|
@@ -110,6 +515,105 @@ var getGeneratedIconMapSource = (entries) => {
|
|
|
110
515
|
}
|
|
111
516
|
return ["{", ...entries.map(({ iconKey, iconName }) => ` ${JSON.stringify(iconKey)}: ${iconName},`), "}"].join("\n");
|
|
112
517
|
};
|
|
518
|
+
var getLucideIconModuleNameByExportName = () => {
|
|
519
|
+
if (lucideIconModuleNameByExportName) {
|
|
520
|
+
return lucideIconModuleNameByExportName;
|
|
521
|
+
}
|
|
522
|
+
const lucideEntrySource = fs.readFileSync(lucideEsmEntryPath, "utf8");
|
|
523
|
+
const exportMap = /* @__PURE__ */ new Map();
|
|
524
|
+
const exportPattern = /export\s+\{\s*([\s\S]*?)\s*\}\s+from\s+'\.\/icons\/([^']+)\.js';/g;
|
|
525
|
+
for (const match of lucideEntrySource.matchAll(exportPattern)) {
|
|
526
|
+
const exportsSource = match[1];
|
|
527
|
+
const moduleName = match[2];
|
|
528
|
+
if (!exportsSource || !moduleName) {
|
|
529
|
+
continue;
|
|
530
|
+
}
|
|
531
|
+
for (const exportPart of exportsSource.split(",").map((value) => value.trim())) {
|
|
532
|
+
const exportMatch = /^default as (\w+)$/.exec(exportPart);
|
|
533
|
+
if (!exportMatch?.[1]) {
|
|
534
|
+
continue;
|
|
535
|
+
}
|
|
536
|
+
exportMap.set(exportMatch[1], moduleName);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
lucideIconModuleNameByExportName = exportMap;
|
|
540
|
+
return exportMap;
|
|
541
|
+
};
|
|
542
|
+
var getDocsIconNode = (iconName) => {
|
|
543
|
+
const cachedIconNode = lucideIconNodeByName.get(iconName);
|
|
544
|
+
if (cachedIconNode) {
|
|
545
|
+
return cachedIconNode;
|
|
546
|
+
}
|
|
547
|
+
const moduleName = getLucideIconModuleNameByExportName().get(iconName);
|
|
548
|
+
if (!moduleName) {
|
|
549
|
+
throw new Error(`Unable to resolve lucide-react module for docs icon "${iconName}".`);
|
|
550
|
+
}
|
|
551
|
+
const iconModuleSource = fs.readFileSync(path.join(lucideEsmIconsDirectoryPath, `${moduleName}.js`), "utf8");
|
|
552
|
+
const iconNodeMatch = /const __iconNode = (\[[\s\S]*?\]);\s*const /.exec(iconModuleSource);
|
|
553
|
+
if (!iconNodeMatch?.[1]) {
|
|
554
|
+
throw new Error(`Unable to read lucide-react icon node for docs icon "${iconName}".`);
|
|
555
|
+
}
|
|
556
|
+
const iconNode = Function(`"use strict"; return (${iconNodeMatch[1]})`)();
|
|
557
|
+
lucideIconNodeByName.set(iconName, iconNode);
|
|
558
|
+
return iconNode;
|
|
559
|
+
};
|
|
560
|
+
var getGeneratedIconDefinitionsSource = (iconNames) => {
|
|
561
|
+
if (iconNames.length === 0) {
|
|
562
|
+
return [];
|
|
563
|
+
}
|
|
564
|
+
const definitions = iconNames.flatMap((iconName) => {
|
|
565
|
+
return [`const ${iconName} = createDocsIcon(${JSON.stringify(getDocsIconNode(iconName))})`, ""];
|
|
566
|
+
});
|
|
567
|
+
return [
|
|
568
|
+
"import { createElement, forwardRef, type SVGProps } from 'react'",
|
|
569
|
+
"",
|
|
570
|
+
"type DocsGeneratedIconProps = SVGProps<SVGSVGElement> & {",
|
|
571
|
+
" size?: string | number",
|
|
572
|
+
" absoluteStrokeWidth?: boolean",
|
|
573
|
+
"}",
|
|
574
|
+
"",
|
|
575
|
+
"type DocsGeneratedIconNode = [tagName: string, attrs: Record<string, string>][]",
|
|
576
|
+
"",
|
|
577
|
+
"const docsGeneratedIconSvgAttrs = {",
|
|
578
|
+
" xmlns: 'http://www.w3.org/2000/svg',",
|
|
579
|
+
" fill: 'none',",
|
|
580
|
+
" viewBox: '0 0 24 24',",
|
|
581
|
+
" stroke: 'currentColor',",
|
|
582
|
+
" strokeWidth: 2,",
|
|
583
|
+
" strokeLinecap: 'round',",
|
|
584
|
+
" strokeLinejoin: 'round',",
|
|
585
|
+
"} as const",
|
|
586
|
+
"",
|
|
587
|
+
"const createDocsIcon = (iconNode: DocsGeneratedIconNode) => {",
|
|
588
|
+
" return forwardRef<SVGSVGElement, DocsGeneratedIconProps>(",
|
|
589
|
+
' ({ color = "currentColor", size = 24, strokeWidth = 2, absoluteStrokeWidth, children, ...props }, ref) => {',
|
|
590
|
+
" const resolvedSize = typeof size === 'number' ? size : Number(size)",
|
|
591
|
+
" const resolvedStrokeWidth =",
|
|
592
|
+
" absoluteStrokeWidth && Number.isFinite(resolvedSize) && resolvedSize > 0",
|
|
593
|
+
" ? (Number(strokeWidth) * 24) / resolvedSize",
|
|
594
|
+
" : strokeWidth",
|
|
595
|
+
"",
|
|
596
|
+
" return createElement(",
|
|
597
|
+
" 'svg',",
|
|
598
|
+
" {",
|
|
599
|
+
" ...docsGeneratedIconSvgAttrs,",
|
|
600
|
+
" ...props,",
|
|
601
|
+
" ref,",
|
|
602
|
+
" width: size,",
|
|
603
|
+
" height: size,",
|
|
604
|
+
" stroke: color,",
|
|
605
|
+
" strokeWidth: resolvedStrokeWidth,",
|
|
606
|
+
" },",
|
|
607
|
+
" ...iconNode.map(([tagName, attrs]) => createElement(tagName, attrs)),",
|
|
608
|
+
" children,",
|
|
609
|
+
" )",
|
|
610
|
+
" },",
|
|
611
|
+
" )",
|
|
612
|
+
"}",
|
|
613
|
+
"",
|
|
614
|
+
...definitions
|
|
615
|
+
];
|
|
616
|
+
};
|
|
113
617
|
var getGeneratedGlobalContextSource = (data) => {
|
|
114
618
|
const iconEntries = data.sidebarSections.flatMap((section) => {
|
|
115
619
|
const sectionIconEntries = section.icon ? [{ iconKey: getDocsIconMapKey("section", section.id), iconName: section.icon }] : [];
|
|
@@ -118,7 +622,7 @@ var getGeneratedGlobalContextSource = (data) => {
|
|
|
118
622
|
const iconImports = [...new Set(iconEntries.map(({ iconName }) => iconName))].sort();
|
|
119
623
|
return [
|
|
120
624
|
"import type { DocsGlobalContextData, DocsGlobalContextSerializableData, DocsIconMap } from '@unterberg/nivel'",
|
|
121
|
-
...iconImports
|
|
625
|
+
...getGeneratedIconDefinitionsSource(iconImports),
|
|
122
626
|
"",
|
|
123
627
|
`const docsGlobalContextSerializableData: DocsGlobalContextSerializableData = ${serializeData(data)}`,
|
|
124
628
|
"",
|
|
@@ -762,6 +1266,9 @@ var initConsumer = (options) => {
|
|
|
762
1266
|
};
|
|
763
1267
|
|
|
764
1268
|
export {
|
|
1269
|
+
resolveDocsHref,
|
|
1270
|
+
resolveDocsConfig,
|
|
1271
|
+
getResolvedPageById,
|
|
765
1272
|
getGeneratedPagesRoot,
|
|
766
1273
|
getDocsSourcePaths,
|
|
767
1274
|
isDocsSourcePath,
|
|
@@ -772,4 +1279,4 @@ export {
|
|
|
772
1279
|
getInitSummary,
|
|
773
1280
|
initConsumer
|
|
774
1281
|
};
|
|
775
|
-
//# sourceMappingURL=chunk-
|
|
1282
|
+
//# sourceMappingURL=chunk-GFZ3P4F4.js.map
|