fumadocs-core 12.0.3 → 12.0.5
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 +21 -7
- package/dist/breadcrumb.js +32 -18
- package/dist/{get-toc-B-AMfFKT.d.ts → get-toc-CM4X3hbw.d.ts} +3 -1
- package/dist/{page-tree-_z0bnHIU.d.ts → page-tree-BTCDMLTU.d.ts} +5 -5
- package/dist/server/index.d.ts +3 -3
- package/dist/source/index.d.ts +1 -1
- package/dist/toc-internal.d.ts +1 -1
- package/dist/toc.d.ts +1 -1
- package/package.json +1 -1
package/dist/breadcrumb.d.ts
CHANGED
|
@@ -1,11 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import '
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { R as Root } from './page-tree-BTCDMLTU.js';
|
|
3
3
|
|
|
4
4
|
interface BreadcrumbItem {
|
|
5
|
-
name:
|
|
6
|
-
url
|
|
5
|
+
name: ReactNode;
|
|
6
|
+
url?: string;
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
interface BreadcrumbOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Include the page itself in the breadcrumb items array
|
|
11
|
+
*
|
|
12
|
+
* @defaultValue true
|
|
13
|
+
*/
|
|
14
|
+
includePage?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Count separator as an item
|
|
17
|
+
*
|
|
18
|
+
* @defaultValue false
|
|
19
|
+
*/
|
|
20
|
+
includeSeparator?: boolean;
|
|
21
|
+
}
|
|
22
|
+
declare function useBreadcrumb(url: string, tree: Root, options?: BreadcrumbOptions): BreadcrumbItem[];
|
|
23
|
+
declare function getBreadcrumbItems(url: string, tree: Root, options?: BreadcrumbOptions): BreadcrumbItem[];
|
|
10
24
|
|
|
11
|
-
export { type BreadcrumbItem, getBreadcrumbItems, useBreadcrumb };
|
|
25
|
+
export { type BreadcrumbItem, type BreadcrumbOptions, getBreadcrumbItems, useBreadcrumb };
|
package/dist/breadcrumb.js
CHANGED
|
@@ -2,41 +2,55 @@ import "./chunk-CWMXXUWU.js";
|
|
|
2
2
|
|
|
3
3
|
// src/breadcrumb.tsx
|
|
4
4
|
import { useMemo } from "react";
|
|
5
|
-
function useBreadcrumb(url, tree) {
|
|
6
|
-
return useMemo(
|
|
5
|
+
function useBreadcrumb(url, tree, options = {}) {
|
|
6
|
+
return useMemo(
|
|
7
|
+
() => getBreadcrumbItems(url, tree, options),
|
|
8
|
+
[tree, url, options]
|
|
9
|
+
);
|
|
7
10
|
}
|
|
8
|
-
function getBreadcrumbItems(url, tree) {
|
|
9
|
-
var _a;
|
|
10
|
-
return (
|
|
11
|
+
function getBreadcrumbItems(url, tree, options = {}) {
|
|
12
|
+
var _a, _b, _c;
|
|
13
|
+
return (_c = searchPath(tree.children, url, {
|
|
14
|
+
includePage: (_a = options.includePage) != null ? _a : true,
|
|
15
|
+
includeSeparator: (_b = options.includeSeparator) != null ? _b : false
|
|
16
|
+
})) != null ? _c : [];
|
|
11
17
|
}
|
|
12
|
-
function searchPath(nodes, url) {
|
|
18
|
+
function searchPath(nodes, url, options) {
|
|
13
19
|
var _a, _b;
|
|
20
|
+
let separator;
|
|
14
21
|
for (const node of nodes) {
|
|
22
|
+
if (options.includeSeparator && node.type === "separator")
|
|
23
|
+
separator = node.name;
|
|
15
24
|
if (node.type === "folder") {
|
|
16
|
-
if (node.index
|
|
17
|
-
|
|
18
|
-
|
|
25
|
+
if (((_a = node.index) == null ? void 0 : _a.url) === url) {
|
|
26
|
+
const items2 = [];
|
|
27
|
+
if (separator) items2.push({ name: separator });
|
|
28
|
+
if (options.includePage)
|
|
29
|
+
items2.push({
|
|
19
30
|
name: node.index.name,
|
|
20
31
|
url: node.index.url
|
|
21
|
-
}
|
|
22
|
-
|
|
32
|
+
});
|
|
33
|
+
return items2;
|
|
23
34
|
}
|
|
24
|
-
const items = searchPath(node.children, url);
|
|
25
|
-
if (items
|
|
35
|
+
const items = searchPath(node.children, url, options);
|
|
36
|
+
if (items) {
|
|
26
37
|
items.unshift({
|
|
27
38
|
name: node.name,
|
|
28
|
-
url: (_b =
|
|
39
|
+
url: (_b = node.index) == null ? void 0 : _b.url
|
|
29
40
|
});
|
|
41
|
+
if (separator) items.unshift({ name: separator });
|
|
30
42
|
return items;
|
|
31
43
|
}
|
|
32
44
|
}
|
|
33
45
|
if (node.type === "page" && node.url === url) {
|
|
34
|
-
|
|
35
|
-
|
|
46
|
+
const items = [];
|
|
47
|
+
if (separator) items.push({ name: separator });
|
|
48
|
+
if (options.includePage)
|
|
49
|
+
items.push({
|
|
36
50
|
name: node.name,
|
|
37
51
|
url: node.url
|
|
38
|
-
}
|
|
39
|
-
|
|
52
|
+
});
|
|
53
|
+
return items;
|
|
40
54
|
}
|
|
41
55
|
}
|
|
42
56
|
return null;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
1
|
+
import { ReactNode, ReactElement } from 'react';
|
|
2
2
|
|
|
3
3
|
interface Root {
|
|
4
|
-
name:
|
|
4
|
+
name: ReactNode;
|
|
5
5
|
children: Node[];
|
|
6
6
|
}
|
|
7
7
|
type Node = Item | Separator | Folder;
|
|
8
8
|
interface Item {
|
|
9
9
|
type: 'page';
|
|
10
|
-
name:
|
|
10
|
+
name: ReactNode;
|
|
11
11
|
url: string;
|
|
12
12
|
external?: boolean;
|
|
13
13
|
icon?: ReactElement;
|
|
14
14
|
}
|
|
15
15
|
interface Separator {
|
|
16
16
|
type: 'separator';
|
|
17
|
-
name:
|
|
17
|
+
name: ReactNode;
|
|
18
18
|
}
|
|
19
19
|
interface Folder {
|
|
20
20
|
/**
|
|
@@ -22,7 +22,7 @@ interface Folder {
|
|
|
22
22
|
*/
|
|
23
23
|
id?: string;
|
|
24
24
|
type: 'folder';
|
|
25
|
-
name:
|
|
25
|
+
name: ReactNode;
|
|
26
26
|
root?: boolean;
|
|
27
27
|
defaultOpen?: boolean;
|
|
28
28
|
index?: Item;
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { a as TOCItemType, T as TableOfContents, g as getTableOfContents } from '../get-toc-
|
|
2
|
-
import { N as Node, I as Item, R as Root } from '../page-tree-
|
|
3
|
-
export { p as PageTree } from '../page-tree-
|
|
1
|
+
export { a as TOCItemType, T as TableOfContents, g as getTableOfContents } from '../get-toc-CM4X3hbw.js';
|
|
2
|
+
import { N as Node, I as Item, R as Root } from '../page-tree-BTCDMLTU.js';
|
|
3
|
+
export { p as PageTree } from '../page-tree-BTCDMLTU.js';
|
|
4
4
|
import 'react';
|
|
5
5
|
|
|
6
6
|
/**
|
package/dist/source/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
|
-
import { R as Root, I as Item, F as Folder$1, S as Separator } from '../page-tree-
|
|
2
|
+
import { R as Root, I as Item, F as Folder$1, S as Separator } from '../page-tree-BTCDMLTU.js';
|
|
3
3
|
|
|
4
4
|
interface FileInfo {
|
|
5
5
|
locale?: string;
|
package/dist/toc-internal.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode, RefObject, AnchorHTMLAttributes } from 'react';
|
|
3
|
-
import { T as TableOfContents } from './get-toc-
|
|
3
|
+
import { T as TableOfContents } from './get-toc-CM4X3hbw.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* The id of active anchor (doesn't include hash)
|
package/dist/toc.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { HTMLAttributes, RefObject, ReactNode, AnchorHTMLAttributes } from 'react';
|
|
3
|
-
import { T as TableOfContents } from './get-toc-
|
|
3
|
+
import { T as TableOfContents } from './get-toc-CM4X3hbw.js';
|
|
4
4
|
|
|
5
5
|
declare const useActiveAnchor: (url: string) => boolean;
|
|
6
6
|
interface TOCProviderProps extends HTMLAttributes<HTMLDivElement> {
|