fumadocs-core 15.5.1 → 15.5.2
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-KJKVXZ5Q.js → algolia-NXNLN7TR.js} +0 -2
- package/dist/breadcrumb.js +0 -2
- package/dist/chunk-7GNSIKII.js +47 -0
- package/dist/content/index.js +0 -2
- package/dist/dynamic-link.js +0 -1
- package/dist/{fetch-M245YYDD.js → fetch-ZSD7GUCX.js} +0 -2
- package/dist/framework/index.js +0 -1
- package/dist/framework/next.js +0 -1
- package/dist/framework/react-router.js +0 -1
- package/dist/framework/tanstack.js +0 -1
- package/dist/hide-if-empty.d.ts +2 -2
- package/dist/hide-if-empty.js +0 -1
- package/dist/highlight/client.js +0 -1
- package/dist/highlight/index.js +0 -1
- package/dist/i18n/index.js +0 -2
- package/dist/link.js +0 -1
- package/dist/mdx-plugins/index.js +0 -1
- package/dist/{orama-cloud-SBXZAVQC.js → orama-cloud-I4WBDIAI.js} +0 -1
- package/dist/search/algolia.js +0 -2
- package/dist/search/client.js +4 -5
- package/dist/search/orama-cloud.js +0 -2
- package/dist/search/server.js +5 -2
- package/dist/server/index.js +0 -1
- package/dist/sidebar.js +0 -1
- package/dist/source/index.d.ts +91 -95
- package/dist/source/index.js +200 -213
- package/dist/{static-IM4OAJFY.js → static-QTPM5MZT.js} +0 -1
- package/dist/toc.js +0 -1
- package/dist/utils/use-effect-event.js +0 -1
- package/dist/utils/use-media-query.js +0 -1
- package/dist/utils/use-on-change.js +0 -1
- package/package.json +17 -13
- package/dist/chunk-MLKGABMK.js +0 -9
package/dist/breadcrumb.js
CHANGED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// src/source/path.ts
|
|
2
|
+
function basename(path, ext) {
|
|
3
|
+
const idx = path.lastIndexOf("/");
|
|
4
|
+
return path.substring(
|
|
5
|
+
idx === -1 ? 0 : idx + 1,
|
|
6
|
+
ext ? path.length - ext.length : path.length
|
|
7
|
+
);
|
|
8
|
+
}
|
|
9
|
+
function extname(path) {
|
|
10
|
+
const dotIdx = path.lastIndexOf(".");
|
|
11
|
+
if (dotIdx !== -1) {
|
|
12
|
+
return path.substring(dotIdx);
|
|
13
|
+
}
|
|
14
|
+
return "";
|
|
15
|
+
}
|
|
16
|
+
function dirname(path) {
|
|
17
|
+
return path.split("/").slice(0, -1).join("/");
|
|
18
|
+
}
|
|
19
|
+
function parseFilePath(path) {
|
|
20
|
+
const ext = extname(path);
|
|
21
|
+
const name = basename(path, ext);
|
|
22
|
+
const dir = dirname(path);
|
|
23
|
+
return {
|
|
24
|
+
dirname: dir,
|
|
25
|
+
name,
|
|
26
|
+
ext,
|
|
27
|
+
path,
|
|
28
|
+
get flattenedPath() {
|
|
29
|
+
return [dir, name].filter((p) => p.length > 0).join("/");
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function parseFolderPath(path) {
|
|
34
|
+
return {
|
|
35
|
+
dirname: dirname(path),
|
|
36
|
+
name: basename(path),
|
|
37
|
+
path
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export {
|
|
42
|
+
basename,
|
|
43
|
+
extname,
|
|
44
|
+
dirname,
|
|
45
|
+
parseFilePath,
|
|
46
|
+
parseFolderPath
|
|
47
|
+
};
|
package/dist/content/index.js
CHANGED
package/dist/dynamic-link.js
CHANGED
package/dist/framework/index.js
CHANGED
package/dist/framework/next.js
CHANGED
package/dist/hide-if-empty.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The built-in CSS `:empty` selector cannot detect if the children is hidden, classes such as `md:hidden` causes it to fail.
|
|
@@ -8,7 +8,7 @@ import react__default from 'react';
|
|
|
8
8
|
* This can be expensive, please avoid this whenever possible.
|
|
9
9
|
*/
|
|
10
10
|
declare function HideIfEmpty({ children }: {
|
|
11
|
-
children:
|
|
11
|
+
children: ReactNode;
|
|
12
12
|
}): react_jsx_runtime.JSX.Element;
|
|
13
13
|
|
|
14
14
|
export { HideIfEmpty };
|
package/dist/hide-if-empty.js
CHANGED
package/dist/highlight/client.js
CHANGED
package/dist/highlight/index.js
CHANGED
package/dist/i18n/index.js
CHANGED
package/dist/link.js
CHANGED
package/dist/search/algolia.js
CHANGED
package/dist/search/client.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useOnChange
|
|
3
3
|
} from "../chunk-EMWGTXSW.js";
|
|
4
|
-
import "../chunk-MLKGABMK.js";
|
|
5
4
|
|
|
6
5
|
// src/search/client.ts
|
|
7
6
|
import { useRef as useRef2, useState as useState2 } from "react";
|
|
@@ -65,19 +64,19 @@ function useDocsSearch(clientOptions, _locale, _tag, _delayMs = 100, _allowEmpty
|
|
|
65
64
|
async function run() {
|
|
66
65
|
if (debouncedValue.length === 0 && !allowEmpty) return "empty";
|
|
67
66
|
if (client.type === "fetch") {
|
|
68
|
-
const { fetchDocs } = await import("../fetch-
|
|
67
|
+
const { fetchDocs } = await import("../fetch-ZSD7GUCX.js");
|
|
69
68
|
return fetchDocs(debouncedValue, client);
|
|
70
69
|
}
|
|
71
70
|
if (client.type === "algolia") {
|
|
72
|
-
const { searchDocs } = await import("../algolia-
|
|
71
|
+
const { searchDocs } = await import("../algolia-NXNLN7TR.js");
|
|
73
72
|
return searchDocs(debouncedValue, client);
|
|
74
73
|
}
|
|
75
74
|
if (client.type === "orama-cloud") {
|
|
76
|
-
const { searchDocs } = await import("../orama-cloud-
|
|
75
|
+
const { searchDocs } = await import("../orama-cloud-I4WBDIAI.js");
|
|
77
76
|
return searchDocs(debouncedValue, client);
|
|
78
77
|
}
|
|
79
78
|
if (client.type === "static") {
|
|
80
|
-
const { search: search2 } = await import("../static-
|
|
79
|
+
const { search: search2 } = await import("../static-QTPM5MZT.js");
|
|
81
80
|
return search2(debouncedValue, client);
|
|
82
81
|
}
|
|
83
82
|
throw new Error("unknown search client");
|
package/dist/search/server.js
CHANGED
|
@@ -3,7 +3,10 @@ import {
|
|
|
3
3
|
searchSimple
|
|
4
4
|
} from "../chunk-WFUH5VBX.js";
|
|
5
5
|
import "../chunk-KAOEMCTI.js";
|
|
6
|
-
import
|
|
6
|
+
import {
|
|
7
|
+
basename,
|
|
8
|
+
extname
|
|
9
|
+
} from "../chunk-7GNSIKII.js";
|
|
7
10
|
|
|
8
11
|
// src/search/server.ts
|
|
9
12
|
import {
|
|
@@ -150,7 +153,7 @@ function pageToIndex(page) {
|
|
|
150
153
|
}
|
|
151
154
|
const structuredData = page.data.structuredData;
|
|
152
155
|
return {
|
|
153
|
-
title: page.data.title ?? page.
|
|
156
|
+
title: page.data.title ?? basename(page.path, extname(page.path)),
|
|
154
157
|
description: "description" in page.data ? page.data.description : void 0,
|
|
155
158
|
url: page.url,
|
|
156
159
|
id: page.url,
|
package/dist/server/index.js
CHANGED
package/dist/sidebar.js
CHANGED
package/dist/source/index.d.ts
CHANGED
|
@@ -1,8 +1,48 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
2
|
import { I18nConfig } from '../i18n/index.js';
|
|
3
|
-
import { R as Root, I as Item, F as Folder
|
|
3
|
+
import { R as Root, I as Item, F as Folder, S as Separator } from '../page-tree-bSt6K__E.js';
|
|
4
4
|
import 'next/dist/server/web/types';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* In memory file system.
|
|
8
|
+
*/
|
|
9
|
+
declare class FileSystem<File> {
|
|
10
|
+
files: Map<string, File>;
|
|
11
|
+
folders: Map<string, string[]>;
|
|
12
|
+
constructor();
|
|
13
|
+
read(path: string): File | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* get the direct children of folder (in virtual file path)
|
|
16
|
+
*/
|
|
17
|
+
readDir(path: string): string[] | undefined;
|
|
18
|
+
write(path: string, file: File): void;
|
|
19
|
+
getFiles(): string[];
|
|
20
|
+
makeDir(path: string): void;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface LoadOptions {
|
|
24
|
+
transformers?: Transformer[];
|
|
25
|
+
}
|
|
26
|
+
type ContentStorage = FileSystem<MetaFile | PageFile>;
|
|
27
|
+
interface MetaFile<Data extends MetaData = MetaData> {
|
|
28
|
+
path: string;
|
|
29
|
+
absolutePath: string;
|
|
30
|
+
format: 'meta';
|
|
31
|
+
data: Data;
|
|
32
|
+
}
|
|
33
|
+
interface PageFile<Data extends PageData = PageData> {
|
|
34
|
+
path: string;
|
|
35
|
+
absolutePath: string;
|
|
36
|
+
format: 'page';
|
|
37
|
+
slugs: string[];
|
|
38
|
+
data: Data;
|
|
39
|
+
}
|
|
40
|
+
type Transformer = (context: {
|
|
41
|
+
storage: ContentStorage;
|
|
42
|
+
options: LoadOptions;
|
|
43
|
+
}) => void;
|
|
44
|
+
declare function loadFiles(files: VirtualFile[], buildFile: (file: VirtualFile) => MetaFile | PageFile, options: LoadOptions): ContentStorage;
|
|
45
|
+
|
|
6
46
|
interface FileInfo {
|
|
7
47
|
/**
|
|
8
48
|
* File path without extension
|
|
@@ -38,32 +78,11 @@ interface FolderInfo {
|
|
|
38
78
|
dirname: string;
|
|
39
79
|
}
|
|
40
80
|
declare function parseFilePath(path: string): FileInfo;
|
|
81
|
+
/**
|
|
82
|
+
* @deprecated use `dirname` and `basename` directly.
|
|
83
|
+
*/
|
|
41
84
|
declare function parseFolderPath(path: string): FolderInfo;
|
|
42
85
|
|
|
43
|
-
interface LoadOptions {
|
|
44
|
-
transformers?: Transformer[];
|
|
45
|
-
getSlugs: (info: FileInfo) => string[];
|
|
46
|
-
}
|
|
47
|
-
interface VirtualFile {
|
|
48
|
-
/**
|
|
49
|
-
* Relative path
|
|
50
|
-
*
|
|
51
|
-
* @example `docs/page.mdx`
|
|
52
|
-
*/
|
|
53
|
-
path: string;
|
|
54
|
-
type: 'page' | 'meta';
|
|
55
|
-
/**
|
|
56
|
-
* Specified Slugs for page
|
|
57
|
-
*/
|
|
58
|
-
slugs?: string[];
|
|
59
|
-
data: unknown;
|
|
60
|
-
}
|
|
61
|
-
type Transformer = (context: {
|
|
62
|
-
storage: Storage;
|
|
63
|
-
options: LoadOptions;
|
|
64
|
-
}) => void;
|
|
65
|
-
declare function loadFiles<O extends LoadOptions>(files: VirtualFile[], options: O): Storage;
|
|
66
|
-
|
|
67
86
|
interface LoaderConfig {
|
|
68
87
|
source: SourceConfig;
|
|
69
88
|
i18n: boolean;
|
|
@@ -74,15 +93,15 @@ interface SourceConfig {
|
|
|
74
93
|
}
|
|
75
94
|
interface LoaderOptions<T extends SourceConfig = SourceConfig, I18n extends I18nConfig | undefined = I18nConfig | undefined> {
|
|
76
95
|
baseUrl: string;
|
|
77
|
-
icon?: NonNullable<
|
|
78
|
-
slugs?:
|
|
96
|
+
icon?: NonNullable<BuildPageTreeOptions['resolveIcon']>;
|
|
97
|
+
slugs?: (info: FileInfo) => string[];
|
|
79
98
|
url?: UrlFn;
|
|
80
99
|
source: Source<T>;
|
|
81
100
|
transformers?: Transformer[];
|
|
82
101
|
/**
|
|
83
102
|
* Additional options for page tree builder
|
|
84
103
|
*/
|
|
85
|
-
pageTree?: Partial<
|
|
104
|
+
pageTree?: Partial<Omit<BuildPageTreeOptions<T['pageData'], T['metaData']>, 'storage'>>;
|
|
86
105
|
/**
|
|
87
106
|
* Configure i18n
|
|
88
107
|
*/
|
|
@@ -95,21 +114,49 @@ interface Source<Config extends SourceConfig> {
|
|
|
95
114
|
_config?: Config;
|
|
96
115
|
files: VirtualFile[] | (() => VirtualFile[]);
|
|
97
116
|
}
|
|
98
|
-
interface
|
|
117
|
+
interface SharedFileInfo {
|
|
99
118
|
/**
|
|
100
|
-
* Virtualized file path
|
|
119
|
+
* Virtualized file path (parsed)
|
|
120
|
+
*
|
|
121
|
+
* @deprecated Use `path` instead.
|
|
101
122
|
*/
|
|
102
123
|
file: FileInfo;
|
|
124
|
+
/**
|
|
125
|
+
* Virtualized file path (relative to content directory)
|
|
126
|
+
*
|
|
127
|
+
* @example `docs/page.mdx`
|
|
128
|
+
*/
|
|
129
|
+
path: string;
|
|
130
|
+
/**
|
|
131
|
+
* Absolute path of the file
|
|
132
|
+
*/
|
|
133
|
+
absolutePath: string;
|
|
134
|
+
}
|
|
135
|
+
interface VirtualFile {
|
|
136
|
+
/**
|
|
137
|
+
* Virtualized path (relative to content directory)
|
|
138
|
+
*
|
|
139
|
+
* @example `docs/page.mdx`
|
|
140
|
+
*/
|
|
141
|
+
path: string;
|
|
142
|
+
/**
|
|
143
|
+
* Absolute path of the file
|
|
144
|
+
*/
|
|
145
|
+
absolutePath?: string;
|
|
146
|
+
type: 'page' | 'meta';
|
|
147
|
+
/**
|
|
148
|
+
* Specified Slugs for page
|
|
149
|
+
*/
|
|
150
|
+
slugs?: string[];
|
|
151
|
+
data: unknown;
|
|
152
|
+
}
|
|
153
|
+
interface Page<Data = PageData> extends SharedFileInfo {
|
|
103
154
|
slugs: string[];
|
|
104
155
|
url: string;
|
|
105
156
|
data: Data;
|
|
106
157
|
locale?: string | undefined;
|
|
107
158
|
}
|
|
108
|
-
interface Meta<Data = MetaData> {
|
|
109
|
-
/**
|
|
110
|
-
* Virtualized file path
|
|
111
|
-
*/
|
|
112
|
-
file: FileInfo;
|
|
159
|
+
interface Meta<Data = MetaData> extends SharedFileInfo {
|
|
113
160
|
data: Data;
|
|
114
161
|
}
|
|
115
162
|
interface LanguageEntry<Data = PageData> {
|
|
@@ -144,7 +191,7 @@ interface LoaderOutput<Config extends LoaderConfig> {
|
|
|
144
191
|
*/
|
|
145
192
|
getPage: (slugs: string[] | undefined, language?: string) => Page<Config['source']['pageData']> | undefined;
|
|
146
193
|
getNodePage: (node: Item, language?: string) => Page<Config['source']['pageData']> | undefined;
|
|
147
|
-
getNodeMeta: (node: Folder
|
|
194
|
+
getNodeMeta: (node: Folder, language?: string) => Meta<Config['source']['metaData']> | undefined;
|
|
148
195
|
/**
|
|
149
196
|
* generate static params for Next.js SSG
|
|
150
197
|
*
|
|
@@ -183,59 +230,6 @@ type InferMetaType<Utils extends LoaderOutput<any>> = Utils extends LoaderOutput
|
|
|
183
230
|
*/
|
|
184
231
|
type UrlFn = (slugs: string[], locale?: string) => string;
|
|
185
232
|
|
|
186
|
-
interface MetaFile<Data extends MetaData = MetaData> {
|
|
187
|
-
file: FileInfo;
|
|
188
|
-
format: 'meta';
|
|
189
|
-
data: Data;
|
|
190
|
-
}
|
|
191
|
-
interface PageFile<Data extends PageData = PageData> {
|
|
192
|
-
file: FileInfo;
|
|
193
|
-
format: 'page';
|
|
194
|
-
data: {
|
|
195
|
-
slugs: string[];
|
|
196
|
-
data: Data;
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
type File = MetaFile | PageFile;
|
|
200
|
-
interface Folder<Page extends PageData = PageData, Meta extends MetaData = MetaData> {
|
|
201
|
-
file: FolderInfo;
|
|
202
|
-
children: (MetaFile<Meta> | PageFile<Page> | Folder<Page, Meta>)[];
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* A virtual file system that solves inconsistent behaviours
|
|
206
|
-
*
|
|
207
|
-
* Some source providers may not provide the full file structure, this will cause inconsistent outputs for page builder and other transformers
|
|
208
|
-
*/
|
|
209
|
-
declare class Storage {
|
|
210
|
-
files: Map<string, File>;
|
|
211
|
-
folders: Map<string, Folder<PageData, MetaData>>;
|
|
212
|
-
private rootFolder;
|
|
213
|
-
constructor();
|
|
214
|
-
/**
|
|
215
|
-
* @param path - flattened path
|
|
216
|
-
* @param format - file format
|
|
217
|
-
*/
|
|
218
|
-
read<F extends File['format']>(path: string, format: F): Extract<File, {
|
|
219
|
-
format: F;
|
|
220
|
-
}> | undefined;
|
|
221
|
-
readDir(path: string): Folder | undefined;
|
|
222
|
-
root(): Folder;
|
|
223
|
-
write<F extends File['format']>(path: string, format: F, data: Extract<File, {
|
|
224
|
-
format: F;
|
|
225
|
-
}>['data']): void;
|
|
226
|
-
list(): File[];
|
|
227
|
-
makeDir(path: string): void;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
type fileSystem_Folder<Page extends PageData = PageData, Meta extends MetaData = MetaData> = Folder<Page, Meta>;
|
|
231
|
-
type fileSystem_MetaFile<Data extends MetaData = MetaData> = MetaFile<Data>;
|
|
232
|
-
type fileSystem_PageFile<Data extends PageData = PageData> = PageFile<Data>;
|
|
233
|
-
type fileSystem_Storage = Storage;
|
|
234
|
-
declare const fileSystem_Storage: typeof Storage;
|
|
235
|
-
declare namespace fileSystem {
|
|
236
|
-
export { type fileSystem_Folder as Folder, type fileSystem_MetaFile as MetaFile, type fileSystem_PageFile as PageFile, fileSystem_Storage as Storage };
|
|
237
|
-
}
|
|
238
|
-
|
|
239
233
|
interface BaseOptions<Page extends PageData = PageData, Meta extends MetaData = MetaData> {
|
|
240
234
|
/**
|
|
241
235
|
* Remove references to the file path of original nodes (`$ref`)
|
|
@@ -244,15 +238,17 @@ interface BaseOptions<Page extends PageData = PageData, Meta extends MetaData =
|
|
|
244
238
|
*/
|
|
245
239
|
noRef?: boolean;
|
|
246
240
|
attachFile?: (node: Item, file?: PageFile<Page>) => Item;
|
|
247
|
-
attachFolder?: (node: Folder
|
|
241
|
+
attachFolder?: (node: Folder, folder: {
|
|
242
|
+
children: (PageFile<Page> | MetaFile<Meta>)[];
|
|
243
|
+
}, meta?: MetaFile<Meta>) => Folder;
|
|
248
244
|
attachSeparator?: (node: Separator) => Separator;
|
|
249
245
|
resolveIcon?: (icon: string | undefined) => ReactElement | undefined;
|
|
250
246
|
}
|
|
251
|
-
interface BuildPageTreeOptions extends BaseOptions {
|
|
252
|
-
storage:
|
|
247
|
+
interface BuildPageTreeOptions<Page extends PageData = PageData, Meta extends MetaData = MetaData> extends BaseOptions<Page, Meta> {
|
|
248
|
+
storage: ContentStorage;
|
|
253
249
|
}
|
|
254
|
-
interface BuildPageTreeOptionsWithI18n extends BaseOptions {
|
|
255
|
-
storages: Record<string,
|
|
250
|
+
interface BuildPageTreeOptionsWithI18n<Page extends PageData = PageData, Meta extends MetaData = MetaData> extends BaseOptions<Page, Meta> {
|
|
251
|
+
storages: Record<string, ContentStorage>;
|
|
256
252
|
i18n: I18nConfig;
|
|
257
253
|
}
|
|
258
254
|
interface PageTreeBuilder {
|
|
@@ -264,4 +260,4 @@ interface PageTreeBuilder {
|
|
|
264
260
|
}
|
|
265
261
|
declare function createPageTreeBuilder(getUrl: UrlFn): PageTreeBuilder;
|
|
266
262
|
|
|
267
|
-
export { type
|
|
263
|
+
export { type BuildPageTreeOptions, type BuildPageTreeOptionsWithI18n, type ContentStorage, type FileInfo, FileSystem, type FolderInfo, type InferMetaType, type InferPageType, type LanguageEntry, type LoadOptions, type LoaderConfig, type LoaderOptions, type LoaderOutput, type Meta, type MetaData, type MetaFile, type Page, type PageData, type PageFile, type PageTreeBuilder, type Source, type SourceConfig, type Transformer, type UrlFn, type VirtualFile, createGetUrl, createPageTreeBuilder, getSlugs, loadFiles, loader, parseFilePath, parseFolderPath };
|
package/dist/source/index.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
basename,
|
|
3
|
+
dirname,
|
|
4
|
+
extname,
|
|
5
|
+
parseFilePath,
|
|
6
|
+
parseFolderPath
|
|
7
|
+
} from "../chunk-7GNSIKII.js";
|
|
1
8
|
import {
|
|
2
9
|
joinPath,
|
|
3
10
|
slash,
|
|
4
11
|
splitPath
|
|
5
12
|
} from "../chunk-3JSIVMCJ.js";
|
|
6
|
-
import {
|
|
7
|
-
__export
|
|
8
|
-
} from "../chunk-MLKGABMK.js";
|
|
9
13
|
|
|
10
14
|
// src/source/page-tree-builder.ts
|
|
11
15
|
var group = /^\((?<name>.+)\)$/;
|
|
@@ -15,44 +19,30 @@ var rest = "...";
|
|
|
15
19
|
var restReversed = "z...a";
|
|
16
20
|
var extractPrefix = "...";
|
|
17
21
|
var excludePrefix = "!";
|
|
18
|
-
function
|
|
19
|
-
return "data" in node && node.format === "page";
|
|
20
|
-
}
|
|
21
|
-
function buildAll(nodes, ctx, filter, reversed = false) {
|
|
22
|
-
const { localeStorage } = ctx;
|
|
22
|
+
function buildAll(paths, ctx, filter, reversed = false) {
|
|
23
23
|
const output = [];
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
);
|
|
37
|
-
const treeNode = buildFileNode(localized ?? node, ctx);
|
|
38
|
-
if (node.file.name === "index") {
|
|
39
|
-
output.unshift(treeNode);
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
output.push(treeNode);
|
|
43
|
-
} else if ("children" in node) {
|
|
44
|
-
output.push(buildFolderNode(node, false, ctx));
|
|
45
|
-
}
|
|
24
|
+
const sortedPaths = (filter ? paths.filter(filter) : [...paths]).sort(
|
|
25
|
+
(a, b) => a.localeCompare(b) * (reversed ? -1 : 1)
|
|
26
|
+
);
|
|
27
|
+
for (const path of sortedPaths) {
|
|
28
|
+
const fileNode = buildFileNode(path, ctx);
|
|
29
|
+
if (!fileNode) continue;
|
|
30
|
+
if (basename(path, extname(path)) === "index") output.unshift(fileNode);
|
|
31
|
+
else output.push(fileNode);
|
|
32
|
+
}
|
|
33
|
+
for (const dir of sortedPaths) {
|
|
34
|
+
const dirNode = buildFolderNode(dir, false, ctx);
|
|
35
|
+
if (dirNode) output.push(dirNode);
|
|
46
36
|
}
|
|
47
37
|
return output;
|
|
48
38
|
}
|
|
49
|
-
function resolveFolderItem(
|
|
39
|
+
function resolveFolderItem(folderPath, item, ctx, idx, restNodePaths) {
|
|
50
40
|
if (item === rest || item === restReversed) return item;
|
|
51
|
-
const { options,
|
|
41
|
+
const { options, resolveName } = ctx;
|
|
52
42
|
let match = separator.exec(item);
|
|
53
43
|
if (match?.groups) {
|
|
54
44
|
const node = {
|
|
55
|
-
$id: `${
|
|
45
|
+
$id: `${folderPath}#${idx}`,
|
|
56
46
|
type: "separator",
|
|
57
47
|
icon: options.resolveIcon?.(match.groups.icon),
|
|
58
48
|
name: match.groups.name
|
|
@@ -80,93 +70,101 @@ function resolveFolderItem(folder, item, ctx, idx, addedNodePaths) {
|
|
|
80
70
|
} else if (isExtract) {
|
|
81
71
|
filename = item.slice(extractPrefix.length);
|
|
82
72
|
}
|
|
83
|
-
const path = joinPath(
|
|
84
|
-
|
|
85
|
-
if (!itemNode) return [];
|
|
86
|
-
addedNodePaths.add(itemNode.file.path);
|
|
73
|
+
const path = resolveName(joinPath(folderPath, filename), "page");
|
|
74
|
+
restNodePaths.delete(path);
|
|
87
75
|
if (isExcept) return [];
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
return isExtract ?
|
|
76
|
+
const dirNode = buildFolderNode(path, false, ctx);
|
|
77
|
+
if (dirNode) {
|
|
78
|
+
return isExtract ? dirNode.children : [dirNode];
|
|
91
79
|
}
|
|
92
|
-
|
|
80
|
+
const fileNode = buildFileNode(path, ctx);
|
|
81
|
+
return fileNode ? [fileNode] : [];
|
|
93
82
|
}
|
|
94
|
-
function buildFolderNode(
|
|
95
|
-
const { storage, localeStorage, options } = ctx;
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
const
|
|
99
|
-
const
|
|
83
|
+
function buildFolderNode(folderPath, isGlobalRoot, ctx) {
|
|
84
|
+
const { storage, localeStorage, options, resolveName } = ctx;
|
|
85
|
+
const files = storage.readDir(folderPath);
|
|
86
|
+
if (!files) return;
|
|
87
|
+
const metaPath = resolveName(joinPath(folderPath, "meta"), "meta");
|
|
88
|
+
const indexPath = resolveName(joinPath(folderPath, "index"), "page");
|
|
89
|
+
let meta = localeStorage?.read(metaPath) ?? storage.read(metaPath);
|
|
90
|
+
if (meta?.format !== "meta") {
|
|
91
|
+
meta = void 0;
|
|
92
|
+
}
|
|
100
93
|
const isRoot = meta?.data.root ?? isGlobalRoot;
|
|
101
|
-
let
|
|
94
|
+
let indexDisabled = false;
|
|
102
95
|
let children;
|
|
103
96
|
if (!meta?.data.pages) {
|
|
104
|
-
|
|
105
|
-
children = buildAll(folder.children, ctx, (node2) => {
|
|
106
|
-
return node2.file.name !== "index" || isRoot;
|
|
107
|
-
});
|
|
97
|
+
children = buildAll(files, ctx, (file) => isRoot || file !== indexPath);
|
|
108
98
|
} else {
|
|
109
|
-
const
|
|
110
|
-
const resolved = meta.data.pages.flatMap((item, i) => resolveFolderItem(
|
|
111
|
-
if (
|
|
112
|
-
|
|
99
|
+
const restItems = new Set(files);
|
|
100
|
+
const resolved = meta.data.pages.flatMap((item, i) => resolveFolderItem(folderPath, item, ctx, i, restItems));
|
|
101
|
+
if (!isRoot && !restItems.has(indexPath)) {
|
|
102
|
+
indexDisabled = true;
|
|
113
103
|
}
|
|
114
104
|
for (let i = 0; i < resolved.length; i++) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
resolved[i] === restReversed
|
|
127
|
-
)
|
|
128
|
-
);
|
|
129
|
-
break;
|
|
130
|
-
}
|
|
105
|
+
const item = resolved[i];
|
|
106
|
+
if (item !== rest && item !== restReversed) continue;
|
|
107
|
+
const items = buildAll(
|
|
108
|
+
files,
|
|
109
|
+
ctx,
|
|
110
|
+
// index files are not included in ... unless it's a root folder
|
|
111
|
+
(file) => (file !== indexPath || isRoot) && restItems.has(file),
|
|
112
|
+
item === restReversed
|
|
113
|
+
);
|
|
114
|
+
resolved.splice(i, 1, ...items);
|
|
115
|
+
break;
|
|
131
116
|
}
|
|
132
117
|
children = resolved;
|
|
133
118
|
}
|
|
119
|
+
const index = !indexDisabled ? buildFileNode(indexPath, ctx) : void 0;
|
|
120
|
+
let name = meta?.data.title ?? index?.name;
|
|
121
|
+
if (!name) {
|
|
122
|
+
const folderName = basename(folderPath);
|
|
123
|
+
name = pathToName(group.exec(folderName)?.[1] ?? folderName);
|
|
124
|
+
}
|
|
134
125
|
const node = {
|
|
135
126
|
type: "folder",
|
|
136
|
-
name
|
|
137
|
-
pathToName(group.exec(folder.file.name)?.[1] ?? folder.file.name),
|
|
127
|
+
name,
|
|
138
128
|
icon: options.resolveIcon?.(meta?.data.icon) ?? index?.icon,
|
|
139
129
|
root: meta?.data.root,
|
|
140
130
|
defaultOpen: meta?.data.defaultOpen,
|
|
141
131
|
description: meta?.data.description,
|
|
142
132
|
index,
|
|
143
133
|
children,
|
|
144
|
-
$id:
|
|
134
|
+
$id: folderPath,
|
|
145
135
|
$ref: !options.noRef && meta ? {
|
|
146
136
|
metaFile: metaPath
|
|
147
137
|
} : void 0
|
|
148
138
|
};
|
|
149
|
-
return options.attachFolder?.(
|
|
139
|
+
return options.attachFolder?.(
|
|
140
|
+
node,
|
|
141
|
+
{
|
|
142
|
+
get children() {
|
|
143
|
+
return files.flatMap((file) => storage.read(file) ?? []);
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
meta
|
|
147
|
+
) ?? node;
|
|
150
148
|
}
|
|
151
|
-
function buildFileNode(
|
|
152
|
-
const
|
|
153
|
-
|
|
149
|
+
function buildFileNode(path, { options, getUrl, storage, localeStorage, locale }) {
|
|
150
|
+
const page = localeStorage?.read(path) ?? storage.read(path);
|
|
151
|
+
if (page?.format !== "page") return;
|
|
152
|
+
const { title, description, icon } = page.data;
|
|
154
153
|
const item = {
|
|
155
|
-
$id:
|
|
154
|
+
$id: path,
|
|
156
155
|
type: "page",
|
|
157
|
-
name:
|
|
158
|
-
description
|
|
159
|
-
icon: options.resolveIcon?.(
|
|
160
|
-
url: getUrl(slugs, locale),
|
|
156
|
+
name: title ?? pathToName(basename(path, extname(path))),
|
|
157
|
+
description,
|
|
158
|
+
icon: options.resolveIcon?.(icon),
|
|
159
|
+
url: getUrl(page.slugs, locale),
|
|
161
160
|
$ref: !options.noRef ? {
|
|
162
|
-
file:
|
|
161
|
+
file: path
|
|
163
162
|
} : void 0
|
|
164
163
|
};
|
|
165
164
|
return options.attachFile?.(item, page) ?? item;
|
|
166
165
|
}
|
|
167
166
|
function build(ctx) {
|
|
168
|
-
const
|
|
169
|
-
const folder = buildFolderNode(root, true, ctx);
|
|
167
|
+
const folder = buildFolderNode("", true, ctx);
|
|
170
168
|
return {
|
|
171
169
|
$id: ctx.locale ?? "root",
|
|
172
170
|
name: folder.name,
|
|
@@ -174,24 +172,45 @@ function build(ctx) {
|
|
|
174
172
|
};
|
|
175
173
|
}
|
|
176
174
|
function createPageTreeBuilder(getUrl) {
|
|
175
|
+
function createFlattenPathResolver(storage) {
|
|
176
|
+
const map = /* @__PURE__ */ new Map();
|
|
177
|
+
const files = storage.getFiles();
|
|
178
|
+
for (const file of files) {
|
|
179
|
+
const content = storage.read(file);
|
|
180
|
+
const flattenPath = file.substring(0, file.length - extname(file).length);
|
|
181
|
+
map.set(flattenPath + "." + content.format, file);
|
|
182
|
+
}
|
|
183
|
+
return (name, format) => {
|
|
184
|
+
return map.get(name + "." + format);
|
|
185
|
+
};
|
|
186
|
+
}
|
|
177
187
|
return {
|
|
178
188
|
build(options) {
|
|
189
|
+
const resolve = createFlattenPathResolver(options.storage);
|
|
179
190
|
return build({
|
|
180
191
|
options,
|
|
181
192
|
builder: this,
|
|
182
193
|
storage: options.storage,
|
|
183
|
-
getUrl
|
|
194
|
+
getUrl,
|
|
195
|
+
resolveName(name, format) {
|
|
196
|
+
return resolve(name, format) ?? name;
|
|
197
|
+
}
|
|
184
198
|
});
|
|
185
199
|
},
|
|
186
200
|
buildI18n({ i18n, ...options }) {
|
|
201
|
+
const storage = options.storages[i18n.defaultLanguage];
|
|
202
|
+
const resolve = createFlattenPathResolver(storage);
|
|
187
203
|
const entries = i18n.languages.map((lang) => {
|
|
188
204
|
const tree = build({
|
|
189
205
|
options,
|
|
190
206
|
getUrl,
|
|
191
207
|
builder: this,
|
|
192
208
|
locale: lang,
|
|
193
|
-
storage
|
|
194
|
-
localeStorage: options.storages[lang]
|
|
209
|
+
storage,
|
|
210
|
+
localeStorage: options.storages[lang],
|
|
211
|
+
resolveName(name, format) {
|
|
212
|
+
return resolve(name, format) ?? name;
|
|
213
|
+
}
|
|
195
214
|
});
|
|
196
215
|
return [lang, tree];
|
|
197
216
|
});
|
|
@@ -209,118 +228,49 @@ function pathToName(name) {
|
|
|
209
228
|
return result.join("");
|
|
210
229
|
}
|
|
211
230
|
|
|
212
|
-
// src/source/path.ts
|
|
213
|
-
function parseFilePath(path) {
|
|
214
|
-
const segments = splitPath(slash(path));
|
|
215
|
-
const dirname = segments.slice(0, -1).join("/");
|
|
216
|
-
let name = segments.at(-1) ?? "";
|
|
217
|
-
let ext = "";
|
|
218
|
-
const dotIdx = name.lastIndexOf(".");
|
|
219
|
-
if (dotIdx !== -1) {
|
|
220
|
-
ext = name.substring(dotIdx);
|
|
221
|
-
name = name.substring(0, dotIdx);
|
|
222
|
-
}
|
|
223
|
-
return {
|
|
224
|
-
dirname,
|
|
225
|
-
name,
|
|
226
|
-
path: segments.join("/"),
|
|
227
|
-
ext,
|
|
228
|
-
get flattenedPath() {
|
|
229
|
-
return [dirname, name].filter((p) => p.length > 0).join("/");
|
|
230
|
-
}
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
function parseFolderPath(path) {
|
|
234
|
-
const segments = splitPath(slash(path));
|
|
235
|
-
const base = segments.at(-1) ?? "";
|
|
236
|
-
return {
|
|
237
|
-
dirname: segments.slice(0, -1).join("/"),
|
|
238
|
-
name: base,
|
|
239
|
-
path: segments.join("/")
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
function normalizePath(path) {
|
|
243
|
-
const segments = splitPath(slash(path));
|
|
244
|
-
if (segments[0] === "." || segments[0] === "..")
|
|
245
|
-
throw new Error("It must not start with './' or '../'");
|
|
246
|
-
return segments.join("/");
|
|
247
|
-
}
|
|
248
|
-
|
|
249
231
|
// src/source/file-system.ts
|
|
250
|
-
var
|
|
251
|
-
__export(file_system_exports, {
|
|
252
|
-
Storage: () => Storage
|
|
253
|
-
});
|
|
254
|
-
var Storage = class {
|
|
232
|
+
var FileSystem = class {
|
|
255
233
|
constructor() {
|
|
256
234
|
this.files = /* @__PURE__ */ new Map();
|
|
257
235
|
this.folders = /* @__PURE__ */ new Map();
|
|
258
|
-
this.
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
this.folders.set("", this.rootFolder);
|
|
236
|
+
this.folders.set("", []);
|
|
237
|
+
}
|
|
238
|
+
read(path) {
|
|
239
|
+
return this.files.get(path);
|
|
263
240
|
}
|
|
264
241
|
/**
|
|
265
|
-
*
|
|
266
|
-
* @param format - file format
|
|
242
|
+
* get the direct children of folder (in virtual file path)
|
|
267
243
|
*/
|
|
268
|
-
read(path, format) {
|
|
269
|
-
return this.files.get(`${path}.${format}`);
|
|
270
|
-
}
|
|
271
244
|
readDir(path) {
|
|
272
245
|
return this.folders.get(path);
|
|
273
246
|
}
|
|
274
|
-
|
|
275
|
-
|
|
247
|
+
write(path, file) {
|
|
248
|
+
const dir = dirname(path);
|
|
249
|
+
this.makeDir(dir);
|
|
250
|
+
this.readDir(dir)?.push(path);
|
|
251
|
+
this.files.set(path, file);
|
|
276
252
|
}
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
format,
|
|
280
|
-
file: parseFilePath(path),
|
|
281
|
-
data
|
|
282
|
-
};
|
|
283
|
-
this.makeDir(node.file.dirname);
|
|
284
|
-
this.readDir(node.file.dirname)?.children.push(node);
|
|
285
|
-
this.files.set(
|
|
286
|
-
joinPath(node.file.dirname, `${node.file.name}.${node.format}`),
|
|
287
|
-
node
|
|
288
|
-
);
|
|
289
|
-
}
|
|
290
|
-
list() {
|
|
291
|
-
return Array.from(this.files.values());
|
|
253
|
+
getFiles() {
|
|
254
|
+
return Array.from(this.files.keys());
|
|
292
255
|
}
|
|
293
256
|
makeDir(path) {
|
|
294
257
|
const segments = splitPath(path);
|
|
295
258
|
for (let i = 0; i < segments.length; i++) {
|
|
296
259
|
const segment = segments.slice(0, i + 1).join("/");
|
|
297
260
|
if (this.folders.has(segment)) continue;
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
children: []
|
|
301
|
-
};
|
|
302
|
-
this.folders.set(folder.file.path, folder);
|
|
303
|
-
this.readDir(folder.file.dirname)?.children.push(folder);
|
|
261
|
+
this.folders.set(segment, []);
|
|
262
|
+
this.readDir(dirname(segment))?.push(path);
|
|
304
263
|
}
|
|
305
264
|
}
|
|
306
265
|
};
|
|
307
266
|
|
|
308
267
|
// src/source/load-files.ts
|
|
309
|
-
function loadFiles(files, options) {
|
|
268
|
+
function loadFiles(files, buildFile, options) {
|
|
310
269
|
const { transformers = [] } = options;
|
|
311
|
-
const storage = new
|
|
270
|
+
const storage = new FileSystem();
|
|
312
271
|
for (const file of files) {
|
|
313
272
|
const parsedPath = normalizePath(file.path);
|
|
314
|
-
|
|
315
|
-
const slugs = file.slugs ?? options.getSlugs(parseFilePath(parsedPath));
|
|
316
|
-
storage.write(parsedPath, file.type, {
|
|
317
|
-
slugs,
|
|
318
|
-
data: file.data
|
|
319
|
-
});
|
|
320
|
-
}
|
|
321
|
-
if (file.type === "meta") {
|
|
322
|
-
storage.write(parsedPath, file.type, file.data);
|
|
323
|
-
}
|
|
273
|
+
storage.write(parsedPath, buildFile(file));
|
|
324
274
|
}
|
|
325
275
|
for (const transformer of transformers) {
|
|
326
276
|
transformer({
|
|
@@ -330,7 +280,7 @@ function loadFiles(files, options) {
|
|
|
330
280
|
}
|
|
331
281
|
return storage;
|
|
332
282
|
}
|
|
333
|
-
function loadFilesI18n(files, options) {
|
|
283
|
+
function loadFilesI18n(files, buildFile, options) {
|
|
334
284
|
const parser = options.i18n.parser === "dir" ? dirParser : dotParser;
|
|
335
285
|
const storages = {};
|
|
336
286
|
for (const lang of options.i18n.languages) {
|
|
@@ -345,6 +295,7 @@ function loadFilesI18n(files, options) {
|
|
|
345
295
|
}
|
|
346
296
|
return [];
|
|
347
297
|
}),
|
|
298
|
+
buildFile,
|
|
348
299
|
options
|
|
349
300
|
);
|
|
350
301
|
}
|
|
@@ -368,39 +319,56 @@ function dotParser(path) {
|
|
|
368
319
|
}
|
|
369
320
|
return [path];
|
|
370
321
|
}
|
|
322
|
+
function normalizePath(path) {
|
|
323
|
+
const segments = splitPath(slash(path));
|
|
324
|
+
if (segments[0] === "." || segments[0] === "..")
|
|
325
|
+
throw new Error("It must not start with './' or '../'");
|
|
326
|
+
return segments.join("/");
|
|
327
|
+
}
|
|
371
328
|
|
|
372
329
|
// src/source/loader.ts
|
|
373
330
|
function indexPages(storages, getUrl, i18n) {
|
|
331
|
+
const result = {
|
|
332
|
+
// (locale.slugs -> page)
|
|
333
|
+
pages: /* @__PURE__ */ new Map(),
|
|
334
|
+
// (locale.path -> page)
|
|
335
|
+
pathToMeta: /* @__PURE__ */ new Map(),
|
|
336
|
+
// (locale.path -> meta)
|
|
337
|
+
pathToPage: /* @__PURE__ */ new Map()
|
|
338
|
+
};
|
|
374
339
|
const defaultLanguage = i18n?.defaultLanguage ?? "";
|
|
375
|
-
const
|
|
376
|
-
|
|
377
|
-
for (const item of storages[defaultLanguage].list()) {
|
|
340
|
+
for (const filePath of storages[defaultLanguage].getFiles()) {
|
|
341
|
+
const item = storages[defaultLanguage].read(filePath);
|
|
378
342
|
if (item.format === "meta") {
|
|
379
|
-
|
|
343
|
+
result.pathToMeta.set(
|
|
344
|
+
`${defaultLanguage}.${item.path}`,
|
|
345
|
+
fileToMeta(item)
|
|
346
|
+
);
|
|
380
347
|
}
|
|
381
348
|
if (item.format === "page") {
|
|
382
349
|
const page = fileToPage(item, getUrl, defaultLanguage);
|
|
383
|
-
|
|
384
|
-
|
|
350
|
+
result.pathToPage.set(`${defaultLanguage}.${item.path}`, page);
|
|
351
|
+
result.pages.set(`${defaultLanguage}.${page.slugs.join("/")}`, page);
|
|
385
352
|
if (!i18n) continue;
|
|
386
|
-
const path = joinPath(item.file.dirname, item.file.name);
|
|
387
353
|
for (const lang of i18n.languages) {
|
|
388
354
|
if (lang === defaultLanguage) continue;
|
|
389
|
-
const localizedItem = storages[lang].read(
|
|
390
|
-
const localizedPage = fileToPage(
|
|
355
|
+
const localizedItem = storages[lang].read(filePath);
|
|
356
|
+
const localizedPage = fileToPage(
|
|
357
|
+
localizedItem?.format === "page" ? localizedItem : item,
|
|
358
|
+
getUrl,
|
|
359
|
+
lang
|
|
360
|
+
);
|
|
391
361
|
if (localizedItem) {
|
|
392
|
-
|
|
362
|
+
result.pathToPage.set(`${lang}.${item.path}`, localizedPage);
|
|
393
363
|
}
|
|
394
|
-
|
|
364
|
+
result.pages.set(
|
|
365
|
+
`${lang}.${localizedPage.slugs.join("/")}`,
|
|
366
|
+
localizedPage
|
|
367
|
+
);
|
|
395
368
|
}
|
|
396
369
|
}
|
|
397
370
|
}
|
|
398
|
-
return
|
|
399
|
-
pages: map,
|
|
400
|
-
getResultFromFile(file) {
|
|
401
|
-
return fileMapped.get(file);
|
|
402
|
-
}
|
|
403
|
-
};
|
|
371
|
+
return result;
|
|
404
372
|
}
|
|
405
373
|
function createGetUrl(baseUrl, i18n) {
|
|
406
374
|
const baseSlugs = baseUrl.split("/");
|
|
@@ -438,18 +406,31 @@ function createOutput(options) {
|
|
|
438
406
|
const defaultLanguage = i18n?.defaultLanguage ?? "";
|
|
439
407
|
const getUrl = options.url ?? createGetUrl(options.baseUrl ?? "/", options.i18n);
|
|
440
408
|
const files = typeof source.files === "function" ? source.files() : source.files;
|
|
441
|
-
|
|
409
|
+
function buildFile(file) {
|
|
410
|
+
if (file.type === "page") {
|
|
411
|
+
return {
|
|
412
|
+
format: "page",
|
|
413
|
+
path: file.path,
|
|
414
|
+
slugs: file.slugs ?? slugsFn(parseFilePath(file.path)),
|
|
415
|
+
data: file.data,
|
|
416
|
+
absolutePath: file.absolutePath ?? ""
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
return {
|
|
420
|
+
format: "meta",
|
|
421
|
+
path: file.path,
|
|
422
|
+
absolutePath: file.absolutePath ?? "",
|
|
423
|
+
data: file.data
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
const storages = i18n ? loadFilesI18n(files, buildFile, {
|
|
427
|
+
...options,
|
|
442
428
|
i18n: {
|
|
443
429
|
...i18n,
|
|
444
430
|
parser: i18n.parser ?? "dot"
|
|
445
|
-
}
|
|
446
|
-
transformers: options.transformers,
|
|
447
|
-
getSlugs: slugsFn
|
|
431
|
+
}
|
|
448
432
|
}) : {
|
|
449
|
-
"": loadFiles(files,
|
|
450
|
-
transformers: options.transformers,
|
|
451
|
-
getSlugs: slugsFn
|
|
452
|
-
})
|
|
433
|
+
"": loadFiles(files, buildFile, options)
|
|
453
434
|
};
|
|
454
435
|
const walker = indexPages(storages, getUrl, i18n);
|
|
455
436
|
const builder = createPageTreeBuilder(getUrl);
|
|
@@ -516,14 +497,12 @@ function createOutput(options) {
|
|
|
516
497
|
getNodeMeta(node, language = defaultLanguage) {
|
|
517
498
|
const ref = node.$ref?.metaFile;
|
|
518
499
|
if (!ref) return;
|
|
519
|
-
|
|
520
|
-
if (file) return walker.getResultFromFile(file);
|
|
500
|
+
return walker.pathToMeta.get(`${language}.${ref}`);
|
|
521
501
|
},
|
|
522
502
|
getNodePage(node, language = defaultLanguage) {
|
|
523
503
|
const ref = node.$ref?.file;
|
|
524
504
|
if (!ref) return;
|
|
525
|
-
|
|
526
|
-
if (file) return walker.getResultFromFile(file);
|
|
505
|
+
return walker.pathToPage.get(`${language}.${ref}`);
|
|
527
506
|
},
|
|
528
507
|
getPageTree(locale) {
|
|
529
508
|
if (options.i18n) {
|
|
@@ -549,21 +528,29 @@ function createOutput(options) {
|
|
|
549
528
|
}
|
|
550
529
|
function fileToMeta(file) {
|
|
551
530
|
return {
|
|
552
|
-
|
|
531
|
+
path: file.path,
|
|
532
|
+
absolutePath: file.absolutePath,
|
|
533
|
+
get file() {
|
|
534
|
+
return parseFilePath(this.path);
|
|
535
|
+
},
|
|
553
536
|
data: file.data
|
|
554
537
|
};
|
|
555
538
|
}
|
|
556
539
|
function fileToPage(file, getUrl, locale) {
|
|
557
540
|
return {
|
|
558
|
-
file
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
541
|
+
get file() {
|
|
542
|
+
return parseFilePath(this.path);
|
|
543
|
+
},
|
|
544
|
+
absolutePath: file.absolutePath,
|
|
545
|
+
path: file.path,
|
|
546
|
+
url: getUrl(file.slugs, locale),
|
|
547
|
+
slugs: file.slugs,
|
|
548
|
+
data: file.data,
|
|
562
549
|
locale
|
|
563
550
|
};
|
|
564
551
|
}
|
|
565
552
|
export {
|
|
566
|
-
|
|
553
|
+
FileSystem,
|
|
567
554
|
createGetUrl,
|
|
568
555
|
createPageTreeBuilder,
|
|
569
556
|
getSlugs,
|
package/dist/toc.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-core",
|
|
3
|
-
"version": "15.5.
|
|
3
|
+
"version": "15.5.2",
|
|
4
4
|
"description": "The library for building a documentation website in Next.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
@@ -87,37 +87,37 @@
|
|
|
87
87
|
"dependencies": {
|
|
88
88
|
"@formatjs/intl-localematcher": "^0.6.1",
|
|
89
89
|
"@orama/orama": "^3.1.6",
|
|
90
|
-
"@shikijs/rehype": "^3.
|
|
91
|
-
"@shikijs/transformers": "^3.
|
|
90
|
+
"@shikijs/rehype": "^3.6.0",
|
|
91
|
+
"@shikijs/transformers": "^3.6.0",
|
|
92
92
|
"github-slugger": "^2.0.0",
|
|
93
93
|
"hast-util-to-estree": "^3.1.3",
|
|
94
94
|
"hast-util-to-jsx-runtime": "^2.3.6",
|
|
95
95
|
"image-size": "^2.0.2",
|
|
96
96
|
"negotiator": "^1.0.0",
|
|
97
|
-
"react-remove-scroll": "^2.
|
|
97
|
+
"react-remove-scroll": "^2.7.1",
|
|
98
98
|
"remark": "^15.0.0",
|
|
99
99
|
"remark-gfm": "^4.0.1",
|
|
100
100
|
"remark-rehype": "^11.1.2",
|
|
101
101
|
"scroll-into-view-if-needed": "^3.1.0",
|
|
102
|
-
"shiki": "^3.
|
|
102
|
+
"shiki": "^3.6.0",
|
|
103
103
|
"unist-util-visit": "^5.0.0"
|
|
104
104
|
},
|
|
105
105
|
"devDependencies": {
|
|
106
106
|
"@mdx-js/mdx": "^3.1.0",
|
|
107
107
|
"@oramacloud/client": "^2.1.4",
|
|
108
|
-
"@tanstack/react-router": "^1.
|
|
108
|
+
"@tanstack/react-router": "^1.121.2",
|
|
109
109
|
"@types/estree-jsx": "^1.0.5",
|
|
110
110
|
"@types/hast": "^3.0.4",
|
|
111
111
|
"@types/mdast": "^4.0.3",
|
|
112
|
-
"@types/negotiator": "^0.6.
|
|
113
|
-
"@types/node": "
|
|
114
|
-
"@types/react": "^19.1.
|
|
115
|
-
"@types/react-dom": "^19.1.
|
|
116
|
-
"algoliasearch": "5.
|
|
112
|
+
"@types/negotiator": "^0.6.4",
|
|
113
|
+
"@types/node": "24.0.1",
|
|
114
|
+
"@types/react": "^19.1.8",
|
|
115
|
+
"@types/react-dom": "^19.1.6",
|
|
116
|
+
"algoliasearch": "5.27.0",
|
|
117
117
|
"mdast-util-mdx-jsx": "^3.2.0",
|
|
118
118
|
"mdast-util-mdxjs-esm": "^2.0.1",
|
|
119
119
|
"next": "^15.3.3",
|
|
120
|
-
"react-router": "^7.6.
|
|
120
|
+
"react-router": "^7.6.2",
|
|
121
121
|
"remark-mdx": "^3.1.0",
|
|
122
122
|
"typescript": "^5.8.3",
|
|
123
123
|
"unified": "^11.0.5",
|
|
@@ -130,9 +130,13 @@
|
|
|
130
130
|
"algoliasearch": "5.x.x",
|
|
131
131
|
"next": "14.x.x || 15.x.x",
|
|
132
132
|
"react": "18.x.x || 19.x.x",
|
|
133
|
-
"react-dom": "18.x.x || 19.x.x"
|
|
133
|
+
"react-dom": "18.x.x || 19.x.x",
|
|
134
|
+
"@types/react": "*"
|
|
134
135
|
},
|
|
135
136
|
"peerDependenciesMeta": {
|
|
137
|
+
"@types/react": {
|
|
138
|
+
"optional": true
|
|
139
|
+
},
|
|
136
140
|
"@oramacloud/client": {
|
|
137
141
|
"optional": true
|
|
138
142
|
},
|