fumadocs-core 15.8.2 → 15.8.4
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/{algolia-Z232AL35.js → algolia-IZEDLPHE.js} +1 -1
- package/dist/breadcrumb.js +4 -4
- package/dist/builder-5BHIAfCi.d.ts +383 -0
- package/dist/{chunk-DDDU7USP.js → chunk-FAEPKD7U.js} +1 -0
- package/dist/{chunk-Z5V4JSQY.js → chunk-LMRZFODA.js} +16 -1
- package/dist/{chunk-JSBRDJBE.js → chunk-U67V476Y.js} +5 -0
- package/dist/content/github.js +1 -1
- package/dist/content/index.js +1 -1
- package/dist/content/toc.js +1 -1
- package/dist/dynamic-link.js +1 -1
- package/dist/{fetch-C3XV44E6.js → fetch-2XFMBLBA.js} +1 -1
- package/dist/framework/index.js +1 -1
- package/dist/framework/next.js +1 -1
- package/dist/framework/react-router.js +1 -1
- package/dist/framework/tanstack.js +1 -1
- package/dist/framework/waku.js +1 -1
- package/dist/hide-if-empty.js +1 -1
- package/dist/highlight/client.js +1 -1
- package/dist/highlight/index.js +1 -1
- package/dist/i18n/index.js +1 -1
- package/dist/i18n/legacy.js +1 -1
- package/dist/i18n/middleware.js +1 -1
- package/dist/link.js +1 -1
- package/dist/mdx-plugins/index.js +1 -1
- package/dist/{mixedbread-AG5AAOKO.js → mixedbread-RAHDVXGJ.js} +1 -1
- package/dist/negotiation/index.js +1 -1
- package/dist/{orama-cloud-GMFFJOIB.js → orama-cloud-74FM25SB.js} +1 -1
- package/dist/page-tree/index.js +1 -1
- package/dist/search/algolia.js +1 -1
- package/dist/search/client.js +6 -6
- package/dist/search/index.js +1 -1
- package/dist/search/orama-cloud.js +1 -1
- package/dist/search/server.d.ts +1 -1
- package/dist/search/server.js +5 -5
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +4 -4
- package/dist/sidebar.js +1 -1
- package/dist/source/index.d.ts +6 -331
- package/dist/source/index.js +200 -150
- package/dist/source/plugins/lucide-icons.d.ts +1 -1
- package/dist/source/plugins/lucide-icons.js +2 -2
- package/dist/{static-UVSWNGTY.js → static-A2YJ5TXV.js} +1 -1
- package/dist/toc.js +1 -1
- package/dist/utils/use-effect-event.d.ts +4 -3
- package/dist/utils/use-effect-event.js +9 -6
- package/dist/utils/use-media-query.js +1 -1
- package/dist/utils/use-on-change.js +1 -1
- package/package.json +12 -12
package/dist/source/index.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
2
|
iconPlugin
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-FAEPKD7U.js";
|
|
4
4
|
import {
|
|
5
5
|
basename,
|
|
6
6
|
dirname,
|
|
7
7
|
extname,
|
|
8
8
|
joinPath,
|
|
9
9
|
parseFilePath,
|
|
10
|
+
path_exports,
|
|
10
11
|
slash,
|
|
11
12
|
splitPath
|
|
12
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-LMRZFODA.js";
|
|
13
14
|
import {
|
|
14
15
|
normalizeUrl
|
|
15
16
|
} from "../chunk-PFNP6PEB.js";
|
|
16
|
-
import "../chunk-
|
|
17
|
+
import "../chunk-U67V476Y.js";
|
|
17
18
|
|
|
18
19
|
// src/source/page-tree/transformer-fallback.ts
|
|
19
20
|
function transformerFallback() {
|
|
20
21
|
const addedFiles = /* @__PURE__ */ new Set();
|
|
21
22
|
return {
|
|
22
|
-
name: "fumadocs:fallback",
|
|
23
23
|
root(root) {
|
|
24
24
|
const isolatedStorage = new FileSystem();
|
|
25
25
|
for (const file of this.storage.getFiles()) {
|
|
@@ -28,10 +28,9 @@ function transformerFallback() {
|
|
|
28
28
|
if (content) isolatedStorage.write(file, content);
|
|
29
29
|
}
|
|
30
30
|
if (isolatedStorage.getFiles().length === 0) return root;
|
|
31
|
-
root.fallback = this.builder.build({
|
|
31
|
+
root.fallback = this.builder.build(isolatedStorage, {
|
|
32
32
|
...this.options,
|
|
33
33
|
id: `fallback-${root.$id ?? ""}`,
|
|
34
|
-
storage: isolatedStorage,
|
|
35
34
|
generateFallback: false
|
|
36
35
|
});
|
|
37
36
|
addedFiles.clear();
|
|
@@ -145,13 +144,7 @@ function buildFolderNode(folderPath, isGlobalRoot, ctx) {
|
|
|
145
144
|
ctx.visitedPaths.add(indexPath);
|
|
146
145
|
index = buildFileNode(indexPath, ctx);
|
|
147
146
|
}
|
|
148
|
-
if (
|
|
149
|
-
setIndexIfUnused();
|
|
150
|
-
children = buildAll(
|
|
151
|
-
files.filter((file) => !ctx.visitedPaths.has(file)),
|
|
152
|
-
ctx
|
|
153
|
-
);
|
|
154
|
-
} else {
|
|
147
|
+
if (meta && meta.data.pages) {
|
|
155
148
|
const resolved = meta.data.pages.flatMap((item, i) => resolveFolderItem(folderPath, item, ctx, i));
|
|
156
149
|
setIndexIfUnused();
|
|
157
150
|
for (let i = 0; i < resolved.length; i++) {
|
|
@@ -166,6 +159,12 @@ function buildFolderNode(folderPath, isGlobalRoot, ctx) {
|
|
|
166
159
|
break;
|
|
167
160
|
}
|
|
168
161
|
children = resolved;
|
|
162
|
+
} else {
|
|
163
|
+
setIndexIfUnused();
|
|
164
|
+
children = buildAll(
|
|
165
|
+
files.filter((file) => !ctx.visitedPaths.has(file)),
|
|
166
|
+
ctx
|
|
167
|
+
);
|
|
169
168
|
}
|
|
170
169
|
let name = meta?.data.title ?? index?.name;
|
|
171
170
|
if (!name) {
|
|
@@ -227,10 +226,10 @@ function build(id, ctx) {
|
|
|
227
226
|
}
|
|
228
227
|
return root;
|
|
229
228
|
}
|
|
230
|
-
function createPageTreeBuilder(getUrl) {
|
|
231
|
-
function getTransformers(
|
|
229
|
+
function createPageTreeBuilder(getUrl, plugins) {
|
|
230
|
+
function getTransformers(generateFallback) {
|
|
232
231
|
const transformers = [];
|
|
233
|
-
for (const plugin of
|
|
232
|
+
for (const plugin of plugins ?? []) {
|
|
234
233
|
if (plugin.transformPageTree) transformers.push(plugin.transformPageTree);
|
|
235
234
|
}
|
|
236
235
|
if (generateFallback) {
|
|
@@ -239,28 +238,25 @@ function createPageTreeBuilder(getUrl) {
|
|
|
239
238
|
return transformers;
|
|
240
239
|
}
|
|
241
240
|
function createFlattenPathResolver(storage) {
|
|
242
|
-
const
|
|
241
|
+
const map2 = /* @__PURE__ */ new Map();
|
|
243
242
|
const files = storage.getFiles();
|
|
244
243
|
for (const file of files) {
|
|
245
244
|
const content = storage.read(file);
|
|
246
245
|
const flattenPath = file.substring(0, file.length - extname(file).length);
|
|
247
|
-
|
|
246
|
+
map2.set(flattenPath + "." + content.format, file);
|
|
248
247
|
}
|
|
249
248
|
return (name, format) => {
|
|
250
|
-
return
|
|
249
|
+
return map2.get(name + "." + format);
|
|
251
250
|
};
|
|
252
251
|
}
|
|
253
252
|
return {
|
|
254
|
-
build(
|
|
253
|
+
build(storage, options) {
|
|
255
254
|
const key = "";
|
|
256
|
-
return this.buildI18n({
|
|
257
|
-
id,
|
|
258
|
-
storages: { [key]: storage },
|
|
259
|
-
...options
|
|
260
|
-
})[key];
|
|
255
|
+
return this.buildI18n({ [key]: storage }, options)[key];
|
|
261
256
|
},
|
|
262
|
-
buildI18n(
|
|
263
|
-
const
|
|
257
|
+
buildI18n(storages, options = {}) {
|
|
258
|
+
const { id, generateFallback = true } = options;
|
|
259
|
+
const transformers = getTransformers(generateFallback);
|
|
264
260
|
const out = {};
|
|
265
261
|
for (const [locale, storage] of Object.entries(storages)) {
|
|
266
262
|
const resolve = createFlattenPathResolver(storage);
|
|
@@ -293,7 +289,7 @@ function pathToName(name) {
|
|
|
293
289
|
return result.join("");
|
|
294
290
|
}
|
|
295
291
|
|
|
296
|
-
// src/source/file-system.ts
|
|
292
|
+
// src/source/storage/file-system.ts
|
|
297
293
|
var FileSystem = class {
|
|
298
294
|
constructor(inherit) {
|
|
299
295
|
this.files = /* @__PURE__ */ new Map();
|
|
@@ -319,20 +315,31 @@ var FileSystem = class {
|
|
|
319
315
|
return this.folders.get(path);
|
|
320
316
|
}
|
|
321
317
|
write(path, file) {
|
|
322
|
-
if (this.files.has(path)) {
|
|
323
|
-
|
|
324
|
-
|
|
318
|
+
if (!this.files.has(path)) {
|
|
319
|
+
const dir = dirname(path);
|
|
320
|
+
this.makeDir(dir);
|
|
321
|
+
this.readDir(dir)?.push(path);
|
|
325
322
|
}
|
|
326
|
-
const dir = dirname(path);
|
|
327
|
-
this.makeDir(dir);
|
|
328
|
-
this.readDir(dir)?.push(path);
|
|
329
323
|
this.files.set(path, file);
|
|
330
324
|
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
325
|
+
/**
|
|
326
|
+
* Delete files at specified path.
|
|
327
|
+
*
|
|
328
|
+
* @param path - the target path.
|
|
329
|
+
* @param [recursive=false] - if set to `true`, it will also delete directories.
|
|
330
|
+
*/
|
|
331
|
+
delete(path, recursive = false) {
|
|
332
|
+
if (this.files.delete(path)) return true;
|
|
333
|
+
if (recursive) {
|
|
334
|
+
const folder = this.folders.get(path);
|
|
335
|
+
if (!folder) return false;
|
|
336
|
+
this.folders.delete(path);
|
|
337
|
+
for (const child of folder) {
|
|
338
|
+
this.delete(child);
|
|
339
|
+
}
|
|
340
|
+
return true;
|
|
341
|
+
}
|
|
342
|
+
return false;
|
|
336
343
|
}
|
|
337
344
|
getFiles() {
|
|
338
345
|
return Array.from(this.files.keys());
|
|
@@ -348,7 +355,7 @@ var FileSystem = class {
|
|
|
348
355
|
}
|
|
349
356
|
};
|
|
350
357
|
|
|
351
|
-
// src/source/
|
|
358
|
+
// src/source/storage/content.ts
|
|
352
359
|
function isLocaleValid(locale) {
|
|
353
360
|
return locale.length > 0 && !/\d+/.test(locale);
|
|
354
361
|
}
|
|
@@ -372,8 +379,7 @@ var parsers = {
|
|
|
372
379
|
return [path];
|
|
373
380
|
}
|
|
374
381
|
};
|
|
375
|
-
function
|
|
376
|
-
const { buildFile, plugins = [] } = options;
|
|
382
|
+
function buildContentStorage(files, buildFile, plugins, i18n) {
|
|
377
383
|
const parser = parsers[i18n.parser ?? "dot"];
|
|
378
384
|
const storages = {};
|
|
379
385
|
const normalized = files.map(
|
|
@@ -415,8 +421,20 @@ function normalizePath(path) {
|
|
|
415
421
|
}
|
|
416
422
|
|
|
417
423
|
// src/source/plugins/index.ts
|
|
424
|
+
var priorityMap = {
|
|
425
|
+
pre: 1,
|
|
426
|
+
default: 0,
|
|
427
|
+
post: -1
|
|
428
|
+
};
|
|
418
429
|
function buildPlugins(plugins) {
|
|
419
|
-
|
|
430
|
+
const flatten = [];
|
|
431
|
+
for (const plugin of plugins) {
|
|
432
|
+
if (Array.isArray(plugin)) flatten.push(...plugin);
|
|
433
|
+
else if (plugin) flatten.push(plugin);
|
|
434
|
+
}
|
|
435
|
+
return flatten.sort(
|
|
436
|
+
(a, b) => priorityMap[b.enforce ?? "default"] - priorityMap[a.enforce ?? "default"]
|
|
437
|
+
);
|
|
420
438
|
}
|
|
421
439
|
|
|
422
440
|
// src/source/plugins/slugs.ts
|
|
@@ -425,6 +443,7 @@ function slugsPlugin(slugsFn) {
|
|
|
425
443
|
return basename(file, extname(file)) === "index";
|
|
426
444
|
}
|
|
427
445
|
return {
|
|
446
|
+
name: "fumadocs:slugs",
|
|
428
447
|
transformStorage({ storage }) {
|
|
429
448
|
const indexFiles = /* @__PURE__ */ new Set();
|
|
430
449
|
const taken = /* @__PURE__ */ new Set();
|
|
@@ -450,50 +469,69 @@ function slugsPlugin(slugsFn) {
|
|
|
450
469
|
}
|
|
451
470
|
};
|
|
452
471
|
}
|
|
472
|
+
var GroupRegex = /^\(.+\)$/;
|
|
473
|
+
function getSlugs(file) {
|
|
474
|
+
if (typeof file !== "string") return getSlugs(file.path);
|
|
475
|
+
const dir = dirname(file);
|
|
476
|
+
const name = basename(file, extname(file));
|
|
477
|
+
const slugs = [];
|
|
478
|
+
for (const seg of dir.split("/")) {
|
|
479
|
+
if (seg.length > 0 && !GroupRegex.test(seg)) slugs.push(encodeURI(seg));
|
|
480
|
+
}
|
|
481
|
+
if (GroupRegex.test(name))
|
|
482
|
+
throw new Error(`Cannot use folder group in file names: ${file}`);
|
|
483
|
+
if (name !== "index") {
|
|
484
|
+
slugs.push(encodeURI(name));
|
|
485
|
+
}
|
|
486
|
+
return slugs;
|
|
487
|
+
}
|
|
453
488
|
|
|
454
489
|
// src/source/plugins/compat.ts
|
|
455
|
-
function compatPlugin(
|
|
456
|
-
|
|
457
|
-
attachSeparator,
|
|
458
|
-
attachFolder,
|
|
490
|
+
function compatPlugin({
|
|
491
|
+
pageTree,
|
|
459
492
|
transformers
|
|
460
493
|
}) {
|
|
461
|
-
const
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
const content = file ? this.storage.read(file) : void 0;
|
|
467
|
-
return attachFile(
|
|
468
|
-
node,
|
|
469
|
-
content?.format === "page" ? content : void 0
|
|
470
|
-
);
|
|
471
|
-
},
|
|
472
|
-
folder(node, folderPath, metaPath) {
|
|
473
|
-
if (!attachFolder) return node;
|
|
474
|
-
const files = this.storage.readDir(folderPath) ?? [];
|
|
475
|
-
const meta = metaPath ? this.storage.read(metaPath) : void 0;
|
|
476
|
-
return attachFolder(
|
|
477
|
-
node,
|
|
478
|
-
{
|
|
479
|
-
children: files.flatMap((file) => this.storage.read(file) ?? [])
|
|
480
|
-
},
|
|
481
|
-
meta?.format === "meta" ? meta : void 0
|
|
482
|
-
);
|
|
483
|
-
},
|
|
484
|
-
separator(node) {
|
|
485
|
-
if (!attachSeparator) return node;
|
|
486
|
-
return attachSeparator(node);
|
|
487
|
-
}
|
|
494
|
+
const plugins = [];
|
|
495
|
+
if (pageTree) {
|
|
496
|
+
const { attachFile, attachSeparator, attachFolder, transformers: transformers2 } = pageTree;
|
|
497
|
+
for (const transformer of transformers2 ?? []) {
|
|
498
|
+
plugins.push(fromPageTreeTransformer(transformer));
|
|
488
499
|
}
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
500
|
+
plugins.push(
|
|
501
|
+
fromPageTreeTransformer({
|
|
502
|
+
file(node, file) {
|
|
503
|
+
if (!attachFile) return node;
|
|
504
|
+
const content = file ? this.storage.read(file) : void 0;
|
|
505
|
+
return attachFile(
|
|
506
|
+
node,
|
|
507
|
+
content?.format === "page" ? content : void 0
|
|
508
|
+
);
|
|
509
|
+
},
|
|
510
|
+
folder(node, folderPath, metaPath) {
|
|
511
|
+
if (!attachFolder) return node;
|
|
512
|
+
const files = this.storage.readDir(folderPath) ?? [];
|
|
513
|
+
const meta = metaPath ? this.storage.read(metaPath) : void 0;
|
|
514
|
+
return attachFolder(
|
|
515
|
+
node,
|
|
516
|
+
{
|
|
517
|
+
children: files.flatMap((file) => this.storage.read(file) ?? [])
|
|
518
|
+
},
|
|
519
|
+
meta?.format === "meta" ? meta : void 0
|
|
520
|
+
);
|
|
521
|
+
},
|
|
522
|
+
separator(node) {
|
|
523
|
+
if (!attachSeparator) return node;
|
|
524
|
+
return attachSeparator(node);
|
|
525
|
+
}
|
|
526
|
+
})
|
|
527
|
+
);
|
|
492
528
|
}
|
|
493
|
-
|
|
494
|
-
|
|
529
|
+
if (transformers) {
|
|
530
|
+
for (const transformer of transformers) {
|
|
531
|
+
plugins.push(fromStorageTransformer(transformer));
|
|
532
|
+
}
|
|
495
533
|
}
|
|
496
|
-
return
|
|
534
|
+
return plugins;
|
|
497
535
|
}
|
|
498
536
|
function fromPageTreeTransformer(transformer) {
|
|
499
537
|
return {
|
|
@@ -546,60 +584,57 @@ function createGetUrl(baseUrl, i18n) {
|
|
|
546
584
|
return `/${paths.filter((v) => v.length > 0).join("/")}`;
|
|
547
585
|
};
|
|
548
586
|
}
|
|
549
|
-
function loader(
|
|
550
|
-
|
|
587
|
+
function loader(...args) {
|
|
588
|
+
const resolved = args.length === 2 ? resolveConfig(args[0], args[1]) : resolveConfig(args[0].source, args[0]);
|
|
589
|
+
return createOutput(resolved);
|
|
551
590
|
}
|
|
552
|
-
function
|
|
553
|
-
const
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
591
|
+
function resolveConfig(source, { slugs, icon, plugins = [], baseUrl, url, ...base }) {
|
|
592
|
+
const getUrl = url ? (...args) => normalizeUrl(url(...args)) : createGetUrl(baseUrl, base.i18n);
|
|
593
|
+
let config = {
|
|
594
|
+
...base,
|
|
595
|
+
url: getUrl,
|
|
596
|
+
source,
|
|
597
|
+
plugins: buildPlugins([
|
|
598
|
+
slugsPlugin(slugs),
|
|
599
|
+
icon && iconPlugin(icon),
|
|
600
|
+
compatPlugin(base),
|
|
601
|
+
...plugins
|
|
602
|
+
])
|
|
603
|
+
};
|
|
604
|
+
for (const plugin of config.plugins ?? []) {
|
|
605
|
+
const result = plugin.config?.(config);
|
|
606
|
+
if (result) config = result;
|
|
560
607
|
}
|
|
561
|
-
return
|
|
608
|
+
return config;
|
|
562
609
|
}
|
|
563
|
-
function createOutput(
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
610
|
+
function createOutput({
|
|
611
|
+
source: { files },
|
|
612
|
+
url: getUrl,
|
|
613
|
+
i18n,
|
|
614
|
+
plugins = [],
|
|
615
|
+
pageTree: pageTreeConfig
|
|
616
|
+
}) {
|
|
569
617
|
const defaultLanguage = i18n?.defaultLanguage ?? "";
|
|
570
|
-
const
|
|
571
|
-
const plugins = [slugsPlugin(slugsFn)];
|
|
572
|
-
if (options.icon) {
|
|
573
|
-
plugins.push(iconPlugin(options.icon));
|
|
574
|
-
}
|
|
575
|
-
if (options.plugins) {
|
|
576
|
-
plugins.push(...buildPlugins(options.plugins));
|
|
577
|
-
}
|
|
578
|
-
if (options.pageTree) {
|
|
579
|
-
plugins.push(...compatPlugin(options, options.pageTree));
|
|
580
|
-
}
|
|
581
|
-
const storages = loadFiles(
|
|
618
|
+
const storages = buildContentStorage(
|
|
582
619
|
files,
|
|
583
|
-
{
|
|
584
|
-
|
|
585
|
-
if (file.type === "page") {
|
|
586
|
-
return {
|
|
587
|
-
format: "page",
|
|
588
|
-
path: file.path,
|
|
589
|
-
slugs: file.slugs,
|
|
590
|
-
data: file.data,
|
|
591
|
-
absolutePath: file.absolutePath ?? ""
|
|
592
|
-
};
|
|
593
|
-
}
|
|
620
|
+
(file) => {
|
|
621
|
+
if (file.type === "page") {
|
|
594
622
|
return {
|
|
595
|
-
format: "
|
|
623
|
+
format: "page",
|
|
596
624
|
path: file.path,
|
|
597
|
-
|
|
598
|
-
data: file.data
|
|
625
|
+
slugs: file.slugs,
|
|
626
|
+
data: file.data,
|
|
627
|
+
absolutePath: file.absolutePath ?? ""
|
|
599
628
|
};
|
|
600
|
-
}
|
|
601
|
-
|
|
629
|
+
}
|
|
630
|
+
return {
|
|
631
|
+
format: "meta",
|
|
632
|
+
path: file.path,
|
|
633
|
+
absolutePath: file.absolutePath ?? "",
|
|
634
|
+
data: file.data
|
|
635
|
+
};
|
|
602
636
|
},
|
|
637
|
+
plugins,
|
|
603
638
|
i18n ?? {
|
|
604
639
|
defaultLanguage,
|
|
605
640
|
parser: "none",
|
|
@@ -607,16 +642,12 @@ function createOutput(options) {
|
|
|
607
642
|
}
|
|
608
643
|
);
|
|
609
644
|
const walker = indexPages(storages, getUrl);
|
|
610
|
-
const builder = createPageTreeBuilder(getUrl);
|
|
645
|
+
const builder = createPageTreeBuilder(getUrl, plugins);
|
|
611
646
|
let pageTree;
|
|
612
647
|
return {
|
|
613
648
|
_i18n: i18n,
|
|
614
649
|
get pageTree() {
|
|
615
|
-
pageTree ??= builder.buildI18n(
|
|
616
|
-
storages,
|
|
617
|
-
plugins,
|
|
618
|
-
...options.pageTree
|
|
619
|
-
});
|
|
650
|
+
pageTree ??= builder.buildI18n(storages, pageTreeConfig);
|
|
620
651
|
return i18n ? pageTree : pageTree[defaultLanguage];
|
|
621
652
|
},
|
|
622
653
|
set pageTree(v) {
|
|
@@ -654,8 +685,8 @@ function createOutput(options) {
|
|
|
654
685
|
},
|
|
655
686
|
getLanguages() {
|
|
656
687
|
const list = [];
|
|
657
|
-
if (!
|
|
658
|
-
for (const language of
|
|
688
|
+
if (!i18n) return list;
|
|
689
|
+
for (const language of i18n.languages) {
|
|
659
690
|
list.push({
|
|
660
691
|
language,
|
|
661
692
|
pages: this.getPages(language)
|
|
@@ -677,14 +708,14 @@ function createOutput(options) {
|
|
|
677
708
|
return walker.pathToPage.get(`${language}.${ref}`);
|
|
678
709
|
},
|
|
679
710
|
getPageTree(locale) {
|
|
680
|
-
if (
|
|
711
|
+
if (i18n) {
|
|
681
712
|
return this.pageTree[locale ?? defaultLanguage];
|
|
682
713
|
}
|
|
683
714
|
return this.pageTree;
|
|
684
715
|
},
|
|
685
716
|
// @ts-expect-error -- ignore this
|
|
686
717
|
generateParams(slug, lang) {
|
|
687
|
-
if (
|
|
718
|
+
if (i18n) {
|
|
688
719
|
return this.getLanguages().flatMap(
|
|
689
720
|
(entry) => entry.pages.map((page) => ({
|
|
690
721
|
[slug ?? "slug"]: page.slugs,
|
|
@@ -721,28 +752,47 @@ function fileToPage(file, getUrl, locale) {
|
|
|
721
752
|
locale
|
|
722
753
|
};
|
|
723
754
|
}
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
slugs.push(encodeURI(name));
|
|
755
|
+
function multiple(sources) {
|
|
756
|
+
const out = { files: [] };
|
|
757
|
+
for (const [type, source] of Object.entries(sources)) {
|
|
758
|
+
for (const file of source.files) {
|
|
759
|
+
out.files.push({
|
|
760
|
+
...file,
|
|
761
|
+
data: {
|
|
762
|
+
...file.data,
|
|
763
|
+
type
|
|
764
|
+
}
|
|
765
|
+
});
|
|
766
|
+
}
|
|
737
767
|
}
|
|
738
|
-
return
|
|
768
|
+
return out;
|
|
769
|
+
}
|
|
770
|
+
function map(source) {
|
|
771
|
+
return {
|
|
772
|
+
page(fn) {
|
|
773
|
+
return {
|
|
774
|
+
files: source.files.map(
|
|
775
|
+
(file) => file.type === "page" ? fn(file) : file
|
|
776
|
+
)
|
|
777
|
+
};
|
|
778
|
+
},
|
|
779
|
+
meta(fn) {
|
|
780
|
+
return {
|
|
781
|
+
files: source.files.map(
|
|
782
|
+
(file) => file.type === "meta" ? fn(file) : file
|
|
783
|
+
)
|
|
784
|
+
};
|
|
785
|
+
}
|
|
786
|
+
};
|
|
739
787
|
}
|
|
740
788
|
export {
|
|
741
789
|
FileSystem,
|
|
790
|
+
path_exports as PathUtils,
|
|
742
791
|
createGetUrl,
|
|
743
792
|
createPageTreeBuilder,
|
|
744
793
|
getSlugs,
|
|
745
|
-
loadFiles,
|
|
746
794
|
loader,
|
|
795
|
+
map,
|
|
796
|
+
multiple,
|
|
747
797
|
parseFilePath
|
|
748
798
|
};
|
package/dist/toc.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
type UseEffectEvent = <F extends (...params: never[]) => unknown>(callback: F) => F;
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
+
* Polyfill for React.js 19.2 `useEffectEvent`.
|
|
3
4
|
*
|
|
4
|
-
* @internal
|
|
5
|
+
* @internal Don't use this, could be deleted anytime.
|
|
5
6
|
*/
|
|
6
|
-
declare
|
|
7
|
+
declare const useEffectEvent: UseEffectEvent;
|
|
7
8
|
|
|
8
9
|
export { useEffectEvent };
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import "../chunk-
|
|
2
|
+
import "../chunk-U67V476Y.js";
|
|
3
3
|
|
|
4
4
|
// src/utils/use-effect-event.ts
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
const ref = useRef(callback);
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
var useEffectEvent = "useEffectEvent" in React ? { ...React }.useEffectEvent : (callback) => {
|
|
7
|
+
const ref = React.useRef(callback);
|
|
8
8
|
ref.current = callback;
|
|
9
|
-
return useCallback(
|
|
10
|
-
|
|
9
|
+
return React.useCallback(
|
|
10
|
+
((...params) => ref.current(...params)),
|
|
11
|
+
[]
|
|
12
|
+
);
|
|
13
|
+
};
|
|
11
14
|
export {
|
|
12
15
|
useEffectEvent
|
|
13
16
|
};
|