From 8b85780d76ad45675582f4478eedb026b7ac25e1 Mon Sep 17 00:00:00 2001
From: Quentin Gliech <quentingliech@gmail.com>
Date: Thu, 13 Feb 2020 00:53:29 +0100
Subject: webui: start reorganizing the component structure

---
 webui/src/components/Content/index.tsx | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 webui/src/components/Content/index.tsx

(limited to 'webui/src/components/Content/index.tsx')

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;
-- 
cgit 

