fumadocs-mdx 11.7.4 → 11.8.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.
Files changed (44) hide show
  1. package/dist/{chunk-OWZSTKKX.js → chunk-6Y5JDZHD.js} +8 -1
  2. package/dist/chunk-7JFPDRW7.js +42 -0
  3. package/dist/chunk-GBMFGEC7.js +57 -0
  4. package/dist/{chunk-ZOWJF3OH.js → chunk-GX3THK2Q.js} +25 -20
  5. package/dist/{chunk-2CSSQTP6.js → chunk-GYWPPGFD.js} +9 -1
  6. package/dist/{chunk-PQCNPAD3.js → chunk-IGXZS2W6.js} +10 -7
  7. package/dist/chunk-UCY7OBZG.js +12 -0
  8. package/dist/{chunk-KVWX6THC.js → chunk-VWJKRQZR.js} +2 -2
  9. package/dist/{chunk-JFNBRKRV.js → chunk-XVL4ZQFK.js} +12 -6
  10. package/dist/{chunk-4CGSOZUZ.js → chunk-XZR5QXVY.js} +32 -2
  11. package/dist/config/index.cjs +21 -11
  12. package/dist/config/index.d.cts +2 -2
  13. package/dist/config/index.d.ts +2 -2
  14. package/dist/config/index.js +9 -37
  15. package/dist/config/zod-3.cjs +371 -0
  16. package/dist/config/zod-3.d.cts +53 -0
  17. package/dist/config/zod-3.d.ts +53 -0
  18. package/dist/config/zod-3.js +40 -0
  19. package/dist/{define-E6TRBwBQ.d.cts → define-DnJzAZrj.d.cts} +3 -2
  20. package/dist/{define-E6TRBwBQ.d.ts → define-DnJzAZrj.d.ts} +3 -2
  21. package/dist/index.d.cts +3 -3
  22. package/dist/index.d.ts +3 -3
  23. package/dist/loader-mdx.cjs +83 -50
  24. package/dist/loader-mdx.js +10 -10
  25. package/dist/{mdx-options-UDV5WEFU.js → mdx-options-3NB74EMB.js} +1 -1
  26. package/dist/next/index.cjs +63 -29
  27. package/dist/next/index.js +7 -9
  28. package/dist/runtime/async.cjs +167 -128
  29. package/dist/runtime/async.d.cts +3 -3
  30. package/dist/runtime/async.d.ts +3 -3
  31. package/dist/runtime/async.js +30 -46
  32. package/dist/runtime/vite.cjs +49 -41
  33. package/dist/runtime/vite.d.cts +26 -18
  34. package/dist/runtime/vite.d.ts +26 -18
  35. package/dist/runtime/vite.js +49 -41
  36. package/dist/{types-Lh_-Uuix.d.cts → types-B2ozVm_9.d.ts} +11 -5
  37. package/dist/{types-DiL328cG.d.ts → types-BukvTPdG.d.cts} +11 -5
  38. package/dist/vite/index.cjs +125 -99
  39. package/dist/vite/index.d.cts +6 -1
  40. package/dist/vite/index.d.ts +6 -1
  41. package/dist/vite/index.js +54 -38
  42. package/package.json +17 -12
  43. package/dist/chunk-2K55VKP6.js +0 -49
  44. package/dist/chunk-VUEZTR2H.js +0 -26
@@ -2,12 +2,12 @@ import { TableOfContents } from 'fumadocs-core/server';
2
2
  import { FC, ReactNode } from 'react';
3
3
  import { MDXProps } from 'mdx/types';
4
4
  import { StructuredData } from 'fumadocs-core/mdx-plugins';
5
- import { a as DocCollection, M as MetaCollection, b as DocsCollection } from '../define-E6TRBwBQ.cjs';
5
+ import { a as DocCollection, b as DocsCollection, M as MetaCollection } from '../define-DnJzAZrj.cjs';
6
6
  import { StandardSchemaV1 } from '@standard-schema/spec';
7
7
  import { PageData, MetaData, Source } from 'fumadocs-core/source';
8
- import 'zod';
9
8
  import '@mdx-js/mdx';
