import { MDXComponents } from "mdx/types";
import CodeBlock from "../elements/CodeBlock";
import H1 from "../layout/H1";
import H4 from "../layout/H4";
import React from "react";
import twuiSlugify from "../utils/slugify";
import H2 from "../layout/H2";
import P from "../layout/P";
import H3 from "../layout/H3";
type Params = {
components: MDXComponents;
codeBgColor?: string;
};
export function useMDXComponents(params?: Params) {
const codeBgColor = params?.codeBgColor || "#000000";
return {
components: {
h1: ({ children }) =>
{children}
,
h4: ({ children }) => {children}
,
pre: ({ children, ...props }) => {
if (React.isValidElement(children) && children.props) {
return (
// @ts-ignore
{/* @ts-ignore */}
{children.props.children}
);
}
return (
// @ts-ignore
{children}
);
},
h2: ({ children }) => {
const slug = twuiSlugify(children?.toString());
return (
{children}
);
},
h3: ({ children }) => {
const slug = twuiSlugify(children?.toString());
return (
{children}
);
},
img: (props) => (
// @ts-ignore
),
p: ({ children }) => (
{children}
),
li: ({ children }) => {children},
...params?.components,
} as MDXComponents,
codeBgColor: "rgb(7 12 22)",
};
}