2024-04-19 23:34:42 +00:00
|
|
|
import { MDXRemote } from "remote-mdx/rsc";
|
2024-04-20 01:35:52 +00:00
|
|
|
import { ReactElement } from "react";
|
2024-04-20 01:59:07 +00:00
|
|
|
import { formatCode, formatHeading, formatLink, formatList } from "@/app/components/mdx-renderer";
|
2024-04-20 01:04:42 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The components to use in the MDX renderer.
|
|
|
|
*/
|
2024-04-19 23:34:42 +00:00
|
|
|
const components = {
|
2024-04-20 01:54:04 +00:00
|
|
|
h1: (props: any) => formatHeading(1, props),
|
|
|
|
h2: (props: any) => formatHeading(2, props),
|
|
|
|
h3: (props: any) => formatHeading(3, props),
|
|
|
|
h4: (props: any) => formatHeading(4, props),
|
|
|
|
h5: (props: any) => formatHeading(5, props),
|
|
|
|
h6: (props: any) => formatHeading(6, props),
|
|
|
|
code: (props: any) => formatCode(props),
|
|
|
|
ul: (props: any) => formatList(props),
|
|
|
|
a: (props: any) => formatLink(props),
|
2024-04-19 23:34:42 +00:00
|
|
|
};
|
|
|
|
|
2024-04-20 01:35:52 +00:00
|
|
|
export function CustomMDX(props: any): ReactElement {
|
2024-04-19 23:34:42 +00:00
|
|
|
return <MDXRemote {...props} components={{ ...components, ...(props.components || {}) }} />;
|
|
|
|
}
|