diff --git a/_config.yml b/_config.yml index 65c2280..b0f9310 100644 --- a/_config.yml +++ b/_config.yml @@ -51,6 +51,27 @@ search: # Supports true or false (default) button: false +# Enable or disable support for mermaid diagrams (https://mermaid-js.github.io/mermaid/) +# Supports true or false (default) +mermaid_enabled: false +mermaid: + # Version of mermaid library + # Pick an available version from https://cdn.jsdelivr.net/npm/mermaid/ + version: "9.1.3" + # Configured theme of mermaid diagrams + # Pick an avaiable theme from https://mermaid-js.github.io/mermaid/#/theming + theme: "default" + # Additional configuration available matching pattern as defined in https://mermaid-js.github.io/mermaid/#/./Setup. + # For example, + # logLevel: 'fatal', + # sequence: + # diagramMarginX: 50 + # actorMargin: 50 + # gantt: + # barGap: 4 + # topPadding: 50 + + # Enable or disable heading anchors heading_anchors: true diff --git a/_includes/head.html b/_includes/head.html index d26a42a..1b4f7b7 100644 --- a/_includes/head.html +++ b/_includes/head.html @@ -29,6 +29,11 @@ {% if site.search_enabled != false %} {% endif %} + + {% if site.mermaid_enabled != false %} + + {% endif %} + diff --git a/_includes/mermaid_init.html b/_includes/mermaid_init.html new file mode 100644 index 0000000..327dfdf --- /dev/null +++ b/_includes/mermaid_init.html @@ -0,0 +1,58 @@ + diff --git a/_layouts/default.html b/_layouts/default.html index efaa1e5..63e23b0 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -214,4 +214,7 @@ layout: table_wrappers {% endif %} +{% if site.mermaid_enabled != false %} + {%- include mermaid_init.html -%} +{% endif %} diff --git a/_sass/code.scss b/_sass/code.scss index a479c70..6ad832f 100644 --- a/_sass/code.scss +++ b/_sass/code.scss @@ -139,4 +139,11 @@ figure.highlight { } } +// Mermaid diagram code blocks should be left unstyled. +code.language-mermaid { + padding: 0; + background-color: inherit; + border: 0; +} + // {% endraw %} diff --git a/docs/configuration.md b/docs/configuration.md index e1ba544..cb0b7fd 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -59,6 +59,31 @@ search: button: false ``` +## Mermaid Diagrams +See [Code]({{ site.baseurl }}{% link docs/ui-components/code.md %}#mermaid-diagram-code-blocks) for more information. + +```yaml +# Enable or disable support for mermaid diagrams (https://mermaid-js.github.io/mermaid/) +# Supports true or false (default) +mermaid_enabled: false +mermaid: + # Version of mermaid library + # Pick an available version from https://cdn.jsdelivr.net/npm/mermaid/ + version: "9.1.3" + # Configured theme of mermaid diagrams + # Pick an avaiable theme from https://mermaid-js.github.io/mermaid/#/theming + theme: "default" + # Additional configuration available matching pattern as defined in https://mermaid-js.github.io/mermaid/#/./Setup. + # For example, + # logLevel: 'fatal', + # sequence: + # diagramMarginX: 50 + # actorMargin: 50 + # gantt: + # barGap: 4 + # topPadding: 50 +``` + ## Aux links ```yaml diff --git a/docs/ui-components/code.md b/docs/ui-components/code.md index b8136a3..0ea9b71 100644 --- a/docs/ui-components/code.md +++ b/docs/ui-components/code.md @@ -86,3 +86,21 @@ To demonstrate front end code, sometimes it's useful to show a rendered example [Link button](http://example.com/){: .btn } ``` {% endhighlight %} + +--- + +## Mermaid diagram code blocks + +[Mermaid](https://mermaid-js.github.io/mermaid/) allows you to add diagrams and visualizations using Markdown code blocks. You can turn on support for mermaid by adding `mermaid_enabled: true` to your \_config.yml. + +The markdown for a simple flowchart example might look like the following: + +{% highlight markdown %} +```mermaid +graph TD; + A-->B; + A-->C; + B-->D; + C-->D; +``` +{% endhighlight %}