fumadocs-mdx 11.4.1 → 11.5.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/{chunk-IU4D6M3A.js → chunk-2C4NRJ5O.js} +1 -1
- package/dist/chunk-3PXNPJQ2.js +72 -0
- package/dist/{chunk-2DJQ3DOD.js → chunk-6ZVE73IT.js} +9 -6
- package/dist/config/index.cjs +1 -1
- package/dist/config/index.d.cts +4 -4
- package/dist/config/index.d.ts +4 -4
- package/dist/config/index.js +1 -1
- package/dist/define-_brlBG8j.d.cts +201 -0
- package/dist/define-_brlBG8j.d.ts +201 -0
- package/dist/index.cjs +34 -17
- package/dist/index.d.cts +23 -6
- package/dist/index.d.ts +23 -6
- package/dist/index.js +7 -51
- package/dist/loader-mdx.cjs +26 -30
- package/dist/loader-mdx.js +19 -26
- package/dist/next/index.cjs +159 -121
- package/dist/next/index.js +144 -117
- package/dist/runtime/async.cjs +125 -41
- package/dist/runtime/async.d.cts +25 -14
- package/dist/runtime/async.d.ts +25 -14
- package/dist/runtime/async.js +53 -35
- package/dist/{watcher-7ALL6XOY.js → watcher-IAZDSTU7.js} +10 -2
- package/package.json +6 -5
- package/dist/build-mdx-o0kbHSlp.d.cts +0 -109
- package/dist/build-mdx-o0kbHSlp.d.ts +0 -109
- package/dist/define-BB9hRiTI.d.cts +0 -106
- package/dist/define-D3l733EX.d.ts +0 -106
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// src/runtime/index.ts
|
|
2
|
+
var _runtime = {
|
|
3
|
+
doc(files) {
|
|
4
|
+
return files.map((file) => {
|
|
5
|
+
const { default: body, frontmatter, ...exports } = file.data;
|
|
6
|
+
return {
|
|
7
|
+
body,
|
|
8
|
+
...exports,
|
|
9
|
+
...frontmatter,
|
|
10
|
+
_exports: file.data,
|
|
11
|
+
_file: file.info
|
|
12
|
+
};
|
|
13
|
+
});
|
|
14
|
+
},
|
|
15
|
+
meta(files) {
|
|
16
|
+
return files.map((file) => {
|
|
17
|
+
return {
|
|
18
|
+
...file.data.default,
|
|
19
|
+
_file: file.info
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
},
|
|
23
|
+
docs(docs, metas) {
|
|
24
|
+
const parsedDocs = this.doc(docs);
|
|
25
|
+
const parsedMetas = this.meta(metas);
|
|
26
|
+
return {
|
|
27
|
+
docs: parsedDocs,
|
|
28
|
+
meta: parsedMetas,
|
|
29
|
+
toFumadocsSource() {
|
|
30
|
+
return createMDXSource(parsedDocs, parsedMetas);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
function createMDXSource(docs, meta = []) {
|
|
36
|
+
return {
|
|
37
|
+
files: (rootDir) => resolveFiles({
|
|
38
|
+
docs,
|
|
39
|
+
meta,
|
|
40
|
+
rootDir
|
|
41
|
+
})
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function resolveFiles({
|
|
45
|
+
docs,
|
|
46
|
+
meta,
|
|
47
|
+
rootDir = ""
|
|
48
|
+
}) {
|
|
49
|
+
const outputs = [];
|
|
50
|
+
for (const entry of docs) {
|
|
51
|
+
if (!entry._file.path.startsWith(rootDir)) continue;
|
|
52
|
+
outputs.push({
|
|
53
|
+
type: "page",
|
|
54
|
+
path: entry._file.path,
|
|
55
|
+
data: entry
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
for (const entry of meta) {
|
|
59
|
+
outputs.push({
|
|
60
|
+
type: "meta",
|
|
61
|
+
path: entry._file.path,
|
|
62
|
+
data: entry
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return outputs;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export {
|
|
69
|
+
_runtime,
|
|
70
|
+
createMDXSource,
|
|
71
|
+
resolveFiles
|
|
72
|
+
};
|
|
@@ -6,12 +6,15 @@ function buildConfig(config) {
|
|
|
6
6
|
if (!v) {
|
|
7
7
|
continue;
|
|
8
8
|
}
|
|
9
|
-
if (typeof v === "object" && "
|
|
10
|
-
|
|
11
|
-
k,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
if (typeof v === "object" && "type" in v) {
|
|
10
|
+
if (v.type === "docs") {
|
|
11
|
+
collections.set(k, v);
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
14
|
+
if (v.type === "doc" || v.type === "meta") {
|
|
15
|
+
collections.set(k, v);
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
15
18
|
}
|
|
16
19
|
if (k === "default") {
|
|
17
20
|
globalConfig = v;
|
package/dist/config/index.cjs
CHANGED
|
@@ -62,7 +62,6 @@ var frontmatterSchema = import_zod.z.object({
|
|
|
62
62
|
// src/config/define.ts
|
|
63
63
|
function defineCollections(options) {
|
|
64
64
|
return {
|
|
65
|
-
_doc: "collections",
|
|
66
65
|
// @ts-expect-error -- internal type inferring
|
|
67
66
|
_type: void 0,
|
|
68
67
|
...options
|
|
@@ -71,6 +70,7 @@ function defineCollections(options) {
|
|
|
71
70
|
function defineDocs(options) {
|
|
72
71
|
const dir = options?.dir ?? "content/docs";
|
|
73
72
|
return {
|
|
73
|
+
type: "docs",
|
|
74
74
|
docs: defineCollections({
|
|
75
75
|
type: "doc",
|
|
76
76
|
dir,
|
package/dist/config/index.d.cts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export { B as BaseCollectionEntry,
|
|
2
|
-
export { B as BaseCollection, D as DocCollection, M as MetaCollection, T as TransformContext, d as defineCollections, b as defineConfig, a as defineDocs, f as frontmatterSchema, m as metaSchema } from '../define-BB9hRiTI.cjs';
|
|
1
|
+
export { b as BaseCollection, B as BaseCollectionEntry, i as DefaultMDXOptions, D as DocCollection, d as DocsCollection, F as FileInfo, G as GlobalConfig, I as InferSchema, a as InferSchemaType, M as MarkdownProps, c as MetaCollection, T as TransformContext, e as defineCollections, h as defineConfig, g as defineDocs, f as frontmatterSchema, j as getDefaultMDXOptions, m as metaSchema } from '../define-_brlBG8j.cjs';
|
|
3
2
|
import { Processor, Transformer } from 'unified';
|
|
4
3
|
import { Root } from 'mdast';
|
|
5
|
-
import '
|
|
4
|
+
import '@mdx-js/mdx';
|
|
6
5
|
import 'mdx/types';
|
|
7
6
|
import 'fumadocs-core/mdx-plugins';
|
|
8
7
|
import 'fumadocs-core/server';
|
|
9
|
-
import '@mdx-js/mdx';
|
|
10
8
|
import 'react';
|
|
9
|
+
import '@standard-schema/spec';
|
|
10
|
+
import 'zod';
|
|
11
11
|
|
|
12
12
|
declare function remarkInclude(this: Processor): Transformer<Root, Root>;
|
|
13
13
|
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export { B as BaseCollectionEntry,
|
|
2
|
-
export { B as BaseCollection, D as DocCollection, M as MetaCollection, T as TransformContext, d as defineCollections, b as defineConfig, a as defineDocs, f as frontmatterSchema, m as metaSchema } from '../define-D3l733EX.js';
|
|
1
|
+
export { b as BaseCollection, B as BaseCollectionEntry, i as DefaultMDXOptions, D as DocCollection, d as DocsCollection, F as FileInfo, G as GlobalConfig, I as InferSchema, a as InferSchemaType, M as MarkdownProps, c as MetaCollection, T as TransformContext, e as defineCollections, h as defineConfig, g as defineDocs, f as frontmatterSchema, j as getDefaultMDXOptions, m as metaSchema } from '../define-_brlBG8j.js';
|
|
3
2
|
import { Processor, Transformer } from 'unified';
|
|
4
3
|
import { Root } from 'mdast';
|
|
5
|
-
import '
|
|
4
|
+
import '@mdx-js/mdx';
|
|
6
5
|
import 'mdx/types';
|
|
7
6
|
import 'fumadocs-core/mdx-plugins';
|
|
8
7
|
import 'fumadocs-core/server';
|
|
9
|
-
import '@mdx-js/mdx';
|
|
10
8
|
import 'react';
|
|
9
|
+
import '@standard-schema/spec';
|
|
10
|
+
import 'zod';
|
|
11
11
|
|
|
12
12
|
declare function remarkInclude(this: Processor): Transformer<Root, Root>;
|
|
13
13
|
|
package/dist/config/index.js
CHANGED
|
@@ -27,7 +27,6 @@ var frontmatterSchema = z.object({
|
|
|
27
27
|
// src/config/define.ts
|
|
28
28
|
function defineCollections(options) {
|
|
29
29
|
return {
|
|
30
|
-
_doc: "collections",
|
|
31
30
|
// @ts-expect-error -- internal type inferring
|
|
32
31
|
_type: void 0,
|
|
33
32
|
...options
|
|
@@ -36,6 +35,7 @@ function defineCollections(options) {
|
|
|
36
35
|
function defineDocs(options) {
|
|
37
36
|
const dir = options?.dir ?? "content/docs";
|
|
38
37
|
return {
|
|
38
|
+
type: "docs",
|
|
39
39
|
docs: defineCollections({
|
|
40
40
|
type: "doc",
|
|
41
41
|
dir,
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { ProcessorOptions } from '@mdx-js/mdx';
|
|
2
|
+
import { MDXProps } from 'mdx/types';
|
|
3
|
+
import * as plugins from 'fumadocs-core/mdx-plugins';
|
|
4
|
+
import { StructuredData } from 'fumadocs-core/mdx-plugins';
|
|
5
|
+
import { TableOfContents } from 'fumadocs-core/server';
|
|
6
|
+
import { Pluggable } from 'unified';
|
|
7
|
+
import { FC } from 'react';
|
|
8
|
+
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
|
|
11
|
+
type ResolvePlugins = Pluggable[] | ((v: Pluggable[]) => Pluggable[]);
|
|
12
|
+
type DefaultMDXOptions = Omit<NonNullable<ProcessorOptions>, 'rehypePlugins' | 'remarkPlugins' | '_ctx'> & {
|
|
13
|
+
rehypePlugins?: ResolvePlugins;
|
|
14
|
+
remarkPlugins?: ResolvePlugins;
|
|
15
|
+
/**
|
|
16
|
+
* Properties to export from `vfile.data`
|
|
17
|
+
*/
|
|
18
|
+
valueToExport?: string[];
|
|
19
|
+
remarkStructureOptions?: plugins.StructureOptions | false;
|
|
20
|
+
remarkHeadingOptions?: plugins.RemarkHeadingOptions;
|
|
21
|
+
remarkImageOptions?: plugins.RemarkImageOptions | false;
|
|
22
|
+
remarkCodeTabOptions?: false;
|
|
23
|
+
rehypeCodeOptions?: plugins.RehypeCodeOptions | false;
|
|
24
|
+
};
|
|
25
|
+
declare function getDefaultMDXOptions({ valueToExport, rehypeCodeOptions, remarkImageOptions, remarkHeadingOptions, remarkStructureOptions, remarkCodeTabOptions, ...mdxOptions }: DefaultMDXOptions): ProcessorOptions;
|
|
26
|
+
|
|
27
|
+
interface GlobalConfig {
|
|
28
|
+
/**
|
|
29
|
+
* Configure global MDX options
|
|
30
|
+
*/
|
|
31
|
+
mdxOptions?: DefaultMDXOptions | (() => DefaultMDXOptions | Promise<DefaultMDXOptions>);
|
|
32
|
+
/**
|
|
33
|
+
* Fetch last modified time with specified version control
|
|
34
|
+
* @defaultValue 'none'
|
|
35
|
+
*/
|
|
36
|
+
lastModifiedTime?: 'git' | 'none';
|
|
37
|
+
/**
|
|
38
|
+
* Generate manifest file on build mode
|
|
39
|
+
*
|
|
40
|
+
* @defaultValue false
|
|
41
|
+
* @deprecated No longer needed, use a route handler to export build time info
|
|
42
|
+
*/
|
|
43
|
+
generateManifest?: boolean;
|
|
44
|
+
}
|
|
45
|
+
type InferSchema<CollectionOut> = CollectionOut extends {
|
|
46
|
+
_type: {
|
|
47
|
+
schema: infer T;
|
|
48
|
+
};
|
|
49
|
+
} ? T : never;
|
|
50
|
+
type InferSchemaType<C> = InferSchema<C> extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<InferSchema<C>> : never;
|
|
51
|
+
interface FileInfo {
|
|
52
|
+
path: string;
|
|
53
|
+
absolutePath: string;
|
|
54
|
+
}
|
|
55
|
+
interface MarkdownProps {
|
|
56
|
+
body: FC<MDXProps>;
|
|
57
|
+
structuredData: StructuredData;
|
|
58
|
+
toc: TableOfContents;
|
|
59
|
+
_exports: Record<string, unknown>;
|
|
60
|
+
/**
|
|
61
|
+
* Only available when `lastModifiedTime` is enabled on MDX loader
|
|
62
|
+
*/
|
|
63
|
+
lastModified?: Date;
|
|
64
|
+
}
|
|
65
|
+
interface BaseCollectionEntry {
|
|
66
|
+
_file: FileInfo;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
interface MDXOptions extends ProcessorOptions {
|
|
70
|
+
/**
|
|
71
|
+
* Name of collection
|
|
72
|
+
*/
|
|
73
|
+
collection?: string;
|
|
74
|
+
/**
|
|
75
|
+
* Specify a file path for source
|
|
76
|
+
*/
|
|
77
|
+
filePath?: string;
|
|
78
|
+
frontmatter?: Record<string, unknown>;
|
|
79
|
+
/**
|
|
80
|
+
* Custom Vfile data
|
|
81
|
+
*/
|
|
82
|
+
data?: Record<string, unknown>;
|
|
83
|
+
_compiler?: CompilerOptions;
|
|
84
|
+
}
|
|
85
|
+
interface CompilerOptions {
|
|
86
|
+
addDependency: (file: string) => void;
|
|
87
|
+
}
|
|
88
|
+
declare module 'vfile' {
|
|
89
|
+
interface DataMap {
|
|
90
|
+
/**
|
|
91
|
+
* The compiler object from loader
|
|
92
|
+
*/
|
|
93
|
+
_compiler?: CompilerOptions;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
declare const metaSchema: z.ZodObject<{
|
|
98
|
+
title: z.ZodOptional<z.ZodString>;
|
|
99
|
+
pages: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
100
|
+
description: z.ZodOptional<z.ZodString>;
|
|
101
|
+
root: z.ZodOptional<z.ZodBoolean>;
|
|
102
|
+
defaultOpen: z.ZodOptional<z.ZodBoolean>;
|
|
103
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
104
|
+
}, "strip", z.ZodTypeAny, {
|
|
105
|
+
root?: boolean | undefined;
|
|
106
|
+
title?: string | undefined;
|
|
107
|
+
icon?: string | undefined;
|
|
108
|
+
pages?: string[] | undefined;
|
|
109
|
+
description?: string | undefined;
|
|
110
|
+
defaultOpen?: boolean | undefined;
|
|
111
|
+
}, {
|
|
112
|
+
root?: boolean | undefined;
|
|
113
|
+
title?: string | undefined;
|
|
114
|
+
icon?: string | undefined;
|
|
115
|
+
pages?: string[] | undefined;
|
|
116
|
+
description?: string | undefined;
|
|
117
|
+
defaultOpen?: boolean | undefined;
|
|
118
|
+
}>;
|
|
119
|
+
declare const frontmatterSchema: z.ZodObject<{
|
|
120
|
+
title: z.ZodString;
|
|
121
|
+
description: z.ZodOptional<z.ZodString>;
|
|
122
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
123
|
+
full: z.ZodOptional<z.ZodBoolean>;
|
|
124
|
+
_openapi: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
|
125
|
+
}, "strip", z.ZodTypeAny, {
|
|
126
|
+
title: string;
|
|
127
|
+
icon?: string | undefined;
|
|
128
|
+
description?: string | undefined;
|
|
129
|
+
full?: boolean | undefined;
|
|
130
|
+
_openapi?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
131
|
+
}, {
|
|
132
|
+
title: string;
|
|
133
|
+
icon?: string | undefined;
|
|
134
|
+
description?: string | undefined;
|
|
135
|
+
full?: boolean | undefined;
|
|
136
|
+
_openapi?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
137
|
+
}>;
|
|
138
|
+
|
|
139
|
+
interface TransformContext {
|
|
140
|
+
path: string;
|
|
141
|
+
source: string;
|
|
142
|
+
/**
|
|
143
|
+
* Compile MDX to JavaScript
|
|
144
|
+
*/
|
|
145
|
+
buildMDX: (source: string, options?: ProcessorOptions) => Promise<string>;
|
|
146
|
+
}
|
|
147
|
+
interface BaseCollection<Schema> {
|
|
148
|
+
/**
|
|
149
|
+
* Directories to scan
|
|
150
|
+
*/
|
|
151
|
+
dir: string | string[];
|
|
152
|
+
/**
|
|
153
|
+
* what files to include/exclude (glob patterns)
|
|
154
|
+
*
|
|
155
|
+
* Include all files if not specified
|
|
156
|
+
*/
|
|
157
|
+
files?: string[];
|
|
158
|
+
schema?: Schema | ((ctx: TransformContext) => Schema);
|
|
159
|
+
}
|
|
160
|
+
interface MetaCollection<Schema extends StandardSchemaV1 = StandardSchemaV1> extends BaseCollection<Schema> {
|
|
161
|
+
type: 'meta';
|
|
162
|
+
}
|
|
163
|
+
interface DocCollection<Schema extends StandardSchemaV1 = StandardSchemaV1, Async extends boolean = boolean> extends BaseCollection<Schema> {
|
|
164
|
+
type: 'doc';
|
|
165
|
+
mdxOptions?: MDXOptions;
|
|
166
|
+
/**
|
|
167
|
+
* Load files with async
|
|
168
|
+
*/
|
|
169
|
+
async?: Async;
|
|
170
|
+
}
|
|
171
|
+
interface DocsCollection {
|
|
172
|
+
type: 'docs';
|
|
173
|
+
docs: DocCollection;
|
|
174
|
+
meta: MetaCollection;
|
|
175
|
+
}
|
|
176
|
+
declare function defineCollections<T extends 'doc' | 'meta', Schema extends StandardSchemaV1 = StandardSchemaV1, Async extends boolean = false>(options: {
|
|
177
|
+
type: T;
|
|
178
|
+
} & (T extends 'doc' ? DocCollection<Schema, Async> : MetaCollection<Schema>)): {
|
|
179
|
+
type: T;
|
|
180
|
+
_type: {
|
|
181
|
+
async: Async;
|
|
182
|
+
schema: Schema;
|
|
183
|
+
};
|
|
184
|
+
};
|
|
185
|
+
declare function defineDocs<DocData extends StandardSchemaV1 = typeof frontmatterSchema, MetaData extends StandardSchemaV1 = typeof metaSchema, DocAsync extends boolean = false>(options?: {
|
|
186
|
+
/**
|
|
187
|
+
* The directory to scan files
|
|
188
|
+
*
|
|
189
|
+
* @defaultValue 'content/docs'
|
|
190
|
+
*/
|
|
191
|
+
dir?: string | string[];
|
|
192
|
+
docs?: Omit<DocCollection<DocData, DocAsync>, 'dir' | 'type'>;
|
|
193
|
+
meta?: Omit<MetaCollection<MetaData>, 'dir' | 'type'>;
|
|
194
|
+
}): {
|
|
195
|
+
type: 'docs';
|
|
196
|
+
docs: ReturnType<typeof defineCollections<'doc', DocData, DocAsync>>;
|
|
197
|
+
meta: ReturnType<typeof defineCollections<'meta', MetaData, false>>;
|
|
198
|
+
};
|
|
199
|
+
declare function defineConfig(config?: GlobalConfig): GlobalConfig;
|
|
200
|
+
|
|
201
|
+
export { type BaseCollectionEntry as B, type DocCollection as D, type FileInfo as F, type GlobalConfig as G, type InferSchema as I, type MarkdownProps as M, type TransformContext as T, type InferSchemaType as a, type BaseCollection as b, type MetaCollection as c, type DocsCollection as d, defineCollections as e, frontmatterSchema as f, defineDocs as g, defineConfig as h, type DefaultMDXOptions as i, getDefaultMDXOptions as j, metaSchema as m };
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { ProcessorOptions } from '@mdx-js/mdx';
|
|
2
|
+
import { MDXProps } from 'mdx/types';
|
|
3
|
+
import * as plugins from 'fumadocs-core/mdx-plugins';
|
|
4
|
+
import { StructuredData } from 'fumadocs-core/mdx-plugins';
|
|
5
|
+
import { TableOfContents } from 'fumadocs-core/server';
|
|
6
|
+
import { Pluggable } from 'unified';
|
|
7
|
+
import { FC } from 'react';
|
|
8
|
+
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
|
|
11
|
+
type ResolvePlugins = Pluggable[] | ((v: Pluggable[]) => Pluggable[]);
|
|
12
|
+
type DefaultMDXOptions = Omit<NonNullable<ProcessorOptions>, 'rehypePlugins' | 'remarkPlugins' | '_ctx'> & {
|
|
13
|
+
rehypePlugins?: ResolvePlugins;
|
|
14
|
+
remarkPlugins?: ResolvePlugins;
|
|
15
|
+
/**
|
|
16
|
+
* Properties to export from `vfile.data`
|
|
17
|
+
*/
|
|
18
|
+
valueToExport?: string[];
|
|
19
|
+
remarkStructureOptions?: plugins.StructureOptions | false;
|
|
20
|
+
remarkHeadingOptions?: plugins.RemarkHeadingOptions;
|
|
21
|
+
remarkImageOptions?: plugins.RemarkImageOptions | false;
|
|
22
|
+
remarkCodeTabOptions?: false;
|
|
23
|
+
rehypeCodeOptions?: plugins.RehypeCodeOptions | false;
|
|
24
|
+
};
|
|
25
|
+
declare function getDefaultMDXOptions({ valueToExport, rehypeCodeOptions, remarkImageOptions, remarkHeadingOptions, remarkStructureOptions, remarkCodeTabOptions, ...mdxOptions }: DefaultMDXOptions): ProcessorOptions;
|
|
26
|
+
|
|
27
|
+
interface GlobalConfig {
|
|
28
|
+
/**
|
|
29
|
+
* Configure global MDX options
|
|
30
|
+
*/
|
|
31
|
+
mdxOptions?: DefaultMDXOptions | (() => DefaultMDXOptions | Promise<DefaultMDXOptions>);
|
|
32
|
+
/**
|
|
33
|
+
* Fetch last modified time with specified version control
|
|
34
|
+
* @defaultValue 'none'
|
|
35
|
+
*/
|
|
36
|
+
lastModifiedTime?: 'git' | 'none';
|
|
37
|
+
/**
|
|
38
|
+
* Generate manifest file on build mode
|
|
39
|
+
*
|
|
40
|
+
* @defaultValue false
|
|
41
|
+
* @deprecated No longer needed, use a route handler to export build time info
|
|
42
|
+
*/
|
|
43
|
+
generateManifest?: boolean;
|
|
44
|
+
}
|
|
45
|
+
type InferSchema<CollectionOut> = CollectionOut extends {
|
|
46
|
+
_type: {
|
|
47
|
+
schema: infer T;
|
|
48
|
+
};
|
|
49
|
+
} ? T : never;
|
|
50
|
+
type InferSchemaType<C> = InferSchema<C> extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<InferSchema<C>> : never;
|
|
51
|
+
interface FileInfo {
|
|
52
|
+
path: string;
|
|
53
|
+
absolutePath: string;
|
|
54
|
+
}
|
|
55
|
+
interface MarkdownProps {
|
|
56
|
+
body: FC<MDXProps>;
|
|
57
|
+
structuredData: StructuredData;
|
|
58
|
+
toc: TableOfContents;
|
|
59
|
+
_exports: Record<string, unknown>;
|
|
60
|
+
/**
|
|
61
|
+
* Only available when `lastModifiedTime` is enabled on MDX loader
|
|
62
|
+
*/
|
|
63
|
+
lastModified?: Date;
|
|
64
|
+
}
|
|
65
|
+
interface BaseCollectionEntry {
|
|
66
|
+
_file: FileInfo;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
interface MDXOptions extends ProcessorOptions {
|
|
70
|
+
/**
|
|
71
|
+
* Name of collection
|
|
72
|
+
*/
|
|
73
|
+
collection?: string;
|
|
74
|
+
/**
|
|
75
|
+
* Specify a file path for source
|
|
76
|
+
*/
|
|
77
|
+
filePath?: string;
|
|
78
|
+
frontmatter?: Record<string, unknown>;
|
|
79
|
+
/**
|
|
80
|
+
* Custom Vfile data
|
|
81
|
+
*/
|
|
82
|
+
data?: Record<string, unknown>;
|
|
83
|
+
_compiler?: CompilerOptions;
|
|
84
|
+
}
|
|
85
|
+
interface CompilerOptions {
|
|
86
|
+
addDependency: (file: string) => void;
|
|
87
|
+
}
|
|
88
|
+
declare module 'vfile' {
|
|
89
|
+
interface DataMap {
|
|
90
|
+
/**
|
|
91
|
+
* The compiler object from loader
|
|
92
|
+
*/
|
|
93
|
+
_compiler?: CompilerOptions;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
declare const metaSchema: z.ZodObject<{
|
|
98
|
+
title: z.ZodOptional<z.ZodString>;
|
|
99
|
+
pages: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
100
|
+
description: z.ZodOptional<z.ZodString>;
|
|
101
|
+
root: z.ZodOptional<z.ZodBoolean>;
|
|
102
|
+
defaultOpen: z.ZodOptional<z.ZodBoolean>;
|
|
103
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
104
|
+
}, "strip", z.ZodTypeAny, {
|
|
105
|
+
root?: boolean | undefined;
|
|
106
|
+
title?: string | undefined;
|
|
107
|
+
icon?: string | undefined;
|
|
108
|
+
pages?: string[] | undefined;
|
|
109
|
+
description?: string | undefined;
|
|
110
|
+
defaultOpen?: boolean | undefined;
|
|
111
|
+
}, {
|
|
112
|
+
root?: boolean | undefined;
|
|
113
|
+
title?: string | undefined;
|
|
114
|
+
icon?: string | undefined;
|
|
115
|
+
pages?: string[] | undefined;
|
|
116
|
+
description?: string | undefined;
|
|
117
|
+
defaultOpen?: boolean | undefined;
|
|
118
|
+
}>;
|
|
119
|
+
declare const frontmatterSchema: z.ZodObject<{
|
|
120
|
+
title: z.ZodString;
|
|
121
|
+
description: z.ZodOptional<z.ZodString>;
|
|
122
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
123
|
+
full: z.ZodOptional<z.ZodBoolean>;
|
|
124
|
+
_openapi: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
|
125
|
+
}, "strip", z.ZodTypeAny, {
|
|
126
|
+
title: string;
|
|
127
|
+
icon?: string | undefined;
|
|
128
|
+
description?: string | undefined;
|
|
129
|
+
full?: boolean | undefined;
|
|
130
|
+
_openapi?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
131
|
+
}, {
|
|
132
|
+
title: string;
|
|
133
|
+
icon?: string | undefined;
|
|
134
|
+
description?: string | undefined;
|
|
135
|
+
full?: boolean | undefined;
|
|
136
|
+
_openapi?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
137
|
+
}>;
|
|
138
|
+
|
|
139
|
+
interface TransformContext {
|
|
140
|
+
path: string;
|
|
141
|
+
source: string;
|
|
142
|
+
/**
|
|
143
|
+
* Compile MDX to JavaScript
|
|
144
|
+
*/
|
|
145
|
+
buildMDX: (source: string, options?: ProcessorOptions) => Promise<string>;
|
|
146
|
+
}
|
|
147
|
+
interface BaseCollection<Schema> {
|
|
148
|
+
/**
|
|
149
|
+
* Directories to scan
|
|
150
|
+
*/
|
|
151
|
+
dir: string | string[];
|
|
152
|
+
/**
|
|
153
|
+
* what files to include/exclude (glob patterns)
|
|
154
|
+
*
|
|
155
|
+
* Include all files if not specified
|
|
156
|
+
*/
|
|
157
|
+
files?: string[];
|
|
158
|
+
schema?: Schema | ((ctx: TransformContext) => Schema);
|
|
159
|
+
}
|
|
160
|
+
interface MetaCollection<Schema extends StandardSchemaV1 = StandardSchemaV1> extends BaseCollection<Schema> {
|
|
161
|
+
type: 'meta';
|
|
162
|
+
}
|
|
163
|
+
interface DocCollection<Schema extends StandardSchemaV1 = StandardSchemaV1, Async extends boolean = boolean> extends BaseCollection<Schema> {
|
|
164
|
+
type: 'doc';
|
|
165
|
+
mdxOptions?: MDXOptions;
|
|
166
|
+
/**
|
|
167
|
+
* Load files with async
|
|
168
|
+
*/
|
|
169
|
+
async?: Async;
|
|
170
|
+
}
|
|
171
|
+
interface DocsCollection {
|
|
172
|
+
type: 'docs';
|
|
173
|
+
docs: DocCollection;
|
|
174
|
+
meta: MetaCollection;
|
|
175
|
+
}
|
|
176
|
+
declare function defineCollections<T extends 'doc' | 'meta', Schema extends StandardSchemaV1 = StandardSchemaV1, Async extends boolean = false>(options: {
|
|
177
|
+
type: T;
|
|
178
|
+
} & (T extends 'doc' ? DocCollection<Schema, Async> : MetaCollection<Schema>)): {
|
|
179
|
+
type: T;
|
|
180
|
+
_type: {
|
|
181
|
+
async: Async;
|
|
182
|
+
schema: Schema;
|
|
183
|
+
};
|
|
184
|
+
};
|
|
185
|
+
declare function defineDocs<DocData extends StandardSchemaV1 = typeof frontmatterSchema, MetaData extends StandardSchemaV1 = typeof metaSchema, DocAsync extends boolean = false>(options?: {
|
|
186
|
+
/**
|
|
187
|
+
* The directory to scan files
|
|
188
|
+
*
|
|
189
|
+
* @defaultValue 'content/docs'
|
|
190
|
+
*/
|
|
191
|
+
dir?: string | string[];
|
|
192
|
+
docs?: Omit<DocCollection<DocData, DocAsync>, 'dir' | 'type'>;
|
|
193
|
+
meta?: Omit<MetaCollection<MetaData>, 'dir' | 'type'>;
|
|
194
|
+
}): {
|
|
195
|
+
type: 'docs';
|
|
196
|
+
docs: ReturnType<typeof defineCollections<'doc', DocData, DocAsync>>;
|
|
197
|
+
meta: ReturnType<typeof defineCollections<'meta', MetaData, false>>;
|
|
198
|
+
};
|
|
199
|
+
declare function defineConfig(config?: GlobalConfig): GlobalConfig;
|
|
200
|
+
|
|
201
|
+
export { type BaseCollectionEntry as B, type DocCollection as D, type FileInfo as F, type GlobalConfig as G, type InferSchema as I, type MarkdownProps as M, type TransformContext as T, type InferSchemaType as a, type BaseCollection as b, type MetaCollection as c, type DocsCollection as d, defineCollections as e, frontmatterSchema as f, defineDocs as g, defineConfig as h, type DefaultMDXOptions as i, getDefaultMDXOptions as j, metaSchema as m };
|
package/dist/index.cjs
CHANGED
|
@@ -20,29 +20,46 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
_runtime: () => _runtime,
|
|
23
24
|
createMDXSource: () => createMDXSource,
|
|
24
|
-
resolveFiles: () => resolveFiles
|
|
25
|
-
toRuntime: () => toRuntime
|
|
25
|
+
resolveFiles: () => resolveFiles
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(index_exports);
|
|
28
28
|
|
|
29
29
|
// src/runtime/index.ts
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
var _runtime = {
|
|
31
|
+
doc(files) {
|
|
32
|
+
return files.map((file) => {
|
|
33
|
+
const { default: body, frontmatter, ...exports2 } = file.data;
|
|
34
|
+
return {
|
|
35
|
+
body,
|
|
36
|
+
...exports2,
|
|
37
|
+
...frontmatter,
|
|
38
|
+
_exports: file.data,
|
|
39
|
+
_file: file.info
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
meta(files) {
|
|
44
|
+
return files.map((file) => {
|
|
45
|
+
return {
|
|
46
|
+
...file.data.default,
|
|
47
|
+
_file: file.info
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
docs(docs, metas) {
|
|
52
|
+
const parsedDocs = this.doc(docs);
|
|
53
|
+
const parsedMetas = this.meta(metas);
|
|
33
54
|
return {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
55
|
+
docs: parsedDocs,
|
|
56
|
+
meta: parsedMetas,
|
|
57
|
+
toFumadocsSource() {
|
|
58
|
+
return createMDXSource(parsedDocs, parsedMetas);
|
|
59
|
+
}
|
|
39
60
|
};
|
|
40
61
|
}
|
|
41
|
-
|
|
42
|
-
...file.default,
|
|
43
|
-
_file: info
|
|
44
|
-
};
|
|
45
|
-
}
|
|
62
|
+
};
|
|
46
63
|
function createMDXSource(docs, meta = []) {
|
|
47
64
|
return {
|
|
48
65
|
files: (rootDir) => resolveFiles({
|
|
@@ -77,7 +94,7 @@ function resolveFiles({
|
|
|
77
94
|
}
|
|
78
95
|
// Annotate the CommonJS export names for ESM import in node:
|
|
79
96
|
0 && (module.exports = {
|
|
97
|
+
_runtime,
|
|
80
98
|
createMDXSource,
|
|
81
|
-
resolveFiles
|
|
82
|
-
toRuntime
|
|
99
|
+
resolveFiles
|
|
83
100
|
});
|