simple-fs-server/islands/MarkdownRenderer.tsx

14 lines
447 B
TypeScript
Raw Normal View History

2023-01-05 18:18:07 +09:00
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 = "";
}
const index = text.indexOf('\n---', 3);
const c = text.slice(index + 4, text.length);
return <div class="markdown-body" dangerouslySetInnerHTML={{ __html: marked.parse(c) }} />;
}
export default MarkdownRenderer;