import type { MDXComponents } from 'mdx/types'
import { Callout } from '@/components/ui/Callout'
export function useMDXComponents(components: MDXComponents): MDXComponents {
return {
...components,
Callout,
// Typography
h1: (props) => (
{props.children}
),
h2: (props) => (
{props.children}
),
h3: (props) => (
{props.children}
),
h4: ({ children, ...props }) => (
{children}
),
h5: ({ children, ...props }) => (
{children}
),
h6: ({ children, ...props }) => (
{children}
),
p: ({ children }) => (
{children}
),
blockquote: ({ children }) => (
{children}
),
hr: () =>
,
a: ({ href, children, ...props }) => {
const isExternal = typeof href === 'string' && (href.startsWith('http://') || href.startsWith('https://'))
return (
{children}
)
},
code: ({ children, className, ...props }: { children: React.ReactNode; className?: string }) => {
const isInline = !className?.includes('language-');
if (isInline) {
return (
{children}
);
}
return ;
},
pre: ({ children, ...props }: { children: React.ReactNode } & React.HTMLAttributes) => (
{children}
),
img: ({ src, alt, ...rest }) => (
),
table: ({ children }) => (
),
// Lists
ul: (props) => ,
ol: (props) =>
,
li: (props) => ,
// Figures and captions
figure: (props) => ,
figcaption: (props) => ,
// Subscripts and superscripts
sup: (props) => ,
sub: (props) => ,
// Keyboard keys
kbd: (props) => (
),
// Collapsible sections
details: (props) => ,
summary: (props) => ,
}
}