1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | import React from 'react';
|
9 | import MD from 'markdown-it';
|
10 | import { Maybe } from '../../types';
|
11 |
|
12 | const md = new MD({
|
13 |
|
14 | breaks: true,
|
15 | linkify: true,
|
16 | });
|
17 |
|
18 | type MarkdownContentProps = {
|
19 | markdown?: Maybe<string>;
|
20 | className?: string;
|
21 | };
|
22 |
|
23 | export default function MarkdownContent({
|
24 | markdown,
|
25 | className,
|
26 | }: MarkdownContentProps) {
|
27 | if (!markdown) {
|
28 | return <div />;
|
29 | }
|
30 |
|
31 | return (
|
32 | <div
|
33 | className={className}
|
34 | dangerouslySetInnerHTML={{ __html: md.render(markdown) }}
|
35 | />
|
36 | );
|
37 | }
|