fumadocs-mdx 11.5.3 → 11.5.5

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.
@@ -15,7 +15,7 @@ var _runtime = {
15
15
  meta(files) {
16
16
  return files.map((file) => {
17
17
  return {
18
- ...file.data.default,
18
+ ...file.data,
19
19
  _file: file.info
20
20
  };
21
21
  });
@@ -0,0 +1,43 @@
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
+ async function validate(schema, data, context, errorMessage) {
20
+ if (typeof schema === "function" && !("~standard" in schema)) {
21
+ schema = schema(context);
22
+ }
23
+ if ("~standard" in schema) {
24
+ const result = await schema["~standard"].validate(
25
+ data
26
+ );
27
+ if (result.issues) {
28
+ throw new Error(formatError(errorMessage, result.issues));
29
+ }
30
+ return result.value;
31
+ }
32
+ return data;
33
+ }
34
+ function formatError(message, issues) {
35
+ return `${message}:
36
+ ${issues.map((issue) => ` ${issue.path}: ${issue.message}`).join("\n")}`;
37
+ }
38
+
39
+ export {
40
+ metaSchema,
41
+ frontmatterSchema,
42
+ validate
43
+ };
@@ -1,22 +1,21 @@
1
1
  import {
2
2
  buildConfig
3
- } from "./chunk-6ZVE73IT.js";
3
+ } from "./chunk-SLCPEEMF.js";
4
4
 
5
5
  // src/utils/config.ts
6
- import { createHash } from "node:crypto";
7
- import * as fs from "node:fs";
6
+ import * as fs from "node:fs/promises";
8
7
  import * as path from "node:path";
9
8
  import { pathToFileURL } from "node:url";
10
9
  function findConfigFile() {
11
10
  return path.resolve("source.config.ts");
12
11
  }
13
- var cache = /* @__PURE__ */ new Map();
14
- async function compileConfig(configPath) {
12
+ var cache = null;
13
+ async function compileConfig(configPath, outDir) {
15
14
  const { build } = await import("esbuild");
16
15
  const transformed = await build({
17
16
  entryPoints: [{ in: configPath, out: "source.config" }],
18
17
  bundle: true,
19
- outdir: ".source",
18
+ outdir: outDir,
20
19
  target: "node18",
21
20
  write: true,
22
21
  platform: "node",
@@ -32,13 +31,12 @@ async function compileConfig(configPath) {
32
31
  }
33
32
  }
34
33
  async function loadConfig(configPath, hash, build = false) {
35
- const cached = cache.get(configPath);
36
- if (cached && cached.hash === hash) {
37
- return await cached.config;
34
+ if (cache && cache.hash === hash) {
35
+ return await cache.config;
38
36
  }
39
- if (build) await compileConfig(configPath);
37
+ if (build) await compileConfig(configPath, ".source");
40
38
  const url = pathToFileURL(path.resolve(".source/source.config.mjs"));
41
- const config = import(`${url.href}?hash=${configPath}`).then((loaded) => {
39
+ const config = import(`${url.href}?hash=${hash}`).then((loaded) => {
42
40
  const [err, config2] = buildConfig(
43
41
  // every call to `loadConfig` will cause the previous cache to be ignored
44
42
  loaded
@@ -46,16 +44,15 @@ async function loadConfig(configPath, hash, build = false) {
46
44
  if (err !== null) throw new Error(err);
47
45
  return config2;
48
46
  });
49
- cache.set(configPath, { config, hash });
47
+ cache = { config, hash };
50
48
  return await config;
51
49
  }
52
50
  async function getConfigHash(configPath) {
53
- const hash = createHash("md5");
54
- const rs = fs.createReadStream(configPath);
55
- for await (const chunk of rs) {
56
- hash.update(chunk);
51
+ const stats = await fs.stat(configPath).catch(() => void 0);
52
+ if (stats) {
53
+ return stats.mtime.getTime().toString();
57
54
  }
58
- return hash.digest("hex");
55
+ throw new Error("Cannot find config file");
59
56
  }
60
57
 
61
58
  export {
@@ -25,23 +25,11 @@ function buildConfig(config) {
25
25
  null
26
26
  ];
27
27
  }
28
- let cachedMdxOptions;
29
28
  return [
30
29
  null,
31
30
  {
32
31
  global: globalConfig,
33
32
  collections,
34
- async getDefaultMDXOptions() {
35
- if (cachedMdxOptions) return cachedMdxOptions;
36
- const { getDefaultMDXOptions } = await import("./mdx-options-CAU273O3.js");
37
- const mdxOptions = globalConfig?.mdxOptions ?? {};
38
- if (typeof mdxOptions === "function") {
39
- cachedMdxOptions = getDefaultMDXOptions(await mdxOptions());
40
- } else {
41
- cachedMdxOptions = getDefaultMDXOptions(mdxOptions);
42
- }
43
- return cachedMdxOptions;
44
- },
45
33
  _runtime: {
46
34
  files: /* @__PURE__ */ new Map()
47
35
  }
@@ -1,4 +1,4 @@
1
- export { a as BaseCollection, B as BaseCollectionEntry, h as DefaultMDXOptions, D as DocCollection, c as DocsCollection, F as FileInfo, G as GlobalConfig, M as MarkdownProps, b as MetaCollection, T as TransformContext, d as defineCollections, g as defineConfig, e as defineDocs, f as frontmatterSchema, i as getDefaultMDXOptions, m as metaSchema } from '../define-BUjajTka.cjs';
1
+ export { a as BaseCollection, B as BaseCollectionEntry, C as CollectionSchema, h as DefaultMDXOptions, D as DocCollection, c as DocsCollection, F as FileInfo, G as GlobalConfig, M as MarkdownProps, b as MetaCollection, d as defineCollections, g as defineConfig, e as defineDocs, f as frontmatterSchema, i as getDefaultMDXOptions, m as metaSchema } from '../define-DxwgTgV6.cjs';
2
2
  import { Processor, Transformer } from 'unified';
3
3
  import { Root } from 'mdast';
4
4
  import '@mdx-js/mdx';
@@ -1,4 +1,4 @@
1
- export { a as BaseCollection, B as BaseCollectionEntry, h as DefaultMDXOptions, D as DocCollection, c as DocsCollection, F as FileInfo, G as GlobalConfig, M as MarkdownProps, b as MetaCollection, T as TransformContext, d as defineCollections, g as defineConfig, e as defineDocs, f as frontmatterSchema, i as getDefaultMDXOptions, m as metaSchema } from '../define-BUjajTka.js';
1
+ export { a as BaseCollection, B as BaseCollectionEntry, C as CollectionSchema, h as DefaultMDXOptions, D as DocCollection, c as DocsCollection, F as FileInfo, G as GlobalConfig, M as MarkdownProps, b as MetaCollection, d as defineCollections, g as defineConfig, e as defineDocs, f as frontmatterSchema, i as getDefaultMDXOptions, m as metaSchema } from '../define-DxwgTgV6.js';
2
2
  import { Processor, Transformer } from 'unified';
3
3
  import { Root } from 'mdast';
4
4
  import '@mdx-js/mdx';
@@ -1,3 +1,7 @@
1
+ import {
2
+ frontmatterSchema,
3
+ metaSchema
4
+ } from "../chunk-KGLACICA.js";
1
5
  import {
2
6
  remarkInclude
3
7
  } from "../chunk-PY2KKTR2.js";
@@ -5,25 +9,6 @@ import {
5
9
  getDefaultMDXOptions
6
10
  } from "../chunk-IOENRFUX.js";
7
11
 
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
12
  // src/config/define.ts
28
13
  function defineCollections(options) {
29
14
  return {
@@ -130,15 +130,8 @@ declare const frontmatterSchema: z.ZodObject<{
130
130
  _openapi?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
131
131
  }>;
132
132
 
133
- interface TransformContext {
134
- path: string;
135
- source: string;
136
- /**
137
- * Compile MDX to JavaScript
138
- */
139
- buildMDX: (source: string, options?: ProcessorOptions) => Promise<string>;
140
- }
141
- interface BaseCollection<Schema> {
133
+ type CollectionSchema<Schema extends StandardSchemaV1, Context> = Schema | ((ctx: Context) => Schema);
134
+ interface BaseCollection {
142
135
  /**
143
136
  * Directories to scan
144
137
  */
@@ -149,18 +142,25 @@ interface BaseCollection<Schema> {
149
142
  * Include all files if not specified
150
143
  */
151
144
  files?: string[];
152
- schema?: Schema | ((ctx: TransformContext) => Schema);
153
145
  }
154
- interface MetaCollection<Schema extends StandardSchemaV1 = StandardSchemaV1> extends BaseCollection<Schema> {
146
+ interface MetaCollection<Schema extends StandardSchemaV1 = StandardSchemaV1> extends BaseCollection {
155
147
  type: 'meta';
148
+ schema?: CollectionSchema<Schema, {
149
+ path: string;
150
+ source: string;
151
+ }>;
156
152
  }
157
- interface DocCollection<Schema extends StandardSchemaV1 = StandardSchemaV1, Async extends boolean = boolean> extends BaseCollection<Schema> {
153
+ interface DocCollection<Schema extends StandardSchemaV1 = StandardSchemaV1, Async extends boolean = boolean> extends BaseCollection {
158
154
  type: 'doc';
159
155
  mdxOptions?: MDXOptions;
160
156
  /**
161
157
  * Load files with async
162
158
  */
163
159
  async?: Async;
160
+ schema?: CollectionSchema<Schema, {
161
+ path: string;
162
+ source: string;
163
+ }>;
164
164
  }
165
165
  interface DocsCollection<DocSchema extends StandardSchemaV1 = StandardSchemaV1, MetaSchema extends StandardSchemaV1 = StandardSchemaV1, Async extends boolean = boolean> {
166
166
  type: 'docs';
@@ -205,4 +205,4 @@ declare function defineDocs<DocSchema extends StandardSchemaV1 = typeof frontmat
205
205
  };
206
206
  declare function defineConfig(config?: GlobalConfig): GlobalConfig;
207
207
 
208
- export { type BaseCollectionEntry as B, type DocCollection as D, type FileInfo as F, type GlobalConfig as G, type MarkdownProps as M, type TransformContext as T, type BaseCollection as a, type MetaCollection as b, type DocsCollection as c, defineCollections as d, defineDocs as e, frontmatterSchema as f, defineConfig as g, type DefaultMDXOptions as h, getDefaultMDXOptions as i, metaSchema as m };
208
+ export { type BaseCollectionEntry as B, type CollectionSchema as C, type DocCollection as D, type FileInfo as F, type GlobalConfig as G, type MarkdownProps as M, type BaseCollection as a, type MetaCollection as b, type DocsCollection as c, defineCollections as d, defineDocs as e, frontmatterSchema as f, defineConfig as g, type DefaultMDXOptions as h, getDefaultMDXOptions as i, metaSchema as m };
@@ -130,15 +130,8 @@ declare const frontmatterSchema: z.ZodObject<{
130
130
  _openapi?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
131
131
  }>;
132
132
 
133
- interface TransformContext {
134
- path: string;
135
- source: string;
136
- /**
137
- * Compile MDX to JavaScript
138
- */
139
- buildMDX: (source: string, options?: ProcessorOptions) => Promise<string>;
140
- }
141
- interface BaseCollection<Schema> {
133
+ type CollectionSchema<Schema extends StandardSchemaV1, Context> = Schema | ((ctx: Context) => Schema);
134
+ interface BaseCollection {
142
135
  /**
143
136
  * Directories to scan
144
137
  */
@@ -149,18 +142,25 @@ interface BaseCollection<Schema> {
149
142
  * Include all files if not specified
150
143
  */
151
144
  files?: string[];
152
- schema?: Schema | ((ctx: TransformContext) => Schema);
153
145
  }
154
- interface MetaCollection<Schema extends StandardSchemaV1 = StandardSchemaV1> extends BaseCollection<Schema> {
146
+ interface MetaCollection<Schema extends StandardSchemaV1 = StandardSchemaV1> extends BaseCollection {
155
147
  type: 'meta';
148
+ schema?: CollectionSchema<Schema, {
149
+ path: string;
150
+ source: string;
151
+ }>;
156
152
  }
157
- interface DocCollection<Schema extends StandardSchemaV1 = StandardSchemaV1, Async extends boolean = boolean> extends BaseCollection<Schema> {
153
+ interface DocCollection<Schema extends StandardSchemaV1 = StandardSchemaV1, Async extends boolean = boolean> extends BaseCollection {
158
154
  type: 'doc';
159
155
  mdxOptions?: MDXOptions;
160
156
  /**
161
157
  * Load files with async
162
158
  */
163
159
  async?: Async;
160
+ schema?: CollectionSchema<Schema, {
161
+ path: string;
162
+ source: string;
163
+ }>;
164
164
  }
165
165
  interface DocsCollection<DocSchema extends StandardSchemaV1 = StandardSchemaV1, MetaSchema extends StandardSchemaV1 = StandardSchemaV1, Async extends boolean = boolean> {
166
166
  type: 'docs';
@@ -205,4 +205,4 @@ declare function defineDocs<DocSchema extends StandardSchemaV1 = typeof frontmat
205
205
  };
206
206
  declare function defineConfig(config?: GlobalConfig): GlobalConfig;
207
207
 
208
- export { type BaseCollectionEntry as B, type DocCollection as D, type FileInfo as F, type GlobalConfig as G, type MarkdownProps as M, type TransformContext as T, type BaseCollection as a, type MetaCollection as b, type DocsCollection as c, defineCollections as d, defineDocs as e, frontmatterSchema as f, defineConfig as g, type DefaultMDXOptions as h, getDefaultMDXOptions as i, metaSchema as m };
208
+ export { type BaseCollectionEntry as B, type CollectionSchema as C, type DocCollection as D, type FileInfo as F, type GlobalConfig as G, type MarkdownProps as M, type BaseCollection as a, type MetaCollection as b, type DocsCollection as c, defineCollections as d, defineDocs as e, frontmatterSchema as f, defineConfig as g, type DefaultMDXOptions as h, getDefaultMDXOptions as i, metaSchema as m };
package/dist/index.cjs CHANGED
@@ -43,7 +43,7 @@ var _runtime = {
43
43
  meta(files) {
44
44
  return files.map((file) => {
45
45
  return {
46
- ...file.data.default,
46
+ ...file.data,
47
47
  _file: file.info
48
48
  };
49
49
  });
package/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { PageData, MetaData, Source, VirtualFile } from 'fumadocs-core/source';
2
- import { B as BaseCollectionEntry } from './define-BUjajTka.cjs';
3
- import { R as Runtime } from './types-Dh6jLIT1.cjs';
4
- export { a as RuntimeFile } from './types-Dh6jLIT1.cjs';
2
+ import { B as BaseCollectionEntry } from './define-DxwgTgV6.cjs';
3
+ import { R as Runtime } from './types-BIA23Xld.cjs';
4
+ export { a as RuntimeFile } from './types-BIA23Xld.cjs';
5
5
  import '@mdx-js/mdx';
6
6
  import 'mdx/types';
7
7
  import 'fumadocs-core/mdx-plugins';
@@ -10,6 +10,7 @@ import 'unified';
10
10
  import 'react';
11
11
  import 'zod';
12
12
  import '@standard-schema/spec';
13
+ import '@fumadocs/mdx-remote';
13
14
 
14
15
  declare const _runtime: Runtime;
15
16
  declare function createMDXSource<Doc extends PageData & BaseCollectionEntry, Meta extends MetaData & BaseCollectionEntry>(docs: Doc[], meta?: Meta[]): Source<{
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { PageData, MetaData, Source, VirtualFile } from 'fumadocs-core/source';
2
- import { B as BaseCollectionEntry } from './define-BUjajTka.js';
3
- import { R as Runtime } from './types-CvzwQDWV.js';
4
- export { a as RuntimeFile } from './types-CvzwQDWV.js';
2
+ import { B as BaseCollectionEntry } from './define-DxwgTgV6.js';
3
+ import { R as Runtime } from './types-2R3kLFSi.js';
4
+ export { a as RuntimeFile } from './types-2R3kLFSi.js';
5
5
  import '@mdx-js/mdx';
6
6
  import 'mdx/types';
7
7
  import 'fumadocs-core/mdx-plugins';
@@ -10,6 +10,7 @@ import 'unified';
10
10
  import 'react';
11
11
  import 'zod';
12
12
  import '@standard-schema/spec';
13
+ import '@fumadocs/mdx-remote';
13
14
 
14
15
  declare const _runtime: Runtime;
15
16
  declare function createMDXSource<Doc extends PageData & BaseCollectionEntry, Meta extends MetaData & BaseCollectionEntry>(docs: Doc[], meta?: Meta[]): Source<{
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  _runtime,
3
3
  createMDXSource,
4
4
  resolveFiles
5
- } from "./chunk-3PXNPJQ2.js";
5
+ } from "./chunk-IZURUUPO.js";
6
6
  export {
7
7
  _runtime,
8
8
  createMDXSource,
@@ -165,8 +165,7 @@ var import_node_querystring = require("querystring");
165
165
  var import_gray_matter2 = __toESM(require("gray-matter"), 1);
166
166
 
167
167
  // src/utils/config.ts
168
- var import_node_crypto = require("crypto");
169
- var fs = __toESM(require("fs"), 1);
168
+ var fs = __toESM(require("fs/promises"), 1);
170
169
  var path = __toESM(require("path"), 1);
171
170
  var import_node_url = require("url");
172
171
 
@@ -197,23 +196,11 @@ function buildConfig(config) {
197
196
  null
198
197
  ];
199
198
  }
200
- let cachedMdxOptions;
201
199
  return [
202
200
  null,
203
201
  {
204
202
  global: globalConfig,
205
203
  collections,
206
- async getDefaultMDXOptions() {
207
- if (cachedMdxOptions) return cachedMdxOptions;
208
- const { getDefaultMDXOptions: getDefaultMDXOptions2 } = await Promise.resolve().then(() => (init_mdx_options(), mdx_options_exports));
209
- const mdxOptions = globalConfig?.mdxOptions ?? {};
210
- if (typeof mdxOptions === "function") {
211
- cachedMdxOptions = getDefaultMDXOptions2(await mdxOptions());
212
- } else {
213
- cachedMdxOptions = getDefaultMDXOptions2(mdxOptions);
214
- }
215
- return cachedMdxOptions;
216
- },
217
204
  _runtime: {
218
205
  files: /* @__PURE__ */ new Map()
219
206
  }
@@ -222,13 +209,13 @@ function buildConfig(config) {
222
209
  }
223
210
 
224
211
  // src/utils/config.ts
225
- var cache = /* @__PURE__ */ new Map();
226
- async function compileConfig(configPath) {
212
+ var cache = null;
213
+ async function compileConfig(configPath, outDir) {
227
214
  const { build } = await import("esbuild");
228
215
  const transformed = await build({
229
216
  entryPoints: [{ in: configPath, out: "source.config" }],
230
217
  bundle: true,
231
- outdir: ".source",
218
+ outdir: outDir,
232
219
  target: "node18",
233
220
  write: true,
234
221
  platform: "node",
@@ -244,13 +231,12 @@ async function compileConfig(configPath) {
244
231
  }
245
232
  }
246
233
  async function loadConfig(configPath, hash, build = false) {
247
- const cached = cache.get(configPath);
248
- if (cached && cached.hash === hash) {
249
- return await cached.config;
234
+ if (cache && cache.hash === hash) {
235
+ return await cache.config;
250
236
  }
251
- if (build) await compileConfig(configPath);
237
+ if (build) await compileConfig(configPath, ".source");
252
238
  const url = (0, import_node_url.pathToFileURL)(path.resolve(".source/source.config.mjs"));
253
- const config = import(`${url.href}?hash=${configPath}`).then((loaded) => {
239
+ const config = import(`${url.href}?hash=${hash}`).then((loaded) => {
254
240
  const [err, config2] = buildConfig(
255
241
  // every call to `loadConfig` will cause the previous cache to be ignored
256
242
  loaded
@@ -258,16 +244,15 @@ async function loadConfig(configPath, hash, build = false) {
258
244
  if (err !== null) throw new Error(err);
259
245
  return config2;
260
246
  });
261
- cache.set(configPath, { config, hash });
247
+ cache = { config, hash };
262
248
  return await config;
263
249
  }
264
250
  async function getConfigHash(configPath) {
265
- const hash = (0, import_node_crypto.createHash)("md5");
266
- const rs = fs.createReadStream(configPath);
267
- for await (const chunk of rs) {
268
- hash.update(chunk);
251
+ const stats = await fs.stat(configPath).catch(() => void 0);
252
+ if (stats) {
253
+ return stats.mtime.getTime().toString();
269
254
  }
270
- return hash.digest("hex");
255
+ throw new Error("Cannot find config file");
271
256
  }
272
257
 
273
258
  // src/utils/build-mdx.ts
@@ -355,12 +340,6 @@ async function buildMDX(cacheKey, source, options = {}) {
355
340
  });
356
341
  }
357
342
 
358
- // src/utils/format-error.ts
359
- function formatError(message, issues) {
360
- return `${message}:
361
- ${issues.map((issue) => ` ${issue.path}: ${issue.message}`).join("\n")}`;
362
- }
363
-
364
343
  // src/utils/git-timestamp.ts
365
344
  var import_node_path = __toESM(require("path"), 1);
366
345
  var import_node_fs = __toESM(require("fs"), 1);
@@ -389,6 +368,44 @@ function getGitTimestamp(file) {
389
368
  });
390
369
  }
391
370
 
371
+ // src/utils/schema.ts
372
+ var import_zod = require("zod");
373
+ var metaSchema = import_zod.z.object({
374
+ title: import_zod.z.string().optional(),
375
+ pages: import_zod.z.array(import_zod.z.string()).optional(),
376
+ description: import_zod.z.string().optional(),
377
+ root: import_zod.z.boolean().optional(),
378
+ defaultOpen: import_zod.z.boolean().optional(),
379
+ icon: import_zod.z.string().optional()
380
+ });
381
+ var frontmatterSchema = import_zod.z.object({
382
+ title: import_zod.z.string(),
383
+ description: import_zod.z.string().optional(),
384
+ icon: import_zod.z.string().optional(),
385
+ full: import_zod.z.boolean().optional(),
386
+ // Fumadocs OpenAPI generated
387
+ _openapi: import_zod.z.object({}).passthrough().optional()
388
+ });
389
+ async function validate(schema, data, context, errorMessage) {
390
+ if (typeof schema === "function" && !("~standard" in schema)) {
391
+ schema = schema(context);
392
+ }
393
+ if ("~standard" in schema) {
394
+ const result = await schema["~standard"].validate(
395
+ data
396
+ );
397
+ if (result.issues) {
398
+ throw new Error(formatError(errorMessage, result.issues));
399
+ }
400
+ return result.value;
401
+ }
402
+ return data;
403
+ }
404
+ function formatError(message, issues) {
405
+ return `${message}:
406
+ ${issues.map((issue) => ` ${issue.path}: ${issue.message}`).join("\n")}`;
407
+ }
408
+
392
409
  // src/loader-mdx.ts
393
410
  function parseQuery(query) {
394
411
  let collection;
@@ -415,37 +432,24 @@ async function loader(source, callback) {
415
432
  if (collection && collection.type !== "doc") {
416
433
  collection = void 0;
417
434
  }
418
- const mdxOptions = collection?.mdxOptions ?? await config.getDefaultMDXOptions();
435
+ let mdxOptions = collection?.mdxOptions;
436
+ if (!mdxOptions) {
437
+ const { getDefaultMDXOptions: getDefaultMDXOptions2 } = await Promise.resolve().then(() => (init_mdx_options(), mdx_options_exports));
438
+ config._mdx_loader ??= {};
439
+ const extendedOptions = config.global?.mdxOptions;
440
+ config._mdx_loader.cachedProcessorOptions ??= typeof extendedOptions === "function" ? getDefaultMDXOptions2(await extendedOptions()) : getDefaultMDXOptions2(extendedOptions ?? {});
441
+ mdxOptions = config._mdx_loader.cachedProcessorOptions;
442
+ }
419
443
  if (collection?.schema) {
420
- let schema = collection.schema;
421
- if (typeof schema === "function" && !("~standard" in schema)) {
422
- schema = schema({
423
- async buildMDX(v, options = mdxOptions) {
424
- const res = await buildMDX(
425
- `${configHash}:${collectionId ?? "global"}`,
426
- v,
427
- options
428
- );
429
- return String(res.value);
430
- },
444
+ matter2.data = await validate(
445
+ collection.schema,
446
+ matter2.data,
447
+ {
431
448
  source,
432
449
  path: filePath
433
- });
434
- }
435
- if ("~standard" in schema) {
436
- const result = await schema["~standard"].validate(
437
- matter2.data
438
- );
439
- if (result.issues) {
440
- callback(
441
- new Error(
442
- formatError(`invalid frontmatter in ${filePath}:`, result.issues)
443
- )
444
- );
445
- return;
446
- }
447
- matter2.data = result.value;
448
- }
450
+ },
451
+ `invalid frontmatter in ${filePath}:`
452
+ );
449
453
  }
450
454
  let timestamp;
451
455
  if (config.global?.lastModifiedTime === "git")
@@ -1,11 +1,14 @@
1
1
  import {
2
2
  getConfigHash,
3
3
  loadConfig
4
- } from "./chunk-USWGH3VH.js";
4
+ } from "./chunk-R6U7CJLB.js";
5
+ import {
6
+ validate
7
+ } from "./chunk-KGLACICA.js";
5
8
  import {
6
9
  remarkInclude
7
10
  } from "./chunk-PY2KKTR2.js";
8
- import "./chunk-6ZVE73IT.js";
11
+ import "./chunk-SLCPEEMF.js";
9
12
 
10
13
  // src/loader-mdx.ts
11
14
  import * as path2 from "node:path";
@@ -45,12 +48,6 @@ async function buildMDX(cacheKey, source, options = {}) {
45
48
  });
46
49
  }
47
50
 
48
- // src/utils/format-error.ts
49
- function formatError(message, issues) {
50
- return `${message}:
51
- ${issues.map((issue) => ` ${issue.path}: ${issue.message}`).join("\n")}`;
52
- }
53
-
54
51
  // src/utils/git-timestamp.ts
55
52
  import path from "node:path";
56
53
  import fs from "node:fs";
@@ -105,37 +102,24 @@ async function loader(source, callback) {
105
102
  if (collection && collection.type !== "doc") {
106
103
  collection = void 0;
107
104
  }
108
- const mdxOptions = collection?.mdxOptions ?? await config.getDefaultMDXOptions();
105
+ let mdxOptions = collection?.mdxOptions;
106
+ if (!mdxOptions) {
107
+ const { getDefaultMDXOptions } = await import("./mdx-options-CAU273O3.js");
108
+ config._mdx_loader ??= {};
109
+ const extendedOptions = config.global?.mdxOptions;
110
+ config._mdx_loader.cachedProcessorOptions ??= typeof extendedOptions === "function" ? getDefaultMDXOptions(await extendedOptions()) : getDefaultMDXOptions(extendedOptions ?? {});
111
+ mdxOptions = config._mdx_loader.cachedProcessorOptions;
112
+ }
109
113
  if (collection?.schema) {
110
- let schema = collection.schema;
111
- if (typeof schema === "function" && !("~standard" in schema)) {
112
- schema = schema({
113
- async buildMDX(v, options = mdxOptions) {
114
- const res = await buildMDX(
115
- `${configHash}:${collectionId ?? "global"}`,
116
- v,
117
- options
118
- );
119
- return String(res.value);
120
- },
114
+ matter.data = await validate(
115
+ collection.schema,
116
+ matter.data,
117
+ {
121
118
  source,
122
119
  path: filePath
123
- });
124
- }
125
- if ("~standard" in schema) {
126
- const result = await schema["~standard"].validate(
127
- matter.data
128
- );
129
- if (result.issues) {
130
- callback(
131
- new Error(
132
- formatError(`invalid frontmatter in ${filePath}:`, result.issues)
133
- )
134
- );
135
- return;
136
- }
137
- matter.data = result.value;
138
- }
120
+ },
121
+ `invalid frontmatter in ${filePath}:`
122
+ );
139
123
  }
140
124
  let timestamp;
141
125
  if (config.global?.lastModifiedTime === "git")