fumadocs-mdx 13.0.7 → 14.0.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.
- package/dist/bin.cjs +927 -904
- package/dist/bin.js +3 -3
- package/dist/build-mdx-6UAK5FF5.js +8 -0
- package/dist/bun/index.cjs +592 -481
- package/dist/bun/index.d.cts +3 -2
- package/dist/bun/index.d.ts +3 -2
- package/dist/bun/index.js +12 -12
- package/dist/chunk-4JSFLXXT.js +8 -0
- package/dist/chunk-5UMZCWKV.js +17 -0
- package/dist/chunk-5YXP7JLN.js +138 -0
- package/dist/{chunk-2E2JCOSO.js → chunk-6NISOLQ6.js} +16 -44
- package/dist/chunk-7L2KNF6B.js +180 -0
- package/dist/chunk-E5DJTSIM.js +86 -0
- package/dist/{chunk-K5ZLPEIQ.js → chunk-FBLMK4RS.js} +9 -6
- package/dist/{chunk-QXHN25N3.js → chunk-OXSRIWQW.js} +7 -8
- package/dist/chunk-PKI7ZDA5.js +29 -0
- package/dist/{chunk-3J3WL7WN.js → chunk-SLY7WXTX.js} +71 -58
- package/dist/{chunk-ETIN2W7C.js → chunk-SRSRFOVI.js} +22 -19
- package/dist/chunk-TYJDYTKH.js +85 -0
- package/dist/chunk-XHJCLBZ4.js +406 -0
- package/dist/{chunk-2HXTGJBI.js → chunk-ZY6UZ7NH.js} +22 -19
- package/dist/config/index.cjs +79 -71
- package/dist/config/index.d.cts +2 -1
- package/dist/config/index.d.ts +2 -1
- package/dist/config/index.js +5 -5
- package/dist/index-BlVBvy-z.d.ts +8 -0
- package/dist/{core-HkAVGq_a.d.cts → index-D7JdSMpp.d.cts} +99 -61
- package/dist/{core-HkAVGq_a.d.ts → index-D7JdSMpp.d.ts} +99 -61
- package/dist/index-P2NNUkHn.d.cts +8 -0
- package/dist/index.d.cts +3 -74
- package/dist/index.d.ts +3 -74
- package/dist/load-from-file-I3ALLIVB.js +8 -0
- package/dist/next/index.cjs +698 -476
- package/dist/next/index.d.cts +11 -1
- package/dist/next/index.d.ts +11 -1
- package/dist/next/index.js +78 -281
- package/dist/node/loader.cjs +705 -603
- package/dist/node/loader.js +10 -11
- package/dist/plugins/index-file.cjs +471 -0
- package/dist/plugins/index-file.d.cts +29 -0
- package/dist/plugins/index-file.d.ts +29 -0
- package/dist/plugins/index-file.js +8 -0
- package/dist/plugins/json-schema.d.cts +3 -2
- package/dist/plugins/json-schema.d.ts +3 -2
- package/dist/plugins/last-modified.cjs +75 -0
- package/dist/plugins/last-modified.d.cts +27 -0
- package/dist/plugins/last-modified.d.ts +27 -0
- package/dist/plugins/last-modified.js +44 -0
- package/dist/runtime/{vite/browser.cjs → browser.cjs} +40 -53
- package/dist/runtime/browser.d.cts +50 -0
- package/dist/runtime/browser.d.ts +50 -0
- package/dist/runtime/browser.js +68 -0
- package/dist/runtime/dynamic.cjs +985 -0
- package/dist/runtime/dynamic.d.cts +27 -0
- package/dist/runtime/dynamic.d.ts +27 -0
- package/dist/runtime/dynamic.js +78 -0
- package/dist/runtime/server.cjs +173 -0
- package/dist/runtime/server.d.cts +161 -0
- package/dist/runtime/server.d.ts +161 -0
- package/dist/runtime/server.js +8 -0
- package/dist/vite/index.cjs +935 -639
- package/dist/vite/index.d.cts +12 -22
- package/dist/vite/index.d.ts +12 -22
- package/dist/vite/index.js +30 -221
- package/dist/webpack/mdx.cjs +614 -515
- package/dist/webpack/mdx.d.cts +9 -1
- package/dist/webpack/mdx.d.ts +9 -1
- package/dist/webpack/mdx.js +12 -17
- package/dist/webpack/meta.cjs +328 -234
- package/dist/webpack/meta.d.cts +9 -1
- package/dist/webpack/meta.d.ts +9 -1
- package/dist/webpack/meta.js +13 -15
- package/package.json +15 -32
- package/dist/build-mdx-BnJhW5O1.d.cts +0 -53
- package/dist/build-mdx-DNzfRRlY.d.ts +0 -53
- package/dist/chunk-2AQRQXSO.js +0 -119
- package/dist/chunk-4757L6ST.js +0 -77
- package/dist/chunk-CXA4JO4Z.js +0 -45
- package/dist/chunk-FSZMKRVH.js +0 -80
- package/dist/chunk-II3H5ZVZ.js +0 -77
- package/dist/chunk-KILFIBVW.js +0 -75
- package/dist/chunk-NVRDCY6Z.js +0 -30
- package/dist/chunk-VUEZTR2H.js +0 -26
- package/dist/index-D7s7kCc2.d.cts +0 -7
- package/dist/index-D7s7kCc2.d.ts +0 -7
- package/dist/load-from-file-AVYOFOI7.js +0 -7
- package/dist/preset-ZMP6U62C.js +0 -6
- package/dist/runtime/next/async.cjs +0 -760
- package/dist/runtime/next/async.d.cts +0 -19
- package/dist/runtime/next/async.d.ts +0 -19
- package/dist/runtime/next/async.js +0 -86
- package/dist/runtime/next/index.cjs +0 -136
- package/dist/runtime/next/index.d.cts +0 -33
- package/dist/runtime/next/index.d.ts +0 -33
- package/dist/runtime/next/index.js +0 -11
- package/dist/runtime/vite/browser.d.cts +0 -59
- package/dist/runtime/vite/browser.d.ts +0 -59
- package/dist/runtime/vite/browser.js +0 -11
- package/dist/runtime/vite/server.cjs +0 -243
- package/dist/runtime/vite/server.d.cts +0 -30
- package/dist/runtime/vite/server.d.ts +0 -30
- package/dist/runtime/vite/server.js +0 -111
- package/dist/types-By6wKOnT.d.cts +0 -45
- package/dist/types-DgD5Omj2.d.ts +0 -45
package/dist/config/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AnyCollection, B as BaseCollection,
|
|
1
|
+
export { A as AnyCollection, B as BaseCollection, a as CollectionSchema, f as DefaultMDXOptions, D as DocCollection, b as DocsCollection, G as GlobalConfig, g as MDXPresetOptions, M as MetaCollection, P as PostprocessOptions, h as applyMdxPreset, d as defineCollections, e as defineConfig, c as defineDocs, i as frontmatterSchema, m as metaSchema } from '../index-D7JdSMpp.js';
|
|
2
2
|
import { Processor, Transformer } from 'unified';
|
|
3
3
|
import { Root } from 'mdast';
|
|
4
4
|
import '@mdx-js/mdx';
|
|
@@ -6,6 +6,7 @@ import '@standard-schema/spec';
|
|
|
6
6
|
import 'fumadocs-core/mdx-plugins';
|
|
7
7
|
import 'zod';
|
|
8
8
|
import 'chokidar';
|
|
9
|
+
import 'vfile';
|
|
9
10
|
|
|
10
11
|
declare function remarkInclude(this: Processor): Transformer<Root, Root>;
|
|
11
12
|
|
package/dist/config/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getDefaultMDXOptions
|
|
3
|
-
} from "../chunk-FSZMKRVH.js";
|
|
4
1
|
import {
|
|
5
2
|
remarkInclude
|
|
6
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-FBLMK4RS.js";
|
|
4
|
+
import {
|
|
5
|
+
applyMdxPreset
|
|
6
|
+
} from "../chunk-E5DJTSIM.js";
|
|
7
7
|
import "../chunk-VWJKRQZR.js";
|
|
8
8
|
|
|
9
9
|
// src/config/zod-4.ts
|
|
@@ -52,11 +52,11 @@ function defineConfig(config = {}) {
|
|
|
52
52
|
return config;
|
|
53
53
|
}
|
|
54
54
|
export {
|
|
55
|
+
applyMdxPreset,
|
|
55
56
|
defineCollections,
|
|
56
57
|
defineConfig,
|
|
57
58
|
defineDocs,
|
|
58
59
|
frontmatterSchema,
|
|
59
|
-
getDefaultMDXOptions,
|
|
60
60
|
metaSchema,
|
|
61
61
|
remarkInclude
|
|
62
62
|
};
|
|
@@ -1,30 +1,10 @@
|
|
|
1
1
|
import { ProcessorOptions } from '@mdx-js/mdx';
|
|
2
2
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
3
|
-
import * as plugins from 'fumadocs-core/mdx-plugins';
|
|
4
3
|
import { Pluggable } from 'unified';
|
|
4
|
+
import * as Plugins from 'fumadocs-core/mdx-plugins';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import { FSWatcher } from 'chokidar';
|
|
7
|
-
|
|
8
|
-
interface ExtractedReference {
|
|
9
|
-
href: string;
|
|
10
|
-
}
|
|
11
|
-
interface PostprocessOptions {
|
|
12
|
-
_format: 'md' | 'mdx';
|
|
13
|
-
/**
|
|
14
|
-
* Properties to export from `vfile.data`
|
|
15
|
-
*/
|
|
16
|
-
valueToExport?: string[];
|
|
17
|
-
/**
|
|
18
|
-
* stringify MDAST and export via `_markdown`.
|
|
19
|
-
*/
|
|
20
|
-
includeProcessedMarkdown?: boolean;
|
|
21
|
-
/**
|
|
22
|
-
* store MDAST and export via `_mdast`.
|
|
23
|
-
*/
|
|
24
|
-
includeMDAST?: boolean | {
|
|
25
|
-
removePosition?: boolean;
|
|
26
|
-
};
|
|
27
|
-
}
|
|
7
|
+
import { VFile } from 'vfile';
|
|
28
8
|
|
|
29
9
|
type ResolvePlugins = Pluggable[] | ((v: Pluggable[]) => Pluggable[]);
|
|
30
10
|
type DefaultMDXOptions = Omit<NonNullable<ProcessorOptions>, 'rehypePlugins' | 'remarkPlugins' | '_ctx'> & {
|
|
@@ -34,15 +14,22 @@ type DefaultMDXOptions = Omit<NonNullable<ProcessorOptions>, 'rehypePlugins' | '
|
|
|
34
14
|
* Properties to export from `vfile.data`
|
|
35
15
|
*/
|
|
36
16
|
valueToExport?: string[];
|
|
37
|
-
remarkStructureOptions?:
|
|
38
|
-
remarkHeadingOptions?:
|
|
39
|
-
remarkImageOptions?:
|
|
40
|
-
remarkCodeTabOptions?:
|
|
41
|
-
remarkNpmOptions?:
|
|
42
|
-
rehypeCodeOptions?:
|
|
43
|
-
_withoutBundler?: boolean;
|
|
17
|
+
remarkStructureOptions?: Plugins.StructureOptions | false;
|
|
18
|
+
remarkHeadingOptions?: Plugins.RemarkHeadingOptions;
|
|
19
|
+
remarkImageOptions?: Plugins.RemarkImageOptions | false;
|
|
20
|
+
remarkCodeTabOptions?: Plugins.RemarkCodeTabOptions | false;
|
|
21
|
+
remarkNpmOptions?: Plugins.RemarkNpmOptions | false;
|
|
22
|
+
rehypeCodeOptions?: Plugins.RehypeCodeOptions | false;
|
|
44
23
|
};
|
|
45
|
-
|
|
24
|
+
type MDXPresetOptions = ({
|
|
25
|
+
preset?: 'fumadocs';
|
|
26
|
+
} & DefaultMDXOptions) | ({
|
|
27
|
+
preset: 'minimal';
|
|
28
|
+
} & ProcessorOptions);
|
|
29
|
+
/**
|
|
30
|
+
* apply MDX processor presets
|
|
31
|
+
*/
|
|
32
|
+
declare function applyMdxPreset(options?: MDXPresetOptions): (environment: BuildEnvironment) => Promise<ProcessorOptions>;
|
|
46
33
|
|
|
47
34
|
/**
|
|
48
35
|
* Zod 4 schema
|
|
@@ -66,13 +53,38 @@ declare const frontmatterSchema: z.ZodObject<{
|
|
|
66
53
|
_openapi: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
67
54
|
}, z.core.$strip>;
|
|
68
55
|
|
|
56
|
+
interface ExtractedReference {
|
|
57
|
+
href: string;
|
|
58
|
+
}
|
|
59
|
+
interface PostprocessOptions {
|
|
60
|
+
_format: 'md' | 'mdx';
|
|
61
|
+
/**
|
|
62
|
+
* Properties to export from `vfile.data`
|
|
63
|
+
*/
|
|
64
|
+
valueToExport?: string[];
|
|
65
|
+
/**
|
|
66
|
+
* stringify MDAST and export via `_markdown`.
|
|
67
|
+
*/
|
|
68
|
+
includeProcessedMarkdown?: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* extract link references, export via `extractedReferences`.
|
|
71
|
+
*/
|
|
72
|
+
extractLinkReferences?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* store MDAST and export via `_mdast`.
|
|
75
|
+
*/
|
|
76
|
+
includeMDAST?: boolean | {
|
|
77
|
+
removePosition?: boolean;
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
69
81
|
type CollectionSchema<Schema extends StandardSchemaV1, Context> = Schema | ((ctx: Context) => Schema);
|
|
70
82
|
type AnyCollection = DocsCollection | DocCollection | MetaCollection;
|
|
71
83
|
interface BaseCollection {
|
|
72
84
|
/**
|
|
73
|
-
*
|
|
85
|
+
* Directory to scan
|
|
74
86
|
*/
|
|
75
|
-
dir: string
|
|
87
|
+
dir: string;
|
|
76
88
|
/**
|
|
77
89
|
* what files to include/exclude (glob patterns)
|
|
78
90
|
*
|
|
@@ -87,44 +99,37 @@ interface MetaCollection<Schema extends StandardSchemaV1 = StandardSchemaV1> ext
|
|
|
87
99
|
source: string;
|
|
88
100
|
}>;
|
|
89
101
|
}
|
|
90
|
-
interface DocCollection<Schema extends StandardSchemaV1 = StandardSchemaV1
|
|
102
|
+
interface DocCollection<Schema extends StandardSchemaV1 = StandardSchemaV1> extends BaseCollection {
|
|
91
103
|
type: 'doc';
|
|
92
104
|
postprocess?: Partial<PostprocessOptions>;
|
|
93
|
-
mdxOptions?: ProcessorOptions;
|
|
105
|
+
mdxOptions?: ProcessorOptions | ((environment: BuildEnvironment) => Promise<ProcessorOptions>);
|
|
94
106
|
/**
|
|
95
107
|
* Load files with async
|
|
96
108
|
*/
|
|
97
|
-
async?:
|
|
109
|
+
async?: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Compile files on-demand
|
|
112
|
+
*/
|
|
113
|
+
dynamic?: boolean;
|
|
98
114
|
schema?: CollectionSchema<Schema, {
|
|
99
115
|
path: string;
|
|
100
116
|
source: string;
|
|
101
117
|
}>;
|
|
102
118
|
}
|
|
103
|
-
interface DocsCollection<DocSchema extends StandardSchemaV1 = StandardSchemaV1, MetaSchema extends StandardSchemaV1 = StandardSchemaV1
|
|
119
|
+
interface DocsCollection<DocSchema extends StandardSchemaV1 = StandardSchemaV1, MetaSchema extends StandardSchemaV1 = StandardSchemaV1> {
|
|
104
120
|
type: 'docs';
|
|
105
121
|
dir: string;
|
|
106
|
-
docs: DocCollection<DocSchema
|
|
122
|
+
docs: DocCollection<DocSchema>;
|
|
107
123
|
meta: MetaCollection<MetaSchema>;
|
|
108
124
|
}
|
|
109
|
-
type GlobalConfigMDXOptions = ({
|
|
110
|
-
preset?: 'fumadocs';
|
|
111
|
-
} & DefaultMDXOptions) | ({
|
|
112
|
-
preset: 'minimal';
|
|
113
|
-
} & ProcessorOptions);
|
|
114
125
|
interface GlobalConfig {
|
|
115
|
-
collections?: Record<string, AnyCollection>;
|
|
116
126
|
plugins?: PluginOption[];
|
|
117
127
|
/**
|
|
118
128
|
* Configure global MDX options
|
|
119
129
|
*
|
|
120
|
-
* @remarks `
|
|
121
|
-
*/
|
|
122
|
-
mdxOptions?: GlobalConfigMDXOptions | (() => Promise<GlobalConfigMDXOptions>);
|
|
123
|
-
/**
|
|
124
|
-
* Fetch last modified time with specified version control
|
|
125
|
-
* @defaultValue 'none'
|
|
130
|
+
* @remarks `MDXPresetOptions`
|
|
126
131
|
*/
|
|
127
|
-
|
|
132
|
+
mdxOptions?: MDXPresetOptions | (() => Promise<MDXPresetOptions>);
|
|
128
133
|
/**
|
|
129
134
|
* specify a directory to access & store cache (disabled during development mode).
|
|
130
135
|
*
|
|
@@ -132,25 +137,26 @@ interface GlobalConfig {
|
|
|
132
137
|
*/
|
|
133
138
|
experimentalBuildCache?: string;
|
|
134
139
|
}
|
|
135
|
-
declare function defineCollections<Schema extends StandardSchemaV1 = StandardSchemaV1
|
|
140
|
+
declare function defineCollections<Schema extends StandardSchemaV1 = StandardSchemaV1>(options: DocCollection<Schema>): DocCollection<Schema>;
|
|
136
141
|
declare function defineCollections<Schema extends StandardSchemaV1 = StandardSchemaV1>(options: MetaCollection<Schema>): MetaCollection<Schema>;
|
|
137
|
-
declare function defineDocs<DocSchema extends StandardSchemaV1 = typeof frontmatterSchema, MetaSchema extends StandardSchemaV1 = typeof metaSchema
|
|
142
|
+
declare function defineDocs<DocSchema extends StandardSchemaV1 = typeof frontmatterSchema, MetaSchema extends StandardSchemaV1 = typeof metaSchema>(options: {
|
|
138
143
|
/**
|
|
139
144
|
* The content directory to scan files
|
|
140
145
|
*
|
|
141
146
|
* @defaultValue 'content/docs'
|
|
142
147
|
*/
|
|
143
148
|
dir?: string;
|
|
144
|
-
docs?: Omit<DocCollection<DocSchema
|
|
149
|
+
docs?: Omit<DocCollection<DocSchema>, 'dir' | 'type'>;
|
|
145
150
|
meta?: Omit<MetaCollection<MetaSchema>, 'dir' | 'type'>;
|
|
146
|
-
}): DocsCollection<DocSchema, MetaSchema
|
|
151
|
+
}): DocsCollection<DocSchema, MetaSchema>;
|
|
147
152
|
declare function defineConfig(config?: GlobalConfig): GlobalConfig;
|
|
148
153
|
|
|
154
|
+
type BuildEnvironment = 'bundler' | 'runtime';
|
|
149
155
|
interface LoadedConfig {
|
|
150
156
|
collectionList: CollectionItem[];
|
|
151
157
|
getCollection(name: string): CollectionItem | undefined;
|
|
152
158
|
global: GlobalConfig;
|
|
153
|
-
|
|
159
|
+
getMDXOptions(collection?: DocCollectionItem, environment?: BuildEnvironment): ProcessorOptions | Promise<ProcessorOptions>;
|
|
154
160
|
}
|
|
155
161
|
type CollectionItem = MetaCollectionItem | DocCollectionItem | DocsCollectionItem;
|
|
156
162
|
type PrimitiveCollectionItem<T extends DocCollection | MetaCollection> = Omit<T, 'files'> & {
|
|
@@ -165,8 +171,8 @@ interface DocsCollectionItem extends DocsCollection {
|
|
|
165
171
|
name: string;
|
|
166
172
|
meta: MetaCollectionItem;
|
|
167
173
|
docs: DocCollectionItem;
|
|
174
|
+
hasFile: (filePath: string) => boolean;
|
|
168
175
|
}
|
|
169
|
-
declare function buildConfig(config: Record<string, unknown>): LoadedConfig;
|
|
170
176
|
|
|
171
177
|
type Awaitable<T> = T | Promise<T>;
|
|
172
178
|
interface EmitEntry {
|
|
@@ -179,6 +185,12 @@ interface EmitEntry {
|
|
|
179
185
|
interface PluginContext extends CoreOptions {
|
|
180
186
|
core: Core;
|
|
181
187
|
}
|
|
188
|
+
type CompilationContext<Collection> = PluginContext & TransformOptions<Collection>;
|
|
189
|
+
interface TransformOptions<Collection> {
|
|
190
|
+
collection: Collection;
|
|
191
|
+
filePath: string;
|
|
192
|
+
source: string;
|
|
193
|
+
}
|
|
182
194
|
interface Plugin {
|
|
183
195
|
name?: string;
|
|
184
196
|
/**
|
|
@@ -193,8 +205,24 @@ interface Plugin {
|
|
|
193
205
|
* Configure Fumadocs dev server
|
|
194
206
|
*/
|
|
195
207
|
configureServer?: (this: PluginContext, server: ServerContext) => Awaitable<void>;
|
|
208
|
+
meta?: {
|
|
209
|
+
/**
|
|
210
|
+
* Transform metadata
|
|
211
|
+
*/
|
|
212
|
+
transform?: (this: CompilationContext<MetaCollectionItem>, data: unknown) => Awaitable<unknown | void>;
|
|
213
|
+
};
|
|
214
|
+
doc?: {
|
|
215
|
+
/**
|
|
216
|
+
* Transform frontmatter
|
|
217
|
+
*/
|
|
218
|
+
frontmatter?: (this: CompilationContext<DocCollectionItem>, data: Record<string, unknown>) => Awaitable<Record<string, unknown> | void>;
|
|
219
|
+
/**
|
|
220
|
+
* Transform `vfile` on compilation stage
|
|
221
|
+
*/
|
|
222
|
+
vfile?: (this: CompilationContext<DocCollectionItem>, file: VFile) => Awaitable<VFile | void>;
|
|
223
|
+
};
|
|
196
224
|
}
|
|
197
|
-
type PluginOption = Awaitable<Plugin |
|
|
225
|
+
type PluginOption = Awaitable<Plugin | PluginOption[] | false>;
|
|
198
226
|
interface ServerContext {
|
|
199
227
|
/**
|
|
200
228
|
* the file watcher, by default all content files are watched, along with other files.
|
|
@@ -214,10 +242,12 @@ interface EmitOptions {
|
|
|
214
242
|
*/
|
|
215
243
|
filterPlugin?: (plugin: Plugin) => boolean;
|
|
216
244
|
}
|
|
217
|
-
declare
|
|
245
|
+
declare const _Defaults: {
|
|
246
|
+
configPath: string;
|
|
247
|
+
outDir: string;
|
|
248
|
+
};
|
|
218
249
|
declare function createCore(options: CoreOptions, defaultPlugins?: PluginOption[]): {
|
|
219
250
|
_options: CoreOptions;
|
|
220
|
-
getPluginContext(): PluginContext;
|
|
221
251
|
/**
|
|
222
252
|
* Convenient cache store, reset when config changes
|
|
223
253
|
*/
|
|
@@ -226,9 +256,17 @@ declare function createCore(options: CoreOptions, defaultPlugins?: PluginOption[
|
|
|
226
256
|
config: Awaitable<LoadedConfig>;
|
|
227
257
|
}): Promise</*elided*/ any>;
|
|
228
258
|
getConfig(): LoadedConfig;
|
|
259
|
+
/**
|
|
260
|
+
* The file path of compiled config file, the file may not exist (e.g. on Vite, or still compiling)
|
|
261
|
+
*/
|
|
262
|
+
getCompiledConfigPath(): string;
|
|
229
263
|
initServer(server: ServerContext): Promise<void>;
|
|
230
|
-
|
|
264
|
+
emit({ filterPlugin }?: EmitOptions): Promise<EmitEntry[]>;
|
|
265
|
+
emitAndWrite(emitOptions?: EmitOptions): Promise<void>;
|
|
266
|
+
transformMeta(options: TransformOptions<MetaCollectionItem>, data: unknown): Promise<unknown>;
|
|
267
|
+
transformFrontmatter(options: TransformOptions<DocCollectionItem>, data: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
268
|
+
transformVFile(options: TransformOptions<DocCollectionItem>, file: VFile): Promise<VFile>;
|
|
231
269
|
};
|
|
232
270
|
type Core = ReturnType<typeof createCore>;
|
|
233
271
|
|
|
234
|
-
export { type AnyCollection as A, type BaseCollection as B, type
|
|
272
|
+
export { type AnyCollection as A, type BaseCollection as B, type CoreOptions as C, type DocCollection as D, type ExtractedReference as E, type GlobalConfig as G, type MetaCollection as M, type PostprocessOptions as P, type ServerContext as S, type TransformOptions as T, _Defaults as _, type CollectionSchema as a, type DocsCollection as b, defineDocs as c, defineCollections as d, defineConfig as e, type DefaultMDXOptions as f, type MDXPresetOptions as g, applyMdxPreset as h, frontmatterSchema as i, type Plugin as j, type EmitEntry as k, type PluginContext as l, metaSchema as m, type CompilationContext as n, type PluginOption as o, type EmitOptions as p, createCore as q, type Core as r };
|
|
@@ -1,30 +1,10 @@
|
|
|
1
1
|
import { ProcessorOptions } from '@mdx-js/mdx';
|
|
2
2
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
3
|
-
import * as plugins from 'fumadocs-core/mdx-plugins';
|
|
4
3
|
import { Pluggable } from 'unified';
|
|
4
|
+
import * as Plugins from 'fumadocs-core/mdx-plugins';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import { FSWatcher } from 'chokidar';
|
|
7
|
-
|
|
8
|
-
interface ExtractedReference {
|
|
9
|
-
href: string;
|
|
10
|
-
}
|
|
11
|
-
interface PostprocessOptions {
|
|
12
|
-
_format: 'md' | 'mdx';
|
|
13
|
-
/**
|
|
14
|
-
* Properties to export from `vfile.data`
|
|
15
|
-
*/
|
|
16
|
-
valueToExport?: string[];
|
|
17
|
-
/**
|
|
18
|
-
* stringify MDAST and export via `_markdown`.
|
|
19
|
-
*/
|
|
20
|
-
includeProcessedMarkdown?: boolean;
|
|
21
|
-
/**
|
|
22
|
-
* store MDAST and export via `_mdast`.
|
|
23
|
-
*/
|
|
24
|
-
includeMDAST?: boolean | {
|
|
25
|
-
removePosition?: boolean;
|
|
26
|
-
};
|
|
27
|
-
}
|
|
7
|
+
import { VFile } from 'vfile';
|
|
28
8
|
|
|
29
9
|
type ResolvePlugins = Pluggable[] | ((v: Pluggable[]) => Pluggable[]);
|
|
30
10
|
type DefaultMDXOptions = Omit<NonNullable<ProcessorOptions>, 'rehypePlugins' | 'remarkPlugins' | '_ctx'> & {
|
|
@@ -34,15 +14,22 @@ type DefaultMDXOptions = Omit<NonNullable<ProcessorOptions>, 'rehypePlugins' | '
|
|
|
34
14
|
* Properties to export from `vfile.data`
|
|
35
15
|
*/
|
|
36
16
|
valueToExport?: string[];
|
|
37
|
-
remarkStructureOptions?:
|
|
38
|
-
remarkHeadingOptions?:
|
|
39
|
-
remarkImageOptions?:
|
|
40
|
-
remarkCodeTabOptions?:
|
|
41
|
-
remarkNpmOptions?:
|
|
42
|
-
rehypeCodeOptions?:
|
|
43
|
-
_withoutBundler?: boolean;
|
|
17
|
+
remarkStructureOptions?: Plugins.StructureOptions | false;
|
|
18
|
+
remarkHeadingOptions?: Plugins.RemarkHeadingOptions;
|
|
19
|
+
remarkImageOptions?: Plugins.RemarkImageOptions | false;
|
|
20
|
+
remarkCodeTabOptions?: Plugins.RemarkCodeTabOptions | false;
|
|
21
|
+
remarkNpmOptions?: Plugins.RemarkNpmOptions | false;
|
|
22
|
+
rehypeCodeOptions?: Plugins.RehypeCodeOptions | false;
|
|
44
23
|
};
|
|
45
|
-
|
|
24
|
+
type MDXPresetOptions = ({
|
|
25
|
+
preset?: 'fumadocs';
|
|
26
|
+
} & DefaultMDXOptions) | ({
|
|
27
|
+
preset: 'minimal';
|
|
28
|
+
} & ProcessorOptions);
|
|
29
|
+
/**
|
|
30
|
+
* apply MDX processor presets
|
|
31
|
+
*/
|
|
32
|
+
declare function applyMdxPreset(options?: MDXPresetOptions): (environment: BuildEnvironment) => Promise<ProcessorOptions>;
|
|
46
33
|
|
|
47
34
|
/**
|
|
48
35
|
* Zod 4 schema
|
|
@@ -66,13 +53,38 @@ declare const frontmatterSchema: z.ZodObject<{
|
|
|
66
53
|
_openapi: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
67
54
|
}, z.core.$strip>;
|
|
68
55
|
|
|
56
|
+
interface ExtractedReference {
|
|
57
|
+
href: string;
|
|
58
|
+
}
|
|
59
|
+
interface PostprocessOptions {
|
|
60
|
+
_format: 'md' | 'mdx';
|
|
61
|
+
/**
|
|
62
|
+
* Properties to export from `vfile.data`
|
|
63
|
+
*/
|
|
64
|
+
valueToExport?: string[];
|
|
65
|
+
/**
|
|
66
|
+
* stringify MDAST and export via `_markdown`.
|
|
67
|
+
*/
|
|
68
|
+
includeProcessedMarkdown?: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* extract link references, export via `extractedReferences`.
|
|
71
|
+
*/
|
|
72
|
+
extractLinkReferences?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* store MDAST and export via `_mdast`.
|
|
75
|
+
*/
|
|
76
|
+
includeMDAST?: boolean | {
|
|
77
|
+
removePosition?: boolean;
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
69
81
|
type CollectionSchema<Schema extends StandardSchemaV1, Context> = Schema | ((ctx: Context) => Schema);
|
|
70
82
|
type AnyCollection = DocsCollection | DocCollection | MetaCollection;
|
|
71
83
|
interface BaseCollection {
|
|
72
84
|
/**
|
|
73
|
-
*
|
|
85
|
+
* Directory to scan
|
|
74
86
|
*/
|
|
75
|
-
dir: string
|
|
87
|
+
dir: string;
|
|
76
88
|
/**
|
|
77
89
|
* what files to include/exclude (glob patterns)
|
|
78
90
|
*
|
|
@@ -87,44 +99,37 @@ interface MetaCollection<Schema extends StandardSchemaV1 = StandardSchemaV1> ext
|
|
|
87
99
|
source: string;
|
|
88
100
|
}>;
|
|
89
101
|
}
|
|
90
|
-
interface DocCollection<Schema extends StandardSchemaV1 = StandardSchemaV1
|
|
102
|
+
interface DocCollection<Schema extends StandardSchemaV1 = StandardSchemaV1> extends BaseCollection {
|
|
91
103
|
type: 'doc';
|
|
92
104
|
postprocess?: Partial<PostprocessOptions>;
|
|
93
|
-
mdxOptions?: ProcessorOptions;
|
|
105
|
+
mdxOptions?: ProcessorOptions | ((environment: BuildEnvironment) => Promise<ProcessorOptions>);
|
|
94
106
|
/**
|
|
95
107
|
* Load files with async
|
|
96
108
|
*/
|
|
97
|
-
async?:
|
|
109
|
+
async?: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Compile files on-demand
|
|
112
|
+
*/
|
|
113
|
+
dynamic?: boolean;
|
|
98
114
|
schema?: CollectionSchema<Schema, {
|
|
99
115
|
path: string;
|
|
100
116
|
source: string;
|
|
101
117
|
}>;
|
|
102
118
|
}
|
|
103
|
-
interface DocsCollection<DocSchema extends StandardSchemaV1 = StandardSchemaV1, MetaSchema extends StandardSchemaV1 = StandardSchemaV1
|
|
119
|
+
interface DocsCollection<DocSchema extends StandardSchemaV1 = StandardSchemaV1, MetaSchema extends StandardSchemaV1 = StandardSchemaV1> {
|
|
104
120
|
type: 'docs';
|
|
105
121
|
dir: string;
|
|
106
|
-
docs: DocCollection<DocSchema
|
|
122
|
+
docs: DocCollection<DocSchema>;
|
|
107
123
|
meta: MetaCollection<MetaSchema>;
|
|
108
124
|
}
|
|
109
|
-
type GlobalConfigMDXOptions = ({
|
|
110
|
-
preset?: 'fumadocs';
|
|
111
|
-
} & DefaultMDXOptions) | ({
|
|
112
|
-
preset: 'minimal';
|
|
113
|
-
} & ProcessorOptions);
|
|
114
125
|
interface GlobalConfig {
|
|
115
|
-
collections?: Record<string, AnyCollection>;
|
|
116
126
|
plugins?: PluginOption[];
|
|
117
127
|
/**
|
|
118
128
|
* Configure global MDX options
|
|
119
129
|
*
|
|
120
|
-
* @remarks `
|
|
121
|
-
*/
|
|
122
|
-
mdxOptions?: GlobalConfigMDXOptions | (() => Promise<GlobalConfigMDXOptions>);
|
|
123
|
-
/**
|
|
124
|
-
* Fetch last modified time with specified version control
|
|
125
|
-
* @defaultValue 'none'
|
|
130
|
+
* @remarks `MDXPresetOptions`
|
|
126
131
|
*/
|
|
127
|
-
|
|
132
|
+
mdxOptions?: MDXPresetOptions | (() => Promise<MDXPresetOptions>);
|
|
128
133
|
/**
|
|
129
134
|
* specify a directory to access & store cache (disabled during development mode).
|
|
130
135
|
*
|
|
@@ -132,25 +137,26 @@ interface GlobalConfig {
|
|
|
132
137
|
*/
|
|
133
138
|
experimentalBuildCache?: string;
|
|
134
139
|
}
|
|
135
|
-
declare function defineCollections<Schema extends StandardSchemaV1 = StandardSchemaV1
|
|
140
|
+
declare function defineCollections<Schema extends StandardSchemaV1 = StandardSchemaV1>(options: DocCollection<Schema>): DocCollection<Schema>;
|
|
136
141
|
declare function defineCollections<Schema extends StandardSchemaV1 = StandardSchemaV1>(options: MetaCollection<Schema>): MetaCollection<Schema>;
|
|
137
|
-
declare function defineDocs<DocSchema extends StandardSchemaV1 = typeof frontmatterSchema, MetaSchema extends StandardSchemaV1 = typeof metaSchema
|
|
142
|
+
declare function defineDocs<DocSchema extends StandardSchemaV1 = typeof frontmatterSchema, MetaSchema extends StandardSchemaV1 = typeof metaSchema>(options: {
|
|
138
143
|
/**
|
|
139
144
|
* The content directory to scan files
|
|
140
145
|
*
|
|
141
146
|
* @defaultValue 'content/docs'
|
|
142
147
|
*/
|
|
143
148
|
dir?: string;
|
|
144
|
-
docs?: Omit<DocCollection<DocSchema
|
|
149
|
+
docs?: Omit<DocCollection<DocSchema>, 'dir' | 'type'>;
|
|
145
150
|
meta?: Omit<MetaCollection<MetaSchema>, 'dir' | 'type'>;
|
|
146
|
-
}): DocsCollection<DocSchema, MetaSchema
|
|
151
|
+
}): DocsCollection<DocSchema, MetaSchema>;
|
|
147
152
|
declare function defineConfig(config?: GlobalConfig): GlobalConfig;
|
|
148
153
|
|
|
154
|
+
type BuildEnvironment = 'bundler' | 'runtime';
|
|
149
155
|
interface LoadedConfig {
|
|
150
156
|
collectionList: CollectionItem[];
|
|
151
157
|
getCollection(name: string): CollectionItem | undefined;
|
|
152
158
|
global: GlobalConfig;
|
|
153
|
-
|
|
159
|
+
getMDXOptions(collection?: DocCollectionItem, environment?: BuildEnvironment): ProcessorOptions | Promise<ProcessorOptions>;
|
|
154
160
|
}
|
|
155
161
|
type CollectionItem = MetaCollectionItem | DocCollectionItem | DocsCollectionItem;
|
|
156
162
|
type PrimitiveCollectionItem<T extends DocCollection | MetaCollection> = Omit<T, 'files'> & {
|
|
@@ -165,8 +171,8 @@ interface DocsCollectionItem extends DocsCollection {
|
|
|
165
171
|
name: string;
|
|
166
172
|
meta: MetaCollectionItem;
|
|
167
173
|
docs: DocCollectionItem;
|
|
174
|
+
hasFile: (filePath: string) => boolean;
|
|
168
175
|
}
|
|
169
|
-
declare function buildConfig(config: Record<string, unknown>): LoadedConfig;
|
|
170
176
|
|
|
171
177
|
type Awaitable<T> = T | Promise<T>;
|
|
172
178
|
interface EmitEntry {
|
|
@@ -179,6 +185,12 @@ interface EmitEntry {
|
|
|
179
185
|
interface PluginContext extends CoreOptions {
|
|
180
186
|
core: Core;
|
|
181
187
|
}
|
|
188
|
+
type CompilationContext<Collection> = PluginContext & TransformOptions<Collection>;
|
|
189
|
+
interface TransformOptions<Collection> {
|
|
190
|
+
collection: Collection;
|
|
191
|
+
filePath: string;
|
|
192
|
+
source: string;
|
|
193
|
+
}
|
|
182
194
|
interface Plugin {
|
|
183
195
|
name?: string;
|
|
184
196
|
/**
|
|
@@ -193,8 +205,24 @@ interface Plugin {
|
|
|
193
205
|
* Configure Fumadocs dev server
|
|
194
206
|
*/
|
|
195
207
|
configureServer?: (this: PluginContext, server: ServerContext) => Awaitable<void>;
|
|
208
|
+
meta?: {
|
|
209
|
+
/**
|
|
210
|
+
* Transform metadata
|
|
211
|
+
*/
|
|
212
|
+
transform?: (this: CompilationContext<MetaCollectionItem>, data: unknown) => Awaitable<unknown | void>;
|
|
213
|
+
};
|
|
214
|
+
doc?: {
|
|
215
|
+
/**
|
|
216
|
+
* Transform frontmatter
|
|
217
|
+
*/
|
|
218
|
+
frontmatter?: (this: CompilationContext<DocCollectionItem>, data: Record<string, unknown>) => Awaitable<Record<string, unknown> | void>;
|
|
219
|
+
/**
|
|
220
|
+
* Transform `vfile` on compilation stage
|
|
221
|
+
*/
|
|
222
|
+
vfile?: (this: CompilationContext<DocCollectionItem>, file: VFile) => Awaitable<VFile | void>;
|
|
223
|
+
};
|
|
196
224
|
}
|
|
197
|
-
type PluginOption = Awaitable<Plugin |
|
|
225
|
+
type PluginOption = Awaitable<Plugin | PluginOption[] | false>;
|
|
198
226
|
interface ServerContext {
|
|
199
227
|
/**
|
|
200
228
|
* the file watcher, by default all content files are watched, along with other files.
|
|
@@ -214,10 +242,12 @@ interface EmitOptions {
|
|
|
214
242
|
*/
|
|
215
243
|
filterPlugin?: (plugin: Plugin) => boolean;
|
|
216
244
|
}
|
|
217
|
-
declare
|
|
245
|
+
declare const _Defaults: {
|
|
246
|
+
configPath: string;
|
|
247
|
+
outDir: string;
|
|
248
|
+
};
|
|
218
249
|
declare function createCore(options: CoreOptions, defaultPlugins?: PluginOption[]): {
|
|
219
250
|
_options: CoreOptions;
|
|
220
|
-
getPluginContext(): PluginContext;
|
|
221
251
|
/**
|
|
222
252
|
* Convenient cache store, reset when config changes
|
|
223
253
|
*/
|
|
@@ -226,9 +256,17 @@ declare function createCore(options: CoreOptions, defaultPlugins?: PluginOption[
|
|
|
226
256
|
config: Awaitable<LoadedConfig>;
|
|
227
257
|
}): Promise</*elided*/ any>;
|
|
228
258
|
getConfig(): LoadedConfig;
|
|
259
|
+
/**
|
|
260
|
+
* The file path of compiled config file, the file may not exist (e.g. on Vite, or still compiling)
|
|
261
|
+
*/
|
|
262
|
+
getCompiledConfigPath(): string;
|
|
229
263
|
initServer(server: ServerContext): Promise<void>;
|
|
230
|
-
|
|
264
|
+
emit({ filterPlugin }?: EmitOptions): Promise<EmitEntry[]>;
|
|
265
|
+
emitAndWrite(emitOptions?: EmitOptions): Promise<void>;
|
|
266
|
+
transformMeta(options: TransformOptions<MetaCollectionItem>, data: unknown): Promise<unknown>;
|
|
267
|
+
transformFrontmatter(options: TransformOptions<DocCollectionItem>, data: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
268
|
+
transformVFile(options: TransformOptions<DocCollectionItem>, file: VFile): Promise<VFile>;
|
|
231
269
|
};
|
|
232
270
|
type Core = ReturnType<typeof createCore>;
|
|
233
271
|
|
|
234
|
-
export { type AnyCollection as A, type BaseCollection as B, type
|
|
272
|
+
export { type AnyCollection as A, type BaseCollection as B, type CoreOptions as C, type DocCollection as D, type ExtractedReference as E, type GlobalConfig as G, type MetaCollection as M, type PostprocessOptions as P, type ServerContext as S, type TransformOptions as T, _Defaults as _, type CollectionSchema as a, type DocsCollection as b, defineDocs as c, defineCollections as d, defineConfig as e, type DefaultMDXOptions as f, type MDXPresetOptions as g, applyMdxPreset as h, frontmatterSchema as i, type Plugin as j, type EmitEntry as k, type PluginContext as l, metaSchema as m, type CompilationContext as n, type PluginOption as o, type EmitOptions as p, createCore as q, type Core as r };
|