fumadocs-core 15.2.15 → 15.3.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.
@@ -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
+ };
@@ -343,10 +343,12 @@ function remarkImage({
343
343
  ]
344
344
  });
345
345
  }).catch((e) => {
346
- console.error(
347
- `[Remark Image] Failed obtain image size for ${url} with public directory ${publicDir}`
346
+ throw new Error(
347
+ `[Remark Image] Failed obtain image size for ${url} (public directory configured as ${publicDir})`,
348
+ {
349
+ cause: e
350
+ }
348
351
  );
349
- throw e;
350
352
  });
351
353
  promises.push(task);
352
354
  } else if (!isExternal) {
@@ -430,8 +432,13 @@ async function getImageSize(src, dir) {
430
432
  } else {
431
433
  return imageSizeFromFile(isRelative ? path.join(dir, src) : src);
432
434
  }
433
- const buffer = await fetch(url).then((res) => res.arrayBuffer());
434
- return imageSize(new Uint8Array(buffer));
435
+ const res = await fetch(url);
436
+ if (!res.ok) {
437
+ throw new Error(
438
+ `[Remark Image] Failed to fetch ${url} (${res.status}): ${await res.text()}`
439
+ );
440
+ }
441
+ return imageSize(new Uint8Array(await res.arrayBuffer()));
435
442
  }
436
443
 
437
444
  // src/mdx-plugins/remark-structure.ts
@@ -499,10 +506,6 @@ function remarkStructure({
499
506
  }
500
507
  if (element.type === "mdxJsxFlowElement" && element.name) {
501
508
  data.contents.push(
502
- {
503
- heading: lastHeading,
504
- content: element.name
505
- },
506
509
  ...element.attributes.flatMap((attribute) => {
507
510
  const value = typeof attribute.value === "string" ? attribute.value : attribute.value?.value;
508
511
  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
- useEffect,
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 [isBlocking, setIsBlocking] = useState(false);
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: Boolean(isBlocking && open),
69
+ enabled: isBlocking && open,
80
70
  ...props,
81
71
  children: props.children
82
72
  }
@@ -0,0 +1,3 @@
1
+ declare function useMediaQuery(query: string, disabled?: boolean): boolean | null;
2
+
3
+ export { useMediaQuery };
@@ -0,0 +1,7 @@
1
+ import {
2
+ useMediaQuery
3
+ } from "../chunk-EP5LHGDZ.js";
4
+ import "../chunk-MLKGABMK.js";
5
+ export {
6
+ useMediaQuery
7
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-core",
3
- "version": "15.2.15",
3
+ "version": "15.3.0",
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.3.0",
83
- "@shikijs/transformers": "^3.3.0",
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.3.0",
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.3",
106
- "@types/react": "^19.1.2",
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
- "tsconfig": "0.0.0",
119
- "eslint-config-custom": "0.0.0"
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",