fumadocs-core 15.2.15 → 15.3.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.
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// src/utils/use-media-query.ts
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
function useMediaQuery(query, disabled = false) {
|
|
4
|
+
const [isMatch, setMatch] = useState(null);
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
if (disabled) return;
|
|
7
|
+
const mediaQueryList = window.matchMedia(query);
|
|
8
|
+
const handleChange = () => {
|
|
9
|
+
setMatch(mediaQueryList.matches);
|
|
10
|
+
};
|
|
11
|
+
handleChange();
|
|
12
|
+
mediaQueryList.addEventListener("change", handleChange);
|
|
13
|
+
return () => {
|
|
14
|
+
mediaQueryList.removeEventListener("change", handleChange);
|
|
15
|
+
};
|
|
16
|
+
}, [disabled, query]);
|
|
17
|
+
return isMatch;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export {
|
|
21
|
+
useMediaQuery
|
|
22
|
+
};
|
|
@@ -184,6 +184,14 @@ var metaValues = [
|
|
|
184
184
|
{
|
|
185
185
|
name: "tab",
|
|
186
186
|
regex: /tab="(?<value>[^"]+)"/
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
regex: /lineNumbers=(\d+)|lineNumbers/,
|
|
190
|
+
onSet(map, args) {
|
|
191
|
+
map["data-line-numbers"] = true;
|
|
192
|
+
if (args[0] !== void 0)
|
|
193
|
+
map["data-line-numbers-start"] = Number(args[0]);
|
|
194
|
+
}
|
|
187
195
|
}
|
|
188
196
|
];
|
|
189
197
|
var rehypeCodeDefaultOptions = {
|
|
@@ -207,8 +215,12 @@ var rehypeCodeDefaultOptions = {
|
|
|
207
215
|
const map = {};
|
|
208
216
|
for (const value of metaValues) {
|
|
209
217
|
meta = meta.replace(value.regex, (_, ...args) => {
|
|
210
|
-
|
|
211
|
-
|
|
218
|
+
if ("onSet" in value) {
|
|
219
|
+
value.onSet(map, args);
|
|
220
|
+
} else {
|
|
221
|
+
const first = args.at(0);
|
|
222
|
+
map[value.name] = typeof first === "string" ? first : "";
|
|
223
|
+
}
|
|
212
224
|
return "";
|
|
213
225
|
});
|
|
214
226
|
}
|
|
@@ -343,10 +355,12 @@ function remarkImage({
|
|
|
343
355
|
]
|
|
344
356
|
});
|
|
345
357
|
}).catch((e) => {
|
|
346
|
-
|
|
347
|
-
`[Remark Image] Failed obtain image size for ${url}
|
|
358
|
+
throw new Error(
|
|
359
|
+
`[Remark Image] Failed obtain image size for ${url} (public directory configured as ${publicDir})`,
|
|
360
|
+
{
|
|
361
|
+
cause: e
|
|
362
|
+
}
|
|
348
363
|
);
|
|
349
|
-
throw e;
|
|
350
364
|
});
|
|
351
365
|
promises.push(task);
|
|
352
366
|
} else if (!isExternal) {
|
|
@@ -430,8 +444,13 @@ async function getImageSize(src, dir) {
|
|
|
430
444
|
} else {
|
|
431
445
|
return imageSizeFromFile(isRelative ? path.join(dir, src) : src);
|
|
432
446
|
}
|
|
433
|
-
const
|
|
434
|
-
|
|
447
|
+
const res = await fetch(url);
|
|
448
|
+
if (!res.ok) {
|
|
449
|
+
throw new Error(
|
|
450
|
+
`[Remark Image] Failed to fetch ${url} (${res.status}): ${await res.text()}`
|
|
451
|
+
);
|
|
452
|
+
}
|
|
453
|
+
return imageSize(new Uint8Array(await res.arrayBuffer()));
|
|
435
454
|
}
|
|
436
455
|
|
|
437
456
|
// src/mdx-plugins/remark-structure.ts
|
|
@@ -499,10 +518,6 @@ function remarkStructure({
|
|
|
499
518
|
}
|
|
500
519
|
if (element.type === "mdxJsxFlowElement" && element.name) {
|
|
501
520
|
data.contents.push(
|
|
502
|
-
{
|
|
503
|
-
heading: lastHeading,
|
|
504
|
-
content: element.name
|
|
505
|
-
},
|
|
506
521
|
...element.attributes.flatMap((attribute) => {
|
|
507
522
|
const value = typeof attribute.value === "string" ? attribute.value : attribute.value?.value;
|
|
508
523
|
if (!value || value.length === 0) return [];
|
package/dist/sidebar.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import {
|
|
3
|
+
useMediaQuery
|
|
4
|
+
} from "./chunk-EP5LHGDZ.js";
|
|
2
5
|
import "./chunk-MLKGABMK.js";
|
|
3
6
|
|
|
4
7
|
// src/sidebar.tsx
|
|
5
8
|
import {
|
|
6
9
|
createContext,
|
|
7
10
|
useContext,
|
|
8
|
-
|
|
9
|
-
useState
|
|
10
|
-
useMemo
|
|
11
|
+
useMemo,
|
|
12
|
+
useState
|
|
11
13
|
} from "react";
|
|
12
14
|
import { RemoveScroll } from "react-remove-scroll";
|
|
13
15
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -58,25 +60,13 @@ function SidebarList({
|
|
|
58
60
|
...props
|
|
59
61
|
}) {
|
|
60
62
|
const { open } = useSidebarContext();
|
|
61
|
-
const
|
|
62
|
-
useEffect(() => {
|
|
63
|
-
if (!removeScrollOn) return;
|
|
64
|
-
const mediaQueryList = window.matchMedia(removeScrollOn);
|
|
65
|
-
const handleChange = () => {
|
|
66
|
-
setIsBlocking(mediaQueryList.matches);
|
|
67
|
-
};
|
|
68
|
-
handleChange();
|
|
69
|
-
mediaQueryList.addEventListener("change", handleChange);
|
|
70
|
-
return () => {
|
|
71
|
-
mediaQueryList.removeEventListener("change", handleChange);
|
|
72
|
-
};
|
|
73
|
-
}, [removeScrollOn]);
|
|
63
|
+
const isBlocking = useMediaQuery(removeScrollOn ?? "", !removeScrollOn) ?? false;
|
|
74
64
|
return /* @__PURE__ */ jsx(
|
|
75
65
|
RemoveScroll,
|
|
76
66
|
{
|
|
77
67
|
as: as ?? "aside",
|
|
78
68
|
"data-open": open,
|
|
79
|
-
enabled:
|
|
69
|
+
enabled: isBlocking && open,
|
|
80
70
|
...props,
|
|
81
71
|
children: props.children
|
|
82
72
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-core",
|
|
3
|
-
"version": "15.
|
|
3
|
+
"version": "15.3.1",
|
|
4
4
|
"description": "The library for building a documentation website in Next.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
@@ -79,8 +79,8 @@
|
|
|
79
79
|
"dependencies": {
|
|
80
80
|
"@formatjs/intl-localematcher": "^0.6.1",
|
|
81
81
|
"@orama/orama": "^3.1.6",
|
|
82
|
-
"@shikijs/rehype": "^3.
|
|
83
|
-
"@shikijs/transformers": "^3.
|
|
82
|
+
"@shikijs/rehype": "^3.4.0",
|
|
83
|
+
"@shikijs/transformers": "^3.4.0",
|
|
84
84
|
"github-slugger": "^2.0.0",
|
|
85
85
|
"hast-util-to-estree": "^3.1.3",
|
|
86
86
|
"hast-util-to-jsx-runtime": "^2.3.6",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"remark": "^15.0.0",
|
|
91
91
|
"remark-gfm": "^4.0.1",
|
|
92
92
|
"scroll-into-view-if-needed": "^3.1.0",
|
|
93
|
-
"shiki": "^3.
|
|
93
|
+
"shiki": "^3.4.0",
|
|
94
94
|
"unist-util-visit": "^5.0.0"
|
|
95
95
|
},
|
|
96
96
|
"devDependencies": {
|
|
@@ -102,8 +102,8 @@
|
|
|
102
102
|
"@types/hast": "^3.0.4",
|
|
103
103
|
"@types/mdast": "^4.0.3",
|
|
104
104
|
"@types/negotiator": "^0.6.3",
|
|
105
|
-
"@types/node": "22.15.
|
|
106
|
-
"@types/react": "^19.1.
|
|
105
|
+
"@types/node": "22.15.12",
|
|
106
|
+
"@types/react": "^19.1.3",
|
|
107
107
|
"@types/react-dom": "^19.1.3",
|
|
108
108
|
"algoliasearch": "4.24.0",
|
|
109
109
|
"mdast-util-mdx-jsx": "^3.2.0",
|
|
@@ -115,8 +115,8 @@
|
|
|
115
115
|
"typescript": "^5.8.3",
|
|
116
116
|
"unified": "^11.0.5",
|
|
117
117
|
"vfile": "^6.0.3",
|
|
118
|
-
"
|
|
119
|
-
"
|
|
118
|
+
"eslint-config-custom": "0.0.0",
|
|
119
|
+
"tsconfig": "0.0.0"
|
|
120
120
|
},
|
|
121
121
|
"peerDependencies": {
|
|
122
122
|
"@oramacloud/client": "1.x.x || 2.x.x",
|