fumadocs-core 16.2.2 → 16.2.4

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.
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
- import { R as Root, N as Node } from './definitions-DbCug1P3.js';
2
+ import { R as Root, N as Node } from './definitions-pJ7PybYY.js';
3
3
 
4
4
  interface BreadcrumbItem {
5
5
  name: ReactNode;
@@ -15,6 +15,20 @@ function remarkImage({
15
15
  const importsToInject = [];
16
16
  const promises = [];
17
17
  async function onImage(src, node) {
18
+ const attributes = [
19
+ {
20
+ type: "mdxJsxAttribute",
21
+ name: "alt",
22
+ value: node.alt ?? "image"
23
+ }
24
+ ];
25
+ if (node.title) {
26
+ attributes.push({
27
+ type: "mdxJsxAttribute",
28
+ name: "title",
29
+ value: node.title
30
+ });
31
+ }
18
32
  if (src.type === "file" && useImport) {
19
33
  const variableName = `__img${importsToInject.length}`;
20
34
  const hasBlur = placeholder === "blur" && VALID_BLUR_EXT.some((ext) => src.file.endsWith(ext));
@@ -27,37 +41,31 @@ function remarkImage({
27
41
  variableName,
28
42
  importPath: getImportPath(src.file, file.dirname)
29
43
  });
44
+ attributes.push({
45
+ type: "mdxJsxAttribute",
46
+ name: "src",
47
+ value: {
48
+ type: "mdxJsxAttributeValueExpression",
49
+ value: variableName,
50
+ data: {
51
+ estree: {
52
+ body: [
53
+ {
54
+ type: "ExpressionStatement",
55
+ expression: { type: "Identifier", name: variableName }
56
+ }
57
+ ],
58
+ type: "Program",
59
+ sourceType: "script"
60
+ }
61
+ }
62
+ }
63
+ });
30
64
  const out = {
31
65
  children: [],
32
66
  type: "mdxJsxFlowElement",
33
67
  name: "img",
34
- attributes: [
35
- {
36
- type: "mdxJsxAttribute",
37
- name: "alt",
38
- value: node.alt ?? "image"
39
- },
40
- {
41
- type: "mdxJsxAttribute",
42
- name: "src",
43
- value: {
44
- type: "mdxJsxAttributeValueExpression",
45
- value: variableName,
46
- data: {
47
- estree: {
48
- body: [
49
- {
50
- type: "ExpressionStatement",
51
- expression: { type: "Identifier", name: variableName }
52
- }
53
- ],
54
- type: "Program",
55
- sourceType: "script"
56
- }
57
- }
58
- }
59
- }
60
- ]
68
+ attributes
61
69
  };
62
70
  if (hasBlur) {
63
71
  out.attributes.push({
@@ -77,32 +85,28 @@ function remarkImage({
77
85
  );
78
86
  });
79
87
  if (!size) return;
88
+ attributes.push(
89
+ {
90
+ type: "mdxJsxAttribute",
91
+ name: "src",
92
+ // `src` doesn't support file paths, we can use `node.url` for files and let the underlying framework handle it
93
+ value: src.type === "url" ? src.url.toString() : node.url
94
+ },
95
+ {
96
+ type: "mdxJsxAttribute",
97
+ name: "width",
98
+ value: size.width.toString()
99
+ },
100
+ {
101
+ type: "mdxJsxAttribute",
102
+ name: "height",
103
+ value: size.height.toString()
104
+ }
105
+ );
80
106
  return {
81
107
  type: "mdxJsxFlowElement",
82
108
  name: "img",
83
- attributes: [
84
- {
85
- type: "mdxJsxAttribute",
86
- name: "alt",
87
- value: node.alt ?? "image"
88
- },
89
- {
90
- type: "mdxJsxAttribute",
91
- name: "src",
92
- // `src` doesn't support file paths, we can use `node.url` for files and let the underlying framework handle it
93
- value: src.type === "url" ? src.url.toString() : node.url
94
- },
95
- {
96
- type: "mdxJsxAttribute",
97
- name: "width",
98
- value: size.width.toString()
99
- },
100
- {
101
- type: "mdxJsxAttribute",
102
- name: "height",
103
- value: size.height.toString()
104
- }
105
- ],
109
+ attributes,
106
110
  children: []
107
111
  };
108
112
  }
@@ -1,26 +1,31 @@
1
1
  import {
2
2
  flattenNode,
3
3
  toMdxExport
4
- } from "./chunk-A4G5V4FQ.js";
4
+ } from "./chunk-VLSDGCJE.js";
5
5
 
6
6
  // src/mdx-plugins/remark-structure.ts
7
7
  import Slugger from "github-slugger";
8
8
  import { remark } from "remark";
9
9
  import remarkGfm from "remark-gfm";
10
10
  import { visit } from "unist-util-visit";
11
- function remarkStructure({
12
- types = [
11
+ var remarkStructureDefaultOptions = {
12
+ types: [
13
13
  "heading",
14
14
  "paragraph",
15
15
  "blockquote",
16
16
  "tableCell",
17
17
  "mdxJsxFlowElement"
18
18
  ],
19
- allowedMdxAttributes = (node) => {
19
+ allowedMdxAttributes: (node) => {
20
20
  if (!node.name) return false;
21
21
  return ["TypeTable", "Callout"].includes(node.name);
22
22
  },
23
- exportAs = false
23
+ exportAs: false
24
+ };
25
+ function remarkStructure({
26
+ types = remarkStructureDefaultOptions.types,
27
+ allowedMdxAttributes = remarkStructureDefaultOptions.allowedMdxAttributes,
28
+ exportAs = remarkStructureDefaultOptions.exportAs
24
29
  } = {}) {
25
30
  const slugger = new Slugger();
26
31
  if (Array.isArray(allowedMdxAttributes)) {
@@ -106,6 +111,7 @@ function structure(content, remarkPlugins = [], options = {}) {
106
111
  }
107
112
 
108
113
  export {
114
+ remarkStructureDefaultOptions,
109
115
  remarkStructure,
110
116
  structure
111
117
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  flattenNode
3
- } from "./chunk-A4G5V4FQ.js";
3
+ } from "./chunk-VLSDGCJE.js";
4
4
 
5
5
  // src/mdx-plugins/remark-heading.ts
6
6
  import Slugger from "github-slugger";
@@ -3,7 +3,7 @@ import { valueToEstree } from "estree-util-value-to-estree";
3
3
  function flattenNode(node) {
4
4
  if ("children" in node)
5
5
  return node.children.map((child) => flattenNode(child)).join("");
6
- if ("value" in node) return node.value;
6
+ if ("value" in node && typeof node.value === "string") return node.value;
7
7
  return "";
8
8
  }
9
9
  function toMdxExport(name, value) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  flattenNode
3
- } from "./chunk-A4G5V4FQ.js";
3
+ } from "./chunk-VLSDGCJE.js";
4
4
 
5
5
  // src/mdx-plugins/remark-admonition.ts
6
6
  import { visit } from "unist-util-visit";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  remarkHeading
3
- } from "../chunk-HNZEUF6C.js";
4
- import "../chunk-A4G5V4FQ.js";
3
+ } from "../chunk-MA6O2UUE.js";
4
+ import "../chunk-VLSDGCJE.js";
5
5
  import "../chunk-U67V476Y.js";
6
6
 
7
7
  // src/content/toc.ts
@@ -1,12 +1,12 @@
1
1
  import { ReactNode } from 'react';
2
2
 
3
- interface INode {
3
+ interface ID {
4
4
  /**
5
5
  * ID for the node, unique in all page trees (even across different locales)
6
6
  */
7
7
  $id?: string;
8
8
  }
9
- interface Root extends INode {
9
+ interface Root extends ID {
10
10
  name: ReactNode;
11
11
  children: Node[];
12
12
  /**
@@ -15,7 +15,7 @@ interface Root extends INode {
15
15
  fallback?: Root;
16
16
  }
17
17
  type Node = Item | Separator | Folder;
18
- interface Item extends INode {
18
+ interface Item extends ID {
19
19
  /**
20
20
  * @internal
21
21
  */
@@ -34,12 +34,12 @@ interface Item extends INode {
34
34
  description?: ReactNode;
35
35
  icon?: ReactNode;
36
36
  }
37
- interface Separator extends INode {
37
+ interface Separator extends ID {
38
38
  type: 'separator';
39
39
  name?: ReactNode;
40
40
  icon?: ReactNode;
41
41
  }
42
- interface Folder extends INode {
42
+ interface Folder extends ID {
43
43
  /**
44
44
  * @internal
45
45
  */
@@ -51,6 +51,7 @@ interface Folder extends INode {
51
51
  description?: ReactNode;
52
52
  root?: boolean;
53
53
  defaultOpen?: boolean;
54
+ collapsible?: boolean;
54
55
  index?: Item;
55
56
  icon?: ReactNode;
56
57
  children: Node[];
@@ -1,12 +1,34 @@
1
- import { NextProxy } from 'next/dist/server/web/types';
1
+ import { NextProxy } from 'next/server';
2
2
  import { I18nConfig } from './index.js';
3
+ import { NextURL } from 'next/dist/server/web/next-url';
3
4
 
4
5
  interface MiddlewareOptions extends I18nConfig {
5
6
  /**
6
- * A function that adds the locale prefix to path name
7
+ * Either:
8
+ * - A formatter object
9
+ * - A function that adds the locale prefix to pathname
7
10
  */
8
- format?: (locale: string, path: string) => string;
11
+ format?: URLFormatter | ((locale: string, pathname: string) => string);
12
+ /**
13
+ * the cookie to store locale code when `hideLocale` is set to `always`.
14
+ */
15
+ cookieName?: string;
16
+ }
17
+ interface URLFormatter {
18
+ /**
19
+ * get locale code from request URL
20
+ */
21
+ get: (url: NextURL) => string | undefined;
22
+ /**
23
+ * add locale code to request URL (which is missing the locale).
24
+ */
25
+ add: (url: NextURL, locale: string) => URL;
26
+ /**
27
+ * remove locale code from request URL
28
+ */
29
+ remove: (url: NextURL) => URL;
9
30
  }
10
- declare function createI18nMiddleware({ languages, defaultLanguage, format, hideLocale, }: MiddlewareOptions): NextProxy;
31
+ declare const DefaultFormatter: URLFormatter;
32
+ declare function createI18nMiddleware({ languages, defaultLanguage, format, cookieName, hideLocale, }: MiddlewareOptions): NextProxy;
11
33
 
12
- export { createI18nMiddleware };
34
+ export { DefaultFormatter, type URLFormatter, createI18nMiddleware };
@@ -6,58 +6,71 @@ import "../chunk-U67V476Y.js";
6
6
  // src/i18n/middleware.ts
7
7
  import { match as matchLocale } from "@formatjs/intl-localematcher";
8
8
  import { NextResponse } from "next/server";
9
- var COOKIE = "FD_LOCALE";
10
- function getLocale(request, locales, defaultLanguage) {
11
- const languages = getNegotiator(request).languages(locales);
12
- return matchLocale(languages, locales, defaultLanguage);
13
- }
14
- var defaultFormat = (locale, path) => {
15
- return `/${locale}${path}`;
9
+ var DefaultFormatter = {
10
+ get(url) {
11
+ const segs = url.pathname.split("/");
12
+ if (segs.length > 1 && segs[1]) return segs[1];
13
+ },
14
+ add(url, locale) {
15
+ const next = new URL(url);
16
+ next.pathname = `${url.basePath}/${locale}/${url.pathname}`.replaceAll(
17
+ /\/+/g,
18
+ "/"
19
+ );
20
+ return next;
21
+ },
22
+ remove(url) {
23
+ const next = new URL(url);
24
+ const pathname = url.pathname.split("/").slice(2).join("/");
25
+ next.pathname = `${url.basePath}/${pathname}`.replaceAll(/\/+/g, "/");
26
+ return next;
27
+ }
16
28
  };
17
29
  function createI18nMiddleware({
18
30
  languages,
19
31
  defaultLanguage,
20
- format = defaultFormat,
32
+ format = DefaultFormatter,
33
+ cookieName = "FD_LOCALE",
21
34
  hideLocale = "never"
22
35
  }) {
23
- function getLocaleUrl(request, locale) {
24
- const next = new URL(request.url);
25
- next.pathname = format(locale, forceSlashPrefix(request.nextUrl.pathname));
26
- return next;
36
+ let formatter;
37
+ if (typeof format === "function") {
38
+ formatter = {
39
+ ...DefaultFormatter,
40
+ add(url, locale) {
41
+ const next = new URL(url);
42
+ next.pathname = format(locale, url.pathname);
43
+ return next;
44
+ }
45
+ };
46
+ } else {
47
+ formatter = format;
27
48
  }
28
49
  return (request) => {
29
50
  const url = request.nextUrl;
30
- const pathLocale = languages.find(
31
- (locale) => url.pathname.startsWith(`/${locale}/`) || url.pathname === `/${locale}`
32
- );
51
+ let pathLocale = formatter.get(url);
52
+ if (pathLocale && !languages.includes(pathLocale)) pathLocale = void 0;
33
53
  if (!pathLocale) {
34
54
  if (hideLocale === "default-locale") {
35
- return NextResponse.rewrite(getLocaleUrl(request, defaultLanguage));
55
+ return NextResponse.rewrite(formatter.add(url, defaultLanguage));
36
56
  }
37
- const preferred = getLocale(request, languages, defaultLanguage);
57
+ const finalLanguages = getNegotiator(request).languages(languages);
58
+ const preferred = matchLocale(finalLanguages, languages, defaultLanguage);
38
59
  if (hideLocale === "always") {
39
- const locale = request.cookies.get(COOKIE)?.value ?? preferred;
40
- return NextResponse.rewrite(getLocaleUrl(request, locale));
60
+ const locale = request.cookies.get(cookieName)?.value ?? preferred;
61
+ return NextResponse.rewrite(formatter.add(url, locale));
41
62
  }
42
- return NextResponse.redirect(getLocaleUrl(request, preferred));
63
+ return NextResponse.redirect(formatter.add(url, preferred));
43
64
  }
44
65
  if (hideLocale === "always" || hideLocale === "default-locale" && pathLocale === defaultLanguage) {
45
- const res = NextResponse.redirect(
46
- new URL(
47
- forceSlashPrefix(url.pathname.slice(`/${pathLocale}`.length)),
48
- request.url
49
- )
50
- );
51
- res.cookies.set(COOKIE, pathLocale);
66
+ const res = NextResponse.redirect(formatter.remove(url));
67
+ res.cookies.set(cookieName, pathLocale);
52
68
  return res;
53
69
  }
54
70
  return NextResponse.next();
55
71
  };
56
72
  }
57
- function forceSlashPrefix(v) {
58
- if (v.startsWith("/")) return v;
59
- return "/" + v;
60
- }
61
73
  export {
74
+ DefaultFormatter,
62
75
  createI18nMiddleware
63
76
  };
@@ -1,4 +1,4 @@
1
- import { R as Root, I as Item, F as Folder, S as Separator } from './definitions-DbCug1P3.js';
1
+ import { R as Root, I as Item, F as Folder, S as Separator } from './definitions-pJ7PybYY.js';
2
2
  import { I18nConfig } from './i18n/index.js';
3
3
  import { ReactNode } from 'react';
4
4
 
@@ -15,6 +15,7 @@ interface MetaData {
15
15
  root?: boolean | undefined;
16
16
  pages?: string[] | undefined;
17
17
  defaultOpen?: boolean | undefined;
18
+ collapsible?: boolean | undefined;
18
19
  description?: string | undefined;
19
20
  }
20
21
  interface PageData {
@@ -1,7 +1,7 @@
1
1
  export { Options as RemarkGfmOptions, default as remarkGfm } from 'remark-gfm';
2
2
  export { CodeBlockIcon, RehypeCodeOptions, rehypeCode, rehypeCodeDefaultOptions, transformerIcon, transformerTab } from './rehype-code.js';
3
3
  export { RemarkImageOptions, remarkImage } from './remark-image.js';
4
- export { StructureOptions, StructuredData, remarkStructure, structure } from './remark-structure.js';
4
+ export { StructureOptions, StructuredData, remarkStructure, remarkStructureDefaultOptions, structure } from './remark-structure.js';
5
5
  export { RemarkHeadingOptions, remarkHeading } from './remark-heading.js';
6
6
  export { RemarkAdmonitionOptions, remarkAdmonition } from './remark-admonition.js';
7
7
  export { RemarkDirectiveAdmonitionOptions, remarkDirectiveAdmonition } from './remark-directive-admonition.js';
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  remarkImage
3
- } from "../chunk-YDNO7UZ6.js";
3
+ } from "../chunk-5PMI7QDD.js";
4
4
  import {
5
5
  remarkMdxFiles
6
6
  } from "../chunk-ADBHPKXG.js";
@@ -15,8 +15,9 @@ import {
15
15
  } from "../chunk-XJ6ZQNEX.js";
16
16
  import {
17
17
  remarkStructure,
18
+ remarkStructureDefaultOptions,
18
19
  structure
19
- } from "../chunk-SLIKY7GW.js";
20
+ } from "../chunk-JUF4WZ6G.js";
20
21
  import {
21
22
  rehypeCode,
22
23
  rehypeCodeDefaultOptions,
@@ -28,7 +29,7 @@ import {
28
29
  } from "../chunk-EFVXL2PP.js";
29
30
  import {
30
31
  remarkAdmonition
31
- } from "../chunk-JOXPHQ2R.js";
32
+ } from "../chunk-W6WTLKRA.js";
32
33
  import {
33
34
  remarkCodeTab
34
35
  } from "../chunk-CH7YHH7V.js";
@@ -45,8 +46,8 @@ import {
45
46
  import "../chunk-XN2LKXFZ.js";
46
47
  import {
47
48
  remarkHeading
48
- } from "../chunk-HNZEUF6C.js";
49
- import "../chunk-A4G5V4FQ.js";
49
+ } from "../chunk-MA6O2UUE.js";
50
+ import "../chunk-VLSDGCJE.js";
50
51
  import "../chunk-U67V476Y.js";
51
52
  export {
52
53
  generateCodeBlockTabs,
@@ -65,6 +66,7 @@ export {
65
66
  remarkNpm,
66
67
  remarkSteps,
67
68
  remarkStructure,
69
+ remarkStructureDefaultOptions,
68
70
  structure,
69
71
  transformerIcon,
70
72
  transformerTab
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  remarkAdmonition
3
- } from "../chunk-JOXPHQ2R.js";
4
- import "../chunk-A4G5V4FQ.js";
3
+ } from "../chunk-W6WTLKRA.js";
4
+ import "../chunk-VLSDGCJE.js";
5
5
  import "../chunk-U67V476Y.js";
6
6
  export {
7
7
  remarkAdmonition
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  remarkHeading
3
- } from "../chunk-HNZEUF6C.js";
4
- import "../chunk-A4G5V4FQ.js";
3
+ } from "../chunk-MA6O2UUE.js";
4
+ import "../chunk-VLSDGCJE.js";
5
5
  import "../chunk-U67V476Y.js";
6
6
  export {
7
7
  remarkHeading
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  remarkImage
3
- } from "../chunk-YDNO7UZ6.js";
3
+ } from "../chunk-5PMI7QDD.js";
4
4
  import "../chunk-U67V476Y.js";
5
5
  export {
6
6
  remarkImage
@@ -52,8 +52,15 @@ declare module 'vfile' {
52
52
  structuredData: StructuredData;
53
53
  }
54
54
  }
55
+ declare const remarkStructureDefaultOptions: {
56
+ types: string[];
57
+ allowedMdxAttributes: (node: MdxJsxFlowElement) => boolean;
58
+ exportAs: false;
59
+ };
55
60
  /**
56
- * Attach structured data to VFile, you can access via `vfile.data.structuredData`.
61
+ * Extract content into structured data.
62
+ *
63
+ * By default, the output is stored into VFile (`vfile.data.structuredData`), you can specify `exportAs` to export it.
57
64
  */
58
65
  declare function remarkStructure({ types, allowedMdxAttributes, exportAs, }?: StructureOptions): Transformer<Root, Root>;
59
66
  /**
@@ -61,4 +68,4 @@ declare function remarkStructure({ types, allowedMdxAttributes, exportAs, }?: St
61
68
  */
62
69
  declare function structure(content: string, remarkPlugins?: PluggableList, options?: StructureOptions): StructuredData;
63
70
 
64
- export { type StructureOptions, type StructuredData, remarkStructure, structure };
71
+ export { type StructureOptions, type StructuredData, remarkStructure, remarkStructureDefaultOptions, structure };
@@ -1,10 +1,12 @@
1
1
  import {
2
2
  remarkStructure,
3
+ remarkStructureDefaultOptions,
3
4
  structure
4
- } from "../chunk-SLIKY7GW.js";
5
- import "../chunk-A4G5V4FQ.js";
5
+ } from "../chunk-JUF4WZ6G.js";
6
+ import "../chunk-VLSDGCJE.js";
6
7
  import "../chunk-U67V476Y.js";
7
8
  export {
8
9
  remarkStructure,
10
+ remarkStructureDefaultOptions,
9
11
  structure
10
12
  };
@@ -1,5 +1,5 @@
1
- import { N as Node, I as Item, R as Root, F as Folder } from '../definitions-DbCug1P3.js';
2
- export { S as Separator } from '../definitions-DbCug1P3.js';
1
+ import { N as Node, I as Item, R as Root, F as Folder } from '../definitions-pJ7PybYY.js';
2
+ export { S as Separator } from '../definitions-pJ7PybYY.js';
3
3
  import 'react';
4
4
 
5
5
  /**
@@ -1,3 +1,4 @@
1
+ import { DependencyList } from 'react';
1
2
  import { AnyOrama } from '@orama/orama';
2
3
  import '../mdx-plugins/remark-structure.js';
3
4
  import { BaseIndex } from './algolia.js';
@@ -9,7 +10,6 @@ import 'mdast';
9
10
  import 'unified';
10
11
  import 'mdast-util-mdx-jsx';
11
12
  import 'algoliasearch';
12
- import 'react';
13
13
 
14
14
  interface FetchOptions {
15
15
  /**
@@ -120,7 +120,7 @@ type Client = ({
120
120
  /**
121
121
  * Provide a hook to query different official search clients.
122
122
  *
123
- * Note: it will re-query when its parameters changed, make sure to use `useCallback()` on functions passed to this hook.
123
+ * Note: it will re-query when its parameters changed, make sure to use `useMemo()` on `clientOptions` or define `deps` array.
124
124
  */
125
125
  declare function useDocsSearch(clientOptions: Client & {
126
126
  /**
@@ -135,6 +135,6 @@ declare function useDocsSearch(clientOptions: Client & {
135
135
  * @defaultValue false
136
136
  */
137
137
  allowEmpty?: boolean;
138
- }): UseDocsSearch;
138
+ }, deps?: DependencyList): UseDocsSearch;
139
139
 
140
140
  export { type AlgoliaOptions, type Client, type FetchOptions, type OramaCloudOptions, type StaticOptions, useDocsSearch };
@@ -22,20 +22,21 @@ function useDebounce(value, delayMs = 1e3) {
22
22
  }
23
23
 
24
24
  // src/search/client.ts
25
- function isDifferentDeep(a, b) {
25
+ function isDeepEqual(a, b) {
26
+ if (a === b) return true;
26
27
  if (Array.isArray(a) && Array.isArray(b)) {
27
- return b.length !== a.length || a.some((v, i) => isDifferentDeep(v, b[i]));
28
+ return b.length === a.length && a.every((v, i) => isDeepEqual(v, b[i]));
28
29
  }
29
30
  if (typeof a === "object" && a && typeof b === "object" && b) {
30
31
  const aKeys = Object.keys(a);
31
32
  const bKeys = Object.keys(b);
32
- return aKeys.length !== bKeys.length || aKeys.some(
33
- (key) => isDifferentDeep(a[key], b[key])
33
+ return aKeys.length === bKeys.length && aKeys.every(
34
+ (key) => Object.hasOwn(b, key) && isDeepEqual(a[key], b[key])
34
35
  );
35
36
  }
36
- return a !== b;
37
+ return false;
37
38
  }
38
- function useDocsSearch(clientOptions) {
39
+ function useDocsSearch(clientOptions, deps) {
39
40
  const { delayMs = 100, allowEmpty = false, ...client } = clientOptions;
40
41
  const [search, setSearch] = useState2("");
41
42
  const [results, setResults] = useState2("empty");
@@ -44,7 +45,7 @@ function useDocsSearch(clientOptions) {
44
45
  const debouncedValue = useDebounce(search, delayMs);
45
46
  const onStart = useRef(void 0);
46
47
  useOnChange(
47
- [client, debouncedValue],
48
+ [deps ?? clientOptions, debouncedValue],
48
49
  () => {
49
50
  if (onStart.current) {
50
51
  onStart.current();
@@ -89,7 +90,7 @@ function useDocsSearch(clientOptions) {
89
90
  setIsLoading(false);
90
91
  });
91
92
  },
92
- isDifferentDeep
93
+ deps ? void 0 : (a, b) => !isDeepEqual(a, b)
93
94
  );
94
95
  return { search, setSearch, query: { isLoading, data: results, error } };
95
96
  }
@@ -3,12 +3,12 @@ import { StructuredData } from '../mdx-plugins/remark-structure.js';
3
3
  import { SortedResult } from './index.js';
4
4
  export { HighlightedText, ReactSortedResult, createContentHighlighter } from './index.js';
5
5
  import { I18nConfig } from '../i18n/index.js';
6
- import { g as LoaderOutput, c as LoaderConfig, I as InferPageType } from '../loader-Dz9yZIJQ.js';
6
+ import { g as LoaderOutput, c as LoaderConfig, I as InferPageType } from '../loader-qkSHi822.js';
7
7
  import 'mdast';
8
8
  import 'unified';
9
9
  import 'mdast-util-mdx-jsx';
10
10
  import 'react';
11
- import '../definitions-DbCug1P3.js';
11
+ import '../definitions-pJ7PybYY.js';
12
12
 
13
13
  type SimpleDocument = TypedDocument<Orama<typeof simpleSchema>>;
14
14
  declare const simpleSchema: {
@@ -1,4 +1,4 @@
1
- import { R as Root } from '../../definitions-DbCug1P3.js';
1
+ import { R as Root } from '../../definitions-pJ7PybYY.js';
2
2
  import 'react';
3
3
 
4
4
  declare function deserializePageTree(root: Root): Root;
@@ -1,5 +1,5 @@
1
- export { C as ContentStorage, q as ContentStorageFile, F as FileSystem, i as InferMetaType, I as InferPageType, c as LoaderConfig, d as LoaderOptions, g as LoaderOutput, L as LoaderPlugin, s as LoaderPluginOption, f as Meta, M as MetaData, e as Page, P as PageData, o as PageTreeBuilder, j as PageTreeBuilderContext, n as PageTreeOptions, k as PageTreeTransformer, R as ResolvedLoaderConfig, S as Source, a as SourceConfig, V as VirtualFile, _ as _ConfigUnion_, r as buildContentStorage, t as buildPlugins, h as createGetUrl, p as createPageTreeBuilder, l as loader, b as map, m as multiple } from '../loader-Dz9yZIJQ.js';
2
- import '../definitions-DbCug1P3.js';
1
+ export { C as ContentStorage, q as ContentStorageFile, F as FileSystem, i as InferMetaType, I as InferPageType, c as LoaderConfig, d as LoaderOptions, g as LoaderOutput, L as LoaderPlugin, s as LoaderPluginOption, f as Meta, M as MetaData, e as Page, P as PageData, o as PageTreeBuilder, j as PageTreeBuilderContext, n as PageTreeOptions, k as PageTreeTransformer, R as ResolvedLoaderConfig, S as Source, a as SourceConfig, V as VirtualFile, _ as _ConfigUnion_, r as buildContentStorage, t as buildPlugins, h as createGetUrl, p as createPageTreeBuilder, l as loader, b as map, m as multiple } from '../loader-qkSHi822.js';
2
+ import '../definitions-pJ7PybYY.js';
3
3
  import 'react';
4
4
  import '../i18n/index.js';
5
5
 
@@ -399,15 +399,14 @@ function createPageTreeBuilderUtils(ctx) {
399
399
  "page"
400
400
  );
401
401
  let meta = storage.read(metaPath);
402
- if (meta?.format !== "meta") {
403
- meta = void 0;
404
- }
405
- const isRoot = meta?.data.root ?? isGlobalRoot;
402
+ if (meta && meta.format !== "meta") meta = void 0;
403
+ const metadata = meta?.data ?? {};
404
+ const { root = isGlobalRoot, pages } = metadata;
406
405
  let index;
407
406
  let children;
408
- if (meta && meta.data.pages) {
409
- const resolved = meta.data.pages.flatMap((item) => this.resolveFolderItem(folderPath, item));
410
- if (!isRoot && !visitedPaths.has(indexPath)) {
407
+ if (pages) {
408
+ const resolved = pages.flatMap((item) => this.resolveFolderItem(folderPath, item));
409
+ if (!root && !visitedPaths.has(indexPath)) {
411
410
  index = this.file(indexPath);
412
411
  }
413
412
  for (let i = 0; i < resolved.length; i++) {
@@ -422,25 +421,24 @@ function createPageTreeBuilderUtils(ctx) {
422
421
  }
423
422
  children = resolved;
424
423
  } else {
425
- if (!isRoot && !visitedPaths.has(indexPath)) {
424
+ if (!root && !visitedPaths.has(indexPath)) {
426
425
  index = this.file(indexPath);
427
426
  }
428
427
  children = this.buildPaths(
429
428
  files.filter((file) => !visitedPaths.has(file))
430
429
  );
431
430
  }
432
- let name = meta?.data.title ?? index?.name;
433
- if (!name) {
434
- const folderName = basename(folderPath);
435
- name = pathToName(group.exec(folderName)?.[1] ?? folderName);
436
- }
437
431
  let node = {
438
432
  type: "folder",
439
- name,
440
- icon: meta?.data.icon ?? index?.icon,
441
- root: meta?.data.root,
442
- defaultOpen: meta?.data.defaultOpen,
443
- description: meta?.data.description,
433
+ name: metadata.title ?? index?.name ?? (() => {
434
+ const folderName = basename(folderPath);
435
+ return pathToName(group.exec(folderName)?.[1] ?? folderName);
436
+ })(),
437
+ icon: metadata.icon,
438
+ root: metadata.root,
439
+ defaultOpen: metadata.defaultOpen,
440
+ description: metadata.description,
441
+ collapsible: metadata.collapsible,
444
442
  index,
445
443
  children,
446
444
  $id: nextNodeId(folderPath),
@@ -1,6 +1,6 @@
1
- import { L as LoaderPlugin } from '../../loader-Dz9yZIJQ.js';
1
+ import { L as LoaderPlugin } from '../../loader-qkSHi822.js';
2
2
  import { icons } from 'lucide-react';
3
- import '../../definitions-DbCug1P3.js';
3
+ import '../../definitions-pJ7PybYY.js';
4
4
  import 'react';
5
5
  import '../../i18n/index.js';
6
6
 
@@ -0,0 +1,26 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * Zod 4 schema
5
+ */
6
+ declare const metaSchema: z.ZodObject<{
7
+ title: z.ZodOptional<z.ZodString>;
8
+ pages: z.ZodOptional<z.ZodArray<z.ZodString>>;
9
+ description: z.ZodOptional<z.ZodString>;
10
+ root: z.ZodOptional<z.ZodBoolean>;
11
+ defaultOpen: z.ZodOptional<z.ZodBoolean>;
12
+ collapsible: z.ZodOptional<z.ZodBoolean>;
13
+ icon: z.ZodOptional<z.ZodString>;
14
+ }, z.core.$strip>;
15
+ /**
16
+ * Zod 4 schema
17
+ */
18
+ declare const pageSchema: z.ZodObject<{
19
+ title: z.ZodString;
20
+ description: z.ZodOptional<z.ZodString>;
21
+ icon: z.ZodOptional<z.ZodString>;
22
+ full: z.ZodOptional<z.ZodBoolean>;
23
+ _openapi: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
24
+ }, z.core.$strip>;
25
+
26
+ export { metaSchema, pageSchema };
@@ -0,0 +1,25 @@
1
+ import "../chunk-U67V476Y.js";
2
+
3
+ // src/source/schema.ts
4
+ import { z } from "zod";
5
+ var metaSchema = z.object({
6
+ title: z.string().optional(),
7
+ pages: z.array(z.string()).optional(),
8
+ description: z.string().optional(),
9
+ root: z.boolean().optional(),
10
+ defaultOpen: z.boolean().optional(),
11
+ collapsible: z.boolean().optional(),
12
+ icon: z.string().optional()
13
+ });
14
+ var pageSchema = z.object({
15
+ title: z.string(),
16
+ description: z.string().optional(),
17
+ icon: z.string().optional(),
18
+ full: z.boolean().optional(),
19
+ // Fumadocs OpenAPI generated
20
+ _openapi: z.looseObject({}).optional()
21
+ });
22
+ export {
23
+ metaSchema,
24
+ pageSchema
25
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-core",
3
- "version": "16.2.2",
3
+ "version": "16.2.4",
4
4
  "description": "The React.js library for building a documentation website",
5
5
  "keywords": [
6
6
  "Fumadocs",
@@ -52,6 +52,10 @@
52
52
  "import": "./dist/source/client/index.js",
53
53
  "types": "./dist/source/client/index.d.ts"
54
54
  },
55
+ "./source/schema": {
56
+ "import": "./dist/source/schema.js",
57
+ "types": "./dist/source/schema.d.ts"
58
+ },
55
59
  "./source/*": {
56
60
  "import": "./dist/source/plugins/*.js",
57
61
  "types": "./dist/source/plugins/*.d.ts"
@@ -107,8 +111,8 @@
107
111
  "dependencies": {
108
112
  "@formatjs/intl-localematcher": "^0.6.2",
109
113
  "@orama/orama": "^3.1.16",
110
- "@shikijs/rehype": "^3.18.0",
111
- "@shikijs/transformers": "^3.18.0",
114
+ "@shikijs/rehype": "^3.19.0",
115
+ "@shikijs/transformers": "^3.19.0",
112
116
  "estree-util-value-to-estree": "^3.5.0",
113
117
  "github-slugger": "^2.0.0",
114
118
  "hast-util-to-estree": "^3.1.3",
@@ -121,36 +125,37 @@
121
125
  "remark-gfm": "^4.0.1",
122
126
  "remark-rehype": "^11.1.2",
123
127
  "scroll-into-view-if-needed": "^3.1.0",
124
- "shiki": "^3.18.0",
128
+ "shiki": "^3.19.0",
125
129
  "unist-util-visit": "^5.0.0"
126
130
  },
127
131
  "devDependencies": {
128
132
  "@mdx-js/mdx": "^3.1.1",
129
- "@mixedbread/sdk": "^0.45.0",
133
+ "@mixedbread/sdk": "^0.46.0",
130
134
  "@orama/core": "^1.2.13",
131
- "@tanstack/react-router": "1.136.18",
135
+ "@tanstack/react-router": "1.140.0",
132
136
  "@types/estree-jsx": "^1.0.5",
133
137
  "@types/hast": "^3.0.4",
134
138
  "@types/mdast": "^4.0.4",
135
139
  "@types/negotiator": "^0.6.4",
136
- "@types/node": "24.10.1",
140
+ "@types/node": "24.10.2",
137
141
  "@types/react": "^19.2.7",
138
142
  "@types/react-dom": "^19.2.3",
139
- "algoliasearch": "5.45.0",
140
- "lucide-react": "^0.555.0",
143
+ "algoliasearch": "5.46.0",
144
+ "lucide-react": "^0.556.0",
141
145
  "mdast-util-mdx-jsx": "^3.2.0",
142
146
  "mdast-util-mdxjs-esm": "^2.0.1",
143
- "next": "16.0.6",
144
- "react-router": "^7.9.6",
147
+ "next": "16.0.8",
148
+ "react-router": "^7.10.1",
145
149
  "remark-directive": "^4.0.0",
146
150
  "remark-mdx": "^3.1.1",
147
151
  "remove-markdown": "^0.6.2",
148
152
  "typescript": "^5.9.3",
149
153
  "unified": "^11.0.5",
150
154
  "vfile": "^6.0.3",
151
- "waku": "^0.27.2",
152
- "tsconfig": "0.0.0",
153
- "eslint-config-custom": "0.0.0"
155
+ "waku": "^0.27.3",
156
+ "zod": "^4.1.13",
157
+ "eslint-config-custom": "0.0.0",
158
+ "tsconfig": "0.0.0"
154
159
  },
155
160
  "peerDependencies": {
156
161
  "@mixedbread/sdk": "^0.19.0",
@@ -163,7 +168,8 @@
163
168
  "react": "^19.2.0",
164
169
  "react-dom": "^19.2.0",
165
170
  "react-router": "7.x.x",
166
- "waku": "^0.26.0 || ^0.27.0"
171
+ "waku": "^0.26.0 || ^0.27.0",
172
+ "zod": "*"
167
173
  },
168
174
  "peerDependenciesMeta": {
169
175
  "@mixedbread/sdk": {
@@ -198,6 +204,9 @@
198
204
  },
199
205
  "lucide-react": {
200
206
  "optional": true
207
+ },
208
+ "zod": {
209
+ "optional": true
201
210
  }
202
211
  },
203
212
  "publishConfig": {