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,263 +1,42 @@
1
- import { ReactElement } from 'react';
2
- import { I as I18nConfig } from '../config-inq6kP6y.js';
3
- import { R as Root, I as Item, F as Folder$1, S as Separator } from '../page-tree-BG3wP0gU.js';
1
+ export { C as ContentStorage, F as FileSystem, t as InferMetaType, I as InferPageType, f as LoaderConfig, g as LoaderOptions, k as LoaderOutput, L as LoaderPlugin, j as Meta, p as MetaData, M as MetaFile, i as Page, q as PageData, e as PageFile, a as PageTreeBuilder, b as PageTreeBuilderContext, d as PageTreeOptions, P as PageTreeTransformer, R as ResolvedLoaderConfig, h as Source, S as SourceConfig, U as UrlFn, s as VirtualFile, r as VirtualMeta, V as VirtualPage, _ as _ConfigUnion_, u as buildPlugins, l as createGetUrl, c as createPageTreeBuilder, m as loader, o as map, n as multiple } from '../builder-feW_xVjc.js';
2
+ import '../definitions-BRsJlZ6m.js';
3
+ import 'react';
4
+ import '../i18n/index.js';
4
5
 
5
- interface FileInfo {
6
- /**
7
- * File path without extension
8
- *
9
- * @deprecated obtain it with `join(dirname, name)`
10
- */
11
- flattenedPath: string;
12
- /**
13
- * Original path of file
14
- */
15
- path: string;
16
- /**
17
- * File name without locale and extension
18
- */
19
- name: string;
20
- /**
21
- * file extension from the last `.`, like `.md`
22
- *
23
- * empty string if no file extension
24
- */
25
- ext: string;
26
- dirname: string;
27
- }
28
- interface FolderInfo {
29
- /**
30
- * Original path of folder
31
- */
32
- path: string;
33
- /**
34
- * folder name
35
- */
36
- name: string;
37
- dirname: string;
38
- }
39
- declare function parseFilePath(path: string): FileInfo;
40
- declare function parseFolderPath(path: string): FolderInfo;
41
-
42
- interface LoadOptions {
43
- transformers?: Transformer[];
44
- getSlugs: (info: FileInfo) => string[];
45
- }
46
- interface I18nLoadOptions extends LoadOptions {
47
- i18n: {
48
- parser: 'dot' | 'dir';
49
- languages: string[];
50
- defaultLanguage: string;
51
- };
52
- }
53
- interface VirtualFile {
54
- /**
55
- * Relative path
56
- *
57
- * @example `docs/page.mdx`
58
- */
59
- path: string;
60
- type: 'page' | 'meta';
61
- /**
62
- * Specified Slugs for page
63
- */
64
- slugs?: string[];
65
- data: unknown;
66
- }
67
- type Transformer = (context: {
68
- storage: Storage;
69
- options: LoadOptions;
70
- }) => void;
71
- declare function loadFiles<O extends LoadOptions>(files: VirtualFile[], options: O): Storage;
72
-
73
- interface LoaderConfig {
74
- source: SourceConfig;
75
- i18n: boolean;
76
- }
77
- interface SourceConfig {
78
- pageData: PageData;
79
- metaData: MetaData;
80
- }
81
- interface LoaderOptions {
82
- baseUrl: string;
83
- icon?: NonNullable<BuildPageTreeOptions['resolveIcon']>;
84
- slugs?: LoadOptions['getSlugs'];
85
- url?: UrlFn;
86
- source: Source<any>;
87
- transformers?: Transformer[];
88
- /**
89
- * Additional options for page tree builder
90
- */
91
- pageTree?: Partial<Omit<BuildPageTreeOptions, 'storage' | 'getUrl'>>;
92
- /**
93
- * Configure i18n
94
- */
95
- i18n?: I18nConfig & {
96
- parser?: I18nLoadOptions['i18n']['parser'];
97
- };
98
- }
99
- interface Source<Config extends SourceConfig> {
100
- /**
101
- * @internal
102
- */
103
- _config?: Config;
104
- files: VirtualFile[] | (() => VirtualFile[]);
105
- }
106
- interface Page<Data = PageData> {
107
- file: FileInfo;
108
- slugs: string[];
109
- url: string;
110
- data: Data;
111
- locale?: string | undefined;
112
- }
113
- interface Meta<Data = MetaData> {
114
- file: FileInfo;
115
- data: Data;
116
- }
117
- interface LanguageEntry<Data = PageData> {
118
- language: string;
119
- pages: Page<Data>[];
120
- }
121
- interface LoaderOutput<Config extends LoaderConfig> {
122
- pageTree: Config['i18n'] extends true ? Record<string, Root> : Root;
123
- getPageTree: (locale?: string) => Root;
124
- getPageByHref: (href: string, options?: {
125
- /**
126
- * resolve relative file paths in `href` from specified dirname, must be a virtual path.
127
- */
128
- dir?: string;
129
- }) => {
130
- page: Page<Config['source']['pageData']>;
131
- hash?: string;
132
- } | undefined;
133
- _i18n?: I18nConfig;
134
- /**
135
- * Get list of pages from language, empty if language hasn't specified
136
- *
137
- * @param language - If empty, the default language will be used
138
- */
139
- getPages: (language?: string) => Page<Config['source']['pageData']>[];
140
- getLanguages: () => LanguageEntry<Config['source']['pageData']>[];
141
- /**
142
- * @param language - If empty, the default language will be used
143
- */
144
- getPage: (slugs: string[] | undefined, language?: string) => Page<Config['source']['pageData']> | undefined;
145
- getNodePage: (node: Item, language?: string) => Page<Config['source']['pageData']> | undefined;
146
- getNodeMeta: (node: Folder$1, language?: string) => Meta<Config['source']['metaData']> | undefined;
147
- /**
148
- * generate static params for Next.js SSG
149
- */
150
- generateParams: <TSlug extends string = 'slug', TLang extends string = 'lang'>(slug?: TSlug, lang?: TLang) => (Record<TSlug, string[]> & Record<TLang, string>)[];
151
- }
152
- declare function createGetUrl(baseUrl: string, i18n?: I18nConfig): UrlFn;
153
- declare function getSlugs(info: FileInfo): string[];
154
- type InferSourceConfig<T> = T extends Source<infer Config> ? Config : never;
155
- declare function loader<Options extends LoaderOptions>(options: Options): LoaderOutput<{
156
- source: InferSourceConfig<Options['source']>;
157
- i18n: Options['i18n'] extends I18nConfig ? true : false;
158
- }>;
159
-
160
- interface MetaData {
161
- icon?: string | undefined;
162
- title?: string | undefined;
163
- root?: boolean | undefined;
164
- pages?: string[] | undefined;
165
- defaultOpen?: boolean | undefined;
166
- description?: string | undefined;
167
- }
168
- interface PageData {
169
- icon?: string | undefined;
170
- title?: string;
171
- description?: string | undefined;
172
- }
173
- type InferPageType<Utils extends LoaderOutput<any>> = Utils extends LoaderOutput<infer Config> ? Page<Config['source']['pageData']> : never;
174
- type InferMetaType<Utils extends LoaderOutput<any>> = Utils extends LoaderOutput<infer Config> ? Meta<Config['source']['metaData']> : never;
175
6
  /**
176
- * @internal
7
+ * Convert file path into slugs, also encode non-ASCII characters, so they can work in pathname
177
8
  */
