fumadocs-core 10.0.0 → 10.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-GT3Y35O6.js → chunk-M6ZDX3QR.js} +2 -2
- package/dist/mdx-plugins/index.js +1 -1
- package/dist/search/client.d.ts +6 -1
- package/dist/search/client.js +3 -5
- package/dist/search/server.js +7 -7
- package/dist/search-algolia/client.js +1 -1
- package/dist/search-algolia/server.d.ts +1 -1
- package/dist/server/index.js +1 -1
- package/dist/source/index.d.ts +5 -5
- package/dist/source/index.js +17 -6
- package/package.json +16 -17
|
@@ -21,12 +21,12 @@ function remarkHeading() {
|
|
|
21
21
|
const toc = [];
|
|
22
22
|
slugger.reset();
|
|
23
23
|
visit(node, ["heading"], (heading) => {
|
|
24
|
-
var _a;
|
|
24
|
+
var _a, _b;
|
|
25
25
|
heading.data || (heading.data = {});
|
|
26
26
|
(_a = heading.data).hProperties || (_a.hProperties = {});
|
|
27
27
|
const text = flattenNode(heading);
|
|
28
28
|
const properties = heading.data.hProperties;
|
|
29
|
-
const id = slugger.slug(properties.id
|
|
29
|
+
const id = slugger.slug((_b = properties.id) != null ? _b : text);
|
|
30
30
|
properties.id = id;
|
|
31
31
|
toc.push({
|
|
32
32
|
title: text,
|
package/dist/search/client.d.ts
CHANGED
|
@@ -8,6 +8,11 @@ interface UseDocsSearch {
|
|
|
8
8
|
keepPreviousData: true;
|
|
9
9
|
}>;
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* @param locale - Filter with locale
|
|
13
|
+
* @param tag - Filter with specific tag
|
|
14
|
+
* @param api - The Search API URL
|
|
15
|
+
*/
|
|
16
|
+
declare function useDocsSearch(locale?: string, tag?: string, api?: string): UseDocsSearch;
|
|
12
17
|
|
|
13
18
|
export { useDocsSearch };
|
package/dist/search/client.js
CHANGED
|
@@ -21,14 +21,12 @@ function fetchDocs(api, query, locale, tag) {
|
|
|
21
21
|
return yield res.json();
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
-
function useDocsSearch(locale, tag) {
|
|
24
|
+
function useDocsSearch(locale, tag, api = "/api/search") {
|
|
25
25
|
const [search, setSearch] = useState("");
|
|
26
26
|
const debouncedValue = useDebounce(search, 100);
|
|
27
27
|
const query = useSWR(
|
|
28
|
-
[
|
|
29
|
-
(
|
|
30
|
-
return fetchDocs(api, value, locale, tag);
|
|
31
|
-
}),
|
|
28
|
+
[api, debouncedValue, locale, tag],
|
|
29
|
+
(args) => fetchDocs(...args),
|
|
32
30
|
{
|
|
33
31
|
keepPreviousData: true
|
|
34
32
|
}
|
package/dist/search/server.js
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
|
|
6
6
|
// src/search/server.ts
|
|
7
7
|
import { Document } from "flexsearch";
|
|
8
|
-
import
|
|
8
|
+
import { NextResponse } from "next/server";
|
|
9
9
|
function createSearchAPI(type, options) {
|
|
10
10
|
if (type === "simple") {
|
|
11
11
|
return initSearchAPI(options);
|
|
@@ -32,7 +32,7 @@ function createI18nSearchAPI(type, options) {
|
|
|
32
32
|
if (handler)
|
|
33
33
|
return handler.GET(request);
|
|
34
34
|
}
|
|
35
|
-
return
|
|
35
|
+
return NextResponse.json([]);
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
}
|
|
@@ -80,20 +80,20 @@ function initSearchAPI({ indexes, language }) {
|
|
|
80
80
|
const { searchParams } = request.nextUrl;
|
|
81
81
|
const query = searchParams.get("query");
|
|
82
82
|
if (!query)
|
|
83
|
-
return
|
|
83
|
+
return NextResponse.json([]);
|
|
84
84
|
const results = index.search(query, 5, {
|
|
85
85
|
enrich: true,
|
|
86
86
|
suggest: true
|
|
87
87
|
});
|
|
88
88
|
if (results.length === 0)
|
|
89
|
-
return
|
|
89
|
+
return NextResponse.json([]);
|
|
90
90
|
const pages = results[0].result.map((page) => ({
|
|
91
91
|
type: "page",
|
|
92
92
|
content: page.doc.title,
|
|
93
93
|
id: page.doc.url,
|
|
94
94
|
url: page.doc.url
|
|
95
95
|
}));
|
|
96
|
-
return
|
|
96
|
+
return NextResponse.json(pages);
|
|
97
97
|
}
|
|
98
98
|
};
|
|
99
99
|
}
|
|
@@ -158,7 +158,7 @@ function initSearchAPIAdvanced({
|
|
|
158
158
|
const query = request.nextUrl.searchParams.get("query");
|
|
159
159
|
const paramTag = request.nextUrl.searchParams.get("tag");
|
|
160
160
|
if (!query)
|
|
161
|
-
return
|
|
161
|
+
return NextResponse.json([]);
|
|
162
162
|
const results = index.search(query, 5, {
|
|
163
163
|
enrich: true,
|
|
164
164
|
tag: paramTag != null ? paramTag : void 0,
|
|
@@ -197,7 +197,7 @@ function initSearchAPIAdvanced({
|
|
|
197
197
|
});
|
|
198
198
|
sortedResult.push(...items);
|
|
199
199
|
}
|
|
200
|
-
return
|
|
200
|
+
return NextResponse.json(sortedResult);
|
|
201
201
|
}
|
|
202
202
|
};
|
|
203
203
|
}
|
|
@@ -49,7 +49,7 @@ function useAlgoliaSearch(index, _a = {}) {
|
|
|
49
49
|
var _b = _a, { allowEmpty = true } = _b, options = __objRest(_b, ["allowEmpty"]);
|
|
50
50
|
const [search, setSearch] = useState("");
|
|
51
51
|
const query = useSWR(
|
|
52
|
-
["
|
|
52
|
+
["algolia-search", search, allowEmpty, options],
|
|
53
53
|
() => __async(this, null, function* () {
|
|
54
54
|
if (allowEmpty && search.length === 0)
|
|
55
55
|
return "empty";
|
package/dist/server/index.js
CHANGED
package/dist/source/index.d.ts
CHANGED
|
@@ -17,6 +17,8 @@ interface FileInfo {
|
|
|
17
17
|
name: string;
|
|
18
18
|
dirname: string;
|
|
19
19
|
}
|
|
20
|
+
declare function parseFilePath(path: string): FileInfo;
|
|
21
|
+
declare function parseFolderPath(path: string): FileInfo;
|
|
20
22
|
|
|
21
23
|
interface LoadOptions {
|
|
22
24
|
files: VirtualFile[];
|
|
@@ -30,15 +32,11 @@ interface VirtualFile {
|
|
|
30
32
|
type: 'page' | 'meta';
|
|
31
33
|
data: unknown;
|
|
32
34
|
}
|
|
33
|
-
interface LoadResult {
|
|
34
|
-
storage: Storage;
|
|
35
|
-
}
|
|
36
35
|
type Transformer = (context: {
|
|
37
36
|
storage: Storage;
|
|
38
37
|
getSlugs: (info: FileInfo) => string[];
|
|
39
38
|
getUrl: (slugs: string[], locale?: string) => string;
|
|
40
39
|
}) => void;
|
|
41
|
-
declare function load(options: LoadOptions): LoadResult;
|
|
42
40
|
|
|
43
41
|
interface LoaderConfig {
|
|
44
42
|
source: SourceConfig;
|
|
@@ -85,6 +83,8 @@ interface LoaderOutput<Config extends LoaderConfig> {
|
|
|
85
83
|
*/
|
|
86
84
|
getPage: (slugs: string[] | undefined, language?: string) => Page<Config['source']['pageData']> | undefined;
|
|
87
85
|
}
|
|
86
|
+
declare function createGetUrl(baseUrl: string): (slugs: string[], locale?: string) => string;
|
|
87
|
+
declare function getSlugs(info: FileInfo): string[];
|
|
88
88
|
type InferSourceConfig<T> = T extends Source<infer Config> ? Config : never;
|
|
89
89
|
declare function loader<Options extends LoaderOptions>(options: Options): LoaderOutput<{
|
|
90
90
|
source: InferSourceConfig<Options['source']>;
|
|
@@ -176,4 +176,4 @@ interface CreatePageTreeBuilderOptions {
|
|
|
176
176
|
}
|
|
177
177
|
declare function createPageTreeBuilder({ storage, resolveIcon, }: CreatePageTreeBuilderOptions): PageTreeBuilder;
|
|
178
178
|
|
|
179
|
-
export { type BuildPageTreeOptionsWithI18n, type CreatePageTreeBuilderOptions, fileSystem as FileSystem, type InferMetaType, type InferPageType, type LoadOptions, type
|
|
179
|
+
export { type BuildPageTreeOptionsWithI18n, type CreatePageTreeBuilderOptions, type FileInfo, fileSystem as FileSystem, type InferMetaType, type InferPageType, type LoadOptions, type LoaderConfig, type LoaderOptions, type LoaderOutput, type MetaData, type PageData, type PageTreeBuilder, type Source, type SourceConfig, type Transformer, type VirtualFile, createGetUrl, createPageTreeBuilder, getSlugs, loader, parseFilePath, parseFolderPath };
|
package/dist/source/index.js
CHANGED
|
@@ -151,7 +151,7 @@ function buildFolderNode(folder, defaultIsRoot, ctx) {
|
|
|
151
151
|
});
|
|
152
152
|
children = nodes != null ? nodes : restNodes;
|
|
153
153
|
}
|
|
154
|
-
return {
|
|
154
|
+
return removeUndefined({
|
|
155
155
|
type: "folder",
|
|
156
156
|
name: (_e = (_d = meta == null ? void 0 : meta.title) != null ? _d : index == null ? void 0 : index.name) != null ? _e : pathToName(folder.file.name),
|
|
157
157
|
icon: ctx.resolveIcon(meta == null ? void 0 : meta.icon),
|
|
@@ -159,7 +159,7 @@ function buildFolderNode(folder, defaultIsRoot, ctx) {
|
|
|
159
159
|
defaultOpen: meta == null ? void 0 : meta.defaultOpen,
|
|
160
160
|
index,
|
|
161
161
|
children
|
|
162
|
-
};
|
|
162
|
+
});
|
|
163
163
|
}
|
|
164
164
|
function buildFileNode(page, ctx) {
|
|
165
165
|
let localePage = page;
|
|
@@ -170,12 +170,12 @@ function buildFileNode(page, ctx) {
|
|
|
170
170
|
if (result)
|
|
171
171
|
localePage = result;
|
|
172
172
|
}
|
|
173
|
-
return {
|
|
173
|
+
return removeUndefined({
|
|
174
174
|
type: "page",
|
|
175
175
|
name: localePage.data.title,
|
|
176
176
|
icon: ctx.resolveIcon(localePage.data.icon),
|
|
177
177
|
url: localePage.url
|
|
178
|
-
};
|
|
178
|
+
});
|
|
179
179
|
}
|
|
180
180
|
function build(ctx) {
|
|
181
181
|
const root = ctx.storage.root();
|
|
@@ -217,6 +217,14 @@ function createPageTreeBuilder({
|
|
|
217
217
|
function pathToName(path2) {
|
|
218
218
|
return path2.slice(0, 1).toUpperCase() + path2.slice(1);
|
|
219
219
|
}
|
|
220
|
+
function removeUndefined(value) {
|
|
221
|
+
const obj = value;
|
|
222
|
+
Object.keys(obj).forEach((key) => {
|
|
223
|
+
if (obj[key] === void 0)
|
|
224
|
+
delete obj[key];
|
|
225
|
+
});
|
|
226
|
+
return value;
|
|
227
|
+
}
|
|
220
228
|
|
|
221
229
|
// src/source/load.ts
|
|
222
230
|
import * as path from "path";
|
|
@@ -411,7 +419,10 @@ function createOutput({
|
|
|
411
419
|
}
|
|
412
420
|
export {
|
|
413
421
|
file_system_exports as FileSystem,
|
|
422
|
+
createGetUrl,
|
|
414
423
|
createPageTreeBuilder,
|
|
415
|
-
|
|
416
|
-
loader
|
|
424
|
+
getSlugs,
|
|
425
|
+
loader,
|
|
426
|
+
parseFilePath,
|
|
427
|
+
parseFolderPath
|
|
417
428
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-core",
|
|
3
|
-
"version": "10.0.
|
|
3
|
+
"version": "10.0.1",
|
|
4
4
|
"description": "The library for building a documentation website in Next.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
@@ -108,40 +108,39 @@
|
|
|
108
108
|
"dist/*"
|
|
109
109
|
],
|
|
110
110
|
"dependencies": {
|
|
111
|
-
"@formatjs/intl-localematcher": "^0.5.
|
|
112
|
-
"@shikijs/rehype": "1.1.7",
|
|
113
|
-
"@shikijs/transformers": "1.1.7",
|
|
114
|
-
"flexsearch": "0.7.
|
|
111
|
+
"@formatjs/intl-localematcher": "^0.5.4",
|
|
112
|
+
"@shikijs/rehype": "^1.1.7",
|
|
113
|
+
"@shikijs/transformers": "^1.1.7",
|
|
114
|
+
"flexsearch": "^0.7.43",
|
|
115
115
|
"github-slugger": "^2.0.0",
|
|
116
116
|
"hast-util-to-estree": "^3.1.0",
|
|
117
117
|
"negotiator": "^0.6.3",
|
|
118
|
-
"react-remove-scroll": "^2.5.
|
|
118
|
+
"react-remove-scroll": "^2.5.7",
|
|
119
119
|
"remark": "^15.0.0",
|
|
120
120
|
"remark-gfm": "^4.0.0",
|
|
121
|
-
"remark-mdx": "^3.0.
|
|
121
|
+
"remark-mdx": "^3.0.1",
|
|
122
122
|
"scroll-into-view-if-needed": "^3.1.0",
|
|
123
|
-
"shiki": "1.1.7",
|
|
124
|
-
"swr": "^2.2.
|
|
123
|
+
"shiki": "^1.1.7",
|
|
124
|
+
"swr": "^2.2.5",
|
|
125
125
|
"unist-util-visit": "^5.0.0"
|
|
126
126
|
},
|
|
127
127
|
"devDependencies": {
|
|
128
|
-
"@algolia/client-search": "^4.
|
|
129
|
-
"@next/eslint-plugin-next": "^14.0.0",
|
|
128
|
+
"@algolia/client-search": "^4.22.1",
|
|
130
129
|
"@types/flexsearch": "0.7.6",
|
|
131
130
|
"@types/hast": "^3.0.4",
|
|
132
131
|
"@types/mdast": "^4.0.3",
|
|
133
|
-
"@types/negotiator": "^0.6.
|
|
132
|
+
"@types/negotiator": "^0.6.3",
|
|
134
133
|
"@types/node": "18.17.5",
|
|
135
|
-
"@types/react": "18.2.0",
|
|
136
|
-
"@types/react-dom": "18.2.1",
|
|
137
|
-
"algoliasearch": "^4.
|
|
138
|
-
"next": "14.1.
|
|
134
|
+
"@types/react": "^18.2.0",
|
|
135
|
+
"@types/react-dom": "^18.2.1",
|
|
136
|
+
"algoliasearch": "^4.22.1",
|
|
137
|
+
"next": "^14.1.2",
|
|
139
138
|
"unified": "^11.0.4",
|
|
140
139
|
"eslint-config-custom": "0.0.0",
|
|
141
140
|
"tsconfig": "0.0.0"
|
|
142
141
|
},
|
|
143
142
|
"peerDependencies": {
|
|
144
|
-
"next": ">=
|
|
143
|
+
"next": ">= 14.1.0",
|
|
145
144
|
"react": ">= 18",
|
|
146
145
|
"react-dom": ">= 18"
|
|
147
146
|
},
|