fumadocs-core 16.0.10 → 16.0.12
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 +1 -1
- package/dist/breadcrumb.js +3 -3
- package/dist/{builder-BynMF2Pa.d.ts → builder-DEvYXjy8.d.ts} +3 -6
- package/dist/{chunk-BBP7MIO4.js → chunk-K4WNLOVQ.js} +10 -27
- package/dist/{chunk-N2ZQXKIX.js → chunk-SH7BNTG7.js} +1 -1
- package/dist/{definitions-DQnHJeWn.d.ts → definitions-DbCug1P3.d.ts} +9 -7
- package/dist/dynamic-link.js +2 -2
- package/dist/framework/index.d.ts +1 -8
- package/dist/framework/index.js +1 -3
- package/dist/framework/next.js +1 -1
- package/dist/framework/react-router.js +1 -1
- package/dist/framework/tanstack.js +3 -8
- package/dist/framework/waku.js +1 -1
- package/dist/link.js +2 -2
- package/dist/page-tree/index.d.ts +2 -2
- package/dist/search/server.d.ts +2 -2
- package/dist/search/server.js +4 -4
- package/dist/source/index.d.ts +2 -2
- package/dist/source/index.js +214 -206
- package/dist/source/plugins/lucide-icons.d.ts +2 -2
- package/package.json +14 -14
package/dist/breadcrumb.d.ts
CHANGED
package/dist/breadcrumb.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as Root, I as Item, F as Folder, S as Separator } from './definitions-
|
|
1
|
+
import { R as Root, I as Item, F as Folder, S as Separator } from './definitions-DbCug1P3.js';
|
|
2
2
|
import { I18nConfig } from './i18n/index.js';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
4
|
|
|
@@ -249,10 +249,8 @@ interface PageFile<Data extends PageData = PageData> {
|
|
|
249
249
|
}
|
|
250
250
|
|
|
251
251
|
interface PageTreeBuilderContext<Page extends PageData = PageData, Meta extends MetaData = MetaData> {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
*/
|
|
255
|
-
resolveName: (name: string, format: 'meta' | 'page') => string;
|
|
252
|
+
rootId: string;
|
|
253
|
+
generateNodeId: () => string;
|
|
256
254
|
options: PageTreeOptions;
|
|
257
255
|
transformers: PageTreeTransformer<Page, Meta>[];
|
|
258
256
|
builder: PageTreeBuilder;
|
|
@@ -260,7 +258,6 @@ interface PageTreeBuilderContext<Page extends PageData = PageData, Meta extends
|
|
|
260
258
|
getUrl: UrlFn;
|
|
261
259
|
storages?: Record<string, ContentStorage<Page, Meta>>;
|
|
262
260
|
locale?: string;
|
|
263
|
-
visitedPaths: Set<string>;
|
|
264
261
|
}
|
|
265
262
|
interface PageTreeTransformer<Page extends PageData = PageData, Meta extends MetaData = MetaData> {
|
|
266
263
|
file?: (this: PageTreeBuilderContext<Page, Meta>, node: Item, filePath?: string) => Item;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// src/framework/index.tsx
|
|
2
|
-
import
|
|
2
|
+
import { createContext, use, useMemo } from "react";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
var notImplemented = () => {
|
|
5
5
|
throw new Error(
|
|
6
6
|
"You need to wrap your application inside `FrameworkProvider`."
|
|
7
7
|
);
|
|
8
8
|
};
|
|
9
|
-
var FrameworkContext = createContext(
|
|
9
|
+
var FrameworkContext = createContext({
|
|
10
10
|
useParams: notImplemented,
|
|
11
11
|
useRouter: notImplemented,
|
|
12
12
|
usePathname: notImplemented
|
|
@@ -19,7 +19,7 @@ function FrameworkProvider({
|
|
|
19
19
|
Image: Image2,
|
|
20
20
|
children
|
|
21
21
|
}) {
|
|
22
|
-
const framework =
|
|
22
|
+
const framework = useMemo(
|
|
23
23
|
() => ({
|
|
24
24
|
usePathname: usePathname2,
|
|
25
25
|
useRouter: useRouter2,
|
|
@@ -29,19 +29,19 @@ function FrameworkProvider({
|
|
|
29
29
|
}),
|
|
30
30
|
[Link2, usePathname2, useRouter2, useParams2, Image2]
|
|
31
31
|
);
|
|
32
|
-
return /* @__PURE__ */ jsx(FrameworkContext
|
|
32
|
+
return /* @__PURE__ */ jsx(FrameworkContext, { value: framework, children });
|
|
33
33
|
}
|
|
34
34
|
function usePathname() {
|
|
35
|
-
return
|
|
35
|
+
return use(FrameworkContext).usePathname();
|
|
36
36
|
}
|
|
37
37
|
function useRouter() {
|
|
38
|
-
return
|
|
38
|
+
return use(FrameworkContext).useRouter();
|
|
39
39
|
}
|
|
40
40
|
function useParams() {
|
|
41
|
-
return
|
|
41
|
+
return use(FrameworkContext).useParams();
|
|
42
42
|
}
|
|
43
43
|
function Image(props) {
|
|
44
|
-
const { Image: Image2 } =
|
|
44
|
+
const { Image: Image2 } = use(FrameworkContext);
|
|
45
45
|
if (!Image2) {
|
|
46
46
|
const { src, alt, priority, ...rest } = props;
|
|
47
47
|
return /* @__PURE__ */ jsx(
|
|
@@ -57,29 +57,13 @@ function Image(props) {
|
|
|
57
57
|
return /* @__PURE__ */ jsx(Image2, { ...props });
|
|
58
58
|
}
|
|
59
59
|
function Link(props) {
|
|
60
|
-
const { Link: Link2 } =
|
|
60
|
+
const { Link: Link2 } = use(FrameworkContext);
|
|
61
61
|
if (!Link2) {
|
|
62
62
|
const { href, prefetch: _, ...rest } = props;
|
|
63
63
|
return /* @__PURE__ */ jsx("a", { href, ...rest });
|
|
64
64
|
}
|
|
65
65
|
return /* @__PURE__ */ jsx(Link2, { ...props });
|
|
66
66
|
}
|
|
67
|
-
function createContext(name, v) {
|
|
68
|
-
const Context = React.createContext(v);
|
|
69
|
-
return {
|
|
70
|
-
Provider: (props) => {
|
|
71
|
-
return /* @__PURE__ */ jsx(Context.Provider, { value: props.value, children: props.children });
|
|
72
|
-
},
|
|
73
|
-
use: (errorMessage) => {
|
|
74
|
-
const value = React.useContext(Context);
|
|
75
|
-
if (!value)
|
|
76
|
-
throw new Error(
|
|
77
|
-
errorMessage ?? `Provider of ${name} is required but missing.`
|
|
78
|
-
);
|
|
79
|
-
return value;
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
67
|
|
|
84
68
|
export {
|
|
85
69
|
FrameworkProvider,
|
|
@@ -87,6 +71,5 @@ export {
|
|
|
87
71
|
useRouter,
|
|
88
72
|
useParams,
|
|
89
73
|
Image,
|
|
90
|
-
Link
|
|
91
|
-
createContext
|
|
74
|
+
Link
|
|
92
75
|
};
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
|
|
3
|
-
interface
|
|
3
|
+
interface INode {
|
|
4
|
+
/**
|
|
5
|
+
* ID for the node, unique in all page trees (even across different locales)
|
|
6
|
+
*/
|
|
4
7
|
$id?: string;
|
|
8
|
+
}
|
|
9
|
+
interface Root extends INode {
|
|
5
10
|
name: ReactNode;
|
|
6
11
|
children: Node[];
|
|
7
12
|
/**
|
|
@@ -10,8 +15,7 @@ interface Root {
|
|
|
10
15
|
fallback?: Root;
|
|
11
16
|
}
|
|
12
17
|
type Node = Item | Separator | Folder;
|
|
13
|
-
interface Item {
|
|
14
|
-
$id?: string;
|
|
18
|
+
interface Item extends INode {
|
|
15
19
|
/**
|
|
16
20
|
* @internal
|
|
17
21
|
*/
|
|
@@ -30,14 +34,12 @@ interface Item {
|
|
|
30
34
|
description?: ReactNode;
|
|
31
35
|
icon?: ReactNode;
|
|
32
36
|
}
|
|
33
|
-
interface Separator {
|
|
34
|
-
$id?: string;
|
|
37
|
+
interface Separator extends INode {
|
|
35
38
|
type: 'separator';
|
|
36
39
|
name?: ReactNode;
|
|
37
40
|
icon?: ReactNode;
|
|
38
41
|
}
|
|
39
|
-
interface Folder {
|
|
40
|
-
$id?: string;
|
|
42
|
+
interface Folder extends INode {
|
|
41
43
|
/**
|
|
42
44
|
* @internal
|
|
43
45
|
*/
|
package/dist/dynamic-link.js
CHANGED
|
@@ -37,12 +37,5 @@ declare function useRouter(): Router;
|
|
|
37
37
|
declare function useParams(): Record<string, string | string[]>;
|
|
38
38
|
declare function Image(props: ImageProps): react_jsx_runtime.JSX.Element;
|
|
39
39
|
declare function Link(props: LinkProps): react_jsx_runtime.JSX.Element;
|
|
40
|
-
declare function createContext<T>(name: string, v?: T): {
|
|
41
|
-
Provider: (props: {
|
|
42
|
-
value: T;
|
|
43
|
-
children: ReactNode;
|
|
44
|
-
}) => react_jsx_runtime.JSX.Element;
|
|
45
|
-
use: (errorMessage?: string) => Exclude<T, undefined | null>;
|
|
46
|
-
};
|
|
47
40
|
|
|
48
|
-
export { type Framework, FrameworkProvider, Image, type ImageProps, Link, type Router,
|
|
41
|
+
export { type Framework, FrameworkProvider, Image, type ImageProps, Link, type Router, useParams, usePathname, useRouter };
|
package/dist/framework/index.js
CHANGED
|
@@ -3,17 +3,15 @@ import {
|
|
|
3
3
|
FrameworkProvider,
|
|
4
4
|
Image,
|
|
5
5
|
Link,
|
|
6
|
-
createContext,
|
|
7
6
|
useParams,
|
|
8
7
|
usePathname,
|
|
9
8
|
useRouter
|
|
10
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-K4WNLOVQ.js";
|
|
11
10
|
import "../chunk-U67V476Y.js";
|
|
12
11
|
export {
|
|
13
12
|
FrameworkProvider,
|
|
14
13
|
Image,
|
|
15
14
|
Link,
|
|
16
|
-
createContext,
|
|
17
15
|
useParams,
|
|
18
16
|
usePathname,
|
|
19
17
|
useRouter
|
package/dist/framework/next.js
CHANGED
|
@@ -1,23 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
FrameworkProvider
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-K4WNLOVQ.js";
|
|
4
4
|
import "../chunk-U67V476Y.js";
|
|
5
5
|
|
|
6
6
|
// src/framework/tanstack.tsx
|
|
7
7
|
import { useMemo } from "react";
|
|
8
|
-
import {
|
|
9
|
-
useParams,
|
|
10
|
-
Link,
|
|
11
|
-
useRouter,
|
|
12
|
-
useLocation
|
|
13
|
-
} from "@tanstack/react-router";
|
|
8
|
+
import { useParams, Link, useRouter, useMatch } from "@tanstack/react-router";
|
|
14
9
|
import { jsx } from "react/jsx-runtime";
|
|
15
10
|
var framework = {
|
|
16
11
|
Link({ href, prefetch, ...props }) {
|
|
17
12
|
return /* @__PURE__ */ jsx(Link, { to: href, preload: prefetch ? "intent" : false, ...props, children: props.children });
|
|
18
13
|
},
|
|
19
14
|
usePathname() {
|
|
20
|
-
return
|
|
15
|
+
return useMatch({ strict: false, select: (s) => s.pathname });
|
|
21
16
|
},
|
|
22
17
|
useRouter() {
|
|
23
18
|
const router = useRouter();
|
package/dist/framework/waku.js
CHANGED
package/dist/link.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { N as Node, I as Item, R as Root, F as Folder } from '../definitions-
|
|
2
|
-
export { S as Separator } from '../definitions-
|
|
1
|
+
import { N as Node, I as Item, R as Root, F as Folder } from '../definitions-DbCug1P3.js';
|
|
2
|
+
export { S as Separator } from '../definitions-DbCug1P3.js';
|
|
3
3
|
import 'react';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/search/server.d.ts
CHANGED
|
@@ -3,12 +3,12 @@ import { StructuredData } from '../mdx-plugins/remark-structure.js';
|
|
|
3
3
|
import { SortedResult } from './index.js';
|
|
4
4
|
export { HighlightedText, ReactSortedResult, createContentHighlighter } from './index.js';
|
|
5
5
|
import { I18nConfig } from '../i18n/index.js';
|
|
6
|
-
import { k as LoaderOutput, f as LoaderConfig, I as InferPageType } from '../builder-
|
|
6
|
+
import { k as LoaderOutput, f as LoaderConfig, I as InferPageType } from '../builder-DEvYXjy8.js';
|
|
7
7
|
import 'mdast';
|
|
8
8
|
import 'unified';
|
|
9
9
|
import 'mdast-util-mdx-jsx';
|
|
10
10
|
import 'react';
|
|
11
|
-
import '../definitions-
|
|
11
|
+
import '../definitions-DbCug1P3.js';
|
|
12
12
|
|
|
13
13
|
type SimpleDocument = TypedDocument<Orama<typeof simpleSchema>>;
|
|
14
14
|
declare const simpleSchema: {
|
package/dist/search/server.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
basename,
|
|
3
|
-
extname
|
|
4
|
-
} from "../chunk-XZSI7AHE.js";
|
|
5
1
|
import {
|
|
6
2
|
searchAdvanced,
|
|
7
3
|
searchSimple
|
|
@@ -10,6 +6,10 @@ import "../chunk-ZMWYLUDP.js";
|
|
|
10
6
|
import {
|
|
11
7
|
createContentHighlighter
|
|
12
8
|
} from "../chunk-OTD7MV33.js";
|
|
9
|
+
import {
|
|
10
|
+
basename,
|
|
11
|
+
extname
|
|
12
|
+
} from "../chunk-XZSI7AHE.js";
|
|
13
13
|
import {
|
|
14
14
|
findPath
|
|
15
15
|
} from "../chunk-IZPLHEX4.js";
|
package/dist/source/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { C as ContentStorage, F as FileSystem, t as InferMetaType, I as InferPageType, f as LoaderConfig, g as LoaderOptions, k as LoaderOutput, L as LoaderPlugin, j as Meta, p as MetaData, M as MetaFile, i as Page, q as PageData, e as PageFile, a as PageTreeBuilder, b as PageTreeBuilderContext, d as PageTreeOptions, P as PageTreeTransformer, R as ResolvedLoaderConfig, h as Source, S as SourceConfig, U as UrlFn, s as VirtualFile, r as VirtualMeta, V as VirtualPage, _ as _ConfigUnion_, u as buildPlugins, l as createGetUrl, c as createPageTreeBuilder, m as loader, o as map, n as multiple } from '../builder-
|
|
2
|
-
import '../definitions-
|
|
1
|
+
export { C as ContentStorage, F as FileSystem, t as InferMetaType, I as InferPageType, f as LoaderConfig, g as LoaderOptions, k as LoaderOutput, L as LoaderPlugin, j as Meta, p as MetaData, M as MetaFile, i as Page, q as PageData, e as PageFile, a as PageTreeBuilder, b as PageTreeBuilderContext, d as PageTreeOptions, P as PageTreeTransformer, R as ResolvedLoaderConfig, h as Source, S as SourceConfig, U as UrlFn, s as VirtualFile, r as VirtualMeta, V as VirtualPage, _ as _ConfigUnion_, u as buildPlugins, l as createGetUrl, c as createPageTreeBuilder, m as loader, o as map, n as multiple } from '../builder-DEvYXjy8.js';
|
|
2
|
+
import '../definitions-DbCug1P3.js';
|
|
3
3
|
import 'react';
|
|
4
4
|
import '../i18n/index.js';
|
|
5
5
|
|
package/dist/source/index.js
CHANGED
|
@@ -54,217 +54,31 @@ var rest = "...";
|
|
|
54
54
|
var restReversed = "z...a";
|
|
55
55
|
var extractPrefix = "...";
|
|
56
56
|
var excludePrefix = "!";
|
|
57
|
-
function buildAll(paths, ctx, reversed = false) {
|
|
58
|
-
const items = [];
|
|
59
|
-
const folders = [];
|
|
60
|
-
const sortedPaths = paths.sort(
|
|
61
|
-
(a, b) => a.localeCompare(b) * (reversed ? -1 : 1)
|
|
62
|
-
);
|
|
63
|
-
for (const path of sortedPaths) {
|
|
64
|
-
ctx.visitedPaths.add(path);
|
|
65
|
-
const fileNode = buildFileNode(path, ctx);
|
|
66
|
-
if (fileNode) {
|
|
67
|
-
if (basename(path, extname(path)) === "index") items.unshift(fileNode);
|
|
68
|
-
else items.push(fileNode);
|
|
69
|
-
continue;
|
|
70
|
-
}
|
|
71
|
-
const dirNode = buildFolderNode(path, false, ctx);
|
|
72
|
-
if (dirNode) folders.push(dirNode);
|
|
73
|
-
}
|
|
74
|
-
return [...items, ...folders];
|
|
75
|
-
}
|
|
76
|
-
function resolveFolderItem(folderPath, item, ctx, idx) {
|
|
77
|
-
if (item === rest || item === restReversed) return item;
|
|
78
|
-
const { resolveName } = ctx;
|
|
79
|
-
let match = separator.exec(item);
|
|
80
|
-
if (match?.groups) {
|
|
81
|
-
let node = {
|
|
82
|
-
$id: `${folderPath}#${idx}`,
|
|
83
|
-
type: "separator",
|
|
84
|
-
icon: match.groups.icon,
|
|
85
|
-
name: match.groups.name
|
|
86
|
-
};
|
|
87
|
-
for (const transformer of ctx.transformers) {
|
|
88
|
-
if (!transformer.separator) continue;
|
|
89
|
-
node = transformer.separator.call(ctx, node);
|
|
90
|
-
}
|
|
91
|
-
return [node];
|
|
92
|
-
}
|
|
93
|
-
match = link.exec(item);
|
|
94
|
-
if (match?.groups) {
|
|
95
|
-
const { icon, url, name, external } = match.groups;
|
|
96
|
-
let node = {
|
|
97
|
-
type: "page",
|
|
98
|
-
icon,
|
|
99
|
-
name,
|
|
100
|
-
url,
|
|
101
|
-
external: external ? true : void 0
|
|
102
|
-
};
|
|
103
|
-
for (const transformer of ctx.transformers) {
|
|
104
|
-
if (!transformer.file) continue;
|
|
105
|
-
node = transformer.file.call(ctx, node);
|
|
106
|
-
}
|
|
107
|
-
return [node];
|
|
108
|
-
}
|
|
109
|
-
const isExcept = item.startsWith(excludePrefix);
|
|
110
|
-
const isExtract = !isExcept && item.startsWith(extractPrefix);
|
|
111
|
-
let filename = item;
|
|
112
|
-
if (isExcept) {
|
|
113
|
-
filename = item.slice(excludePrefix.length);
|
|
114
|
-
} else if (isExtract) {
|
|
115
|
-
filename = item.slice(extractPrefix.length);
|
|
116
|
-
}
|
|
117
|
-
const path = resolveName(joinPath(folderPath, filename), "page");
|
|
118
|
-
ctx.visitedPaths.add(path);
|
|
119
|
-
if (isExcept) return [];
|
|
120
|
-
const dirNode = buildFolderNode(path, false, ctx);
|
|
121
|
-
if (dirNode) {
|
|
122
|
-
return isExtract ? dirNode.children : [dirNode];
|
|
123
|
-
}
|
|
124
|
-
const fileNode = buildFileNode(path, ctx);
|
|
125
|
-
return fileNode ? [fileNode] : [];
|
|
126
|
-
}
|
|
127
|
-
function buildFolderNode(folderPath, isGlobalRoot, ctx) {
|
|
128
|
-
const { storage, options, resolveName, transformers } = ctx;
|
|
129
|
-
const files = storage.readDir(folderPath);
|
|
130
|
-
if (!files) return;
|
|
131
|
-
const metaPath = resolveName(joinPath(folderPath, "meta"), "meta");
|
|
132
|
-
const indexPath = resolveName(joinPath(folderPath, "index"), "page");
|
|
133
|
-
let meta = storage.read(metaPath);
|
|
134
|
-
if (meta?.format !== "meta") {
|
|
135
|
-
meta = void 0;
|
|
136
|
-
}
|
|
137
|
-
const isRoot = meta?.data.root ?? isGlobalRoot;
|
|
138
|
-
let index;
|
|
139
|
-
let children;
|
|
140
|
-
function setIndexIfUnused() {
|
|
141
|
-
if (isRoot || ctx.visitedPaths.has(indexPath)) return;
|
|
142
|
-
ctx.visitedPaths.add(indexPath);
|
|
143
|
-
index = buildFileNode(indexPath, ctx);
|
|
144
|
-
}
|
|
145
|
-
if (meta && meta.data.pages) {
|
|
146
|
-
const resolved = meta.data.pages.flatMap((item, i) => resolveFolderItem(folderPath, item, ctx, i));
|
|
147
|
-
setIndexIfUnused();
|
|
148
|
-
for (let i = 0; i < resolved.length; i++) {
|
|
149
|
-
const item = resolved[i];
|
|
150
|
-
if (item !== rest && item !== restReversed) continue;
|
|
151
|
-
const items = buildAll(
|
|
152
|
-
files.filter((file) => !ctx.visitedPaths.has(file)),
|
|
153
|
-
ctx,
|
|
154
|
-
item === restReversed
|
|
155
|
-
);
|
|
156
|
-
resolved.splice(i, 1, ...items);
|
|
157
|
-
break;
|
|
158
|
-
}
|
|
159
|
-
children = resolved;
|
|
160
|
-
} else {
|
|
161
|
-
setIndexIfUnused();
|
|
162
|
-
children = buildAll(
|
|
163
|
-
files.filter((file) => !ctx.visitedPaths.has(file)),
|
|
164
|
-
ctx
|
|
165
|
-
);
|
|
166
|
-
}
|
|
167
|
-
let name = meta?.data.title ?? index?.name;
|
|
168
|
-
if (!name) {
|
|
169
|
-
const folderName = basename(folderPath);
|
|
170
|
-
name = pathToName(group.exec(folderName)?.[1] ?? folderName);
|
|
171
|
-
}
|
|
172
|
-
let node = {
|
|
173
|
-
type: "folder",
|
|
174
|
-
name,
|
|
175
|
-
icon: meta?.data.icon ?? index?.icon,
|
|
176
|
-
root: meta?.data.root,
|
|
177
|
-
defaultOpen: meta?.data.defaultOpen,
|
|
178
|
-
description: meta?.data.description,
|
|
179
|
-
index,
|
|
180
|
-
children,
|
|
181
|
-
$id: folderPath,
|
|
182
|
-
$ref: !options.noRef && meta ? {
|
|
183
|
-
metaFile: metaPath
|
|
184
|
-
} : void 0
|
|
185
|
-
};
|
|
186
|
-
for (const transformer of transformers) {
|
|
187
|
-
if (!transformer.folder) continue;
|
|
188
|
-
node = transformer.folder.call(ctx, node, folderPath, metaPath);
|
|
189
|
-
}
|
|
190
|
-
return node;
|
|
191
|
-
}
|
|
192
|
-
function buildFileNode(path, ctx) {
|
|
193
|
-
const { options, getUrl, storage, locale, transformers } = ctx;
|
|
194
|
-
const page = storage.read(path);
|
|
195
|
-
if (page?.format !== "page") return;
|
|
196
|
-
const { title, description, icon } = page.data;
|
|
197
|
-
let item = {
|
|
198
|
-
$id: path,
|
|
199
|
-
type: "page",
|
|
200
|
-
name: title ?? pathToName(basename(path, extname(path))),
|
|
201
|
-
description,
|
|
202
|
-
icon,
|
|
203
|
-
url: getUrl(page.slugs, locale),
|
|
204
|
-
$ref: !options.noRef ? {
|
|
205
|
-
file: path
|
|
206
|
-
} : void 0
|
|
207
|
-
};
|
|
208
|
-
for (const transformer of transformers) {
|
|
209
|
-
if (!transformer.file) continue;
|
|
210
|
-
item = transformer.file.call(ctx, item, path);
|
|
211
|
-
}
|
|
212
|
-
return item;
|
|
213
|
-
}
|
|
214
|
-
function build(id, ctx) {
|
|
215
|
-
const folder = buildFolderNode("", true, ctx);
|
|
216
|
-
let root = {
|
|
217
|
-
$id: id,
|
|
218
|
-
name: folder.name || "Docs",
|
|
219
|
-
children: folder.children
|
|
220
|
-
};
|
|
221
|
-
for (const transformer of ctx.transformers) {
|
|
222
|
-
if (!transformer.root) continue;
|
|
223
|
-
root = transformer.root.call(ctx, root);
|
|
224
|
-
}
|
|
225
|
-
return root;
|
|
226
|
-
}
|
|
227
57
|
function createPageTreeBuilder(getUrl, plugins) {
|
|
228
|
-
function getTransformers({
|
|
229
|
-
generateFallback = true,
|
|
230
|
-
...options
|
|
231
|
-
}) {
|
|
232
|
-
const transformers = [];
|
|
233
|
-
if (options.transformers) {
|
|
234
|
-
transformers.push(...options.transformers);
|
|
235
|
-
}
|
|
236
|
-
for (const plugin of plugins ?? []) {
|
|
237
|
-
if (plugin.transformPageTree) transformers.push(plugin.transformPageTree);
|
|
238
|
-
}
|
|
239
|
-
if (generateFallback) {
|
|
240
|
-
transformers.push(transformerFallback());
|
|
241
|
-
}
|
|
242
|
-
return transformers;
|
|
243
|
-
}
|
|
244
|
-
function createFlattenPathResolver(storage) {
|
|
245
|
-
const map2 = /* @__PURE__ */ new Map();
|
|
246
|
-
const files = storage.getFiles();
|
|
247
|
-
for (const file of files) {
|
|
248
|
-
const content = storage.read(file);
|
|
249
|
-
const flattenPath = file.substring(0, file.length - extname(file).length);
|
|
250
|
-
map2.set(flattenPath + "." + content.format, file);
|
|
251
|
-
}
|
|
252
|
-
return (name, format) => {
|
|
253
|
-
return map2.get(name + "." + format);
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
58
|
return {
|
|
257
59
|
build(storage, options) {
|
|
258
60
|
const key = "";
|
|
259
61
|
return this.buildI18n({ [key]: storage }, options)[key];
|
|
260
62
|
},
|
|
261
63
|
buildI18n(storages, options = {}) {
|
|
262
|
-
|
|
64
|
+
let nextId = 0;
|
|
263
65
|
const out = {};
|
|
66
|
+
const transformers = [];
|
|
67
|
+
if (options.transformers) {
|
|
68
|
+
transformers.push(...options.transformers);
|
|
69
|
+
}
|
|
70
|
+
for (const plugin of plugins ?? []) {
|
|
71
|
+
if (plugin.transformPageTree)
|
|
72
|
+
transformers.push(plugin.transformPageTree);
|
|
73
|
+
}
|
|
74
|
+
if (options.generateFallback ?? true) {
|
|
75
|
+
transformers.push(transformerFallback());
|
|
76
|
+
}
|
|
264
77
|
for (const [locale, storage] of Object.entries(storages)) {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
out[locale] =
|
|
78
|
+
let rootId = locale.length === 0 ? "root" : locale;
|
|
79
|
+
if (options.id) rootId = `${options.id}-${rootId}`;
|
|
80
|
+
out[locale] = createPageTreeBuilderUtils({
|
|
81
|
+
rootId,
|
|
268
82
|
transformers,
|
|
269
83
|
builder: this,
|
|
270
84
|
options,
|
|
@@ -272,16 +86,210 @@ function createPageTreeBuilder(getUrl, plugins) {
|
|
|
272
86
|
locale,
|
|
273
87
|
storage,
|
|
274
88
|
storages,
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
return resolve(name, format) ?? name;
|
|
89
|
+
generateNodeId() {
|
|
90
|
+
return "_" + nextId++;
|
|
278
91
|
}
|
|
279
|
-
});
|
|
92
|
+
}).root();
|
|
280
93
|
}
|
|
281
94
|
return out;
|
|
282
95
|
}
|
|
283
96
|
};
|
|
284
97
|
}
|
|
98
|
+
function createFlattenPathResolver(storage) {
|
|
99
|
+
const map2 = /* @__PURE__ */ new Map();
|
|
100
|
+
const files = storage.getFiles();
|
|
101
|
+
for (const file of files) {
|
|
102
|
+
const content = storage.read(file);
|
|
103
|
+
const flattenPath = file.substring(0, file.length - extname(file).length);
|
|
104
|
+
map2.set(flattenPath + "." + content.format, file);
|
|
105
|
+
}
|
|
106
|
+
return (name, format) => {
|
|
107
|
+
return map2.get(name + "." + format) ?? name;
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
function createPageTreeBuilderUtils(ctx) {
|
|
111
|
+
const resolveFlattenPath = createFlattenPathResolver(ctx.storage);
|
|
112
|
+
const visitedPaths = /* @__PURE__ */ new Set();
|
|
113
|
+
function nextNodeId(localId = ctx.generateNodeId()) {
|
|
114
|
+
return `${ctx.rootId}:${localId}`;
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
buildPaths(paths, reversed = false) {
|
|
118
|
+
const items = [];
|
|
119
|
+
const folders = [];
|
|
120
|
+
const sortedPaths = paths.sort(
|
|
121
|
+
(a, b) => a.localeCompare(b) * (reversed ? -1 : 1)
|
|
122
|
+
);
|
|
123
|
+
for (const path of sortedPaths) {
|
|
124
|
+
const fileNode = this.file(path);
|
|
125
|
+
if (fileNode) {
|
|
126
|
+
if (basename(path, extname(path)) === "index")
|
|
127
|
+
items.unshift(fileNode);
|
|
128
|
+
else items.push(fileNode);
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
const dirNode = this.folder(path, false);
|
|
132
|
+
if (dirNode) folders.push(dirNode);
|
|
133
|
+
}
|
|
134
|
+
return [...items, ...folders];
|
|
135
|
+
},
|
|
136
|
+
resolveFolderItem(folderPath, item) {
|
|
137
|
+
if (item === rest || item === restReversed) return item;
|
|
138
|
+
let match = separator.exec(item);
|
|
139
|
+
if (match?.groups) {
|
|
140
|
+
let node = {
|
|
141
|
+
$id: nextNodeId(),
|
|
142
|
+
type: "separator",
|
|
143
|
+
icon: match.groups.icon,
|
|
144
|
+
name: match.groups.name
|
|
145
|
+
};
|
|
146
|
+
for (const transformer of ctx.transformers) {
|
|
147
|
+
if (!transformer.separator) continue;
|
|
148
|
+
node = transformer.separator.call(ctx, node);
|
|
149
|
+
}
|
|
150
|
+
return [node];
|
|
151
|
+
}
|
|
152
|
+
match = link.exec(item);
|
|
153
|
+
if (match?.groups) {
|
|
154
|
+
const { icon, url, name, external } = match.groups;
|
|
155
|
+
let node = {
|
|
156
|
+
$id: nextNodeId(),
|
|
157
|
+
type: "page",
|
|
158
|
+
icon,
|
|
159
|
+
name,
|
|
160
|
+
url,
|
|
161
|
+
external: external ? true : void 0
|
|
162
|
+
};
|
|
163
|
+
for (const transformer of ctx.transformers) {
|
|
164
|
+
if (!transformer.file) continue;
|
|
165
|
+
node = transformer.file.call(ctx, node);
|
|
166
|
+
}
|
|
167
|
+
return [node];
|
|
168
|
+
}
|
|
169
|
+
const isExcept = item.startsWith(excludePrefix);
|
|
170
|
+
const isExtract = !isExcept && item.startsWith(extractPrefix);
|
|
171
|
+
let filename = item;
|
|
172
|
+
if (isExcept) {
|
|
173
|
+
filename = item.slice(excludePrefix.length);
|
|
174
|
+
} else if (isExtract) {
|
|
175
|
+
filename = item.slice(extractPrefix.length);
|
|
176
|
+
}
|
|
177
|
+
const path = resolveFlattenPath(joinPath(folderPath, filename), "page");
|
|
178
|
+
if (isExcept) {
|
|
179
|
+
visitedPaths.add(path);
|
|
180
|
+
return [];
|
|
181
|
+
}
|
|
182
|
+
const dirNode = this.folder(path, false);
|
|
183
|
+
if (dirNode) {
|
|
184
|
+
return isExtract ? dirNode.children : [dirNode];
|
|
185
|
+
}
|
|
186
|
+
const fileNode = this.file(path);
|
|
187
|
+
return fileNode ? [fileNode] : [];
|
|
188
|
+
},
|
|
189
|
+
folder(folderPath, isGlobalRoot) {
|
|
190
|
+
const { storage, options, transformers } = ctx;
|
|
191
|
+
const files = storage.readDir(folderPath);
|
|
192
|
+
if (!files) return;
|
|
193
|
+
const metaPath = resolveFlattenPath(joinPath(folderPath, "meta"), "meta");
|
|
194
|
+
const indexPath = resolveFlattenPath(
|
|
195
|
+
joinPath(folderPath, "index"),
|
|
196
|
+
"page"
|
|
197
|
+
);
|
|
198
|
+
let meta = storage.read(metaPath);
|
|
199
|
+
if (meta?.format !== "meta") {
|
|
200
|
+
meta = void 0;
|
|
201
|
+
}
|
|
202
|
+
const isRoot = meta?.data.root ?? isGlobalRoot;
|
|
203
|
+
let index;
|
|
204
|
+
let children;
|
|
205
|
+
if (meta && meta.data.pages) {
|
|
206
|
+
const resolved = meta.data.pages.flatMap((item) => this.resolveFolderItem(folderPath, item));
|
|
207
|
+
if (!isRoot && !visitedPaths.has(indexPath)) {
|
|
208
|
+
index = this.file(indexPath);
|
|
209
|
+
}
|
|
210
|
+
for (let i = 0; i < resolved.length; i++) {
|
|
211
|
+
const item = resolved[i];
|
|
212
|
+
if (item !== rest && item !== restReversed) continue;
|
|
213
|
+
const items = this.buildPaths(
|
|
214
|
+
files.filter((file) => !visitedPaths.has(file)),
|
|
215
|
+
item === restReversed
|
|
216
|
+
);
|
|
217
|
+
resolved.splice(i, 1, ...items);
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
220
|
+
children = resolved;
|
|
221
|
+
} else {
|
|
222
|
+
if (!isRoot && !visitedPaths.has(indexPath)) {
|
|
223
|
+
index = this.file(indexPath);
|
|
224
|
+
}
|
|
225
|
+
children = this.buildPaths(
|
|
226
|
+
files.filter((file) => !visitedPaths.has(file))
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
let name = meta?.data.title ?? index?.name;
|
|
230
|
+
if (!name) {
|
|
231
|
+
const folderName = basename(folderPath);
|
|
232
|
+
name = pathToName(group.exec(folderName)?.[1] ?? folderName);
|
|
233
|
+
}
|
|
234
|
+
let node = {
|
|
235
|
+
type: "folder",
|
|
236
|
+
name,
|
|
237
|
+
icon: meta?.data.icon ?? index?.icon,
|
|
238
|
+
root: meta?.data.root,
|
|
239
|
+
defaultOpen: meta?.data.defaultOpen,
|
|
240
|
+
description: meta?.data.description,
|
|
241
|
+
index,
|
|
242
|
+
children,
|
|
243
|
+
$id: nextNodeId(folderPath),
|
|
244
|
+
$ref: !options.noRef && meta ? {
|
|
245
|
+
metaFile: metaPath
|
|
246
|
+
} : void 0
|
|
247
|
+
};
|
|
248
|
+
visitedPaths.add(folderPath);
|
|
249
|
+
for (const transformer of transformers) {
|
|
250
|
+
if (!transformer.folder) continue;
|
|
251
|
+
node = transformer.folder.call(ctx, node, folderPath, metaPath);
|
|
252
|
+
}
|
|
253
|
+
return node;
|
|
254
|
+
},
|
|
255
|
+
file(path) {
|
|
256
|
+
const { options, getUrl, storage, locale, transformers } = ctx;
|
|
257
|
+
const page = storage.read(path);
|
|
258
|
+
if (page?.format !== "page") return;
|
|
259
|
+
const { title, description, icon } = page.data;
|
|
260
|
+
let item = {
|
|
261
|
+
$id: nextNodeId(path),
|
|
262
|
+
type: "page",
|
|
263
|
+
name: title ?? pathToName(basename(path, extname(path))),
|
|
264
|
+
description,
|
|
265
|
+
icon,
|
|
266
|
+
url: getUrl(page.slugs, locale),
|
|
267
|
+
$ref: !options.noRef ? {
|
|
268
|
+
file: path
|
|
269
|
+
} : void 0
|
|
270
|
+
};
|
|
271
|
+
visitedPaths.add(path);
|
|
272
|
+
for (const transformer of transformers) {
|
|
273
|
+
if (!transformer.file) continue;
|
|
274
|
+
item = transformer.file.call(ctx, item, path);
|
|
275
|
+
}
|
|
276
|
+
return item;
|
|
277
|
+
},
|
|
278
|
+
root() {
|
|
279
|
+
const folder = this.folder("", true);
|
|
280
|
+
let root = {
|
|
281
|
+
$id: ctx.rootId,
|
|
282
|
+
name: folder.name || "Docs",
|
|
283
|
+
children: folder.children
|
|
284
|
+
};
|
|
285
|
+
for (const transformer of ctx.transformers) {
|
|
286
|
+
if (!transformer.root) continue;
|
|
287
|
+
root = transformer.root.call(ctx, root);
|
|
288
|
+
}
|
|
289
|
+
return root;
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
}
|
|
285
293
|
function pathToName(name) {
|
|
286
294
|
const result = [];
|
|
287
295
|
for (const c of name) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { L as LoaderPlugin } from '../../builder-
|
|
1
|
+
import { L as LoaderPlugin } from '../../builder-DEvYXjy8.js';
|
|
2
2
|
import { icons } from 'lucide-react';
|
|
3
|
-
import '../../definitions-
|
|
3
|
+
import '../../definitions-DbCug1P3.js';
|
|
4
4
|
import 'react';
|
|
5
5
|
import '../../i18n/index.js';
|
|
6
6
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-core",
|
|
3
|
-
"version": "16.0.
|
|
3
|
+
"version": "16.0.12",
|
|
4
4
|
"description": "The library for building a documentation website in any React.js framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Fumadocs",
|
|
@@ -107,8 +107,8 @@
|
|
|
107
107
|
"dependencies": {
|
|
108
108
|
"@formatjs/intl-localematcher": "^0.6.2",
|
|
109
109
|
"@orama/orama": "^3.1.16",
|
|
110
|
-
"@shikijs/rehype": "^3.
|
|
111
|
-
"@shikijs/transformers": "^3.
|
|
110
|
+
"@shikijs/rehype": "^3.15.0",
|
|
111
|
+
"@shikijs/transformers": "^3.15.0",
|
|
112
112
|
"estree-util-value-to-estree": "^3.5.0",
|
|
113
113
|
"github-slugger": "^2.0.0",
|
|
114
114
|
"hast-util-to-estree": "^3.1.3",
|
|
@@ -121,27 +121,27 @@
|
|
|
121
121
|
"remark-gfm": "^4.0.1",
|
|
122
122
|
"remark-rehype": "^11.1.2",
|
|
123
123
|
"scroll-into-view-if-needed": "^3.1.0",
|
|
124
|
-
"shiki": "^3.
|
|
124
|
+
"shiki": "^3.15.0",
|
|
125
125
|
"unist-util-visit": "^5.0.0"
|
|
126
126
|
},
|
|
127
127
|
"devDependencies": {
|
|
128
128
|
"@mdx-js/mdx": "^3.1.1",
|
|
129
|
-
"@mixedbread/sdk": "^0.
|
|
129
|
+
"@mixedbread/sdk": "^0.44.0",
|
|
130
130
|
"@orama/core": "^1.2.13",
|
|
131
|
-
"@tanstack/react-router": "^1.
|
|
131
|
+
"@tanstack/react-router": "^1.136.6",
|
|
132
132
|
"@types/estree-jsx": "^1.0.5",
|
|
133
133
|
"@types/hast": "^3.0.4",
|
|
134
134
|
"@types/mdast": "^4.0.4",
|
|
135
135
|
"@types/negotiator": "^0.6.4",
|
|
136
|
-
"@types/node": "24.10.
|
|
137
|
-
"@types/react": "^19.2.
|
|
138
|
-
"@types/react-dom": "^19.2.
|
|
139
|
-
"algoliasearch": "5.
|
|
140
|
-
"lucide-react": "^0.
|
|
136
|
+
"@types/node": "24.10.1",
|
|
137
|
+
"@types/react": "^19.2.5",
|
|
138
|
+
"@types/react-dom": "^19.2.3",
|
|
139
|
+
"algoliasearch": "5.44.0",
|
|
140
|
+
"lucide-react": "^0.553.0",
|
|
141
141
|
"mdast-util-mdx-jsx": "^3.2.0",
|
|
142
142
|
"mdast-util-mdxjs-esm": "^2.0.1",
|
|
143
|
-
"next": "16.0.
|
|
144
|
-
"react-router": "^7.9.
|
|
143
|
+
"next": "16.0.3",
|
|
144
|
+
"react-router": "^7.9.6",
|
|
145
145
|
"remark-directive": "^4.0.0",
|
|
146
146
|
"remark-mdx": "^3.1.1",
|
|
147
147
|
"remove-markdown": "^0.6.2",
|
|
@@ -163,7 +163,7 @@
|
|
|
163
163
|
"react": "^19.2.0",
|
|
164
164
|
"react-dom": "^19.2.0",
|
|
165
165
|
"react-router": "7.x.x",
|
|
166
|
-
"waku": "^0.26.0"
|
|
166
|
+
"waku": "^0.26.0 || ^0.27.0"
|
|
167
167
|
},
|
|
168
168
|
"peerDependenciesMeta": {
|
|
169
169
|
"@mixedbread/sdk": {
|