178
- type UrlFn = (slugs: string[], locale?: string) => string;
9
+ declare function getSlugs(file: string): string[];
179
10
 
180
- interface MetaFile {
181
- file: FileInfo;
182
- format: 'meta';
183
- data: MetaData;
184
- }
185
- interface PageFile {
186
- file: FileInfo;
187
- format: 'page';
188
- data: {
189
- slugs: string[];
190
- data: PageData;
191
- };
192
- }
193
- type File = MetaFile | PageFile;
194
- interface Folder {
195
- file: FolderInfo;
196
- children: (File | Folder)[];
197
- }
11
+ declare function basename(path: string, ext?: string): string;
12
+ declare function extname(path: string): string;
13
+ declare function dirname(path: string): string;
198
14
  /**
199
- * A virtual file system that solves inconsistent behaviours
200
- *
201
- * Some source providers may not provide the full file structure, this will cause inconsistent outputs for page builder and other transformers
15
+ * Split path into segments, trailing/leading slashes are removed
202
16
  */
203
- declare class Storage {
204
- files: Map<string, File>;
205
- folders: Map<string, Folder>;
206
- private rootFolder;
207
- constructor();
208
- /**
209
- * @param path - flattened path
210
- * @param format - file format
211
- */
212
- read<F extends File['format']>(path: string, format: F): Extract<File, {
213
- format: F;
214
- }> | undefined;
215
- readDir(path: string): Folder | undefined;
216
- root(): Folder;
217
- write<F extends File['format']>(path: string, format: F, data: Extract<File, {
218
- format: F;
219
- }>['data']): void;
220
- list(): File[];
221
- makeDir(path: string): void;
222
- }
223
-
224
- type fileSystem_File = File;
225
- type fileSystem_Folder = Folder;
226
- type fileSystem_MetaFile = MetaFile;
227
- type fileSystem_PageFile = PageFile;
228
- type fileSystem_Storage = Storage;
229
- declare const fileSystem_Storage: typeof Storage;
230
- declare namespace fileSystem {
231
- export { type fileSystem_File as File, type fileSystem_Folder as Folder, type fileSystem_MetaFile as MetaFile, type fileSystem_PageFile as PageFile, fileSystem_Storage as Storage };
232
- }
17
+ declare function splitPath(path: string): string[];
18
+ /**
19
+ * Resolve paths, slashes within the path will be ignored
20
+ * @param paths - Paths to join
21
+ * @example
22
+ * ```
23
+ * ['a','b'] // 'a/b'
24
+ * ['/a'] // 'a'
25
+ * ['a', '/b'] // 'a/b'
26
+ * ['a', '../b/c'] // 'b/c'
27
+ * ```
28
+ */
29
+ declare function joinPath(...paths: string[]): string;
30
+ declare function slash(path: string): string;
233
31
 
