fumadocs-core 15.2.8 → 16.0.3

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.
Files changed (92) hide show
  1. package/README.md +1 -1
  2. package/dist/algolia-IZEDLPHE.js +58 -0
  3. package/dist/breadcrumb.d.ts +7 -5
  4. package/dist/breadcrumb.js +46 -52
  5. package/dist/builder-feW_xVjc.d.ts +296 -0
  6. package/dist/{chunk-FVY6EZ3N.js → chunk-BBP7MIO4.js} +12 -14
  7. package/dist/{chunk-ORHEEQVY.js → chunk-EMWGTXSW.js} +0 -7
  8. package/dist/chunk-FAEPKD7U.js +20 -0
  9. package/dist/{chunk-NNKVN7WA.js → chunk-H2GMUTQG.js} +4 -2
  10. package/dist/chunk-IZPLHEX4.js +113 -0
  11. package/dist/chunk-OTD7MV33.js +53 -0
  12. package/dist/chunk-PFNP6PEB.js +11 -0
  13. package/dist/{chunk-Y2774T3B.js → chunk-QMATWJ5F.js} +6 -7
  14. package/dist/chunk-U67V476Y.js +35 -0
  15. package/dist/{chunk-BUCUQ3WX.js → chunk-XN2LKXFZ.js} +39 -34
  16. package/dist/{chunk-WFUH5VBX.js → chunk-XOFXGHS4.js} +26 -10
  17. package/dist/chunk-XZSI7AHE.js +67 -0
  18. package/dist/chunk-YVVDKJ2H.js +34 -0
  19. package/dist/chunk-ZMWYLUDP.js +21 -0
  20. package/dist/content/github.d.ts +34 -0
  21. package/dist/content/github.js +43 -0
  22. package/dist/content/index.d.ts +16 -0
  23. package/dist/content/index.js +30 -0
  24. package/dist/{get-toc-Cr2URuiP.d.ts → content/toc.d.ts} +6 -10
  25. package/dist/content/toc.js +21 -0
  26. package/dist/{page-tree-BG3wP0gU.d.ts → definitions-BRsJlZ6m.d.ts} +10 -15
  27. package/dist/dynamic-link.js +3 -3
  28. package/dist/fetch-2XFMBLBA.js +22 -0
  29. package/dist/framework/index.d.ts +1 -1
  30. package/dist/framework/index.js +2 -2
  31. package/dist/framework/next.js +2 -2
  32. package/dist/framework/react-router.js +2 -2
  33. package/dist/framework/tanstack.js +2 -2
  34. package/dist/framework/waku.d.ts +8 -0
  35. package/dist/framework/waku.js +51 -0
  36. package/dist/hide-if-empty.d.ts +18 -0
  37. package/dist/hide-if-empty.js +83 -0
  38. package/dist/highlight/client.d.ts +8 -5
  39. package/dist/highlight/client.js +9 -93
  40. package/dist/highlight/index.d.ts +20 -5
  41. package/dist/highlight/index.js +10 -6
  42. package/dist/i18n/index.d.ts +35 -8
  43. package/dist/i18n/index.js +5 -69
  44. package/dist/i18n/middleware.d.ts +12 -0
  45. package/dist/i18n/middleware.js +63 -0
  46. package/dist/link.js +3 -3
  47. package/dist/mdx-plugins/index.d.ts +124 -18
  48. package/dist/mdx-plugins/index.js +605 -203
  49. package/dist/mixedbread-RAHDVXGJ.js +118 -0
  50. package/dist/negotiation/index.d.ts +19 -0
  51. package/dist/negotiation/index.js +11 -0
  52. package/dist/{orama-cloud-USLSOSXS.js → orama-cloud-WEGQE5A6.js} +37 -27
  53. package/dist/page-tree/index.d.ts +32 -0
  54. package/dist/page-tree/index.js +15 -0
  55. package/dist/remark-code-tab-DmyIyi6m.d.ts +57 -0
  56. package/dist/{remark-structure-FIjTA11P.d.ts → remark-structure-DkCXCzpD.d.ts} +13 -2
  57. package/dist/search/algolia.d.ts +9 -7
  58. package/dist/search/algolia.js +31 -17
  59. package/dist/search/client.d.ts +88 -17
  60. package/dist/search/client.js +71 -50
  61. package/dist/search/index.d.ts +26 -0
  62. package/dist/search/index.js +7 -0
  63. package/dist/search/orama-cloud.d.ts +7 -5
  64. package/dist/search/orama-cloud.js +18 -10
  65. package/dist/search/server.d.ts +33 -25
  66. package/dist/search/server.js +109 -47
  67. package/dist/source/index.d.ts +33 -254
  68. package/dist/source/index.js +532 -353
  69. package/dist/source/plugins/lucide-icons.d.ts +14 -0
  70. package/dist/source/plugins/lucide-icons.js +23 -0
  71. package/dist/static-A2YJ5TXV.js +62 -0
  72. package/dist/toc.d.ts +11 -7
  73. package/dist/toc.js +6 -5
  74. package/dist/utils/use-effect-event.d.ts +4 -3
  75. package/dist/utils/use-effect-event.js +9 -6
  76. package/dist/utils/use-media-query.d.ts +3 -0
  77. package/dist/utils/use-media-query.js +23 -0
  78. package/dist/utils/use-on-change.js +2 -2
  79. package/package.json +92 -40
  80. package/dist/algolia-NTWLS6J3.js +0 -49
  81. package/dist/chunk-KAOEMCTI.js +0 -17
  82. package/dist/chunk-MLKGABMK.js +0 -9
  83. package/dist/chunk-XMCPKVJQ.js +0 -34
  84. package/dist/config-inq6kP6y.d.ts +0 -26
  85. package/dist/fetch-W5EHIBOE.js +0 -21
  86. package/dist/remark-heading-BPCoYwjn.d.ts +0 -31
  87. package/dist/server/index.d.ts +0 -117
  88. package/dist/server/index.js +0 -202
  89. package/dist/sidebar.d.ts +0 -33
  90. package/dist/sidebar.js +0 -89
  91. package/dist/static-VESU2S64.js +0 -61
  92. package/dist/types-Ch8gnVgO.d.ts +0 -8
