simple-fs-server/components/MarkdownRenderer.tsx
2023-01-06 22:17:45 +09:00

23 lines
517 B
TypeScript

import { marked } from "https://deno.land/x/marked@1.0.1/mod.ts";
export function MarkdownRenderer(props: { text: string | undefined }) {
let text = props.text;
if (text === undefined) {
text = "";
}
let c = text;
if (text.startsWith("---")) {
const index = text.indexOf("\n---", 3);
c = text.slice(index + 4, text.length);
}
return (
<div
class="markdown-body"
dangerouslySetInnerHTML={{ __html: marked.parse(c) }}
>
</div>
);
}
export default MarkdownRenderer;