fumadocs-mdx 13.0.4 → 13.0.6
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 +164 -133
- package/dist/bin.js +1 -1
- package/dist/bun/index.cjs +156 -132
- package/dist/bun/index.d.cts +6 -1
- package/dist/bun/index.d.ts +6 -1
- package/dist/bun/index.js +8 -11
- package/dist/{chunk-TZ5EQBFW.js → chunk-2AQRQXSO.js} +7 -1
- package/dist/chunk-2E2JCOSO.js +135 -0
- package/dist/chunk-4757L6ST.js +77 -0
- package/dist/{chunk-ZNVPB2IR.js → chunk-ETIN2W7C.js} +49 -41
- package/dist/next/index.js +2 -4
- package/dist/node/loader.cjs +146 -119
- package/dist/node/loader.js +6 -10
- package/dist/vite/index.cjs +167 -135
- package/dist/vite/index.js +9 -15
- package/dist/webpack/mdx.cjs +86 -75
- package/dist/webpack/mdx.js +3 -3
- package/dist/webpack/meta.cjs +64 -37
- package/dist/webpack/meta.js +3 -3
- package/package.json +7 -7
- package/dist/chunk-4JSFLXXT.js +0 -8
- package/dist/chunk-XYGORKQA.js +0 -130
- package/dist/chunk-YAIPHUCZ.js +0 -56
package/dist/vite/index.cjs
CHANGED
|
@@ -710,6 +710,12 @@ var import_zod = require("zod");
|
|
|
710
710
|
var import_promises = __toESM(require("fs/promises"), 1);
|
|
711
711
|
var import_node_path2 = __toESM(require("path"), 1);
|
|
712
712
|
var import_node_crypto = require("crypto");
|
|
713
|
+
|
|
714
|
+
// src/loaders/index.ts
|
|
715
|
+
var metaLoaderGlob = /\.(json|yaml)(\?.+?)?$/;
|
|
716
|
+
var mdxLoaderGlob = /\.mdx?(\?.+?)?$/;
|
|
717
|
+
|
|
718
|
+
// src/loaders/mdx/index.ts
|
|
713
719
|
var querySchema = import_zod.z.object({
|
|
714
720
|
only: import_zod.z.literal(["frontmatter", "all"]).default("all"),
|
|
715
721
|
collection: import_zod.z.string().optional()
|
|
@@ -720,84 +726,88 @@ var cacheEntry = import_zod.z.object({
|
|
|
720
726
|
hash: import_zod.z.string().optional()
|
|
721
727
|
});
|
|
722
728
|
function createMdxLoader(configLoader) {
|
|
723
|
-
return
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
const
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
await import_promises.default.
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
729
|
+
return {
|
|
730
|
+
test: mdxLoaderGlob,
|
|
731
|
+
async load({
|
|
732
|
+
getSource,
|
|
733
|
+
development: isDevelopment,
|
|
734
|
+
query,
|
|
735
|
+
compiler,
|
|
736
|
+
filePath
|
|
737
|
+
}) {
|
|
738
|
+
const value = await getSource();
|
|
739
|
+
const matter = fumaMatter(value);
|
|
740
|
+
const parsed = querySchema.parse(query);
|
|
741
|
+
const config = await configLoader.getConfig();
|
|
742
|
+
let after;
|
|
743
|
+
if (!isDevelopment && config.global.experimentalBuildCache) {
|
|
744
|
+
const cacheDir = config.global.experimentalBuildCache;
|
|
745
|
+
const cacheKey = `${parsed.hash}_${parsed.collection ?? "global"}_${generateCacheHash(filePath)}`;
|
|
746
|
+
const cached = await import_promises.default.readFile(import_node_path2.default.join(cacheDir, cacheKey)).then((content) => cacheEntry.parse(JSON.parse(content.toString()))).catch(() => null);
|
|
747
|
+
if (cached && cached.hash === generateCacheHash(value)) return cached;
|
|
748
|
+
after = async () => {
|
|
749
|
+
await import_promises.default.mkdir(cacheDir, { recursive: true });
|
|
750
|
+
await import_promises.default.writeFile(
|
|
751
|
+
import_node_path2.default.join(cacheDir, cacheKey),
|
|
752
|
+
JSON.stringify({
|
|
753
|
+
...out,
|
|
754
|
+
hash: generateCacheHash(value)
|
|
755
|
+
})
|
|
756
|
+
);
|
|
757
|
+
};
|
|
758
|
+
}
|
|
759
|
+
const collection = parsed.collection ? config.getCollection(parsed.collection) : void 0;
|
|
760
|
+
let docCollection;
|
|
761
|
+
switch (collection?.type) {
|
|
762
|
+
case "doc":
|
|
763
|
+
docCollection = collection;
|
|
764
|
+
break;
|
|
765
|
+
case "docs":
|
|
766
|
+
docCollection = collection.docs;
|
|
767
|
+
break;
|
|
768
|
+
}
|
|
769
|
+
if (docCollection?.schema) {
|
|
770
|
+
matter.data = await validate(
|
|
771
|
+
docCollection.schema,
|
|
772
|
+
matter.data,
|
|
773
|
+
{
|
|
774
|
+
source: value,
|
|
775
|
+
path: filePath
|
|
776
|
+
},
|
|
777
|
+
`invalid frontmatter in ${filePath}`
|
|
747
778
|
);
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
matter.data,
|
|
779
|
+
}
|
|
780
|
+
if (parsed.only === "frontmatter") {
|
|
781
|
+
return {
|
|
782
|
+
code: `export const frontmatter = ${JSON.stringify(matter.data)}`,
|
|
783
|
+
map: null
|
|
784
|
+
};
|
|
785
|
+
}
|
|
786
|
+
const data = {};
|
|
787
|
+
if (config.global.lastModifiedTime === "git") {
|
|
788
|
+
data.lastModified = (await getGitTimestamp(filePath))?.getTime();
|
|
789
|
+
}
|
|
790
|
+
const lineOffset = isDevelopment ? countLines(matter.matter) : 0;
|
|
791
|
+
const compiled = await buildMDX(
|
|
792
|
+
`${getConfigHash(config)}:${parsed.collection ?? "global"}`,
|
|
793
|
+
"\n".repeat(lineOffset) + matter.content,
|
|
764
794
|
{
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
795
|
+
development: isDevelopment,
|
|
796
|
+
...docCollection?.mdxOptions ?? await config.getDefaultMDXOptions(),
|
|
797
|
+
postprocess: docCollection?.postprocess,
|
|
798
|
+
data,
|
|
799
|
+
filePath,
|
|
800
|
+
frontmatter: matter.data,
|
|
801
|
+
_compiler: compiler
|
|
802
|
+
}
|
|
769
803
|
);
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
code: `export const frontmatter = ${JSON.stringify(matter.data)}`,
|
|
774
|
-
map: null
|
|
804
|
+
const out = {
|
|
805
|
+
code: String(compiled.value),
|
|
806
|
+
map: compiled.map
|
|
775
807
|
};
|
|
808
|
+
await after?.();
|
|
809
|
+
return out;
|
|
776
810
|
}
|
|
777
|
-
const data = {};
|
|
778
|
-
if (config.global.lastModifiedTime === "git") {
|
|
779
|
-
data.lastModified = (await getGitTimestamp(filePath))?.getTime();
|
|
780
|
-
}
|
|
781
|
-
const lineOffset = isDevelopment ? countLines(matter.matter) : 0;
|
|
782
|
-
const compiled = await buildMDX(
|
|
783
|
-
`${getConfigHash(config)}:${parsed.collection ?? "global"}`,
|
|
784
|
-
"\n".repeat(lineOffset) + matter.content,
|
|
785
|
-
{
|
|
786
|
-
development: isDevelopment,
|
|
787
|
-
...docCollection?.mdxOptions ?? await config.getDefaultMDXOptions(),
|
|
788
|
-
postprocess: docCollection?.postprocess,
|
|
789
|
-
data,
|
|
790
|
-
filePath,
|
|
791
|
-
frontmatter: matter.data,
|
|
792
|
-
_compiler: compiler
|
|
793
|
-
}
|
|
794
|
-
);
|
|
795
|
-
const out = {
|
|
796
|
-
code: String(compiled.value),
|
|
797
|
-
map: compiled.map
|
|
798
|
-
};
|
|
799
|
-
await after?.();
|
|
800
|
-
return out;
|
|
801
811
|
};
|
|
802
812
|
}
|
|
803
813
|
var hashes = /* @__PURE__ */ new WeakMap();
|
|
@@ -825,23 +835,31 @@ var import_promises2 = __toESM(require("fs/promises"), 1);
|
|
|
825
835
|
var import_node_querystring = require("querystring");
|
|
826
836
|
var import_node_path3 = __toESM(require("path"), 1);
|
|
827
837
|
function toVite(loader) {
|
|
828
|
-
return
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
838
|
+
return {
|
|
839
|
+
filter(id) {
|
|
840
|
+
return !loader.test || loader.test.test(id);
|
|
841
|
+
},
|
|
842
|
+
async transform(value, id) {
|
|
843
|
+
const [file, query = ""] = id.split("?", 2);
|
|
844
|
+
const result = await loader.load({
|
|
845
|
+
filePath: file,
|
|
846
|
+
query: (0, import_node_querystring.parse)(query),
|
|
847
|
+
getSource() {
|
|
848
|
+
return value;
|
|
849
|
+
},
|
|
850
|
+
development: this.environment.mode === "dev",
|
|
851
|
+
compiler: {
|
|
852
|
+
addDependency: (file2) => {
|
|
853
|
+
this.addWatchFile(file2);
|
|
854
|
+
}
|
|
837
855
|
}
|
|
838
|
-
}
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
}
|
|
856
|
+
});
|
|
857
|
+
if (result === null) return null;
|
|
858
|
+
return {
|
|
859
|
+
code: result.code,
|
|
860
|
+
map: result.map
|
|
861
|
+
};
|
|
862
|
+
}
|
|
845
863
|
};
|
|
846
864
|
}
|
|
847
865
|
|
|
@@ -1149,51 +1167,67 @@ var querySchema2 = import_zod2.z.object({
|
|
|
1149
1167
|
}).loose();
|
|
1150
1168
|
function createMetaLoader(configLoader, resolve3 = {}) {
|
|
1151
1169
|
const { json: resolveJson = "js", yaml: resolveYaml = "js" } = resolve3;
|
|
1152
|
-
|
|
1153
|
-
const isJson = filePath.endsWith(".json");
|
|
1154
|
-
const parsed = querySchema2.parse(query);
|
|
1155
|
-
const collection = parsed.collection ? (await configLoader.getConfig()).getCollection(parsed.collection) : void 0;
|
|
1156
|
-
if (!collection) return null;
|
|
1157
|
-
let data;
|
|
1158
|
-
try {
|
|
1159
|
-
data = isJson ? JSON.parse(source) : (0, import_js_yaml2.load)(source);
|
|
1160
|
-
} catch (e) {
|
|
1161
|
-
throw new Error(`invalid data in ${filePath}`, { cause: e });
|
|
1162
|
-
}
|
|
1163
|
-
let schema;
|
|
1164
|
-
switch (collection?.type) {
|
|
1165
|
-
case "meta":
|
|
1166
|
-
schema = collection.schema;
|
|
1167
|
-
break;
|
|
1168
|
-
case "docs":
|
|
1169
|
-
schema = collection.meta.schema;
|
|
1170
|
-
break;
|
|
1171
|
-
}
|
|
1172
|
-
if (schema) {
|
|
1173
|
-
data = await validate(
|
|
1174
|
-
schema,
|
|
1175
|
-
data,
|
|
1176
|
-
{ path: filePath, source },
|
|
1177
|
-
`invalid data in ${filePath}`
|
|
1178
|
-
);
|
|
1179
|
-
}
|
|
1180
|
-
let code;
|
|
1170
|
+
function stringifyOutput(isJson, data) {
|
|
1181
1171
|
if (isJson) {
|
|
1182
|
-
|
|
1172
|
+
return resolveJson === "json" ? JSON.stringify(data) : `export default ${JSON.stringify(data)}`;
|
|
1183
1173
|
} else {
|
|
1184
|
-
|
|
1174
|
+
return resolveYaml === "yaml" ? (0, import_js_yaml2.dump)(data) : `export default ${JSON.stringify(data)}`;
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
return {
|
|
1178
|
+
test: metaLoaderGlob,
|
|
1179
|
+
async load({ filePath, query, getSource }) {
|
|
1180
|
+
const parsed = querySchema2.parse(query);
|
|
1181
|
+
const collection = parsed.collection ? (await configLoader.getConfig()).getCollection(parsed.collection) : void 0;
|
|
1182
|
+
if (!collection) return null;
|
|
1183
|
+
const isJson = filePath.endsWith(".json");
|
|
1184
|
+
const source = await getSource();
|
|
1185
|
+
let data;
|
|
1186
|
+
try {
|
|
1187
|
+
data = isJson ? JSON.parse(source) : (0, import_js_yaml2.load)(source);
|
|
1188
|
+
} catch (e) {
|
|
1189
|
+
throw new Error(`invalid data in ${filePath}`, { cause: e });
|
|
1190
|
+
}
|
|
1191
|
+
let schema;
|
|
1192
|
+
switch (collection?.type) {
|
|
1193
|
+
case "meta":
|
|
1194
|
+
schema = collection.schema;
|
|
1195
|
+
break;
|
|
1196
|
+
case "docs":
|
|
1197
|
+
schema = collection.meta.schema;
|
|
1198
|
+
break;
|
|
1199
|
+
}
|
|
1200
|
+
if (schema) {
|
|
1201
|
+
data = await validate(
|
|
1202
|
+
schema,
|
|
1203
|
+
data,
|
|
1204
|
+
{ path: filePath, source },
|
|
1205
|
+
`invalid data in ${filePath}`
|
|
1206
|
+
);
|
|
1207
|
+
}
|
|
1208
|
+
return {
|
|
1209
|
+
code: stringifyOutput(isJson, data)
|
|
1210
|
+
};
|
|
1211
|
+
},
|
|
1212
|
+
bun: {
|
|
1213
|
+
async fallback({ getSource, filePath }) {
|
|
1214
|
+
const source = await getSource();
|
|
1215
|
+
const isJson = filePath.endsWith(".json");
|
|
1216
|
+
let data;
|
|
1217
|
+
try {
|
|
1218
|
+
data = isJson ? JSON.parse(source) : (0, import_js_yaml2.load)(source);
|
|
1219
|
+
} catch (e) {
|
|
1220
|
+
throw new Error(`invalid data in ${filePath}`, { cause: e });
|
|
1221
|
+
}
|
|
1222
|
+
return {
|
|
1223
|
+
loader: "object",
|
|
1224
|
+
exports: data
|
|
1225
|
+
};
|
|
1226
|
+
}
|
|
1185
1227
|
}
|
|
1186
|
-
return {
|
|
1187
|
-
code,
|
|
1188
|
-
map: null
|
|
1189
|
-
};
|
|
1190
1228
|
};
|
|
1191
1229
|
}
|
|
1192
1230
|
|
|
1193
|
-
// src/loaders/index.ts
|
|
1194
|
-
var metaLoaderGlob = /\.(json|yaml)(\?.+?)?$/;
|
|
1195
|
-
var mdxLoaderGlob = /\.mdx?(\?.+?)?$/;
|
|
1196
|
-
|
|
1197
1231
|
// src/vite/index.ts
|
|
1198
1232
|
var FumadocsDeps = ["fumadocs-core", "fumadocs-ui", "fumadocs-openapi"];
|
|
1199
1233
|
async function mdx(config, pluginOptions = {}) {
|
|
@@ -1206,7 +1240,7 @@ async function mdx(config, pluginOptions = {}) {
|
|
|
1206
1240
|
const metaLoader = toVite(
|
|
1207
1241
|
createMetaLoader(configLoader, {
|
|
1208
1242
|
// vite has built-in plugin for JSON files
|
|
1209
|
-
json: "
|
|
1243
|
+
json: "js"
|
|
1210
1244
|
})
|
|
1211
1245
|
);
|
|
1212
1246
|
return {
|
|
@@ -1235,13 +1269,11 @@ async function mdx(config, pluginOptions = {}) {
|
|
|
1235
1269
|
},
|
|
1236
1270
|
async transform(value, id) {
|
|
1237
1271
|
try {
|
|
1238
|
-
if (
|
|
1239
|
-
|
|
1240
|
-
return await metaLoader.call(this, file, query, value);
|
|
1272
|
+
if (metaLoader.filter(id)) {
|
|
1273
|
+
return await metaLoader.transform.call(this, value, id);
|
|
1241
1274
|
}
|
|
1242
|
-
if (
|
|
1243
|
-
|
|
1244
|
-
return await mdxLoader.call(this, file, query, value);
|
|
1275
|
+
if (mdxLoader.filter(id)) {
|
|
1276
|
+
return await mdxLoader.transform.call(this, value, id);
|
|
1245
1277
|
}
|
|
1246
1278
|
} catch (e) {
|
|
1247
1279
|
if (e instanceof ValidationError) {
|
package/dist/vite/index.js
CHANGED
|
@@ -7,26 +7,22 @@ import {
|
|
|
7
7
|
} from "../chunk-2HXTGJBI.js";
|
|
8
8
|
import {
|
|
9
9
|
createMdxLoader
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-2E2JCOSO.js";
|
|
11
11
|
import {
|
|
12
12
|
createMetaLoader
|
|
13
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-4757L6ST.js";
|
|
14
14
|
import {
|
|
15
15
|
createIntegratedConfigLoader,
|
|
16
16
|
toVite
|
|
17
|
-
} from "../chunk-
|
|
17
|
+
} from "../chunk-ETIN2W7C.js";
|
|
18
18
|
import "../chunk-3J3WL7WN.js";
|
|
19
19
|
import "../chunk-K5ZLPEIQ.js";
|
|
20
|
-
import {
|
|
21
|
-
mdxLoaderGlob,
|
|
22
|
-
metaLoaderGlob
|
|
23
|
-
} from "../chunk-4JSFLXXT.js";
|
|
24
20
|
import "../chunk-VUEZTR2H.js";
|
|
25
21
|
import {
|
|
26
22
|
ValidationError,
|
|
27
23
|
createCore,
|
|
28
24
|
findConfigFile
|
|
29
|
-
} from "../chunk-
|
|
25
|
+
} from "../chunk-2AQRQXSO.js";
|
|
30
26
|
import "../chunk-VWJKRQZR.js";
|
|
31
27
|
|
|
32
28
|
// src/vite/index.ts
|
|
@@ -234,7 +230,7 @@ async function mdx(config, pluginOptions = {}) {
|
|
|
234
230
|
const metaLoader = toVite(
|
|
235
231
|
createMetaLoader(configLoader, {
|
|
236
232
|
// vite has built-in plugin for JSON files
|
|
237
|
-
json: "
|
|
233
|
+
json: "js"
|
|
238
234
|
})
|
|
239
235
|
);
|
|
240
236
|
return {
|
|
@@ -263,13 +259,11 @@ async function mdx(config, pluginOptions = {}) {
|
|
|
263
259
|
},
|
|
264
260
|
async transform(value, id) {
|
|
265
261
|
try {
|
|
266
|
-
if (
|
|
267
|
-
|
|
268
|
-
return await metaLoader.call(this, file, query, value);
|
|
262
|
+
if (metaLoader.filter(id)) {
|
|
263
|
+
return await metaLoader.transform.call(this, value, id);
|
|
269
264
|
}
|
|
270
|
-
if (
|
|
271
|
-
|
|
272
|
-
return await mdxLoader.call(this, file, query, value);
|
|
265
|
+
if (mdxLoader.filter(id)) {
|
|
266
|
+
return await mdxLoader.transform.call(this, value, id);
|
|
273
267
|
}
|
|
274
268
|
} catch (e) {
|
|
275
269
|
if (e instanceof ValidationError) {
|
package/dist/webpack/mdx.cjs
CHANGED
|
@@ -707,6 +707,11 @@ var import_zod = require("zod");
|
|
|
707
707
|
var import_promises = __toESM(require("fs/promises"), 1);
|
|
708
708
|
var import_node_path2 = __toESM(require("path"), 1);
|
|
709
709
|
var import_node_crypto = require("crypto");
|
|
710
|
+
|
|
711
|
+
// src/loaders/index.ts
|
|
712
|
+
var mdxLoaderGlob = /\.mdx?(\?.+?)?$/;
|
|
713
|
+
|
|
714
|
+
// src/loaders/mdx/index.ts
|
|
710
715
|
var querySchema = import_zod.z.object({
|
|
711
716
|
only: import_zod.z.literal(["frontmatter", "all"]).default("all"),
|
|
712
717
|
collection: import_zod.z.string().optional()
|
|
@@ -717,84 +722,88 @@ var cacheEntry = import_zod.z.object({
|
|
|
717
722
|
hash: import_zod.z.string().optional()
|
|
718
723
|
});
|
|
719
724
|
function createMdxLoader(configLoader) {
|
|
720
|
-
return
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
const
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
await import_promises.default.
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
725
|
+
return {
|
|
726
|
+
test: mdxLoaderGlob,
|
|
727
|
+
async load({
|
|
728
|
+
getSource,
|
|
729
|
+
development: isDevelopment,
|
|
730
|
+
query,
|
|
731
|
+
compiler,
|
|
732
|
+
filePath
|
|
733
|
+
}) {
|
|
734
|
+
const value = await getSource();
|
|
735
|
+
const matter = fumaMatter(value);
|
|
736
|
+
const parsed = querySchema.parse(query);
|
|
737
|
+
const config = await configLoader.getConfig();
|
|
738
|
+
let after;
|
|
739
|
+
if (!isDevelopment && config.global.experimentalBuildCache) {
|
|
740
|
+
const cacheDir = config.global.experimentalBuildCache;
|
|
741
|
+
const cacheKey = `${parsed.hash}_${parsed.collection ?? "global"}_${generateCacheHash(filePath)}`;
|
|
742
|
+
const cached = await import_promises.default.readFile(import_node_path2.default.join(cacheDir, cacheKey)).then((content) => cacheEntry.parse(JSON.parse(content.toString()))).catch(() => null);
|
|
743
|
+
if (cached && cached.hash === generateCacheHash(value)) return cached;
|
|
744
|
+
after = async () => {
|
|
745
|
+
await import_promises.default.mkdir(cacheDir, { recursive: true });
|
|
746
|
+
await import_promises.default.writeFile(
|
|
747
|
+
import_node_path2.default.join(cacheDir, cacheKey),
|
|
748
|
+
JSON.stringify({
|
|
749
|
+
...out,
|
|
750
|
+
hash: generateCacheHash(value)
|
|
751
|
+
})
|
|
752
|
+
);
|
|
753
|
+
};
|
|
754
|
+
}
|
|
755
|
+
const collection = parsed.collection ? config.getCollection(parsed.collection) : void 0;
|
|
756
|
+
let docCollection;
|
|
757
|
+
switch (collection?.type) {
|
|
758
|
+
case "doc":
|
|
759
|
+
docCollection = collection;
|
|
760
|
+
break;
|
|
761
|
+
case "docs":
|
|
762
|
+
docCollection = collection.docs;
|
|
763
|
+
break;
|
|
764
|
+
}
|
|
765
|
+
if (docCollection?.schema) {
|
|
766
|
+
matter.data = await validate(
|
|
767
|
+
docCollection.schema,
|
|
768
|
+
matter.data,
|
|
769
|
+
{
|
|
770
|
+
source: value,
|
|
771
|
+
path: filePath
|
|
772
|
+
},
|
|
773
|
+
`invalid frontmatter in ${filePath}`
|
|
744
774
|
);
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
matter.data,
|
|
775
|
+
}
|
|
776
|
+
if (parsed.only === "frontmatter") {
|
|
777
|
+
return {
|
|
778
|
+
code: `export const frontmatter = ${JSON.stringify(matter.data)}`,
|
|
779
|
+
map: null
|
|
780
|
+
};
|
|
781
|
+
}
|
|
782
|
+
const data = {};
|
|
783
|
+
if (config.global.lastModifiedTime === "git") {
|
|
784
|
+
data.lastModified = (await getGitTimestamp(filePath))?.getTime();
|
|
785
|
+
}
|
|
786
|
+
const lineOffset = isDevelopment ? countLines(matter.matter) : 0;
|
|
787
|
+
const compiled = await buildMDX(
|
|
788
|
+
`${getConfigHash(config)}:${parsed.collection ?? "global"}`,
|
|
789
|
+
"\n".repeat(lineOffset) + matter.content,
|
|
761
790
|
{
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
791
|
+
development: isDevelopment,
|
|
792
|
+
...docCollection?.mdxOptions ?? await config.getDefaultMDXOptions(),
|
|
793
|
+
postprocess: docCollection?.postprocess,
|
|
794
|
+
data,
|
|
795
|
+
filePath,
|
|
796
|
+
frontmatter: matter.data,
|
|
797
|
+
_compiler: compiler
|
|
798
|
+
}
|
|
766
799
|
);
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
code: `export const frontmatter = ${JSON.stringify(matter.data)}`,
|
|
771
|
-
map: null
|
|
800
|
+
const out = {
|
|
801
|
+
code: String(compiled.value),
|
|
802
|
+
map: compiled.map
|
|
772
803
|
};
|
|
804
|
+
await after?.();
|
|
805
|
+
return out;
|
|
773
806
|
}
|
|
774
|
-
const data = {};
|
|
775
|
-
if (config.global.lastModifiedTime === "git") {
|
|
776
|
-
data.lastModified = (await getGitTimestamp(filePath))?.getTime();
|
|
777
|
-
}
|
|
778
|
-
const lineOffset = isDevelopment ? countLines(matter.matter) : 0;
|
|
779
|
-
const compiled = await buildMDX(
|
|
780
|
-
`${getConfigHash(config)}:${parsed.collection ?? "global"}`,
|
|
781
|
-
"\n".repeat(lineOffset) + matter.content,
|
|
782
|
-
{
|
|
783
|
-
development: isDevelopment,
|
|
784
|
-
...docCollection?.mdxOptions ?? await config.getDefaultMDXOptions(),
|
|
785
|
-
postprocess: docCollection?.postprocess,
|
|
786
|
-
data,
|
|
787
|
-
filePath,
|
|
788
|
-
frontmatter: matter.data,
|
|
789
|
-
_compiler: compiler
|
|
790
|
-
}
|
|
791
|
-
);
|
|
792
|
-
const out = {
|
|
793
|
-
code: String(compiled.value),
|
|
794
|
-
map: compiled.map
|
|
795
|
-
};
|
|
796
|
-
await after?.();
|
|
797
|
-
return out;
|
|
798
807
|
};
|
|
799
808
|
}
|
|
800
809
|
var hashes = /* @__PURE__ */ new WeakMap();
|
|
@@ -824,10 +833,12 @@ var import_node_path3 = __toESM(require("path"), 1);
|
|
|
824
833
|
function toWebpack(loader2) {
|
|
825
834
|
return async function(source, callback) {
|
|
826
835
|
try {
|
|
827
|
-
const result = await loader2({
|
|
836
|
+
const result = await loader2.load({
|
|
828
837
|
filePath: this.resourcePath,
|
|
829
838
|
query: (0, import_node_querystring.parse)(this.resourceQuery.slice(1)),
|
|
830
|
-
|
|
839
|
+
getSource() {
|
|
840
|
+
return source;
|
|
841
|
+
},
|
|
831
842
|
development: this.mode === "development",
|
|
832
843
|
compiler: this
|
|
833
844
|
});
|
package/dist/webpack/mdx.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createMdxLoader
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-2E2JCOSO.js";
|
|
4
4
|
import {
|
|
5
5
|
createStandaloneConfigLoader,
|
|
6
6
|
toWebpack
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-ETIN2W7C.js";
|
|
8
8
|
import "../chunk-3J3WL7WN.js";
|
|
9
9
|
import "../chunk-K5ZLPEIQ.js";
|
|
10
10
|
import "../chunk-VUEZTR2H.js";
|
|
11
11
|
import {
|
|
12
12
|
createCore
|
|
13
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-2AQRQXSO.js";
|
|
14
14
|
import "../chunk-VWJKRQZR.js";
|
|
15
15
|
|
|
16
16
|
// src/webpack/mdx.ts
|