import { CodeBlock } from '@/components/code-block';
import { Enumeration, EnumerationItem } from '@/components/enumeration';
import { SmartImage } from '@/components/smart-image';
import { InlineCode } from '@/components/inline-code';
import { Paragraph } from '@/components/paragraph';
import { QuoteBlock } from '@/components/quote-block';
import { SmartLink } from '@/components/smart-link';
import { Box, Checkbox, Divider, Stack, Table, Typography } from '@mui/joy';
import type { MDXComponents } from 'mdx/types';
import React from 'react';
// This file allows you to provide custom React components
// to be used in MDX files. You can import and use any
// React component you want, including inline styles,
// components from other libraries, and more.
export function useMDXComponents(components: MDXComponents): MDXComponents {
return {
// Allows customizing built-in components, e.g. to add styling.
h1: (props) => (
),
h2: (props) => (
),
h3: (props) => (
),
h4: (props) => (
),
h5: (props) => (
),
h6: (props) => (
),
p: (props) => (
),
a: (props) => (
),
img: (props) => {
const { alt, ...imageProps } = props;
const regexResult = alt?.match(/(.*)\|([0-9]*)x([0-9]*)$/);
return (
);
},
table: (props) => (
),
ul: (props) => (
),
li: (props) => {
const isTaskListItem = !!props.className?.includes('task-list-item');
return (
{isTaskListItem ? (props.children as any).slice(2) : props.children}
);
},
hr: (props) => (
),
blockquote: (props) => (
),
pre: (props) => {
const additionalProps: Partial> = {};
const child: any = props?.children;
const codeNodeProps = typeof child === "string" ? props : child?.props;
const classes: string[] = codeNodeProps?.className?.split(' ') ?? [];
let parsedLanguage = classes.find((c: string) => c.startsWith('language-'))?.substring(9);
if (parsedLanguage?.startsWith('#')) {
parsedLanguage = parsedLanguage.substring(1);
additionalProps.lineNumbers = true;
}
if (parsedLanguage) {
additionalProps.language = parsedLanguage;
}
additionalProps.code = `${codeNodeProps?.children}`.replace(/\n$/, '');
return (
);
},
code: (props) => (
),
...components,
};
}