fumadocs-mdx 11.3.1 → 11.3.2

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.
@@ -16,9 +16,10 @@ type DefaultMDXOptions = Omit<NonNullable<ProcessorOptions>, 'rehypePlugins' | '
16
16
  remarkStructureOptions?: StructureOptions | false;
17
17
  remarkHeadingOptions?: RemarkHeadingOptions;
18
18
  remarkImageOptions?: RemarkImageOptions | false;
19
+ remarkCodeTabOptions?: false;
19
20
  rehypeCodeOptions?: Partial<RehypeCodeOptions> | false;
20
21
  };
21
- declare function getDefaultMDXOptions({ valueToExport, rehypeCodeOptions, remarkImageOptions, remarkHeadingOptions, remarkStructureOptions, ...mdxOptions }: DefaultMDXOptions): ProcessorOptions;
22
+ declare function getDefaultMDXOptions({ valueToExport, rehypeCodeOptions, remarkImageOptions, remarkHeadingOptions, remarkStructureOptions, remarkCodeTabOptions, ...mdxOptions }: DefaultMDXOptions): ProcessorOptions;
22
23
 
23
24
  interface GlobalConfig {
24
25
  /**
@@ -16,9 +16,10 @@ type DefaultMDXOptions = Omit<NonNullable<ProcessorOptions>, 'rehypePlugins' | '
16
16
  remarkStructureOptions?: StructureOptions | false;
17
17
  remarkHeadingOptions?: RemarkHeadingOptions;
18
18
  remarkImageOptions?: RemarkImageOptions | false;
19
+ remarkCodeTabOptions?: false;
19
20
  rehypeCodeOptions?: Partial<RehypeCodeOptions> | false;
20
21
  };
21
- declare function getDefaultMDXOptions({ valueToExport, rehypeCodeOptions, remarkImageOptions, remarkHeadingOptions, remarkStructureOptions, ...mdxOptions }: DefaultMDXOptions): ProcessorOptions;
22
+ declare function getDefaultMDXOptions({ valueToExport, rehypeCodeOptions, remarkImageOptions, remarkHeadingOptions, remarkStructureOptions, remarkCodeTabOptions, ...mdxOptions }: DefaultMDXOptions): ProcessorOptions;
22
23
 
23
24
  interface GlobalConfig {
24
25
  /**
@@ -2,6 +2,7 @@
2
2
  import {
3
3
  rehypeCode,
4
4
  rehypeToc,
5
+ remarkCodeTab,
5
6
  remarkGfm,
6
7
  remarkHeading,
7
8
  remarkImage,
@@ -68,6 +69,7 @@ function getDefaultMDXOptions({
68
69
  remarkImageOptions,
69
70
  remarkHeadingOptions,
70
71
  remarkStructureOptions,
72
+ remarkCodeTabOptions,
71
73
  ...mdxOptions
72
74
  }) {
73
75
  const mdxExports = [
@@ -87,6 +89,7 @@ function getDefaultMDXOptions({
87
89
  }
88
90
  ],
89
91
  remarkImageOptions !== false && [remarkImage, remarkImageOptions],
92
+ remarkCodeTabOptions !== false && remarkCodeTab,
90
93
  ...v,
91
94
  remarkStructureOptions !== false && [
92
95
  remarkStructure,
@@ -67,7 +67,7 @@ function buildConfig(config) {
67
67
  collections,
68
68
  async getDefaultMDXOptions() {
69
69
  if (cachedMdxOptions) return cachedMdxOptions;
70
- const { getDefaultMDXOptions } = await import("./mdx-options-L5C3NQRY.js");
70
+ const { getDefaultMDXOptions } = await import("./mdx-options-2H42TB7P.js");
71
71
  const mdxOptions = globalConfig?.mdxOptions ?? {};
72
72
  if (typeof mdxOptions === "function") {
73
73
  cachedMdxOptions = getDefaultMDXOptions(await mdxOptions());
@@ -152,6 +152,7 @@ function getDefaultMDXOptions({
152
152
  remarkImageOptions,
153
153
  remarkHeadingOptions,
154
154
  remarkStructureOptions,
155
+ remarkCodeTabOptions,
155
156
  ...mdxOptions
156
157
  }) {
157
158
  const mdxExports = [
@@ -171,6 +172,7 @@ function getDefaultMDXOptions({
171
172
  }
172
173
  ],
173
174
  remarkImageOptions !== false && [import_mdx_plugins.remarkImage, remarkImageOptions],
175
+ remarkCodeTabOptions !== false && import_mdx_plugins.remarkCodeTab,
174
176
  ...v,
175
177
  remarkStructureOptions !== false && [
176
178
  import_mdx_plugins.remarkStructure,
@@ -1,5 +1,5 @@
1
- import { F as FileInfo, G as GlobalConfig, M as MarkdownProps, a as MDXOptions, B as BaseCollectionEntry } from '../build-mdx-C2hor32E.cjs';
2
- export { C as CollectionEntry, D as DefaultMDXOptions, c as GetOutput, I as InferSchema, b as InferSchemaType, g as getDefaultMDXOptions } from '../build-mdx-C2hor32E.cjs';
1
+ import { F as FileInfo, G as GlobalConfig, M as MarkdownProps, a as MDXOptions, B as BaseCollectionEntry } from '../build-mdx-TJcSpR7K.cjs';
2
+ export { C as CollectionEntry, D as DefaultMDXOptions, c as GetOutput, I as InferSchema, b as InferSchemaType, g as getDefaultMDXOptions } from '../build-mdx-TJcSpR7K.cjs';
3
3
  import { z, ZodTypeAny } from 'zod';
4
4
  import { ProcessorOptions } from '@mdx-js/mdx';
5
5
  import { Processor, Transformer } from 'unified';
@@ -1,5 +1,5 @@
1
- import { F as FileInfo, G as GlobalConfig, M as MarkdownProps, a as MDXOptions, B as BaseCollectionEntry } from '../build-mdx-C2hor32E.js';
2
- export { C as CollectionEntry, D as DefaultMDXOptions, c as GetOutput, I as InferSchema, b as InferSchemaType, g as getDefaultMDXOptions } from '../build-mdx-C2hor32E.js';
1
+ import { F as FileInfo, G as GlobalConfig, M as MarkdownProps, a as MDXOptions, B as BaseCollectionEntry } from '../build-mdx-TJcSpR7K.js';
2
+ export { C as CollectionEntry, D as DefaultMDXOptions, c as GetOutput, I as InferSchema, b as InferSchemaType, g as getDefaultMDXOptions } from '../build-mdx-TJcSpR7K.js';
3
3
  import { z, ZodTypeAny } from 'zod';
4
4
  import { ProcessorOptions } from '@mdx-js/mdx';
5
5
  import { Processor, Transformer } from 'unified';
@@ -3,7 +3,7 @@ import {
3
3
  } from "../chunk-PY2KKTR2.js";
4
4
  import {
5
5
  getDefaultMDXOptions
6
- } from "../chunk-6LEQ23AC.js";
6
+ } from "../chunk-CQAAQB5I.js";
7
7
 
8
8
  // src/utils/schema.ts
9
9
  import { z } from "zod";
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { PageData, MetaData, Source } from 'fumadocs-core/source';
2
- import { F as FileInfo, B as BaseCollectionEntry } from './build-mdx-C2hor32E.cjs';
2
+ import { F as FileInfo, B as BaseCollectionEntry } from './build-mdx-TJcSpR7K.cjs';
3
3
  import 'zod';
4
4
  import 'mdx/types';
5
5
  import 'fumadocs-core/mdx-plugins';
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 './build-mdx-C2hor32E.js';
2
+ import { F as FileInfo, B as BaseCollectionEntry } from './build-mdx-TJcSpR7K.js';
3
3
  import 'zod';
4
4
  import 'mdx/types';
5
5
  import 'fumadocs-core/mdx-plugins';
@@ -100,6 +100,7 @@ function getDefaultMDXOptions({
100
100
  remarkImageOptions,
101
101
  remarkHeadingOptions,
102
102
  remarkStructureOptions,
103
+ remarkCodeTabOptions,
103
104
  ...mdxOptions
104
105
  }) {
105
106
  const mdxExports = [
@@ -119,6 +120,7 @@ function getDefaultMDXOptions({
119
120
  }
120
121
  ],
121
122
  remarkImageOptions !== false && [import_mdx_plugins.remarkImage, remarkImageOptions],
123
+ remarkCodeTabOptions !== false && import_mdx_plugins.remarkCodeTab,
122
124
  ...v,
123
125
  remarkStructureOptions !== false && [
124
126
  import_mdx_plugins.remarkStructure,
@@ -356,11 +358,11 @@ function buildMDX(group, configHash, source, options = {}) {
356
358
 
357
359
  // src/utils/format-error.ts
358
360
  function formatError(message, error) {
359
- const lines = [];
361
+ const lines2 = [];
360
362
  function walk(key, { _errors, ...rest }, padStart = 0) {
361
363
  if (key !== void 0 || _errors.length > 0) {
362
364
  const text = key ? `${key}: ${_errors.join("\n ")}` : _errors.join("\n");
363
- lines.push(
365
+ lines2.push(
364
366
  text.split("\n").map((line) => `${" ".repeat(padStart)}${line}`).join("\n")
365
367
  );
366
368
  }
@@ -369,7 +371,7 @@ function formatError(message, error) {
369
371
  }
370
372
  }
371
373
  walk(void 0, error.format());
372
- return [message, ...lines].join("\n");
374
+ return [message, ...lines2].join("\n");
373
375
  }
374
376
 
375
377
  // src/utils/git-timestamp.ts
@@ -426,7 +428,6 @@ async function loader(source, callback) {
426
428
  collection = void 0;
427
429
  }
428
430
  const mdxOptions = collection?.mdxOptions ?? await config.getDefaultMDXOptions();
429
- let frontmatter = matter2.data;
430
431
  if (collection?.schema) {
431
432
  let schema = collection.schema;
432
433
  if (typeof schema === "function") {
@@ -444,7 +445,7 @@ async function loader(source, callback) {
444
445
  path: filePath
445
446
  });
446
447
  }
447
- const result = await schema.safeParseAsync(frontmatter);
448
+ const result = await schema.safeParseAsync(matter2.data);
448
449
  if (result.error) {
449
450
  callback(
450
451
  new Error(
@@ -453,21 +454,24 @@ async function loader(source, callback) {
453
454
  );
454
455
  return;
455
456
  }
456
- frontmatter = result.data;
457
+ matter2.data = result.data;
457
458
  }
458
459
  let timestamp;
459
460
  if (config.global?.lastModifiedTime === "git")
460
461
  timestamp = (await getGitTimestamp(filePath))?.getTime();
461
462
  try {
463
+ const lineOffset = "\n".repeat(
464
+ this.mode === "development" ? lines(source) - lines(matter2.content) : 0
465
+ );
462
466
  const file = await buildMDX(
463
467
  collectionId ?? "global",
464
468
  configHash,
465
- matter2.content,
469
+ lineOffset + matter2.content,
466
470
  {
467
471
  development: this.mode === "development",
468
472
  ...mdxOptions,
469
473
  filePath,
470
- frontmatter,
474
+ frontmatter: matter2.data,
471
475
  data: {
472
476
  lastModified: timestamp
473
477
  },
@@ -482,3 +486,10 @@ async function loader(source, callback) {
482
486
  callback(error);
483
487
  }
484
488
  }
489
+ function lines(s) {
490
+ let num = 0;
491
+ for (const c of s) {
492
+ if (c === "\n") num++;
493
+ }
494
+ return num;
495
+ }
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  getConfigHash,
6
6
  loadConfigCached
7
- } from "./chunk-2ZPSMAUV.js";
7
+ } from "./chunk-HPKXUFKR.js";
8
8
 
9
9
  // src/loader-mdx.ts
10
10
  import * as path2 from "node:path";
@@ -52,11 +52,11 @@ function buildMDX(group, configHash, source, options = {}) {
52
52
 
53
53
  // src/utils/format-error.ts
54
54
  function formatError(message, error) {
55
- const lines = [];
55
+ const lines2 = [];
56
56
  function walk(key, { _errors, ...rest }, padStart = 0) {
57
57
  if (key !== void 0 || _errors.length > 0) {
58
58
  const text = key ? `${key}: ${_errors.join("\n ")}` : _errors.join("\n");
59
- lines.push(
59
+ lines2.push(
60
60
  text.split("\n").map((line) => `${" ".repeat(padStart)}${line}`).join("\n")
61
61
  );
62
62
  }
@@ -65,7 +65,7 @@ function formatError(message, error) {
65
65
  }
66
66
  }
67
67
  walk(void 0, error.format());
68
- return [message, ...lines].join("\n");
68
+ return [message, ...lines2].join("\n");
69
69
  }
70
70
 
71
71
  // src/utils/git-timestamp.ts
@@ -122,7 +122,6 @@ async function loader(source, callback) {
122
122
  collection = void 0;
123
123
  }
124
124
  const mdxOptions = collection?.mdxOptions ?? await config.getDefaultMDXOptions();
125
- let frontmatter = matter.data;
126
125
  if (collection?.schema) {
127
126
  let schema = collection.schema;
128
127
  if (typeof schema === "function") {
@@ -140,7 +139,7 @@ async function loader(source, callback) {
140
139
  path: filePath
141
140
  });
142
141
  }
143
- const result = await schema.safeParseAsync(frontmatter);
142
+ const result = await schema.safeParseAsync(matter.data);
144
143
  if (result.error) {
145
144
  callback(
146
145
  new Error(
@@ -149,21 +148,24 @@ async function loader(source, callback) {
149
148
  );
150
149
  return;
151
150
  }
152
- frontmatter = result.data;
151
+ matter.data = result.data;
153
152
  }
154
153
  let timestamp;
155
154
  if (config.global?.lastModifiedTime === "git")
156
155
  timestamp = (await getGitTimestamp(filePath))?.getTime();
157
156
  try {
157
+ const lineOffset = "\n".repeat(
158
+ this.mode === "development" ? lines(source) - lines(matter.content) : 0
159
+ );
158
160
  const file = await buildMDX(
159
161
  collectionId ?? "global",
160
162
  configHash,
161
- matter.content,
163
+ lineOffset + matter.content,
162
164
  {
163
165
  development: this.mode === "development",
164
166
  ...mdxOptions,
165
167
  filePath,
166
- frontmatter,
168
+ frontmatter: matter.data,
167
169
  data: {
168
170
  lastModified: timestamp
169
171
  },
@@ -178,6 +180,13 @@ async function loader(source, callback) {
178
180
  callback(error);
179
181
  }
180
182
  }
183
+ function lines(s) {
184
+ let num = 0;
185
+ for (const c of s) {
186
+ if (c === "\n") num++;
187
+ }
188
+ return num;
189
+ }
181
190
  export {
182
191
  loader as default
183
192
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getDefaultMDXOptions
3
- } from "./chunk-6LEQ23AC.js";
3
+ } from "./chunk-CQAAQB5I.js";
4
4
  export {
5
5
  getDefaultMDXOptions
6
6
  };
@@ -100,6 +100,7 @@ function getDefaultMDXOptions({
100
100
  remarkImageOptions,
101
101
  remarkHeadingOptions,
102
102
  remarkStructureOptions,
103
+ remarkCodeTabOptions,
103
104
  ...mdxOptions
104
105
  }) {
105
106
  const mdxExports = [
@@ -119,6 +120,7 @@ function getDefaultMDXOptions({
119
120
  }
120
121
  ],
121
122
  remarkImageOptions !== false && [import_mdx_plugins.remarkImage, remarkImageOptions],
123
+ remarkCodeTabOptions !== false && import_mdx_plugins.remarkCodeTab,
122
124
  ...v,
123
125
  remarkStructureOptions !== false && [
124
126
  import_mdx_plugins.remarkStructure,
@@ -3,7 +3,7 @@ import {
3
3
  getConfigHash,
4
4
  loadConfig,
5
5
  loadConfigCached
6
- } from "../chunk-2ZPSMAUV.js";
6
+ } from "../chunk-HPKXUFKR.js";
7
7
 
8
8
  // src/next/create.ts
9
9
  import path3 from "node:path";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-mdx",
3
- "version": "11.3.1",
3
+ "version": "11.3.2",
4
4
  "description": "The built-in source for Fumadocs",
5
5
  "keywords": [
6
6
  "NextJs",
@@ -56,16 +56,16 @@
56
56
  "@types/micromatch": "^4.0.9",
57
57
  "@types/react": "^19.0.7",
58
58
  "mdast-util-mdx-jsx": "^3.2.0",
59
- "next": "^15.1.4",
59
+ "next": "^15.1.6",
60
60
  "unified": "^11.0.5",
61
61
  "vfile": "^6.0.3",
62
62
  "webpack": "^5.97.1",
63
63
  "eslint-config-custom": "0.0.0",
64
- "fumadocs-core": "14.7.4",
64
+ "fumadocs-core": "15.0.0",
65
65
  "tsconfig": "0.0.0"
66
66
  },
67
67
  "peerDependencies": {
68
- "fumadocs-core": "^14.0.0",
68
+ "fumadocs-core": "^14.0.0 || ^15.0.0",
69
69
  "next": "14.x.x || 15.x.x"
70
70
  },
71
71
  "publishConfig": {