fumadocs-core 12.4.2 → 12.5.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/breadcrumb.d.ts
CHANGED
|
@@ -5,7 +5,17 @@ interface BreadcrumbItem {
|
|
|
5
5
|
name: ReactNode;
|
|
6
6
|
url?: string;
|
|
7
7
|
}
|
|
8
|
-
interface BreadcrumbOptions {
|
|
8
|
+
interface BreadcrumbOptions extends SearchOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Include the root itself in the breadcrumb items array
|
|
11
|
+
*
|
|
12
|
+
* @defaultValue false
|
|
13
|
+
*/
|
|
14
|
+
includeRoot?: boolean;
|
|
15
|
+
}
|
|
16
|
+
declare function useBreadcrumb(url: string, tree: Root, options?: BreadcrumbOptions): BreadcrumbItem[];
|
|
17
|
+
declare function getBreadcrumbItems(url: string, tree: Root, options?: BreadcrumbOptions): BreadcrumbItem[];
|
|
18
|
+
interface SearchOptions {
|
|
9
19
|
/**
|
|
10
20
|
* Include the page itself in the breadcrumb items array
|
|
11
21
|
*
|
|
@@ -19,7 +29,5 @@ interface BreadcrumbOptions {
|
|
|
19
29
|
*/
|
|
20
30
|
includeSeparator?: boolean;
|
|
21
31
|
}
|
|
22
|
-
declare function useBreadcrumb(url: string, tree: Root, options?: BreadcrumbOptions): BreadcrumbItem[];
|
|
23
|
-
declare function getBreadcrumbItems(url: string, tree: Root, options?: BreadcrumbOptions): BreadcrumbItem[];
|
|
24
32
|
|
|
25
33
|
export { type BreadcrumbItem, type BreadcrumbOptions, getBreadcrumbItems, useBreadcrumb };
|
package/dist/breadcrumb.js
CHANGED
|
@@ -1,26 +1,33 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
__objRest
|
|
3
|
+
} from "./chunk-CWMXXUWU.js";
|
|
2
4
|
|
|
3
5
|
// src/breadcrumb.tsx
|
|
4
6
|
import { useMemo } from "react";
|
|
5
|
-
function useBreadcrumb(url, tree, options
|
|
7
|
+
function useBreadcrumb(url, tree, options) {
|
|
6
8
|
return useMemo(
|
|
7
9
|
() => getBreadcrumbItems(url, tree, options),
|
|
8
10
|
[tree, url, options]
|
|
9
11
|
);
|
|
10
12
|
}
|
|
11
13
|
function getBreadcrumbItems(url, tree, options = {}) {
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
var _b, _c;
|
|
15
|
+
const _a = options, { includeRoot } = _a, rest = __objRest(_a, ["includeRoot"]);
|
|
16
|
+
const path = (_b = searchPath(tree.children, url, rest)) != null ? _b : [];
|
|
17
|
+
if (includeRoot) {
|
|
18
|
+
path.unshift({
|
|
19
|
+
name: tree.name,
|
|
20
|
+
url: (_c = tree.children.find((p) => p.type === "page")) == null ? void 0 : _c.url
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return path;
|
|
17
24
|
}
|
|
18
25
|
function searchPath(nodes, url, options) {
|
|
19
26
|
var _a, _b;
|
|
27
|
+
const { includePage = true, includeSeparator = false } = options;
|
|
20
28
|
let separator;
|
|
21
29
|
for (const node of nodes) {
|
|
22
|
-
if (
|
|
23
|
-
separator = node.name;
|
|
30
|
+
if (includeSeparator && node.type === "separator") separator = node.name;
|
|
24
31
|
if (node.type === "folder") {
|
|
25
32
|
if (((_a = node.index) == null ? void 0 : _a.url) === url) {
|
|
26
33
|
const items2 = [];
|
|
@@ -45,7 +52,7 @@ function searchPath(nodes, url, options) {
|
|
|
45
52
|
if (node.type === "page" && node.url === url) {
|
|
46
53
|
const items = [];
|
|
47
54
|
if (separator) items.push({ name: separator });
|
|
48
|
-
if (
|
|
55
|
+
if (includePage)
|
|
49
56
|
items.push({
|
|
50
57
|
name: node.name,
|
|
51
58
|
url: node.url
|
|
@@ -14,32 +14,54 @@ interface DocumentRecord {
|
|
|
14
14
|
*/
|
|
15
15
|
url: string;
|
|
16
16
|
structured: StructuredData;
|
|
17
|
+
/**
|
|
18
|
+
* Tag to filter results
|
|
19
|
+
*/
|
|
20
|
+
tag?: string;
|
|
17
21
|
/**
|
|
18
22
|
* Data to be added to each section index
|
|
19
23
|
*/
|
|
20
24
|
extra_data?: object;
|
|
21
25
|
}
|
|
22
26
|
interface SyncOptions {
|
|
27
|
+
/**
|
|
28
|
+
* Index Name for documents
|
|
29
|
+
*/
|
|
23
30
|
document?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Search indexes
|
|
33
|
+
*/
|
|
24
34
|
documents: DocumentRecord[];
|
|
25
35
|
}
|
|
26
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Update index settings and replace all objects
|
|
38
|
+
*
|
|
39
|
+
* @param client - Algolia Admin Client
|
|
40
|
+
* @param options - Index Options
|
|
41
|
+
*/
|
|
42
|
+
declare function sync(client: SearchClient, options: SyncOptions): Promise<void>;
|
|
27
43
|
declare function setIndexSettings(index: SearchIndex): Promise<void>;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
url: string;
|
|
44
|
+
interface Section {
|
|
45
|
+
/**
|
|
46
|
+
* Heading content
|
|
47
|
+
*/
|
|
33
48
|
section?: string;
|
|
34
49
|
/**
|
|
35
50
|
* The anchor id
|
|
36
51
|
*/
|
|
37
52
|
section_id?: string;
|
|
53
|
+
content: string;
|
|
54
|
+
}
|
|
55
|
+
declare function updateDocuments(index: SearchIndex, documents: DocumentRecord[]): Promise<void>;
|
|
56
|
+
interface BaseIndex extends Section {
|
|
57
|
+
objectID: string;
|
|
58
|
+
title: string;
|
|
59
|
+
url: string;
|
|
60
|
+
tag?: string;
|
|
38
61
|
/**
|
|
39
62
|
* The id of page, used for distinct
|
|
40
63
|
*/
|
|
41
64
|
page_id: string;
|
|
42
|
-
content: string;
|
|
43
65
|
}
|
|
44
66
|
|
|
45
67
|
export { type BaseIndex, type SyncOptions, setIndexSettings, sync, updateDocuments };
|
|
@@ -4,9 +4,9 @@ import {
|
|
|
4
4
|
} from "../chunk-CWMXXUWU.js";
|
|
5
5
|
|
|
6
6
|
// src/search-algolia/server.ts
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
function sync(client, options) {
|
|
8
|
+
return __async(this, null, function* () {
|
|
9
|
+
const { document = "document", documents } = options;
|
|
10
10
|
const index = client.initIndex(document);
|
|
11
11
|
yield setIndexSettings(index);
|
|
12
12
|
yield updateDocuments(index, documents);
|
|
@@ -50,11 +50,12 @@ function updateDocuments(index, documents) {
|
|
|
50
50
|
return __async(this, null, function* () {
|
|
51
51
|
const objects = documents.flatMap((page) => {
|
|
52
52
|
return getSections(page).map(
|
|
53
|
-
(section) => __spreadValues(__spreadValues({
|
|
54
|
-
objectID: `${page._id}-${
|
|
53
|
+
(section, idx) => __spreadValues(__spreadValues({
|
|
54
|
+
objectID: `${page._id}-${idx.toString()}`,
|
|
55
55
|
title: page.title,
|
|
56
56
|
url: page.url,
|
|
57
|
-
page_id: page._id
|
|
57
|
+
page_id: page._id,
|
|
58
|
+
tag: page.tag
|
|
58
59
|
}, section), page.extra_data)
|
|
59
60
|
);
|
|
60
61
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-core",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.5.1",
|
|
4
4
|
"description": "The library for building a documentation website in Next.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
@@ -120,8 +120,8 @@
|
|
|
120
120
|
],
|
|
121
121
|
"dependencies": {
|
|
122
122
|
"@formatjs/intl-localematcher": "^0.5.4",
|
|
123
|
-
"@shikijs/rehype": "^1.10.
|
|
124
|
-
"@shikijs/transformers": "^1.10.
|
|
123
|
+
"@shikijs/rehype": "^1.10.3",
|
|
124
|
+
"@shikijs/transformers": "^1.10.3",
|
|
125
125
|
"flexsearch": "0.7.21",
|
|
126
126
|
"github-slugger": "^2.0.0",
|
|
127
127
|
"negotiator": "^0.6.3",
|
|
@@ -131,7 +131,7 @@
|
|
|
131
131
|
"remark-gfm": "^4.0.0",
|
|
132
132
|
"remark-mdx": "^3.0.1",
|
|
133
133
|
"scroll-into-view-if-needed": "^3.1.0",
|
|
134
|
-
"shiki": "^1.10.
|
|
134
|
+
"shiki": "^1.10.3",
|
|
135
135
|
"swr": "^2.2.5",
|
|
136
136
|
"unist-util-visit": "^5.0.0"
|
|
137
137
|
},
|
|
@@ -143,11 +143,11 @@
|
|
|
143
143
|
"@types/hast": "^3.0.4",
|
|
144
144
|
"@types/mdast": "^4.0.3",
|
|
145
145
|
"@types/negotiator": "^0.6.3",
|
|
146
|
-
"@types/node": "20.14.
|
|
146
|
+
"@types/node": "20.14.10",
|
|
147
147
|
"@types/react": "^18.3.3",
|
|
148
148
|
"@types/react-dom": "^18.3.0",
|
|
149
149
|
"algoliasearch": "^4.24.0",
|
|
150
|
-
"next": "^14.2.
|
|
150
|
+
"next": "^14.2.5",
|
|
151
151
|
"unified": "^11.0.5",
|
|
152
152
|
"eslint-config-custom": "0.0.0",
|
|
153
153
|
"tsconfig": "0.0.0"
|