this repo has no description
1import { unified } from "unified";
2import remarkParse from "remark-parse";
3import remarkGfm from "remark-gfm";
4import remarkRehype from "remark-rehype";
5import rehypeRaw from "rehype-raw";
6import rehypeReact from "rehype-react";
7import * as jsxRuntime from "react/jsx-runtime";
8
9export async function renderMarkdown(content: string): Promise<React.ReactNode> {
10 const file = await unified()
11 .use(remarkParse)
12 .use(remarkGfm)
13 .use(remarkRehype, { allowDangerousHtml: true })
14 .use(rehypeRaw)
15 .use(rehypeReact, {
16 Fragment: jsxRuntime.Fragment,
17 jsx: jsxRuntime.jsx,
18 jsxs: jsxRuntime.jsxs,
19 })
20 .process(content);
21
22 return file.result as React.ReactNode;
23}