fumadocs-core 10.0.5 → 10.1.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.
@@ -53,13 +53,21 @@ interface RemarkImageOptions {
53
53
  declare function remarkImage({ placeholder, }?: RemarkImageOptions): Transformer<Root$1, Root$1>;
54
54
 
55
55
  interface RemarkDynamicContentOptions {
56
- /** @defaultValue `process.cwd()` */
56
+ /**
57
+ * @defaultValue `vfile.cwd`
58
+ * @deprecated use the `cwd` option from remark instead
59
+ * */
57
60
  cwd?: string;
58
61
  /** @defaultValue true */
59
62
  trim?: boolean;
63
+ /**
64
+ * Resolve reference files relative to `vfile.path`
65
+ * @defaultValue false
66
+ */
67
+ relative?: boolean;
60
68
  /**
61
69
  * Filter specific element types
62
- * @defaultValue `['text','code']`
70
+ * @defaultValue ['text','code']
63
71
  * */
64
72
  visit?: string[];
65
73
  }
@@ -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, {
@@ -457,18 +457,20 @@ import { visit as visit3 } from "unist-util-visit";
457
457
  var regex = new RegExp("^\\|reference:(?<path>.+)\\|");
458
458
  function remarkDynamicContent(options = {}) {
459
459
  const {
460
- cwd = process.cwd(),
461
460
  trim = true,
461
+ relative = false,
462
462
  visit: filter = ["text", "code"]
463
463
  } = options;
464
- return (tree) => {
464
+ return (tree, file) => {
465
+ var _a;
466
+ const cwd = (_a = options.cwd) != null ? _a : file.cwd;
465
467
  visit3(tree, filter, (node) => {
466
- var _a;
467
- if (!("value" in node) || typeof node.value === "string")
468
+ const canReplace = "value" in node && typeof node.value === "string";
469
+ if (!canReplace)
468
470
  return;
469
471
  const result = regex.exec(node.value);
470
- if ((_a = result == null ? void 0 : result.groups) == null ? void 0 : _a.path) {
471
- const dest = path2.resolve(cwd, result[1]);
472
+ if (result) {
473
+ const dest = relative ? path2.resolve(cwd, path2.dirname(file.path), result[1]) : path2.resolve(cwd, result[1]);
472
474
  let value = fs.readFileSync(dest).toString();
473
475
  if (trim)
474
476
  value = value.trim();
@@ -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",
@@ -9,6 +9,7 @@ import 'react';
9
9
  *
10
10
  * @param value - Blocks
11
11
  * @param slugFn - A function that generates slug from title
12
+ * @deprecated Sanity is no longer supported
12
13
  */
13
14
  declare function getTableOfContentsFromPortableText(value: any): TableOfContents;
14
15
 
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): JSX.Element;
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>): JSX.Element;
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>): JSX.Element;
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(`(min-width: ${minWidth}px)`);
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): JSX.Element;
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.5",
3
+ "version": "10.1.1",
4
4
  "description": "The library for building a documentation website in Next.js",
5
5
  "keywords": [
6
6
  "NextJs",
@@ -109,32 +109,33 @@
109
109
  ],
110
110
  "dependencies": {
111
111
  "@formatjs/intl-localematcher": "^0.5.4",
112
- "@shikijs/rehype": "^1.1.7",
113
- "@shikijs/transformers": "^1.1.7",
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.7",
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.1.7",
123
+ "shiki": "^1.2.0",
124
124
  "swr": "^2.2.5",
125
125
  "unist-util-visit": "^5.0.0"
126
126
  },
127
127
  "devDependencies": {
128
128
  "@algolia/client-search": "^4.22.1",
129
+ "@mdx-js/mdx": "^3.0.1",
129
130
  "@types/flexsearch": "0.7.6",
130
131
  "@types/hast": "^3.0.4",
131
132
  "@types/mdast": "^4.0.3",
132
133
  "@types/negotiator": "^0.6.3",
133
134
  "@types/node": "18.17.5",
134
- "@types/react": "^18.2.0",
135
- "@types/react-dom": "^18.2.1",
135
+ "@types/react": "^18.2.67",
136
+ "@types/react-dom": "^18.2.22",
136
137
  "algoliasearch": "^4.22.1",
137
- "next": "^14.1.2",
138
+ "next": "^14.1.4",
138
139
  "unified": "^11.0.4",
139
140
  "eslint-config-custom": "0.0.0",
140
141
  "tsconfig": "0.0.0"