From 022f510369688084af5bcf314a97fd332d7ee265 Mon Sep 17 00:00:00 2001 From: Quentin Gliech Date: Tue, 4 Feb 2020 22:03:21 +0100 Subject: webui: convert more things to typescript --- webui/src/Content.tsx | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 webui/src/Content.tsx (limited to 'webui/src/Content.tsx') diff --git a/webui/src/Content.tsx b/webui/src/Content.tsx new file mode 100644 index 00000000..9683f478 --- /dev/null +++ b/webui/src/Content.tsx @@ -0,0 +1,25 @@ +import unified from 'unified'; +import parse from 'remark-parse'; +import html from 'remark-html'; +import remark2react from 'remark-react'; +import { ReactNode } from 'react'; +import ImageTag from './tag/ImageTag'; +import PreTag from './tag/PreTag'; + +type Props = { markdown: string }; +const Content = ({ markdown }: Props) => { + const processor = unified() + .use(parse) + .use(html) + .use(remark2react, { + remarkReactComponents: { + img: ImageTag, + pre: PreTag, + }, + }); + + const contents: ReactNode = processor.processSync(markdown).contents; + return contents; +}; + +export default Content; -- cgit From 9ddcb4b09215f942cb7889f9756d426ad3c90253 Mon Sep 17 00:00:00 2001 From: Quentin Gliech Date: Tue, 11 Feb 2020 20:54:01 +0100 Subject: webui: force import order --- webui/src/Content.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'webui/src/Content.tsx') diff --git a/webui/src/Content.tsx b/webui/src/Content.tsx index 9683f478..889c9987 100644 --- a/webui/src/Content.tsx +++ b/webui/src/Content.tsx @@ -1,8 +1,9 @@ -import unified from 'unified'; -import parse from 'remark-parse'; +import { ReactNode } from 'react'; import html from 'remark-html'; +import parse from 'remark-parse'; import remark2react from 'remark-react'; -import { ReactNode } from 'react'; +import unified from 'unified'; + import ImageTag from './tag/ImageTag'; import PreTag from './tag/PreTag'; -- cgit From c2d18b3a9bec9933d2845ce3cfc6dd5b4f3ff348 Mon Sep 17 00:00:00 2001 From: Quentin Gliech Date: Wed, 12 Feb 2020 22:22:43 +0100 Subject: webui: fix Content type --- webui/src/Content.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'webui/src/Content.tsx') diff --git a/webui/src/Content.tsx b/webui/src/Content.tsx index 889c9987..3a7af2f8 100644 --- a/webui/src/Content.tsx +++ b/webui/src/Content.tsx @@ -1,4 +1,4 @@ -import { ReactNode } from 'react'; +import React from 'react'; import html from 'remark-html'; import parse from 'remark-parse'; import remark2react from 'remark-react'; @@ -8,7 +8,7 @@ import ImageTag from './tag/ImageTag'; import PreTag from './tag/PreTag'; type Props = { markdown: string }; -const Content = ({ markdown }: Props) => { +const Content: React.FC = ({ markdown }: Props) => { const processor = unified() .use(parse) .use(html) @@ -19,8 +19,8 @@ const Content = ({ markdown }: Props) => { }, }); - const contents: ReactNode = processor.processSync(markdown).contents; - return contents; + const contents: React.ReactNode = processor.processSync(markdown).contents; + return <>{contents}; }; export default Content; -- cgit