UNPKG

744 BTypeScriptView Raw
1/**
2 * Copyright (c) 2021 GraphQL Contributors.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8import React from 'react';
9import MD from 'markdown-it';
10import { Maybe } from '../../types';
11
12const md = new MD({
13 // render urls as links, à la github-flavored markdown
14 breaks: true,
15 linkify: true,
16});
17
18type MarkdownContentProps = {
19 markdown?: Maybe<string>;
20 className?: string;
21};
22
23export 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}