@@ -1,73 +1,9 @@
1
- import "../chunk-MLKGABMK.js";
1
+ import "../chunk-U67V476Y.js";
2
2
 
3
- // src/i18n/middleware.ts
4
- import { match as matchLocale } from "@formatjs/intl-localematcher";
5
- import Negotiator from "negotiator";
6
- import { NextResponse } from "next/server";
7
- var COOKIE = "FD_LOCALE";
8
- function getLocale(request, locales, defaultLanguage) {
9
- const negotiatorHeaders = {};
10
- request.headers.forEach((value, key) => {
11
- negotiatorHeaders[key] = value;
12
- });
13
- const languages = new Negotiator({ headers: negotiatorHeaders }).languages(
14
- locales
15
- );
16
- return matchLocale(languages, locales, defaultLanguage);
17
- }
18
- var defaultFormat = (locale, path) => {
19
- return `/${locale}/${path}`;
20
- };
21
- function createI18nMiddleware({
22
- languages,
23
- defaultLanguage,
24
- format = defaultFormat,
25
- hideLocale = "never"
26
- }) {
27
- function getUrl(request, pathname, locale) {
28
- if (!locale) {
29
- return new URL(
30
- pathname.startsWith("/") ? pathname : `/${pathname}`,
31
- request.url
32
- );
33
- }
34
- return new URL(
35
- format(locale, pathname.startsWith("/") ? pathname.slice(1) : pathname),
36
- request.url
37
- );
38
- }
39
- return (request) => {
40
- const inputPath = `${request.nextUrl.pathname}${request.nextUrl.search}`;
41
- const pathLocale = languages.find(
42
- (locale) => inputPath.startsWith(`/${locale}/`) || inputPath === `/${locale}`
43
- );
44
- if (!pathLocale) {
45
- if (hideLocale === "default-locale") {
46
- return NextResponse.rewrite(
47
- getUrl(request, inputPath, defaultLanguage)
48
- );
49
- }
50
- const preferred = getLocale(request, languages, defaultLanguage);
51
- if (hideLocale === "always") {
52
- const locale = request.cookies.get(COOKIE)?.value ?? preferred;
53
- return NextResponse.rewrite(getUrl(request, inputPath, locale));
54
- }
55
- return NextResponse.redirect(getUrl(request, inputPath, preferred));
56
- }
57
- if (hideLocale === "always") {
58
- const path = inputPath.slice(`/${pathLocale}`.length);
59
- const res = NextResponse.redirect(getUrl(request, path));
60
- res.cookies.set(COOKIE, pathLocale);
61
- return res;
62
- }
63
- if (hideLocale === "default-locale" && pathLocale === defaultLanguage) {
64
- return NextResponse.redirect(
65
- getUrl(request, inputPath.slice(`/${pathLocale}`.length))
66
- );
67
- }
68
- return NextResponse.next();
69
- };
3
+ // src/i18n/index.ts
4
+ function defineI18n(config) {
5
+ return config;
70
6
  }
71
7
  export {
72
- createI18nMiddleware
8
+ defineI18n
73
9
  };
@@ -0,0 +1,12 @@
1
+ import { NextProxy } from 'next/dist/server/web/types';
2
+ import { I18nConfig } from './index.js';
3
+
4
+ interface MiddlewareOptions extends I18nConfig {
5
+ /**
6
+ * A function that adds the locale prefix to path name
7
+ */
8
+ format?: (locale: string, path: string) => string;
9
+ }
10
+ declare function createI18nMiddleware({ languages, defaultLanguage, format, hideLocale, }: MiddlewareOptions): NextProxy;
11
+
12
+ export { createI18nMiddleware };
@@ -0,0 +1,63 @@
1
+ import {
2
+ getNegotiator
3
+ } from "../chunk-YVVDKJ2H.js";
4
+ import "../chunk-U67V476Y.js";
5
+
6
+ // src/i18n/middleware.ts
7
+ import { match as matchLocale } from "@formatjs/intl-localematcher";
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}`;
16
+ };
17
+ function createI18nMiddleware({
18
+ languages,
19
+ defaultLanguage,
20
+ format = defaultFormat,
21
+ hideLocale = "never"
22
+ }) {
23
+ function getLocaleUrl(request, locale) {
24
+ const next = new URL(request.url);
25
+ next.pathname = format(locale, forceSlashPrefix(request.nextUrl.pathname));
26
+ return next;
27
+ }
28
+ return (request) => {
29
+ const url = request.nextUrl;
30
+ const pathLocale = languages.find(
31
+ (locale) => url.pathname.startsWith(`/${locale}/`) || url.pathname === `/${locale}`
32
+ );
33
+ if (!pathLocale) {
34
+ if (hideLocale === "default-locale") {
35
+ return NextResponse.rewrite(getLocaleUrl(request, defaultLanguage));
36
+ }
37
+ const preferred = getLocale(request, languages, defaultLanguage);
38
+ if (hideLocale === "always") {
39
+ const locale = request.cookies.get(COOKIE)?.value ?? preferred;
40
+ return NextResponse.rewrite(getLocaleUrl(request, locale));
41
+ }
42
+ return NextResponse.redirect(getLocaleUrl(request, preferred));
43
+ }
44
+ 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);
52
+ return res;
53
+ }
54
+ return NextResponse.next();
55
+ };
56
+ }
57
+ function forceSlashPrefix(v) {
58
+ if (v.startsWith("/")) return v;
59
+ return "/" + v;
60
+ }
61
+ export {
62
+ createI18nMiddleware
63
+ };
package/dist/link.js CHANGED
@@ -1,9 +1,9 @@
1
1
  "use client";
2
2
  import {
3
3
  Link
4
- } from "./chunk-NNKVN7WA.js";
5
- import "./chunk-FVY6EZ3N.js";
6
- import "./chunk-MLKGABMK.js";
4
+ } from "./chunk-H2GMUTQG.js";
5
+ import "./chunk-BBP7MIO4.js";
6
+ import "./chunk-U67V476Y.js";
7
7
  export {
8
8
  Link as default
9
9
  };
@@ -3,16 +3,16 @@ import { Root } from 'hast';
3
3
  import { RehypeShikiOptions } from '@shikijs/rehype';
4
4
  import { Processor, Transformer } from 'unified';
5
5
  import { ShikiTransformer } from 'shiki';
6
- import { Root as Root$1 } from 'mdast';
7
- export { a as StructureOptions, S as StructuredData, r as remarkStructure, s as structure } from '../remark-structure-FIjTA11P.js';
8
- export { R as RemarkHeadingOptions, r as remarkHeading } from '../remark-heading-BPCoYwjn.js';
9
- import 'mdast-util-mdx-jsx';
6
+ import { Root as Root$1, BlockContent, Text } from 'mdast';
7
+ export { a as StructureOptions, S as StructuredData, r as remarkStructure, s as structure } from '../remark-structure-DkCXCzpD.js';
8
+ export { a as RemarkCodeTabOptions, R as RemarkHeadingOptions, b as remarkCodeTab, r as remarkHeading } from '../remark-code-tab-DmyIyi6m.js';
9
+ import { MdxJsxAttribute, MdxJsxFlowElement } from 'mdast-util-mdx-jsx';
10
10
 
11
- interface CodeBlockIcon {
11
+ type CodeBlockIcon = {
12
12
  viewBox: string;
13
13
  fill: string;
14
14
  d: string;
15
- }
15
+ } | string;
16
16
  interface IconOptions {
17
17
  shortcuts?: Record<string, string>;
18
18
  extend?: Record<string, CodeBlockIcon>;
@@ -24,6 +24,12 @@ declare function transformerIcon(options?: IconOptions): ShikiTransformer;
24
24
 
25
25
  declare const rehypeCodeDefaultOptions: RehypeCodeOptions;
26
26
  type RehypeCodeOptions = RehypeShikiOptions & {
27
+ /**
28
+ * The regex engine to use.
29
+ *
30
+ * @defaultValue 'js'
31
+ */
32
+ engine?: 'js' | 'oniguruma';
27
33
  /**
28
34
  * Filter meta string before processing
29
35
  */
@@ -37,13 +43,7 @@ type RehypeCodeOptions = RehypeShikiOptions & {
37
43
  *
38
44
  * @defaultValue true
39
45
  */
40
- tab?: false;
41
- /**
42
- * Enable Shiki's experimental JS engine
43
- *
44
- * @defaultValue false
45
- */
46
- experimentalJSEngine?: boolean;
46
+ tab?: boolean;
47
47
  };
48
48
  /**
49
49
  * Handle codeblocks
@@ -57,11 +57,21 @@ interface RemarkImageOptions {
57
57
  */
58
58
  publicDir?: string;
59
59
  /**
60
- * Preferred placeholder type
60
+ * Preferred placeholder type, only available with `useImport` + local images.
61
61
  *
62
62
  * @defaultValue 'blur'
63
63
  */
64
64
  placeholder?: 'blur' | 'none';
65
+ /**
66
+ * Define how to handle errors when fetching image size.
67
+ *
68
+ * - `error` (default): throw an error.
69
+ * - `ignore`: do absolutely nothing (Next.js Image component may complain).
70
+ * - `hide`: remove that image element.
71
+ *
72
+ * @defaultValue 'error'
73
+ */
74
+ onError?: 'error' | 'hide' | 'ignore' | ((error: Error) => void);
65
75
  /**
66
76
  * Import images in the file, and let bundlers handle it.
67
77
  *
@@ -86,7 +96,7 @@ interface RemarkImageOptions {
86
96
  /**
87
97
  * Turn images into Next.js Image compatible usage.
88
98
  */
89
- declare function remarkImage({ placeholder, external, useImport, publicDir, }?: RemarkImageOptions): Transformer<Root$1, Root$1>;
99
+ declare function remarkImage({ placeholder, external, useImport, onError, publicDir, }?: RemarkImageOptions): Transformer<Root$1, Root$1>;
90
100
 
91
101
  interface RemarkAdmonitionOptions {
92
102
  tag?: string;
@@ -112,8 +122,6 @@ interface RehypeTocOptions {
112
122
  }
113
123
  declare function rehypeToc(this: Processor, { exportToc }?: RehypeTocOptions): Transformer<Root, Root>;
114
124
 
115
- declare function remarkCodeTab(): Transformer<Root$1, Root$1>;
116
-
117
125
  interface RemarkStepsOptions {
118
126
  /**
119
127
  * Class name for steps container
@@ -133,4 +141,102 @@ interface RemarkStepsOptions {
133
141
  */
134
142
  declare function remarkSteps({ steps, step, }?: RemarkStepsOptions): Transformer<Root$1, Root$1>;
135
143
 
136
- export { type CodeBlockIcon, type RehypeCodeOptions, type RehypeTocOptions, type RemarkAdmonitionOptions, type RemarkImageOptions, type RemarkStepsOptions, rehypeCode, rehypeCodeDefaultOptions, rehypeToc, remarkAdmonition, remarkCodeTab, remarkImage, remarkSteps, transformerIcon, transformerTab };
144
+ interface PackageManager {
145
+ name: string;
146
+ /**
147
+ * Default to `name`
148
+ */
149
+ value?: string;
150
+ /**
151
+ * Convert from npm to another package manager
152
+ */
153
+ command: (command: string) => string | undefined;
154
+ }
155
+ interface RemarkNpmOptions {
156
+ /**
157
+ * Persist Tab value (Fumadocs UI only)
158
+ *
159
+ * @defaultValue false
160
+ */
161
+ persist?: {
162
+ id: string;
163
+ } | false;
164
+ packageManagers?: PackageManager[];
165
+ }
166
+ /**
167
+ * It generates multiple tabs of codeblocks for different package managers from a npm command codeblock.
168
+ */
169
+ declare function remarkNpm({ persist, packageManagers, }?: RemarkNpmOptions): Transformer<Root$1, Root$1>;
170
+
171
+ interface CodeBlockTabsOptions {
172
+ attributes?: MdxJsxAttribute[];
173
+ defaultValue?: string;
174
+ persist?: {
175
+ id: string;
176
+ } | false;
177
+ triggers: {
178
+ value: string;
179
+ children: (BlockContent | Text)[];
180
+ }[];
181
+ tabs: {
182
+ value: string;
183
+ children: BlockContent[];
184
+ }[];
185
+ }
186
+ declare function generateCodeBlockTabs({ persist, defaultValue, triggers, tabs, ...options }: CodeBlockTabsOptions): MdxJsxFlowElement;
187
+ interface CodeBlockAttributes<Name extends string = string> {
188
+ attributes: Partial<Record<Name, string | null>>;
189
+ rest: string;
190
+ }
191
+ /**
192
+ * Parse Fumadocs-style code block attributes from meta string, like `title="hello world"`
193
+ */
194
+ declare function parseCodeBlockAttributes<Name extends string = string>(meta: string, allowedNames?: Name[]): CodeBlockAttributes<Name>;
195
+
196
+ interface FileNode {
197
+ depth: number;
198
+ type: 'file';
199
+ name: string;
200
+ }
201
+ interface FolderNode {
202
+ depth: number;
203
+ type: 'folder';
204
+ name: string;
205
+ children: Node[];
206
+ }
207
+ type Node = FileNode | FolderNode;
208
+ interface RemarkMdxFilesOptions {
209
+ /**
210
+ * @defaultValue files
211
+ */
212
+ lang?: string;
213
+ toMdx?: (node: Node) => MdxJsxFlowElement;
214
+ }
215
+ /**
216
+ * Convert codeblocks with `files` as lang, like:
217
+ *
218
+ * ```files
219
+ * project
220
+ * ├── src
221
+ * │ ├── index.js
222
+ * │ └── utils
223
+ * │ └── helper.js
224
+ * ├── package.json
225
+ * ```
226
+ *
227
+ * into MDX `<Files />` component
228
+ */
229
+ declare function remarkMdxFiles(options?: RemarkMdxFilesOptions): Transformer<Root$1, Root$1>;
230
+
231
+ interface RemarkMdxMermaidOptions {
232
+ /**
233
+ * @defaultValue mermaid
234
+ */
235
+ lang?: string;
236
+ }
237
+ /**
238
+ * Convert `mermaid` codeblocks into `<Mermaid />` MDX component
239
+ */
240
+ declare function remarkMdxMermaid(options?: RemarkMdxMermaidOptions): Transformer<Root$1, Root$1>;
241
+
242
+ export { type CodeBlockAttributes, type CodeBlockIcon, type CodeBlockTabsOptions, type RehypeCodeOptions, type RehypeTocOptions, type RemarkAdmonitionOptions, type RemarkImageOptions, type RemarkMdxFilesOptions, type RemarkMdxMermaidOptions, type RemarkNpmOptions, type RemarkStepsOptions, generateCodeBlockTabs, parseCodeBlockAttributes, rehypeCode, rehypeCodeDefaultOptions, rehypeToc, remarkAdmonition, remarkImage, remarkMdxFiles, remarkMdxMermaid, remarkNpm, remarkSteps, transformerIcon, transformerTab };