diff options
Diffstat (limited to 'webui/src/components/Content/index.tsx')
-rw-r--r-- | webui/src/components/Content/index.tsx | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/webui/src/components/Content/index.tsx b/webui/src/components/Content/index.tsx new file mode 100644 index 00000000..56e52e1e --- /dev/null +++ b/webui/src/components/Content/index.tsx @@ -0,0 +1,26 @@ +import React from 'react'; +import html from 'remark-html'; +import parse from 'remark-parse'; +import remark2react from 'remark-react'; +import unified from 'unified'; + +import ImageTag from './ImageTag'; +import PreTag from './PreTag'; + +type Props = { markdown: string }; +const Content: React.FC<Props> = ({ markdown }: Props) => { + const processor = unified() + .use(parse) + .use(html) + .use(remark2react, { + remarkReactComponents: { + img: ImageTag, + pre: PreTag, + }, + }); + + const contents: React.ReactNode = processor.processSync(markdown).contents; + return <>{contents}</>; +}; + +export default Content; |