import { unified } from "unified"; import remarkParse from "remark-parse"; import remarkGfm from "remark-gfm"; import remarkRehype from "remark-rehype"; import rehypeRaw from "rehype-raw"; import rehypeReact from "rehype-react"; import * as jsxRuntime from "react/jsx-runtime"; export async function renderMarkdown(content: string): Promise { const file = await unified() .use(remarkParse) .use(remarkGfm) .use(remarkRehype, { allowDangerousHtml: true }) .use(rehypeRaw) .use(rehypeReact, { Fragment: jsxRuntime.Fragment, jsx: jsxRuntime.jsx, jsxs: jsxRuntime.jsxs, }) .process(content); return file.result as React.ReactNode; }