@alauda/doom
Version:
Doctor Doom making docs.
20 lines (19 loc) • 858 B
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import ReactMarkdown from 'react-markdown';
import rehypeRaw from 'rehype-raw';
import rehypeSanitize from 'rehype-sanitize';
import remarkGfm from 'remark-gfm';
import { X } from './_X.js';
const remarkPlugins = [remarkGfm];
const rehypePlugins = [rehypeRaw, rehypeSanitize];
const rehypeUnwrap = () => (tree) => {
if (tree.children.length !== 1) {
return;
}
const child = tree.children[0];
if (child.type === 'element' && child.tagName === 'p') {
tree.children = child.children;
}
};
const inlineRehypePlugins = [rehypeRaw, rehypeUnwrap, rehypeSanitize];
export const Markdown = ({ children, inline, }) => children && (_jsx(ReactMarkdown, { remarkPlugins: remarkPlugins, rehypePlugins: inline ? inlineRehypePlugins : rehypePlugins, components: X, children: children }));