fumadocs-mdx 11.1.2 → 11.2.1
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/{types-BOXkLY5B.d.ts → build-mdx-SZwWfZMp.d.ts} +29 -1
- package/dist/{chunk-QYUB4AKH.js → chunk-EVNXCXU4.js} +43 -37
- package/dist/chunk-GUHWD47S.js +41 -0
- package/dist/{chunk-YA4EPE5U.js → chunk-MKWJLEE7.js} +0 -54
- package/dist/config/index.d.ts +7 -20
- package/dist/config/index.js +56 -8
- package/dist/index.d.ts +1 -1
- package/dist/loader-mdx.js +33 -34
- package/dist/next/index.js +13 -11
- package/package.json +12 -10
|
@@ -74,4 +74,32 @@ type GetOutput<C extends {
|
|
|
74
74
|
};
|
|
75
75
|
}> = CollectionEntry<C>[];
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
interface MDXOptions extends ProcessorOptions {
|
|
78
|
+
/**
|
|
79
|
+
* Name of collection
|
|
80
|
+
*/
|
|
81
|
+
collection?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Specify a file path for source
|
|
84
|
+
*/
|
|
85
|
+
filePath?: string;
|
|
86
|
+
frontmatter?: Record<string, unknown>;
|
|
87
|
+
/**
|
|
88
|
+
* Custom Vfile data
|
|
89
|
+
*/
|
|
90
|
+
data?: Record<string, unknown>;
|
|
91
|
+
_compiler?: CompilerOptions;
|
|
92
|
+
}
|
|
93
|
+
interface CompilerOptions {
|
|
94
|
+
addDependency: (file: string) => void;
|
|
95
|
+
}
|
|
96
|
+
declare module 'vfile' {
|
|
97
|
+
interface DataMap {
|
|
98
|
+
/**
|
|
99
|
+
* The compiler object from loader
|
|
100
|
+
*/
|
|
101
|
+
_compiler?: CompilerOptions;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export { type BaseCollectionEntry as B, type CollectionEntry as C, type DefaultMDXOptions as D, type FileInfo as F, type GlobalConfig as G, type InferSchema as I, type MarkdownProps as M, type MDXOptions as a, type InferSchemaType as b, type GetOutput as c, getDefaultMDXOptions as g };
|
|
@@ -1,44 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getDefaultMDXOptions
|
|
3
|
+
} from "./chunk-MKWJLEE7.js";
|
|
4
|
+
|
|
1
5
|
// src/config/cached.ts
|
|
2
6
|
import { createHash } from "node:crypto";
|
|
3
|
-
import fs from "node:fs";
|
|
7
|
+
import * as fs from "node:fs";
|
|
4
8
|
|
|
5
9
|
// src/config/load.ts
|
|
6
10
|
import * as path from "node:path";
|
|
7
11
|
import { pathToFileURL } from "node:url";
|
|
8
12
|
import { build } from "esbuild";
|
|
9
|
-
|
|
10
|
-
// src/config/validate.ts
|
|
11
|
-
function validateConfig(config) {
|
|
12
|
-
const out = {
|
|
13
|
-
collections: /* @__PURE__ */ new Map(),
|
|
14
|
-
_runtime: {
|
|
15
|
-
files: /* @__PURE__ */ new Map()
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
for (const [k, v] of Object.entries(config)) {
|
|
19
|
-
if (!v) {
|
|
20
|
-
continue;
|
|
21
|
-
}
|
|
22
|
-
if (typeof v === "object" && "_doc" in v && v._doc === "collections") {
|
|
23
|
-
out.collections.set(
|
|
24
|
-
k,
|
|
25
|
-
v
|
|
26
|
-
);
|
|
27
|
-
continue;
|
|
28
|
-
}
|
|
29
|
-
if (k === "default") {
|
|
30
|
-
out.global = v;
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
return [
|
|
34
|
-
`Unknown export "${k}", you can only export collections from source configuration file.`,
|
|
35
|
-
null
|
|
36
|
-
];
|
|
37
|
-
}
|
|
38
|
-
return [null, out];
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// src/config/load.ts
|
|
42
13
|
function findConfigFile() {
|
|
43
14
|
return path.resolve("source.config.ts");
|
|
44
15
|
}
|
|
@@ -63,13 +34,48 @@ async function loadConfig(configPath) {
|
|
|
63
34
|
throw new Error("failed to compile configuration file");
|
|
64
35
|
}
|
|
65
36
|
const url = pathToFileURL(outputPath);
|
|
66
|
-
const [err, config] =
|
|
37
|
+
const [err, config] = buildConfig(
|
|
67
38
|
// every call to `loadConfig` will cause the previous cache to be ignored
|
|
68
39
|
await import(`${url.toString()}?hash=${Date.now().toString()}`)
|
|
69
40
|
);
|
|
70
41
|
if (err !== null) throw new Error(err);
|
|
71
42
|
return config;
|
|
72
43
|
}
|
|
44
|
+
function buildConfig(config) {
|
|
45
|
+
const collections = /* @__PURE__ */ new Map();
|
|
46
|
+
let globalConfig;
|
|
47
|
+
for (const [k, v] of Object.entries(config)) {
|
|
48
|
+
if (!v) {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
if (typeof v === "object" && "_doc" in v && v._doc === "collections") {
|
|
52
|
+
collections.set(
|
|
53
|
+
k,
|
|
54
|
+
v
|
|
55
|
+
);
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
if (k === "default") {
|
|
59
|
+
globalConfig = v;
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
return [
|
|
63
|
+
`Unknown export "${k}", you can only export collections from source configuration file.`,
|
|
64
|
+
null
|
|
65
|
+
];
|
|
66
|
+
}
|
|
67
|
+
return [
|
|
68
|
+
null,
|
|
69
|
+
{
|
|
70
|
+
global: globalConfig,
|
|
71
|
+
collections,
|
|
72
|
+
defaultMdxOptions: getDefaultMDXOptions(globalConfig?.mdxOptions ?? {}),
|
|
73
|
+
_runtime: {
|
|
74
|
+
files: /* @__PURE__ */ new Map()
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
];
|
|
78
|
+
}
|
|
73
79
|
|
|
74
80
|
// src/config/cached.ts
|
|
75
81
|
var cache = /* @__PURE__ */ new Map();
|
|
@@ -92,8 +98,8 @@ async function getConfigHash(configPath) {
|
|
|
92
98
|
}
|
|
93
99
|
|
|
94
100
|
// src/map/manifest.ts
|
|
95
|
-
import fs2 from "node:fs";
|
|
96
|
-
import path2 from "node:path";
|
|
101
|
+
import * as fs2 from "node:fs";
|
|
102
|
+
import * as path2 from "node:path";
|
|
97
103
|
|
|
98
104
|
// src/utils/get-type-from-path.ts
|
|
99
105
|
import { extname } from "node:path";
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// src/mdx-plugins/remark-include.ts
|
|
2
|
+
import { visit } from "unist-util-visit";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
import * as fs from "node:fs/promises";
|
|
5
|
+
import matter from "gray-matter";
|
|
6
|
+
function remarkInclude() {
|
|
7
|
+
return async (tree, file) => {
|
|
8
|
+
const queue = [];
|
|
9
|
+
visit(tree, ["mdxJsxFlowElement", "paragraph"], (node) => {
|
|
10
|
+
let specifier;
|
|
11
|
+
if (node.type === "paragraph" && node.children.length === 3) {
|
|
12
|
+
const [open, content, closure] = node.children;
|
|
13
|
+
if (open.type === "html" && open.value === "<include>" && content.type === "text" && closure.type === "html" && closure.value === "</include>") {
|
|
14
|
+
specifier = content.value.trim();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
if (node.type === "mdxJsxFlowElement" && node.name === "include") {
|
|
18
|
+
const child = node.children.at(0);
|
|
19
|
+
if (!child || child.type !== "text") return;
|
|
20
|
+
specifier = child.value;
|
|
21
|
+
}
|
|
22
|
+
if (!specifier) return "skip";
|
|
23
|
+
const targetPath = path.resolve(path.dirname(file.path), specifier);
|
|
24
|
+
queue.push(
|
|
25
|
+
fs.readFile(targetPath).then((content) => {
|
|
26
|
+
const parsed = this.parse(matter(content).content);
|
|
27
|
+
if (file.data._compiler) {
|
|
28
|
+
file.data._compiler.addDependency(targetPath);
|
|
29
|
+
}
|
|
30
|
+
Object.assign(node, parsed);
|
|
31
|
+
})
|
|
32
|
+
);
|
|
33
|
+
return "skip";
|
|
34
|
+
});
|
|
35
|
+
await Promise.all(queue);
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export {
|
|
40
|
+
remarkInclude
|
|
41
|
+
};
|
|
@@ -1,52 +1,3 @@
|
|
|
1
|
-
// src/utils/schema.ts
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
var metaSchema = z.object({
|
|
4
|
-
title: z.string().optional(),
|
|
5
|
-
pages: z.array(z.string()).optional(),
|
|
6
|
-
description: z.string().optional(),
|
|
7
|
-
root: z.boolean().optional(),
|
|
8
|
-
defaultOpen: z.boolean().optional(),
|
|
9
|
-
icon: z.string().optional()
|
|
10
|
-
});
|
|
11
|
-
var frontmatterSchema = z.object({
|
|
12
|
-
title: z.string(),
|
|
13
|
-
description: z.string().optional(),
|
|
14
|
-
icon: z.string().optional(),
|
|
15
|
-
full: z.boolean().optional(),
|
|
16
|
-
// Fumadocs OpenAPI generated
|
|
17
|
-
_openapi: z.object({}).passthrough().optional()
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
// src/config/define.ts
|
|
21
|
-
function defineCollections(options) {
|
|
22
|
-
return {
|
|
23
|
-
_doc: "collections",
|
|
24
|
-
// @ts-expect-error -- internal type inferring
|
|
25
|
-
_type: void 0,
|
|
26
|
-
...options
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
function defineDocs(options) {
|
|
30
|
-
const dir = options?.dir ?? "content/docs";
|
|
31
|
-
return {
|
|
32
|
-
docs: defineCollections({
|
|
33
|
-
type: "doc",
|
|
34
|
-
dir,
|
|
35
|
-
schema: frontmatterSchema,
|
|
36
|
-
...options?.docs
|
|
37
|
-
}),
|
|
38
|
-
meta: defineCollections({
|
|
39
|
-
type: "meta",
|
|
40
|
-
dir,
|
|
41
|
-
schema: metaSchema,
|
|
42
|
-
...options?.meta
|
|
43
|
-
})
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
function defineConfig(config = {}) {
|
|
47
|
-
return config;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
1
|
// src/utils/mdx-options.ts
|
|
51
2
|
import {
|
|
52
3
|
rehypeCode,
|
|
@@ -161,10 +112,5 @@ function getDefaultMDXOptions({
|
|
|
161
112
|
}
|
|
162
113
|
|
|
163
114
|
export {
|
|
164
|
-
metaSchema,
|
|
165
|
-
frontmatterSchema,
|
|
166
|
-
defineCollections,
|
|
167
|
-
defineDocs,
|
|
168
|
-
defineConfig,
|
|
169
115
|
getDefaultMDXOptions
|
|
170
116
|
};
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,27 +1,12 @@
|
|
|
1
|
-
import { F as FileInfo, G as GlobalConfig, M as MarkdownProps, B as BaseCollectionEntry } from '../
|
|
2
|
-
export { C as CollectionEntry, D as DefaultMDXOptions,
|
|
1
|
+
import { F as FileInfo, G as GlobalConfig, M as MarkdownProps, a as MDXOptions, B as BaseCollectionEntry } from '../build-mdx-SZwWfZMp.js';
|
|
2
|
+
export { C as CollectionEntry, D as DefaultMDXOptions, c as GetOutput, I as InferSchema, b as InferSchemaType, g as getDefaultMDXOptions } from '../build-mdx-SZwWfZMp.js';
|
|
3
3
|
import { z, ZodTypeAny } from 'zod';
|
|
4
4
|
import { ProcessorOptions } from '@mdx-js/mdx';
|
|
5
|
+
import { Processor, Transformer } from 'unified';
|
|
6
|
+
import { Root } from 'mdast';
|
|
5
7
|
import 'mdx/types';
|
|
6
8
|
import 'fumadocs-core/mdx-plugins';
|
|
7
9
|
import 'fumadocs-core/server';
|
|
8
|
-
import 'unified';
|
|
9
|
-
|
|
10
|
-
interface MDXOptions extends ProcessorOptions {
|
|
11
|
-
/**
|
|
12
|
-
* Name of collection
|
|
13
|
-
*/
|
|
14
|
-
collection?: string;
|
|
15
|
-
/**
|
|
16
|
-
* Specify a file path for source
|
|
17
|
-
*/
|
|
18
|
-
filePath?: string;
|
|
19
|
-
frontmatter?: Record<string, unknown>;
|
|
20
|
-
/**
|
|
21
|
-
* Custom Vfile data
|
|
22
|
-
*/
|
|
23
|
-
data?: Record<string, unknown>;
|
|
24
|
-
}
|
|
25
10
|
|
|
26
11
|
declare const metaSchema: z.ZodObject<{
|
|
27
12
|
title: z.ZodOptional<z.ZodString>;
|
|
@@ -144,4 +129,6 @@ declare function defineDocs<DocData extends ZodTypeAny = typeof frontmatterSchem
|
|
|
144
129
|
};
|
|
145
130
|
declare function defineConfig(config?: GlobalConfig): GlobalConfig;
|
|
146
131
|
|
|
147
|
-
|
|
132
|
+
declare function remarkInclude(this: Processor): Transformer<Root, Root>;
|
|
133
|
+
|
|
134
|
+
export { type BaseCollection, BaseCollectionEntry, type DocCollection, FileInfo, GlobalConfig, MarkdownProps, type MetaCollection, type TransformContext, defineCollections, defineConfig, defineDocs, frontmatterSchema, metaSchema, remarkInclude };
|
package/dist/config/index.js
CHANGED
|
@@ -1,16 +1,64 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
remarkInclude
|
|
3
|
+
} from "../chunk-GUHWD47S.js";
|
|
4
|
+
import {
|
|
5
|
+
getDefaultMDXOptions
|
|
6
|
+
} from "../chunk-MKWJLEE7.js";
|
|
7
|
+
|
|
8
|
+
// src/utils/schema.ts
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
var metaSchema = z.object({
|
|
11
|
+
title: z.string().optional(),
|
|
12
|
+
pages: z.array(z.string()).optional(),
|
|
13
|
+
description: z.string().optional(),
|
|
14
|
+
root: z.boolean().optional(),
|
|
15
|
+
defaultOpen: z.boolean().optional(),
|
|
16
|
+
icon: z.string().optional()
|
|
17
|
+
});
|
|
18
|
+
var frontmatterSchema = z.object({
|
|
19
|
+
title: z.string(),
|
|
20
|
+
description: z.string().optional(),
|
|
21
|
+
icon: z.string().optional(),
|
|
22
|
+
full: z.boolean().optional(),
|
|
23
|
+
// Fumadocs OpenAPI generated
|
|
24
|
+
_openapi: z.object({}).passthrough().optional()
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// src/config/define.ts
|
|
28
|
+
function defineCollections(options) {
|
|
29
|
+
return {
|
|
30
|
+
_doc: "collections",
|
|
31
|
+
// @ts-expect-error -- internal type inferring
|
|
32
|
+
_type: void 0,
|
|
33
|
+
...options
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function defineDocs(options) {
|
|
37
|
+
const dir = options?.dir ?? "content/docs";
|
|
38
|
+
return {
|
|
39
|
+
docs: defineCollections({
|
|
40
|
+
type: "doc",
|
|
41
|
+
dir,
|
|
42
|
+
schema: frontmatterSchema,
|
|
43
|
+
...options?.docs
|
|
44
|
+
}),
|
|
45
|
+
meta: defineCollections({
|
|
46
|
+
type: "meta",
|
|
47
|
+
dir,
|
|
48
|
+
schema: metaSchema,
|
|
49
|
+
...options?.meta
|
|
50
|
+
})
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function defineConfig(config = {}) {
|
|
54
|
+
return config;
|
|
55
|
+
}
|
|
9
56
|
export {
|
|
10
57
|
defineCollections,
|
|
11
58
|
defineConfig,
|
|
12
59
|
defineDocs,
|
|
13
60
|
frontmatterSchema,
|
|
14
61
|
getDefaultMDXOptions,
|
|
15
|
-
metaSchema
|
|
62
|
+
metaSchema,
|
|
63
|
+
remarkInclude
|
|
16
64
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PageData, MetaData, Source } from 'fumadocs-core/source';
|
|
2
|
-
import { F as FileInfo, B as BaseCollectionEntry } from './
|
|
2
|
+
import { F as FileInfo, B as BaseCollectionEntry } from './build-mdx-SZwWfZMp.js';
|
|
3
3
|
import { MetaFile } from './loader-mdx.js';
|
|
4
4
|
import 'zod';
|
|
5
5
|
import 'mdx/types';
|
package/dist/loader-mdx.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
2
|
+
remarkInclude
|
|
3
|
+
} from "./chunk-GUHWD47S.js";
|
|
4
4
|
import {
|
|
5
5
|
getConfigHash,
|
|
6
6
|
getManifestEntryPath,
|
|
7
7
|
loadConfigCached
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-EVNXCXU4.js";
|
|
9
|
+
import "./chunk-MKWJLEE7.js";
|
|
9
10
|
|
|
10
11
|
// src/loader-mdx.ts
|
|
11
|
-
import path2 from "node:path";
|
|
12
|
-
import fs2 from "node:fs/promises";
|
|
12
|
+
import * as path2 from "node:path";
|
|
13
|
+
import * as fs2 from "node:fs/promises";
|
|
13
14
|
import { parse } from "node:querystring";
|
|
14
15
|
import grayMatter from "gray-matter";
|
|
15
16
|
|
|
@@ -34,6 +35,7 @@ function buildMDX(group, configHash, source, options = {}) {
|
|
|
34
35
|
outputFormat: "program",
|
|
35
36
|
development: process.env.NODE_ENV === "development",
|
|
36
37
|
...rest,
|
|
38
|
+
remarkPlugins: [remarkInclude, ...rest.remarkPlugins ?? []],
|
|
37
39
|
format
|
|
38
40
|
}),
|
|
39
41
|
configHash
|
|
@@ -45,7 +47,8 @@ function buildMDX(group, configHash, source, options = {}) {
|
|
|
45
47
|
path: filePath,
|
|
46
48
|
data: {
|
|
47
49
|
...data,
|
|
48
|
-
frontmatter
|
|
50
|
+
frontmatter,
|
|
51
|
+
_compiler: options._compiler
|
|
49
52
|
}
|
|
50
53
|
});
|
|
51
54
|
}
|
|
@@ -97,7 +100,7 @@ function getGitTimestamp(file) {
|
|
|
97
100
|
}
|
|
98
101
|
|
|
99
102
|
// src/loader-mdx.ts
|
|
100
|
-
function
|
|
103
|
+
function parseQuery(query) {
|
|
101
104
|
let collection;
|
|
102
105
|
let hash;
|
|
103
106
|
const parsed = parse(query.slice(1));
|
|
@@ -112,33 +115,34 @@ async function loader(source, callback) {
|
|
|
112
115
|
const filePath = this.resourcePath;
|
|
113
116
|
const { _ctx } = this.getOptions();
|
|
114
117
|
const matter = grayMatter(source);
|
|
115
|
-
const
|
|
116
|
-
|
|
118
|
+
const {
|
|
119
|
+
hash: configHash = await getConfigHash(_ctx.configPath),
|
|
120
|
+
collection: collectionId
|
|
121
|
+
} = parseQuery(this.resourceQuery);
|
|
117
122
|
const config = await loadConfigCached(_ctx.configPath, configHash);
|
|
118
|
-
const collectionId = query.collection;
|
|
119
123
|
let collection = collectionId !== void 0 ? config.collections.get(collectionId) : void 0;
|
|
120
124
|
if (collection && collection.type !== "doc") {
|
|
121
125
|
collection = void 0;
|
|
122
126
|
}
|
|
123
|
-
const mdxOptions = collection?.mdxOptions ??
|
|
124
|
-
function getTransformContext() {
|
|
125
|
-
return {
|
|
126
|
-
buildMDX: async (v, options = mdxOptions) => {
|
|
127
|
-
const res = await buildMDX(
|
|
128
|
-
collectionId ?? "global",
|
|
129
|
-
configHash,
|
|
130
|
-
v,
|
|
131
|
-
options
|
|
132
|
-
);
|
|
133
|
-
return String(res.value);
|
|
134
|
-
},
|
|
135
|
-
source,
|
|
136
|
-
path: filePath
|
|
137
|
-
};
|
|
138
|
-
}
|
|
127
|
+
const mdxOptions = collection?.mdxOptions ?? config.defaultMdxOptions;
|
|
139
128
|
let frontmatter = matter.data;
|
|
140
129
|
if (collection?.schema) {
|
|
141
|
-
|
|
130
|
+
let schema = collection.schema;
|
|
131
|
+
if (typeof schema === "function") {
|
|
132
|
+
schema = schema({
|
|
133
|
+
async buildMDX(v, options = mdxOptions) {
|
|
134
|
+
const res = await buildMDX(
|
|
135
|
+
collectionId ?? "global",
|
|
136
|
+
configHash,
|
|
137
|
+
v,
|
|
138
|
+
options
|
|
139
|
+
);
|
|
140
|
+
return String(res.value);
|
|
141
|
+
},
|
|
142
|
+
source,
|
|
143
|
+
path: filePath
|
|
144
|
+
});
|
|
145
|
+
}
|
|
142
146
|
const result = await schema.safeParseAsync(frontmatter);
|
|
143
147
|
if (result.error) {
|
|
144
148
|
callback(new Error(formatError(filePath, result.error)));
|
|
@@ -146,12 +150,6 @@ async function loader(source, callback) {
|
|
|
146
150
|
}
|
|
147
151
|
frontmatter = result.data;
|
|
148
152
|
}
|
|
149
|
-
const props = matter.data._mdx ?? {};
|
|
150
|
-
if (props.mirror) {
|
|
151
|
-
const mirrorPath = path2.resolve(path2.dirname(filePath), props.mirror);
|
|
152
|
-
this.addDependency(mirrorPath);
|
|
153
|
-
matter.content = await fs2.readFile(mirrorPath).then((res) => grayMatter(res.toString()).content);
|
|
154
|
-
}
|
|
155
153
|
let timestamp;
|
|
156
154
|
if (config.global?.lastModifiedTime === "git")
|
|
157
155
|
timestamp = (await getGitTimestamp(filePath))?.getTime();
|
|
@@ -167,7 +165,8 @@ async function loader(source, callback) {
|
|
|
167
165
|
frontmatter,
|
|
168
166
|
data: {
|
|
169
167
|
lastModified: timestamp
|
|
170
|
-
}
|
|
168
|
+
},
|
|
169
|
+
_compiler: this
|
|
171
170
|
}
|
|
172
171
|
);
|
|
173
172
|
callback(void 0, String(file.value), file.map ?? void 0);
|
package/dist/next/index.js
CHANGED
|
@@ -5,21 +5,22 @@ import {
|
|
|
5
5
|
loadConfig,
|
|
6
6
|
loadConfigCached,
|
|
7
7
|
writeManifest
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-EVNXCXU4.js";
|
|
9
|
+
import "../chunk-MKWJLEE7.js";
|
|
9
10
|
|
|
10
11
|
// src/next/create.ts
|
|
11
12
|
import path3 from "node:path";
|
|
12
13
|
|
|
13
14
|
// src/map/index.ts
|
|
14
|
-
import path2 from "node:path";
|
|
15
|
-
import fs from "node:fs";
|
|
15
|
+
import * as path2 from "node:path";
|
|
16
|
+
import * as fs from "node:fs";
|
|
16
17
|
import { readFile, writeFile } from "node:fs/promises";
|
|
17
18
|
import grayMatter from "gray-matter";
|
|
18
19
|
|
|
19
20
|
// src/map/generate.ts
|
|
20
21
|
import * as path from "node:path";
|
|
21
22
|
import fg from "fast-glob";
|
|
22
|
-
async function generateJS(configPath, config, outputPath,
|
|
23
|
+
async function generateJS(configPath, config, outputPath, configHash, getFrontmatter) {
|
|
23
24
|
const outDir2 = path.dirname(outputPath);
|
|
24
25
|
const imports = [
|
|
25
26
|
{
|
|
@@ -36,7 +37,7 @@ async function generateJS(configPath, config, outputPath, hash, getFrontmatter)
|
|
|
36
37
|
const items = files.map(async (file, i) => {
|
|
37
38
|
config._runtime.files.set(file.absolutePath, k);
|
|
38
39
|
if (collection.type === "doc" && collection.async) {
|
|
39
|
-
const importPath = `${toImportPath(file.absolutePath, outDir2)}?hash=${
|
|
40
|
+
const importPath = `${toImportPath(file.absolutePath, outDir2)}?hash=${configHash}&collection=${k}`;
|
|
40
41
|
const frontmatter = await getFrontmatter(file.absolutePath);
|
|
41
42
|
return `toRuntimeAsync(${JSON.stringify(frontmatter)}, () => import(${JSON.stringify(importPath)}), ${JSON.stringify(file)})`;
|
|
42
43
|
}
|
|
@@ -44,7 +45,7 @@ async function generateJS(configPath, config, outputPath, hash, getFrontmatter)
|
|
|
44
45
|
imports.push({
|
|
45
46
|
type: "namespace",
|
|
46
47
|
name: importName,
|
|
47
|
-
specifier: `${toImportPath(file.absolutePath, outDir2)}?collection=${k}&hash=${
|
|
48
|
+
specifier: `${toImportPath(file.absolutePath, outDir2)}?collection=${k}&hash=${configHash}`
|
|
48
49
|
});
|
|
49
50
|
return `toRuntime("${collection.type}", ${importName}, ${JSON.stringify(file)})`;
|
|
50
51
|
});
|
|
@@ -74,13 +75,13 @@ async function getCollectionFiles(collection) {
|
|
|
74
75
|
cwd: path.resolve(dir),
|
|
75
76
|
absolute: true
|
|
76
77
|
});
|
|
77
|
-
|
|
78
|
-
if (getTypeFromPath(item) !== collection.type)
|
|
78
|
+
for (const item of result) {
|
|
79
|
+
if (getTypeFromPath(item) !== collection.type) continue;
|
|
79
80
|
files.set(item, {
|
|
80
81
|
path: path.relative(dir, item),
|
|
81
82
|
absolutePath: item
|
|
82
83
|
});
|
|
83
|
-
}
|
|
84
|
+
}
|
|
84
85
|
})
|
|
85
86
|
);
|
|
86
87
|
return Array.from(files.values());
|
|
@@ -151,6 +152,7 @@ async function start(dev, configPath, outDir2) {
|
|
|
151
152
|
console.log("[MDX] started dev server");
|
|
152
153
|
});
|
|
153
154
|
instance.on("all", (event, file) => {
|
|
155
|
+
if (typeof file !== "string") return;
|
|
154
156
|
const onUpdate = async () => {
|
|
155
157
|
const isConfigFile = path2.resolve(file) === configPath;
|
|
156
158
|
if (isConfigFile) {
|
|
@@ -251,8 +253,8 @@ function createMDX({
|
|
|
251
253
|
}
|
|
252
254
|
|
|
253
255
|
// src/postinstall.ts
|
|
254
|
-
import path4 from "node:path";
|
|
255
|
-
import fs2 from "node:fs";
|
|
256
|
+
import * as path4 from "node:path";
|
|
257
|
+
import * as fs2 from "node:fs";
|
|
256
258
|
async function postInstall(configPath = findConfigFile()) {
|
|
257
259
|
const typeOut = path4.resolve(".source/index.d.ts");
|
|
258
260
|
const config = await loadConfig(configPath);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-mdx",
|
|
3
|
-
"version": "11.1
|
|
3
|
+
"version": "11.2.1",
|
|
4
4
|
"description": "The built-in source for Fumadocs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
@@ -36,28 +36,30 @@
|
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@mdx-js/mdx": "^3.1.0",
|
|
39
|
-
"chokidar": "^4.0.
|
|
40
|
-
"cross-spawn": "^7.0.
|
|
41
|
-
"esbuild": "^0.24.
|
|
39
|
+
"chokidar": "^4.0.3",
|
|
40
|
+
"cross-spawn": "^7.0.6",
|
|
41
|
+
"esbuild": "^0.24.2",
|
|
42
42
|
"estree-util-value-to-estree": "^3.2.1",
|
|
43
43
|
"fast-glob": "^3.3.1",
|
|
44
44
|
"gray-matter": "^4.0.3",
|
|
45
45
|
"micromatch": "^4.0.8",
|
|
46
|
-
"
|
|
46
|
+
"unist-util-visit": "^5.0.0",
|
|
47
|
+
"zod": "^3.24.1"
|
|
47
48
|
},
|
|
48
49
|
"devDependencies": {
|
|
49
50
|
"@types/cross-spawn": "^6.0.6",
|
|
50
51
|
"@types/mdast": "^4.0.3",
|
|
51
52
|
"@types/mdx": "^2.0.13",
|
|
52
53
|
"@types/micromatch": "^4.0.9",
|
|
53
|
-
"@types/react": "^
|
|
54
|
-
"
|
|
54
|
+
"@types/react": "^19.0.2",
|
|
55
|
+
"mdast-util-mdx-jsx": "^3.1.3",
|
|
56
|
+
"next": "^15.1.2",
|
|
55
57
|
"unified": "^11.0.5",
|
|
56
58
|
"vfile": "^6.0.3",
|
|
57
|
-
"webpack": "^5.
|
|
59
|
+
"webpack": "^5.97.1",
|
|
58
60
|
"eslint-config-custom": "0.0.0",
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
+
"fumadocs-core": "14.6.4",
|
|
62
|
+
"tsconfig": "0.0.0"
|
|
61
63
|
},
|
|
62
64
|
"peerDependencies": {
|
|
63
65
|
"fumadocs-core": "^14.0.0",
|