10
9
  import 'unified';
10
+ import 'zod';
11
11
 
12
12
  interface CompiledMDXProperties<Frontmatter> {
13
13
  frontmatter: Frontmatter;
@@ -20,28 +20,36 @@ interface CompiledMDXProperties<Frontmatter> {
20
20
  lastModified?: Date;
21
21
  }
22
22
  type CompiledMDXFile<Frontmatter> = CompiledMDXProperties<Frontmatter> & Record<string, unknown>;
23
- type MDXFileToPageData<Frontmatter> = Frontmatter & Omit<CompiledMDXProperties<Frontmatter>, 'frontmatter'> & {
23
+ type Override<A, B> = Omit<A, keyof B> & B;
24
+ type MDXFileToPageData<Frontmatter> = Override<Omit<CompiledMDXProperties<Frontmatter>, 'frontmatter' | 'default'>, Frontmatter & {
25
+ /**
26
+ * @deprecated use `body` instead.
27
+ */
28
+ default: FC<MDXProps>;
24
29
  _exports: Record<string, unknown>;
25
- };
26
- type AttachGlobValue<GlobValue, Attach> = GlobValue extends () => Promise<unknown> ? () => Promise<Attach> : Attach;
27
- declare function fromConfig<Config>(): {
28
- doc: <Name extends keyof Config, GlobValue>(name: Name, glob: Record<string, GlobValue>) => Config[Name] extends DocCollection<infer Schema> ? Record<string, AttachGlobValue<GlobValue, CompiledMDXFile<StandardSchemaV1.InferOutput<Schema>>>> : never;
29
- meta: <Name extends keyof Config, GlobValue>(name: Name, glob: Record<string, GlobValue>) => Config[Name] extends MetaCollection<infer Schema> ? AttachGlobValue<GlobValue, StandardSchemaV1.InferOutput<Schema>> : never;
30
- docs: <Name extends keyof Config, DocGlobValue, MetaGlobValue>(name: Name, options: {
31
- meta: Record<string, MetaGlobValue>;
32
- doc: Record<string, DocGlobValue>;
33
- }) => Config[Name] extends DocsCollection<infer DocSchema, infer MetaSchema> ? {
34
- doc: Record<string, AttachGlobValue<DocGlobValue, CompiledMDXFile<StandardSchemaV1.InferOutput<DocSchema>>>>;
35
- meta: Record<string, AttachGlobValue<MetaGlobValue, StandardSchemaV1.InferOutput<MetaSchema>>>;
36
- } : never;
37
- source: <DocOut extends PageData, MetaOut extends MetaData>(doc: Record<string, CompiledMDXFile<DocOut>>, meta: Record<string, MetaOut>) => Source<{
38
- pageData: MDXFileToPageData<DocOut>;
39
- metaData: MetaOut;
30
+ body: FC<MDXProps>;
31
+ }>;
32
+ type MDXFileToPageDataLazy<Frontmatter> = Override<Frontmatter, {
33
+ load: () => Promise<Omit<CompiledMDXFile<Frontmatter>, 'default'> & {
34
+ body: FC<MDXProps>;
40
35
  }>;
36
+ }>;
37
+ interface LazyDocMap<Frontmatter> {
38
+ head: Record<string, () => Promise<Frontmatter>>;
39
+ body: Record<string, () => Promise<CompiledMDXFile<Frontmatter>>>;
40
+ }
41
+ declare function fromConfig<Config>(): {
42
+ doc: <Name extends keyof Config>(name: Name, glob: Record<string, () => Promise<unknown>>) => Config[Name] extends DocCollection<infer Schema> | DocsCollection<infer Schema> ? Record<string, () => Promise<CompiledMDXFile<StandardSchemaV1.InferOutput<Schema>>>> : never;
43
+ docLazy: <Name extends keyof Config>(name: Name, headGlob: Record<string, () => Promise<unknown>>, bodyGlob: Record<string, () => Promise<unknown>>) => Config[Name] extends DocCollection<infer Schema> | DocsCollection<infer Schema> ? LazyDocMap<StandardSchemaV1.InferOutput<Schema>> : never;
44
+ meta: <Name extends keyof Config>(name: Name, glob: Record<string, () => Promise<unknown>>) => Config[Name] extends MetaCollection<infer Schema> | DocsCollection<StandardSchemaV1, infer Schema> ? Record<string, () => Promise<StandardSchemaV1.InferOutput<Schema>>> : never;
41
45
  sourceAsync: <DocOut extends PageData, MetaOut extends MetaData>(doc: Record<string, () => Promise<CompiledMDXFile<DocOut>>>, meta: Record<string, () => Promise<MetaOut>>) => Promise<Source<{
42
46
  pageData: MDXFileToPageData<DocOut>;
43
47
  metaData: MetaOut;
44
48
  }>>;
49
+ sourceLazy: <DocOut extends PageData, MetaOut extends MetaData>(doc: LazyDocMap<DocOut>, meta: Record<string, () => Promise<MetaOut>>) => Promise<Source<{
50
+ pageData: MDXFileToPageDataLazy<DocOut>;
51
+ metaData: MetaOut;
52
+ }>>;
45
53
  };
46
54
  interface ClientLoaderOptions<Frontmatter, Props> {
47
55
  /**
@@ -2,12 +2,12 @@ import { TableOfContents } from 'fumadocs-core/server';
2
2
  import { FC, ReactNode } from 'react';
3
3
  import { MDXProps } from 'mdx/types';
4
4
  import { StructuredData } from 'fumadocs-core/mdx-plugins';
5
- import { a as DocCollection, M as MetaCollection, b as DocsCollection } from '../define-E6TRBwBQ.js';
5
+ import { a as DocCollection, b as DocsCollection, M as MetaCollection } from '../define-DnJzAZrj.js';
6
6
  import { StandardSchemaV1 } from '@standard-schema/spec';
7
7
  import { PageData, MetaData, Source } from 'fumadocs-core/source';
8
- import 'zod';
9
8
  import '@mdx-js/mdx';
10
9
  import 'unified';
10
+ import 'zod';
11
11
 
12
12
  interface CompiledMDXProperties<Frontmatter> {
13
13
  frontmatter: Frontmatter;
@@ -20,28 +20,36 @@ interface CompiledMDXProperties<Frontmatter> {
20
20
  lastModified?: Date;
21
21
  }
22
22
  type CompiledMDXFile<Frontmatter> = CompiledMDXProperties<Frontmatter> & Record<string, unknown>;
23
- type MDXFileToPageData<Frontmatter> = Frontmatter & Omit<CompiledMDXProperties<Frontmatter>, 'frontmatter'> & {
23
+ type Override<A, B> = Omit<A, keyof B> & B;
24
+ type MDXFileToPageData<Frontmatter> = Override<Omit<CompiledMDXProperties<Frontmatter>, 'frontmatter' | 'default'>, Frontmatter & {
25
+ /**
26
+ * @deprecated use `body` instead.
27
+ */
28
+ default: FC<MDXProps>;
24
29
  _exports: Record<string, unknown>;
25
- };
26
- type AttachGlobValue<GlobValue, Attach> = GlobValue extends () => Promise<unknown> ? () => Promise<Attach> : Attach;
27
- declare function fromConfig<Config>(): {
28
- doc: <Name extends keyof Config, GlobValue>(name: Name, glob: Record<string, GlobValue>) => Config[Name] extends DocCollection<infer Schema> ? Record<string, AttachGlobValue<GlobValue, CompiledMDXFile<StandardSchemaV1.InferOutput<Schema>>>> : never;
29
- meta: <Name extends keyof Config, GlobValue>(name: Name, glob: Record<string, GlobValue>) => Config[Name] extends MetaCollection<infer Schema> ? AttachGlobValue<GlobValue, StandardSchemaV1.InferOutput<Schema>> : never;
30
- docs: <Name extends keyof Config, DocGlobValue, MetaGlobValue>(name: Name, options: {
31
- meta: Record<string, MetaGlobValue>;
32
- doc: Record<string, DocGlobValue>;
33
- }) => Config[Name] extends DocsCollection<infer DocSchema, infer MetaSchema> ? {
34
- doc: Record<string, AttachGlobValue<DocGlobValue, CompiledMDXFile<StandardSchemaV1.InferOutput<DocSchema>>>>;
35
- meta: Record<string, AttachGlobValue<MetaGlobValue, StandardSchemaV1.InferOutput<MetaSchema>>>;
36
- } : never;
37
- source: <DocOut extends PageData, MetaOut extends MetaData>(doc: Record<string, CompiledMDXFile<DocOut>>, meta: Record<string, MetaOut>) => Source<{
38
- pageData: MDXFileToPageData<DocOut>;
39
- metaData: MetaOut;
30
+ body: FC<MDXProps>;
31
+ }>;
32
+ type MDXFileToPageDataLazy<Frontmatter> = Override<Frontmatter, {
33
+ load: () => Promise<Omit<CompiledMDXFile<Frontmatter>, 'default'> & {
34
+ body: FC<MDXProps>;
40
35
  }>;
36
+ }>;
37
+ interface LazyDocMap<Frontmatter> {
38
+ head: Record<string, () => Promise<Frontmatter>>;
39
+ body: Record<string, () => Promise<CompiledMDXFile<Frontmatter>>>;
40
+ }
41
+ declare function fromConfig<Config>(): {
42
+ doc: <Name extends keyof Config>(name: Name, glob: Record<string, () => Promise<unknown>>) => Config[Name] extends DocCollection<infer Schema> | DocsCollection<infer Schema> ? Record<string, () => Promise<CompiledMDXFile<StandardSchemaV1.InferOutput<Schema>>>> : never;
43
+ docLazy: <Name extends keyof Config>(name: Name, headGlob: Record<string, () => Promise<unknown>>, bodyGlob: Record<string, () => Promise<unknown>>) => Config[Name] extends DocCollection<infer Schema> | DocsCollection<infer Schema> ? LazyDocMap<StandardSchemaV1.InferOutput<Schema>> : never;
44
+ meta: <Name extends keyof Config>(name: Name, glob: Record<string, () => Promise<unknown>>) => Config[Name] extends MetaCollection<infer Schema> | DocsCollection<StandardSchemaV1, infer Schema> ? Record<string, () => Promise<StandardSchemaV1.InferOutput<Schema>>> : never;
41
45
  sourceAsync: <DocOut extends PageData, MetaOut extends MetaData>(doc: Record<string, () => Promise<CompiledMDXFile<DocOut>>>, meta: Record<string, () => Promise<MetaOut>>) => Promise<Source<{
42
46
  pageData: MDXFileToPageData<DocOut>;
43
47
  metaData: MetaOut;
44
48
  }>>;
49
+ sourceLazy: <DocOut extends PageData, MetaOut extends MetaData>(doc: LazyDocMap<DocOut>, meta: Record<string, () => Promise<MetaOut>>) => Promise<Source<{
50
+ pageData: MDXFileToPageDataLazy<DocOut>;
51
+ metaData: MetaOut;
52
+ }>>;
45
53
  };
46
54
  interface ClientLoaderOptions<Frontmatter, Props> {
47
55
  /**
@@ -14,12 +14,22 @@ function fromConfig() {
14
14
  return {
15
15
  ...frontmatter,
16
16
  default: entry.default,
17
+ body: entry.default,
17
18
  toc,
18
19
  structuredData,
19
20
  lastModified,
20
21
  _exports: entry
21
22
  };
22
23
  }
24
+ function mapPageDataLazy(head, content) {
25
+ return {
26
+ ...head,
27
+ async load() {
28
+ const { default: body, ...rest } = await content();
29
+ return { body, ...rest };
30
+ }
31
+ };
32
+ }
23
33
  return {
24
34
  doc(_, glob) {
25
35
  return normalize(glob);
@@ -27,51 +37,49 @@ function fromConfig() {
27
37
  meta(_, glob) {
28
38
  return normalize(glob);
29
39
  },
30
- docs(_, { doc, meta }) {
31
- return {
32
- doc: normalize(doc),
33
- meta: normalize(meta)
34
- };
35
- },
36
- source(doc, meta) {
37
- const virtualFiles = [];
38
- for (const [file, content] of Object.entries(doc)) {
39
- virtualFiles.push({
40
- type: "page",
41
- path: file,
42
- data: mapPageData(content)
43
- });
44
- }
45
- for (const [file, content] of Object.entries(meta)) {
46
- virtualFiles.push({
47
- type: "meta",
48
- path: file,
49
- data: content
50
- });
51
- }
40
+ docLazy(_, head, body) {
52
41
  return {
53
- files: virtualFiles
42
+ head: normalize(head),
43
+ body: normalize(body)
54
44
  };
55
45
  },
56
46
  async sourceAsync(doc, meta) {
57
- const virtualFiles = [];
58
- for (const [file, content] of Object.entries(doc)) {
59
- virtualFiles.push({
60
- type: "page",
61
- path: file,
62
- data: mapPageData(await content())
63
- });
64
- }
65
- for (const [file, content] of Object.entries(meta)) {
66
- virtualFiles.push({
67
- type: "meta",
68
- path: file,
69
- data: await content()
70
- });
71
- }
72
- return {
73
- files: virtualFiles
74
- };
47
+ const virtualFiles = [
48
+ ...Object.entries(doc).map(async ([file, content]) => {
49
+ return {
50
+ type: "page",
51
+ path: file,
52
+ data: mapPageData(await content())
53
+ };
54
+ }),
55
+ ...Object.entries(meta).map(async ([file, content]) => {
56
+ return {
57
+ type: "meta",
58
+ path: file,
59
+ data: await content()
60
+ };
61
+ })
62
+ ];
63
+ return { files: await Promise.all(virtualFiles) };
64
+ },
65
+ async sourceLazy(doc, meta) {
66
+ const virtualFiles = [
67
+ ...Object.entries(doc.head).map(async ([file, frontmatter]) => {
68
+ return {
69
+ type: "page",
70
+ path: file,
71
+ data: mapPageDataLazy(await frontmatter(), doc.body[file])
72
+ };
73
+ }),
74
+ ...Object.entries(meta).map(async ([file, content]) => {
75
+ return {
76
+ type: "meta",
77
+ path: file,
78
+ data: await content()
79
+ };
80
+ })
81
+ ];
82
+ return { files: await Promise.all(virtualFiles) };
75
83
  }
76
84
  };
77
85
  }
@@ -1,6 +1,6 @@
1
1
  import { StandardSchemaV1 } from '@standard-schema/spec';
2
2
  import { Source, PageData, MetaData } from 'fumadocs-core/source';
3
- import { a as DocCollection, M as MetaCollection, b as DocsCollection, G as GlobalConfig } from './define-E6TRBwBQ.cjs';
3
+ import { a as DocCollection, M as MetaCollection, b as DocsCollection, G as GlobalConfig } from './define-DnJzAZrj.js';
4
4
  import { ProcessorOptions } from '@mdx-js/mdx';
5
5
  import { FC } from 'react';
6
6
  import { MDXProps } from 'mdx/types';
@@ -10,7 +10,7 @@ import { TableOfContents } from 'fumadocs-core/server';
10
10
  interface LoadedConfig {
11
11
  collections: Map<string, DocCollection | MetaCollection | DocsCollection>;
12
12
  global: GlobalConfig;
13
- getDefaultMDXOptions(): Promise<ProcessorOptions>;
13
+ getDefaultMDXOptions(mode?: 'default' | 'remote'): Promise<ProcessorOptions>;
14
14
  }
15
15
 
16
16
  interface BaseCollectionEntry {
@@ -27,7 +27,6 @@ interface MarkdownProps {
27
27
  body: FC<MDXProps>;
28
28
  structuredData: StructuredData;
29
29
  toc: TableOfContents;
30
- _exports: Record<string, unknown>;
31
30
  /**
32
31
  * Only available when `lastModifiedTime` is enabled on MDX loader
33
32
  */
@@ -40,10 +39,17 @@ interface RuntimeFile {
40
39
  interface AsyncRuntimeFile {
41
40
  info: FileInfo;
42
41
  data: Record<string, unknown>;
43
- content: string;
42
+ content: {
43
+ matter: string;
44
+ body: string;
45
+ };
44
46
  lastModified?: Date;
45
47
  }
46
48
  type DocOut<Schema extends StandardSchemaV1> = Override<MarkdownProps & {
49
+ /**
50
+ * Other exports in the compiled Markdown/MDX file
51
+ */
52
+ _exports: Record<string, unknown>;
47
53
  /**
48
54
  * Read the original content of file from file system.
49
55
  */
@@ -65,7 +71,7 @@ interface Runtime {
65
71
  }
66
72
  type AsyncDocOut<Schema extends StandardSchemaV1> = StandardSchemaV1.InferOutput<Schema> & BaseCollectionEntry & {
67
73
  content: string;
68
- load: () => Promise<MarkdownProps>;
74
+ load: () => Promise<MarkdownProps & Record<string, unknown>>;
69
75
  };
70
76
  interface RuntimeAsync {
71
77
  doc: <C>(files: AsyncRuntimeFile[], collection: string, config: LoadedConfig) => C extends DocCollection<infer Schema, true> ? AsyncDocOut<Schema>[] : never;
@@ -1,6 +1,6 @@
1
1
  import { StandardSchemaV1 } from '@standard-schema/spec';
2
2
  import { Source, PageData, MetaData } from 'fumadocs-core/source';
3
- import { a as DocCollection, M as MetaCollection, b as DocsCollection, G as GlobalConfig } from './define-E6TRBwBQ.js';
3
+ import { a as DocCollection, M as MetaCollection, b as DocsCollection, G as GlobalConfig } from './define-DnJzAZrj.cjs';
4
4
  import { ProcessorOptions } from '@mdx-js/mdx';
5
5
  import { FC } from 'react';
6
6
  import { MDXProps } from 'mdx/types';
@@ -10,7 +10,7 @@ import { TableOfContents } from 'fumadocs-core/server';
10
10
  interface LoadedConfig {
11
11
  collections: Map<string, DocCollection | MetaCollection | DocsCollection>;
12
12
  global: GlobalConfig;
13
- getDefaultMDXOptions(): Promise<ProcessorOptions>;
13
+ getDefaultMDXOptions(mode?: 'default' | 'remote'): Promise<ProcessorOptions>;
14
14
  }
15
15
 
16
16
  interface BaseCollectionEntry {
@@ -27,7 +27,6 @@ interface MarkdownProps {
27
27
  body: FC<MDXProps>;
28
28
  structuredData: StructuredData;
29
29
  toc: TableOfContents;
30
- _exports: Record<string, unknown>;
31
30
  /**
32
31
  * Only available when `lastModifiedTime` is enabled on MDX loader
33
32
  */
@@ -40,10 +39,17 @@ interface RuntimeFile {
40
39
  interface AsyncRuntimeFile {
41
40
  info: FileInfo;
42
41
  data: Record<string, unknown>;
43
- content: string;
42
+ content: {
43
+ matter: string;
44
+ body: string;
45
+ };
44
46
  lastModified?: Date;
45
47
  }
46
48
  type DocOut<Schema extends StandardSchemaV1> = Override<MarkdownProps & {
49
+ /**
50
+ * Other exports in the compiled Markdown/MDX file
51
+ */
52
+ _exports: Record<string, unknown>;
47
53
  /**
48
54
  * Read the original content of file from file system.
49
55
  */
@@ -65,7 +71,7 @@ interface Runtime {
65
71
  }
66
72
  type AsyncDocOut<Schema extends StandardSchemaV1> = StandardSchemaV1.InferOutput<Schema> & BaseCollectionEntry & {
67
73
  content: string;
68
- load: () => Promise<MarkdownProps>;
74
+ load: () => Promise<MarkdownProps & Record<string, unknown>>;
69
75
  };
70
76
  interface RuntimeAsync {
71
77
  doc: <C>(files: AsyncRuntimeFile[], collection: string, config: LoadedConfig) => C extends DocCollection<infer Schema, true> ? AsyncDocOut<Schema>[] : never;