2020-10-07 09:41:58 -07:00
|
|
|
import ReactMarkdown from 'react-markdown';
|
2020-07-05 17:20:10 -07:00
|
|
|
import {
|
|
|
|
List,
|
|
|
|
ListItem,
|
|
|
|
Heading,
|
|
|
|
Link,
|
|
|
|
CodeBlock,
|
|
|
|
TableData,
|
|
|
|
Paragraph,
|
|
|
|
InlineCode,
|
|
|
|
Divider,
|
2020-10-07 09:41:58 -07:00
|
|
|
Table,
|
2020-11-29 01:25:48 -07:00
|
|
|
} from './elements';
|
2020-07-05 17:20:10 -07:00
|
|
|
|
2020-11-29 01:25:48 -07:00
|
|
|
import type { ReactMarkdownProps } from 'react-markdown';
|
|
|
|
import type { TMarkdown } from './types';
|
2020-10-19 08:17:10 -07:00
|
|
|
|
2020-11-29 01:25:48 -07:00
|
|
|
const renderers = {
|
2020-07-05 17:20:10 -07:00
|
|
|
paragraph: Paragraph,
|
|
|
|
link: Link,
|
|
|
|
heading: Heading,
|
|
|
|
inlineCode: InlineCode,
|
|
|
|
list: List,
|
|
|
|
listItem: ListItem,
|
|
|
|
thematicBreak: Divider,
|
|
|
|
code: CodeBlock,
|
|
|
|
table: Table,
|
2020-10-07 09:41:58 -07:00
|
|
|
tableCell: TableData,
|
2020-11-29 01:25:48 -07:00
|
|
|
} as ReactMarkdownProps['renderers'];
|
2020-07-05 17:20:10 -07:00
|
|
|
|
2020-11-29 01:25:48 -07:00
|
|
|
export const Markdown = (props: TMarkdown) => (
|
|
|
|
<ReactMarkdown renderers={renderers} source={props.content} />
|
2020-10-19 08:17:10 -07:00
|
|
|
);
|