fumadocs-core 10.0.4 → 10.1.0
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-M6ZDX3QR.js → chunk-D3Y6KNIC.js} +4 -9
- package/dist/mdx-plugins/index.d.ts +8 -3
- package/dist/mdx-plugins/index.js +18 -13
- package/dist/search/server.js +2 -2
- package/dist/server/index.js +1 -1
- package/dist/sidebar.d.ts +3 -3
- package/dist/sidebar.js +3 -1
- package/dist/toc.d.ts +1 -1
- package/package.json +8 -8
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
// src/mdx-plugins/remark-heading.ts
|
|
2
2
|
import Slugger from "github-slugger";
|
|
3
|
-
|
|
4
|
-
// src/mdx-plugins/unist-visit.ts
|
|
5
|
-
import { visit as original } from "unist-util-visit";
|
|
6
|
-
var visit = original;
|
|
3
|
+
import { visit } from "unist-util-visit";
|
|
7
4
|
|
|
8
5
|
// src/mdx-plugins/remark-utils.ts
|
|
9
6
|
function flattenNode(node) {
|
|
@@ -20,14 +17,13 @@ function remarkHeading() {
|
|
|
20
17
|
return (node, file) => {
|
|
21
18
|
const toc = [];
|
|
22
19
|
slugger.reset();
|
|
23
|
-
visit(node,
|
|
20
|
+
visit(node, "heading", (heading) => {
|
|
24
21
|
var _a, _b;
|
|
25
22
|
heading.data || (heading.data = {});
|
|
26
23
|
(_a = heading.data).hProperties || (_a.hProperties = {});
|
|
27
24
|
const text = flattenNode(heading);
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
properties.id = id;
|
|
25
|
+
const id = slugger.slug((_b = heading.data.hProperties.id) != null ? _b : text);
|
|
26
|
+
heading.data.hProperties.id = id;
|
|
31
27
|
toc.push({
|
|
32
28
|
title: text,
|
|
33
29
|
url: `#${id}`,
|
|
@@ -40,7 +36,6 @@ function remarkHeading() {
|
|
|
40
36
|
}
|
|
41
37
|
|
|
42
38
|
export {
|
|
43
|
-
visit,
|
|
44
39
|
flattenNode,
|
|
45
40
|
remarkHeading
|
|
46
41
|
};
|
|
@@ -71,8 +71,12 @@ interface RemarkDynamicContentOptions {
|
|
|
71
71
|
*/
|
|
72
72
|
declare function remarkDynamicContent(options?: RemarkDynamicContentOptions): Transformer<Root$1, Root$1>;
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
declare module 'mdast' {
|
|
75
|
+
interface HeadingData extends Data {
|
|
76
|
+
hProperties?: {
|
|
77
|
+
id?: string;
|
|
78
|
+
};
|
|
79
|
+
}
|
|
76
80
|
}
|
|
77
81
|
/**
|
|
78
82
|
* Add heading ids and extract TOC
|
|
@@ -93,6 +97,7 @@ type RemarkInstallOptions = Partial<{
|
|
|
93
97
|
/**
|
|
94
98
|
* It generates the following structure from a code block with `package-install` as language
|
|
95
99
|
*
|
|
100
|
+
* @example
|
|
96
101
|
* ```tsx
|
|
97
102
|
* <Tabs items={["pnpm", "npm", "yarn"]}>
|
|
98
103
|
* <Tab value="pnpm">...</Tab>
|
|
@@ -102,4 +107,4 @@ type RemarkInstallOptions = Partial<{
|
|
|
102
107
|
*/
|
|
103
108
|
declare function remarkInstall({ Tab, Tabs, packageManagers, }?: RemarkInstallOptions): Transformer<Root$1, Root$1>;
|
|
104
109
|
|
|
105
|
-
export { type CodeBlockIcon, type
|
|
110
|
+
export { type CodeBlockIcon, type RehypeCodeOptions, type RemarkDynamicContentOptions, type RemarkImageOptions, type RemarkInstallOptions, rehypeCode, rehypeCodeDefaultOptions, remarkDynamicContent, remarkHeading, remarkImage, remarkInstall, transformerIcon };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
flattenNode,
|
|
3
|
-
remarkHeading
|
|
4
|
-
|
|
5
|
-
} from "../chunk-M6ZDX3QR.js";
|
|
3
|
+
remarkHeading
|
|
4
|
+
} from "../chunk-D3Y6KNIC.js";
|
|
6
5
|
import {
|
|
7
6
|
slash
|
|
8
7
|
} from "../chunk-UWEEHUJV.js";
|
|
@@ -24,7 +23,7 @@ import {
|
|
|
24
23
|
} from "@shikijs/transformers";
|
|
25
24
|
|
|
26
25
|
// src/mdx-plugins/hast-utils.ts
|
|
27
|
-
function
|
|
26
|
+
function visit(node, tagNames, handler) {
|
|
28
27
|
if (node.type === "element") {
|
|
29
28
|
if (tagNames.includes(node.tagName)) {
|
|
30
29
|
handler(node);
|
|
@@ -33,7 +32,7 @@ function visit2(node, tagNames, handler) {
|
|
|
33
32
|
}
|
|
34
33
|
if ("children" in node)
|
|
35
34
|
node.children.forEach((n) => {
|
|
36
|
-
|
|
35
|
+
visit(n, tagNames, handler);
|
|
37
36
|
});
|
|
38
37
|
}
|
|
39
38
|
|
|
@@ -339,7 +338,7 @@ function rehypeCode(options = {}) {
|
|
|
339
338
|
const prefix = "language-";
|
|
340
339
|
const transformer = rehypeShiki.call(this, codeOptions);
|
|
341
340
|
return (root, vfile) => __async(this, null, function* () {
|
|
342
|
-
|
|
341
|
+
visit(root, ["pre"], (element) => {
|
|
343
342
|
var _a;
|
|
344
343
|
const head = element.children[0];
|
|
345
344
|
if (element.children.length === 0 || head.type !== "element" || head.tagName !== "code")
|
|
@@ -363,6 +362,7 @@ function rehypeCode(options = {}) {
|
|
|
363
362
|
// src/mdx-plugins/remark-image.ts
|
|
364
363
|
import { existsSync } from "fs";
|
|
365
364
|
import path from "path";
|
|
365
|
+
import { visit as visit2 } from "unist-util-visit";
|
|
366
366
|
var VALID_BLUR_EXT = [".jpeg", ".png", ".webp", ".avif", ".jpg"];
|
|
367
367
|
var EXTERNAL_URL_REGEX = /^https?:\/\//;
|
|
368
368
|
var PUBLIC_DIR = path.join(process.cwd(), "public");
|
|
@@ -371,7 +371,7 @@ function remarkImage({
|
|
|
371
371
|
} = {}) {
|
|
372
372
|
return (tree, _file, done) => {
|
|
373
373
|
const importsToInject = [];
|
|
374
|
-
|
|
374
|
+
visit2(tree, "image", (node) => {
|
|
375
375
|
var _a;
|
|
376
376
|
let url = decodeURI(node.url);
|
|
377
377
|
if (!url || EXTERNAL_URL_REGEX.test(url)) {
|
|
@@ -384,7 +384,7 @@ function remarkImage({
|
|
|
384
384
|
}
|
|
385
385
|
url = slash(urlPath);
|
|
386
386
|
}
|
|
387
|
-
const variableName = `__img${importsToInject.length}`;
|
|
387
|
+
const variableName = `__img${importsToInject.length.toString()}`;
|
|
388
388
|
const hasBlur = placeholder === "blur" && VALID_BLUR_EXT.some((ext) => url.endsWith(ext));
|
|
389
389
|
importsToInject.push({ variableName, importPath: url });
|
|
390
390
|
Object.assign(node, {
|
|
@@ -453,6 +453,7 @@ function remarkImage({
|
|
|
453
453
|
// src/mdx-plugins/remark-dynamic-content.ts
|
|
454
454
|
import fs from "fs";
|
|
455
455
|
import path2 from "path";
|
|
456
|
+
import { visit as visit3 } from "unist-util-visit";
|
|
456
457
|
var regex = new RegExp("^\\|reference:(?<path>.+)\\|");
|
|
457
458
|
function remarkDynamicContent(options = {}) {
|
|
458
459
|
const {
|
|
@@ -461,9 +462,9 @@ function remarkDynamicContent(options = {}) {
|
|
|
461
462
|
visit: filter = ["text", "code"]
|
|
462
463
|
} = options;
|
|
463
464
|
return (tree) => {
|
|
464
|
-
|
|
465
|
+
visit3(tree, filter, (node) => {
|
|
465
466
|
var _a;
|
|
466
|
-
if (!("value" in node) || typeof node.value
|
|
467
|
+
if (!("value" in node) || typeof node.value === "string")
|
|
467
468
|
return;
|
|
468
469
|
const result = regex.exec(node.value);
|
|
469
470
|
if ((_a = result == null ? void 0 : result.groups) == null ? void 0 : _a.path) {
|
|
@@ -482,6 +483,7 @@ import Slugger from "github-slugger";
|
|
|
482
483
|
import { remark } from "remark";
|
|
483
484
|
import remarkGfm from "remark-gfm";
|
|
484
485
|
import remarkMdx from "remark-mdx";
|
|
486
|
+
import { visit as visit4 } from "unist-util-visit";
|
|
485
487
|
var slugger = new Slugger();
|
|
486
488
|
function remarkStructure({
|
|
487
489
|
types = ["paragraph", "blockquote", "heading"]
|
|
@@ -490,8 +492,10 @@ function remarkStructure({
|
|
|
490
492
|
slugger.reset();
|
|
491
493
|
const data = { contents: [], headings: [] };
|
|
492
494
|
let lastHeading = "";
|
|
493
|
-
|
|
495
|
+
visit4(node, types, (element) => {
|
|
494
496
|
var _a, _b;
|
|
497
|
+
if (element.type === "root")
|
|
498
|
+
return;
|
|
495
499
|
const content = flattenNode(element).trim();
|
|
496
500
|
if (element.type === "heading") {
|
|
497
501
|
element.data || (element.data = {});
|
|
@@ -510,8 +514,8 @@ function remarkStructure({
|
|
|
510
514
|
heading: lastHeading,
|
|
511
515
|
content
|
|
512
516
|
});
|
|
517
|
+
return "skip";
|
|
513
518
|
}
|
|
514
|
-
return "skip";
|
|
515
519
|
});
|
|
516
520
|
file.data.structuredData = data;
|
|
517
521
|
};
|
|
@@ -522,6 +526,7 @@ function structure(content, remarkPlugins = [], options = {}) {
|
|
|
522
526
|
}
|
|
523
527
|
|
|
524
528
|
// src/mdx-plugins/remark-install.ts
|
|
529
|
+
import { visit as visit5 } from "unist-util-visit";
|
|
525
530
|
function remarkInstall({
|
|
526
531
|
Tab = "Tab",
|
|
527
532
|
Tabs = "Tabs",
|
|
@@ -532,7 +537,7 @@ function remarkInstall({
|
|
|
532
537
|
]
|
|
533
538
|
} = {}) {
|
|
534
539
|
return (tree) => {
|
|
535
|
-
|
|
540
|
+
visit5(tree, "code", (node) => {
|
|
536
541
|
if (node.lang !== "package-install")
|
|
537
542
|
return "skip";
|
|
538
543
|
const managers = packageManagers.map((manager) => manager(node.value));
|
package/dist/search/server.js
CHANGED
|
@@ -140,7 +140,7 @@ function initSearchAPIAdvanced({
|
|
|
140
140
|
});
|
|
141
141
|
for (const heading of data.headings) {
|
|
142
142
|
index.add({
|
|
143
|
-
id: page.id + id
|
|
143
|
+
id: page.id + (id++).toString(),
|
|
144
144
|
page_id: page.id,
|
|
145
145
|
type: "heading",
|
|
146
146
|
tag: page.tag,
|
|
@@ -150,7 +150,7 @@ function initSearchAPIAdvanced({
|
|
|
150
150
|
}
|
|
151
151
|
for (const content of data.contents) {
|
|
152
152
|
index.add({
|
|
153
|
-
id: page.id + id
|
|
153
|
+
id: page.id + (id++).toString(),
|
|
154
154
|
page_id: page.id,
|
|
155
155
|
tag: page.tag,
|
|
156
156
|
type: "text",
|
package/dist/server/index.js
CHANGED
package/dist/sidebar.d.ts
CHANGED
|
@@ -5,15 +5,15 @@ interface SidebarProviderProps {
|
|
|
5
5
|
onOpenChange?: (v: boolean) => void;
|
|
6
6
|
children: ReactNode;
|
|
7
7
|
}
|
|
8
|
-
declare function SidebarProvider(props: SidebarProviderProps):
|
|
8
|
+
declare function SidebarProvider(props: SidebarProviderProps): React.ReactElement;
|
|
9
9
|
type WithAs<T extends ElementType, Extend = object> = Omit<ComponentPropsWithoutRef<T>, 'as' | keyof Extend> & Extend & {
|
|
10
10
|
as?: T;
|
|
11
11
|
};
|
|
12
12
|
type SidebarTriggerProps<T extends ElementType> = WithAs<T>;
|
|
13
|
-
declare function SidebarTrigger<T extends ElementType = 'button'>({ as, ...props }: SidebarTriggerProps<T>):
|
|
13
|
+
declare function SidebarTrigger<T extends ElementType = 'button'>({ as, ...props }: SidebarTriggerProps<T>): React.ReactElement;
|
|
14
14
|
type SidebarContentProps<T extends ElementType> = WithAs<T, {
|
|
15
15
|
minWidth?: number;
|
|
16
16
|
}>;
|
|
17
|
-
declare function SidebarList<T extends ElementType = 'aside'>({ as, minWidth, ...props }: SidebarContentProps<T>):
|
|
17
|
+
declare function SidebarList<T extends ElementType = 'aside'>({ as, minWidth, ...props }: SidebarContentProps<T>): React.ReactElement;
|
|
18
18
|
|
|
19
19
|
export { type SidebarContentProps, SidebarList, SidebarProvider, type SidebarProviderProps, SidebarTrigger, type SidebarTriggerProps };
|
package/dist/sidebar.js
CHANGED
|
@@ -60,7 +60,9 @@ function SidebarList(_a) {
|
|
|
60
60
|
useEffect(() => {
|
|
61
61
|
if (minWidth === void 0)
|
|
62
62
|
return;
|
|
63
|
-
const mediaQueryList = window.matchMedia(
|
|
63
|
+
const mediaQueryList = window.matchMedia(
|
|
64
|
+
`(min-width: ${minWidth.toString()}px)`
|
|
65
|
+
);
|
|
64
66
|
const handleChange = () => {
|
|
65
67
|
setIsMobileLayout(!mediaQueryList.matches);
|
|
66
68
|
};
|
package/dist/toc.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ interface TOCScrollProvider {
|
|
|
12
12
|
toc: TableOfContents;
|
|
13
13
|
children: ReactNode;
|
|
14
14
|
}
|
|
15
|
-
declare function TOCScrollProvider({ toc, containerRef, children, }: TOCScrollProvider):
|
|
15
|
+
declare function TOCScrollProvider({ toc, containerRef, children, }: TOCScrollProvider): React.ReactElement;
|
|
16
16
|
interface TOCItemProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
17
17
|
href: string;
|
|
18
18
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-core",
|
|
3
|
-
"version": "10.0
|
|
3
|
+
"version": "10.1.0",
|
|
4
4
|
"description": "The library for building a documentation website in Next.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
@@ -109,18 +109,18 @@
|
|
|
109
109
|
],
|
|
110
110
|
"dependencies": {
|
|
111
111
|
"@formatjs/intl-localematcher": "^0.5.4",
|
|
112
|
-
"@shikijs/rehype": "^1.
|
|
113
|
-
"@shikijs/transformers": "^1.
|
|
112
|
+
"@shikijs/rehype": "^1.2.0",
|
|
113
|
+
"@shikijs/transformers": "^1.2.0",
|
|
114
114
|
"flexsearch": "0.7.21",
|
|
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.9",
|
|
119
119
|
"remark": "^15.0.0",
|
|
120
120
|
"remark-gfm": "^4.0.0",
|
|
121
121
|
"remark-mdx": "^3.0.1",
|
|
122
122
|
"scroll-into-view-if-needed": "^3.1.0",
|
|
123
|
-
"shiki": "^1.
|
|
123
|
+
"shiki": "^1.2.0",
|
|
124
124
|
"swr": "^2.2.5",
|
|
125
125
|
"unist-util-visit": "^5.0.0"
|
|
126
126
|
},
|
|
@@ -131,10 +131,10 @@
|
|
|
131
131
|
"@types/mdast": "^4.0.3",
|
|
132
132
|
"@types/negotiator": "^0.6.3",
|
|
133
133
|
"@types/node": "18.17.5",
|
|
134
|
-
"@types/react": "^18.2.
|
|
135
|
-
"@types/react-dom": "^18.2.
|
|
134
|
+
"@types/react": "^18.2.67",
|
|
135
|
+
"@types/react-dom": "^18.2.22",
|
|
136
136
|
"algoliasearch": "^4.22.1",
|
|
137
|
-
"next": "^14.1.
|
|
137
|
+
"next": "^14.1.4",
|
|
138
138
|
"unified": "^11.0.4",
|
|
139
139
|
"eslint-config-custom": "0.0.0",
|
|
140
140
|
"tsconfig": "0.0.0"
|