fumadocs-core
Version:
The React.js library for building a documentation website
31 lines (29 loc) • 684 B
JavaScript
import { visit } from "unist-util-visit";
//#region src/mdx-plugins/remark-mdx-mermaid.ts
function toMDX(code) {
return {
type: "mdxJsxFlowElement",
name: "Mermaid",
attributes: [{
type: "mdxJsxAttribute",
name: "chart",
value: code.trim()
}],
children: []
};
}
/**
* Convert `mermaid` codeblocks into `<Mermaid />` MDX component
*/
function remarkMdxMermaid(options = {}) {
const { lang = "mermaid" } = options;
return (tree) => {
visit(tree, "code", (node) => {
if (node.lang !== lang || !node.value) return;
Object.assign(node, toMDX(node.value));
});
};
}
//#endregion
export { remarkMdxMermaid };
//# sourceMappingURL=remark-mdx-mermaid.js.map