Skip to main content

    Add Graphs to MDX

    Mermaid Library

    To generate graphs in MDX files, we need to use the mermaid library. We forked the gatsby-remark-graph plugin and modified it to work with MDX files. You can see the contents of the modified plugin in /plugins/remarks/gatsby-remark-mdx-mermaid/

    This current file (src/pages/getting-started/add-graphs-to-mdx.mdx) is an example of how to implement graphs in MDX.

    Example code

    Markdown

    ```mermaid
    graph LR
        A[Square Rect] -- Link text --> B((Circle))
        A --> C(Round Rect)
        B --> D{Rhombus}
        C --> D
    ```
    

    HTML Output

    Link text
    Square Rect
    Circle
    Round Rect
    Rhombus