fumadocs-mdx 15.5.0 → 15.5.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/press.d.ts CHANGED
@@ -1,10 +1,14 @@
1
+ import { LoaderConfig, Page } from "fumadocs-core/source";
1
2
  import { MDXComponents } from "mdx/types";
2
3
  import { Plugin } from "fumadocs-core/framework/plugin";
3
- export interface MdxPluginOptions {
4
- /** MDX components of the page body and its processed Markdown, relative links in `a` resolve to the URLs of their pages */
5
- components?: MDXComponents;
4
+ export interface MdxPluginOptions<P extends Page = Page> {
5
+ /**
6
+ * MDX components of the page body and its processed Markdown, or a function returning those of a page; relative links in
7
+ * `a` resolve to the URLs of their pages
8
+ */
9
+ components?: MDXComponents | ((page: P) => MDXComponents);
6
10
  }
7
11
  /**
8
12
  * Render the pages of Fumadocs MDX collections: their body, Markdown, table of contents, structured data and dates.
9
13
  */
10
- export default function mdxPlugin({ components }?: MdxPluginOptions): Plugin;
14
+ export default function mdxPlugin<Config extends LoaderConfig = LoaderConfig>({ components: componentsOption }?: MdxPluginOptions<Config['page']>): Plugin<Config>;
package/dist/press.js CHANGED
@@ -3,10 +3,11 @@ import { createElement } from "react";
3
3
  /**
4
4
  * Render the pages of Fumadocs MDX collections: their body, Markdown, table of contents, structured data and dates.
5
5
  */
6
- function mdxPlugin({ components } = {}) {
7
- const Link = components?.a ?? "a";
6
+ function mdxPlugin({ components: componentsOption } = {}) {
8
7
  async function getComponents(ctx, page) {
9
8
  const loader = await ctx.getLoader();
9
+ const components = typeof componentsOption === "function" ? componentsOption(page) : componentsOption;
10
+ const Link = components?.a ?? "a";
10
11
  return {
11
12
  ...components,
12
13
  a: (props) => createElement(Link, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-mdx",
3
- "version": "15.5.0",
3
+ "version": "15.5.1",
4
4
  "description": "The built-in source for Fumadocs",
5
5
  "keywords": [
6
6
  "Docs",
@@ -84,7 +84,7 @@
84
84
  "@types/picomatch": "^4.0.3",
85
85
  "@types/react": "^19.3.0",
86
86
  "@vitejs/plugin-rsc": "^0.5.38",
87
- "fumadocs-core": "16.18.0",
87
+ "fumadocs-core": "16.18.2",
88
88
  "mdast-util-directive": "^3.1.1",
89
89
  "next": "^16.4.2",
90
90
  "react": "^19.3.1",