forked from commune-ai/frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmdx-components.tsx
21 lines (19 loc) · 1.16 KB
/
mdx-components.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import classnames from 'classnames';
import classes from './mdx-components.module.css';
import type { MDXComponents } from 'mdx/types';
export function useMDXComponents(components: MDXComponents): MDXComponents {
return {
h1: ({ children }) => <h1 className={classes.h1}>{children}</h1>,
h2: ({ children }) => <h2 className={classes.h2}>{children}</h2>,
h3: ({ children }) => <h3 className={classes.h3}>{children}</h3>,
p: ({ children }) => <p className={classes.p}>{children}</p>,
a: ({ children, ...rest}) => <a className={classes.a} {...rest}>{children}</a>,
ol: ({ children, ...rest}) => <ol className={classes.ol} {...rest}>{children}</ol>,
ul: ({ children, ...rest}) => <ul className={classes.ul} {...rest}>{children}</ul>,
li: ({ children, ...rest}) => <li className={classes.li} {...rest}>{children}</li>,
code: ({ children, className, ...rest}) => <code className={classnames(className, classes.code)} {...rest}>{children}</code>,
pre: ({ children, ...rest}) => <pre className={classes.pre} {...rest}>{children}</pre>,
hr: ({ children, ...rest}) => <hr className={classes.hr} {...rest}>{children}</hr>,
...components,
}
}