Itay4 / mdx-mermaid

Plug and play Mermaid in MDX

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mdx-mermaid

Plug and play Mermaid in MDX

npm version GitHub license build codecov Maintainability PRs Welcome

Use Mermaid in .md, .mdx, .jsx and .tsx files with ease.

Based off the answer here by unknown.

More documentation available here

Quick start with Docusaurus

Install mdx-mermaid and mermaid

mermaid is a peer dependency so you can specify the version to use

yarn add mdx-mermaid mermaid

Update docusaurus.config.js

 presets: [
    [
      '@docusaurus/preset-classic',
      {
        docs: {
          remarkPlugins: [require('mdx-mermaid')],

Use code blocks in .md or .mdx files:

```mermaid
graph TD;
    A-->B;
    A-->C;
    B-->D;
    C-->D;
```

Use the component in .mdx, .jsx or .tsx files:

import { Mermaid } from 'mdx-mermaid/Mermaid';

<Mermaid chart={`graph TD;
    A-->B;
    A-->C;
    B-->D;
    C-->D;
`} />

There are more examples here

License

MIT © Samuel Wall

About

Plug and play Mermaid in MDX

License:MIT License


Languages

Language:Shell 45.5%Language:TypeScript 44.4%Language:Dockerfile 4.0%Language:HTML 3.1%Language:CSS 1.7%Language:JavaScript 1.4%