234
- interface Options {
235
- /**
236
- * Remove references to the file path of original nodes (`$ref`)
237
- *
238
- * @defaultValue false
239
- */
240
- noRef?: boolean;
241
- attachFile?: (node: Item, file?: PageFile) => Item;
242
- attachFolder?: (node: Folder$1, folder: Folder, meta?: MetaFile) => Folder$1;
243
- attachSeparator?: (node: Separator) => Separator;
244
- getUrl: UrlFn;
245
- resolveIcon?: (icon: string | undefined) => ReactElement | undefined;
246
- }
247
- interface BuildPageTreeOptions extends Options {
248
- storage: Storage;
249
- }
250
- interface BuildPageTreeOptionsWithI18n extends Options {
251
- storages: Record<string, Storage>;
252
- i18n: I18nConfig;
253
- }
254
- interface PageTreeBuilder {
255
- build: (options: BuildPageTreeOptions) => Root;
256
- /**
257
- * Build page tree and fallback to the default language if the localized page doesn't exist
258
- */
259
- buildI18n: (options: BuildPageTreeOptionsWithI18n) => Record<string, Root>;
32
+ declare const path_basename: typeof basename;
33
+ declare const path_dirname: typeof dirname;
34
+ declare const path_extname: typeof extname;
35
+ declare const path_joinPath: typeof joinPath;
36
+ declare const path_slash: typeof slash;
37
+ declare const path_splitPath: typeof splitPath;
38
+ declare namespace path {
39
+ export { path_basename as basename, path_dirname as dirname, path_extname as extname, path_joinPath as joinPath, path_slash as slash, path_splitPath as splitPath };
260
40
  }
261
- declare function createPageTreeBuilder(): PageTreeBuilder;
262
41
 
263
- export { type BuildPageTreeOptions, type BuildPageTreeOptionsWithI18n, type FileInfo, fileSystem as FileSystem, type FolderInfo, type InferMetaType, type InferPageType, type LanguageEntry, type LoadOptions, type LoaderConfig, type LoaderOptions, type LoaderOutput, type Meta, type MetaData, type Page, type PageData, type PageTreeBuilder, type Source, type SourceConfig, type Transformer, type UrlFn, type VirtualFile, createGetUrl, createPageTreeBuilder, getSlugs, loadFiles, loader, parseFilePath, parseFolderPath };
42
+ export { path as PathUtils, getSlugs };