fumadocs-core 15.2.5 → 15.2.6
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/breadcrumb.d.ts
CHANGED
|
@@ -8,6 +8,9 @@ interface Root {
|
|
|
8
8
|
type Node = Item | Separator | Folder;
|
|
9
9
|
interface Item {
|
|
10
10
|
$id?: string;
|
|
11
|
+
/**
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
11
14
|
$ref?: {
|
|
12
15
|
file: string;
|
|
13
16
|
};
|
|
@@ -26,6 +29,9 @@ interface Separator {
|
|
|
26
29
|
}
|
|
27
30
|
interface Folder {
|
|
28
31
|
$id?: string;
|
|
32
|
+
/**
|
|
33
|
+
* @internal
|
|
34
|
+
*/
|
|
29
35
|
$ref?: {
|
|
30
36
|
metaFile?: string;
|
|
31
37
|
};
|
package/dist/search/server.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { LoaderOutput, LoaderConfig, InferPageType } from '../source/index.js';
|
|
|
6
6
|
import 'mdast';
|
|
7
7
|
import 'unified';
|
|
8
8
|
import 'react';
|
|
9
|
-
import '../page-tree-
|
|
9
|
+
import '../page-tree-BG3wP0gU.js';
|
|
10
10
|
|
|
11
11
|
type AdvancedDocument = TypedDocument<Orama<typeof advancedSchema>>;
|
|
12
12
|
declare const advancedSchema: {
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { a as TOCItemType, T as TableOfContents, g as getTableOfContents } from '../get-toc-Cr2URuiP.js';
|
|
2
|
-
import { N as Node, I as Item, R as Root, F as Folder } from '../page-tree-
|
|
3
|
-
export { p as PageTree } from '../page-tree-
|
|
2
|
+
import { N as Node, I as Item, R as Root, F as Folder } from '../page-tree-BG3wP0gU.js';
|
|
3
|
+
export { p as PageTree } from '../page-tree-BG3wP0gU.js';
|
|
4
4
|
export { S as SortedResult } from '../types-Ch8gnVgO.js';
|
|
5
5
|
import { Metadata } from 'next';
|
|
6
6
|
import { NextRequest } from 'next/server';
|
package/dist/source/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
2
|
import { I as I18nConfig } from '../config-inq6kP6y.js';
|
|
3
|
-
import { R as Root, I as Item, F as Folder$1, S as Separator } from '../page-tree-
|
|
3
|
+
import { R as Root, I as Item, F as Folder$1, S as Separator } from '../page-tree-BG3wP0gU.js';
|
|
4
4
|
|
|
5
5
|
interface FileInfo {
|
|
6
6
|
/**
|
|
@@ -142,8 +142,8 @@ interface LoaderOutput<Config extends LoaderConfig> {
|
|
|
142
142
|
* @param language - If empty, the default language will be used
|
|
143
143
|
*/
|
|
144
144
|
getPage: (slugs: string[] | undefined, language?: string) => Page<Config['source']['pageData']> | undefined;
|
|
145
|
-
getNodePage: (node: Item) => Page<Config['source']['pageData']> | undefined;
|
|
146
|
-
getNodeMeta: (node: Folder$1) => Meta<Config['source']['metaData']> | undefined;
|
|
145
|
+
getNodePage: (node: Item, language?: string) => Page<Config['source']['pageData']> | undefined;
|
|
146
|
+
getNodeMeta: (node: Folder$1, language?: string) => Meta<Config['source']['metaData']> | undefined;
|
|
147
147
|
/**
|
|
148
148
|
* generate static params for Next.js SSG
|
|
149
149
|
*/
|
package/dist/source/index.js
CHANGED
|
@@ -32,17 +32,12 @@ function buildAll(nodes, ctx, skipIndex) {
|
|
|
32
32
|
const treeNode = buildFileNode(localized ?? node, ctx);
|
|
33
33
|
if (node.file.name === "index") {
|
|
34
34
|
if (!skipIndex) output.unshift(treeNode);
|
|
35
|
-
|
|
35
|
+
} else {
|
|
36
|
+
output.push(treeNode);
|
|
36
37
|
}
|
|
37
|
-
output.push(treeNode);
|
|
38
38
|
}
|
|
39
39
|
if ("children" in node) {
|
|
40
|
-
|
|
41
|
-
if (folder.children.length === 0 && folder.index) {
|
|
42
|
-
output.push(folder.index);
|
|
43
|
-
} else {
|
|
44
|
-
folders.push(folder);
|
|
45
|
-
}
|
|
40
|
+
folders.push(buildFolderNode(node, false, ctx));
|
|
46
41
|
}
|
|
47
42
|
}
|
|
48
43
|
output.push(...folders);
|
|
@@ -94,19 +89,16 @@ function resolveFolderItem(folder, item, ctx, idx, addedNodePaths) {
|
|
|
94
89
|
function buildFolderNode(folder, isGlobalRoot, ctx) {
|
|
95
90
|
const metaPath = joinPath(folder.file.path, "meta");
|
|
96
91
|
const meta = ctx.localeStorage?.read(metaPath, "meta") ?? ctx.storage.read(metaPath, "meta");
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
);
|
|
101
|
-
const metadata = meta?.data;
|
|
102
|
-
const isRoot = metadata?.root ?? isGlobalRoot;
|
|
92
|
+
const indexPath = joinPath(folder.file.path, "index");
|
|
93
|
+
const indexFile = ctx.localeStorage?.read(indexPath, "page") ?? ctx.storage.read(indexPath, "page");
|
|
94
|
+
const isRoot = meta?.data.root ?? isGlobalRoot;
|
|
103
95
|
const index = indexFile ? buildFileNode(indexFile, ctx) : void 0;
|
|
96
|
+
const addedNodePaths = /* @__PURE__ */ new Set();
|
|
104
97
|
let children;
|
|
105
|
-
if (!
|
|
98
|
+
if (!meta?.data.pages) {
|
|
106
99
|
children = buildAll(folder.children, ctx, !isRoot);
|
|
107
100
|
} else {
|
|
108
|
-
const
|
|
109
|
-
const resolved = metadata?.pages?.flatMap((item, i) => {
|
|
101
|
+
const resolved = meta.data.pages.flatMap((item, i) => {
|
|
110
102
|
return resolveFolderItem(folder, item, ctx, i, addedNodePaths);
|
|
111
103
|
});
|
|
112
104
|
const restNodes = buildAll(
|
|
@@ -126,13 +118,13 @@ function buildFolderNode(folder, isGlobalRoot, ctx) {
|
|
|
126
118
|
}
|
|
127
119
|
const node = {
|
|
128
120
|
type: "folder",
|
|
129
|
-
name:
|
|
121
|
+
name: meta?.data.title ?? index?.name ?? // resolve folder groups like (group_name)
|
|
130
122
|
pathToName(group.exec(folder.file.name)?.[1] ?? folder.file.name),
|
|
131
|
-
icon: ctx.options.resolveIcon?.(
|
|
132
|
-
root:
|
|
133
|
-
defaultOpen:
|
|
134
|
-
description:
|
|
135
|
-
index,
|
|
123
|
+
icon: ctx.options.resolveIcon?.(meta?.data.icon) ?? index?.icon,
|
|
124
|
+
root: meta?.data.root,
|
|
125
|
+
defaultOpen: meta?.data.defaultOpen,
|
|
126
|
+
description: meta?.data.description,
|
|
127
|
+
index: isRoot || indexFile && !addedNodePaths.has(indexFile.file.path) ? index : void 0,
|
|
136
128
|
children,
|
|
137
129
|
$id: folder.file.path,
|
|
138
130
|
$ref: !ctx.options.noRef ? {
|
|
@@ -360,30 +352,33 @@ function dotParser(path) {
|
|
|
360
352
|
function indexPages(storages, getUrl, i18n) {
|
|
361
353
|
const defaultLanguage = i18n?.defaultLanguage ?? "";
|
|
362
354
|
const map = /* @__PURE__ */ new Map();
|
|
363
|
-
const
|
|
355
|
+
const fileMapped = /* @__PURE__ */ new WeakMap();
|
|
364
356
|
for (const item of storages[defaultLanguage].list()) {
|
|
365
|
-
if (item.format === "meta")
|
|
366
|
-
|
|
357
|
+
if (item.format === "meta") {
|
|
358
|
+
fileMapped.set(item, fileToMeta(item));
|
|
359
|
+
}
|
|
367
360
|
if (item.format === "page") {
|
|
368
361
|
const page = fileToPage(item, getUrl, defaultLanguage);
|
|
369
|
-
|
|
362
|
+
fileMapped.set(item, page);
|
|
370
363
|
map.set(`${defaultLanguage}.${page.slugs.join("/")}`, page);
|
|
371
364
|
if (!i18n) continue;
|
|
372
365
|
const path = joinPath(item.file.dirname, item.file.name);
|
|
373
366
|
for (const lang of i18n.languages) {
|
|
374
367
|
if (lang === defaultLanguage) continue;
|
|
375
|
-
const
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
368
|
+
const localizedItem = storages[lang].read(path, "page");
|
|
369
|
+
const localizedPage = fileToPage(localizedItem ?? item, getUrl, lang);
|
|
370
|
+
if (localizedItem) {
|
|
371
|
+
fileMapped.set(localizedItem, localizedPage);
|
|
372
|
+
}
|
|
380
373
|
map.set(`${lang}.${localizedPage.slugs.join("/")}`, localizedPage);
|
|
381
374
|
}
|
|
382
375
|
}
|
|
383
376
|
}
|
|
384
377
|
return {
|
|
385
378
|
pages: map,
|
|
386
|
-
|
|
379
|
+
getResultFromFile(file) {
|
|
380
|
+
return fileMapped.get(file);
|
|
381
|
+
}
|
|
387
382
|
};
|
|
388
383
|
}
|
|
389
384
|
function createGetUrl(baseUrl, i18n) {
|
|
@@ -500,9 +495,17 @@ function createOutput(options) {
|
|
|
500
495
|
getPage(slugs = [], language = options.i18n?.defaultLanguage ?? "") {
|
|
501
496
|
return walker.pages.get(`${language}.${slugs.join("/")}`);
|
|
502
497
|
},
|
|
503
|
-
getNodeMeta(node) {
|
|
504
|
-
|
|
505
|
-
|
|
498
|
+
getNodeMeta(node, language = options.i18n?.defaultLanguage ?? "") {
|
|
499
|
+
const ref = node.$ref?.metaFile;
|
|
500
|
+
if (!ref) return;
|
|
501
|
+
const file = storages[language].list().find((v) => v.format === "meta" && v.file.path === ref);
|
|
502
|
+
if (file) return walker.getResultFromFile(file);
|
|
503
|
+
},
|
|
504
|
+
getNodePage(node, language = options.i18n?.defaultLanguage ?? "") {
|
|
505
|
+
const ref = node.$ref?.file;
|
|
506
|
+
if (!ref) return;
|
|
507
|
+
const file = storages[language].list().find((v) => v.format === "page" && v.file.path === ref);
|
|
508
|
+
if (file) return walker.getResultFromFile(file);
|
|
506
509
|
},
|
|
507
510
|
getPageTree(locale) {
|
|
508
511
|
if (options.i18n) {
|
|
@@ -510,11 +513,6 @@ function createOutput(options) {
|
|
|
510
513
|
}
|
|
511
514
|
return this.pageTree;
|
|
512
515
|
},
|
|
513
|
-
getNodePage(node) {
|
|
514
|
-
const ref = node.$ref?.file ?? node.$id;
|
|
515
|
-
if (!ref) return;
|
|
516
|
-
return walker.pathToFile.get(ref);
|
|
517
|
-
},
|
|
518
516
|
// @ts-expect-error -- ignore this
|
|
519
517
|
generateParams(slug, lang) {
|
|
520
518
|
if (options.i18n) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-core",
|
|
3
|
-
"version": "15.2.
|
|
3
|
+
"version": "15.2.6",
|
|
4
4
|
"description": "The library for building a documentation website in Next.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
"@algolia/client-search": "4.24.0",
|
|
98
98
|
"@mdx-js/mdx": "^3.1.0",
|
|
99
99
|
"@oramacloud/client": "^2.1.4",
|
|
100
|
-
"@tanstack/react-router": "^1.
|
|
100
|
+
"@tanstack/react-router": "^1.115.2",
|
|
101
101
|
"@types/estree-jsx": "^1.0.5",
|
|
102
102
|
"@types/hast": "^3.0.4",
|
|
103
103
|
"@types/mdast": "^4.0.3",
|