1+ import type { MDXComponents } from "mdx/types" ;
12import Blockquote from "@/components/blockquote" ;
23import ButtonLinks from "@/components/button-links" ;
34import Callout , {
@@ -9,7 +10,6 @@ import Callout, {
910} from "@/components/callout" ;
1011import CardLinks from "@/components/card-links" ;
1112import CodeBlock from "@/components/codeblock" ;
12- import s from "@/components/custom-mdx/CustomMDX.module.css" ;
1313import DonateCard from "@/components/donate-card" ;
1414import GitHub from "@/components/github" ;
1515import { processGitHubLinks } from "@/components/github/mdx" ;
@@ -19,7 +19,13 @@ import SponsorCard from "@/components/sponsor-card";
1919import { BodyParagraph , LI } from "@/components/text" ;
2020import VTSequence from "@/components/vt-sequence" ;
2121import Video from "@/components/video" ;
22- import { isValidElement , type ReactElement } from "react" ;
22+ import s from "@/lib/docs/docs-mdx.module.css" ;
23+ import {
24+ isValidElement ,
25+ type ComponentPropsWithoutRef ,
26+ type ImgHTMLAttributes ,
27+ type ReactElement ,
28+ } from "react" ;
2329
2430type MermaidCodeElement = {
2531 className ?: string ;
@@ -33,35 +39,35 @@ function isReactElement(
3339 return isValidElement ( children ) ;
3440}
3541
36- // mdxComponents defines the React component map used by docs MDX compilation .
37- export const mdxComponents = {
38- h1 : ( props : React . ComponentPropsWithoutRef < "h1" > ) => (
42+ // mdxComponents defines the React component map used while rendering docs MDX.
43+ const mdxComponents : MDXComponents = {
44+ h1 : ( props : ComponentPropsWithoutRef < "h1" > ) => (
3945 < JumplinkHeader { ...props } as = "h1" />
4046 ) ,
41- h2 : ( props : React . ComponentPropsWithoutRef < "h2" > ) => (
47+ h2 : ( props : ComponentPropsWithoutRef < "h2" > ) => (
4248 < JumplinkHeader { ...props } as = "h2" />
4349 ) ,
44- h3 : ( props : React . ComponentPropsWithoutRef < "h3" > ) => (
50+ h3 : ( props : ComponentPropsWithoutRef < "h3" > ) => (
4551 < JumplinkHeader { ...props } as = "h3" />
4652 ) ,
47- h4 : ( props : React . ComponentPropsWithoutRef < "h4" > ) => (
53+ h4 : ( props : ComponentPropsWithoutRef < "h4" > ) => (
4854 < JumplinkHeader { ...props } as = "h4" />
4955 ) ,
50- h5 : ( props : React . ComponentPropsWithoutRef < "h5" > ) => (
56+ h5 : ( props : ComponentPropsWithoutRef < "h5" > ) => (
5157 < JumplinkHeader { ...props } as = "h5" />
5258 ) ,
53- h6 : ( props : React . ComponentPropsWithoutRef < "h6" > ) => (
59+ h6 : ( props : ComponentPropsWithoutRef < "h6" > ) => (
5460 < JumplinkHeader { ...props } as = "h6" />
5561 ) ,
56- li : ( props : React . ComponentPropsWithoutRef < "li" > ) => {
62+ li : ( props : ComponentPropsWithoutRef < "li" > ) => {
5763 const processedChildren = processGitHubLinks ( props . children ) ;
5864 return < LI { ...props } > { processedChildren } </ LI > ;
5965 } ,
60- p : ( props : React . ComponentPropsWithoutRef < "p" > ) => {
66+ p : ( props : ComponentPropsWithoutRef < "p" > ) => {
6167 const processedChildren = processGitHubLinks ( props . children ) ;
6268 return < BodyParagraph { ...props } > { processedChildren } </ BodyParagraph > ;
6369 } ,
64- code : ( props : React . ComponentPropsWithoutRef < "code" > ) => {
70+ code : ( props : ComponentPropsWithoutRef < "code" > ) => {
6571 if ( ! props . className ) {
6672 return < code { ...props } /> ;
6773 }
@@ -75,7 +81,7 @@ export const mdxComponents = {
7581
7682 return < code { ...props } /> ;
7783 } ,
78- pre : ( props : React . ComponentPropsWithoutRef < "pre" > ) => {
84+ pre : ( props : ComponentPropsWithoutRef < "pre" > ) => {
7985 const { children } = props ;
8086 if ( isReactElement ( children ) ) {
8187 const className = children . props ?. className ;
@@ -93,7 +99,7 @@ export const mdxComponents = {
9399 return < CodeBlock { ...props } /> ;
94100 } ,
95101 blockquote : Blockquote ,
96- img : ( props : React . ImgHTMLAttributes < HTMLImageElement > ) => (
102+ img : ( props : ImgHTMLAttributes < HTMLImageElement > ) => (
97103 // biome-ignore lint/performance/noImgElement: Docs content deliberately uses plain img tags.
98104 < img className = { s . image } src = { props . src } alt = { props . alt } />
99105 ) ,
@@ -115,3 +121,11 @@ export const mdxComponents = {
115121 < Mermaid { ...props } />
116122 ) ,
117123} ;
124+
125+ // useMDXComponents returns the component map that Next.js uses while rendering MDX files.
126+ export function useMDXComponents ( components : MDXComponents ) : MDXComponents {
127+ return {
128+ ...mdxComponents ,
129+ ...components ,
130+ } ;
131+ }
0 commit comments