Skip to content
Snippets Groups Projects
Unverified Commit b2bbdb70 authored by Christian Bäuerlein's avatar Christian Bäuerlein Committed by GitHub
Browse files

Add configuration key to load a local version of mermaid (#1153)

Hi there!

Thank you for the great theme! I am a happy user and was delighted to see that mermaid support has landed.

In some cases the usage of jsDelivr might not be possible for technical or compliance reasons.

This commit adds a second way to include the mermaid lib by specifying a path in the mermaid config. This way a local version of the lib can be used.

It should be fully backwards compatible, not requiring any action by users that already include the lib from the CDN.

I already added some documentation, but I am also happy to extend this, if this change is generally well-received.

Cheers,
Christian
parent cf72c436
No related branches found
No related tags found
No related merge requests found
......@@ -85,6 +85,8 @@ mermaid:
version: "9.1.6"
# Put any additional configuration, such as setting the theme, in _includes/mermaid_config.js
# See also docs/ui-components/code
# To load mermaid from a local file use the `path` key to specify the location of the library instead; e.g.
# path: "/assets/js/mermaid.min.js"
# Enable or disable heading anchors
heading_anchors: true
......
......@@ -23,13 +23,17 @@
{% endif %}
{% if site.mermaid %}
<script src="https://cdn.jsdelivr.net/npm/mermaid@{{ site.mermaid.version }}/dist/mermaid.min.js"></script>
{% if site.mermaid.path %}
<script src="{{ site.mermaid.path | relative_url }}"></script>
{% else %}
<script src="https://cdn.jsdelivr.net/npm/mermaid@{{ site.mermaid.version }}/dist/mermaid.min.js"></script>
{% endif %}
{% endif %}
<script src="{{ '/assets/js/just-the-docs.js' | relative_url }}"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
{% for file in site.static_files %}
{% if file.path == site.favicon_ico or file.path == '/favicon.ico' %}
{% assign favicon = true %}
......
......@@ -83,6 +83,8 @@ mermaid:
version: "9.1.3"
```
Provide a `path` instead of a `version` key to load the mermaid library from a local file.
See [the Code documentation]({% link docs/ui-components/code.md %}#mermaid-diagram-code-blocks) for more configuration options and information.
## Aux links
......
......@@ -148,6 +148,16 @@ graph TD;
*Note: for demonstration purposes, we've enabled mermaid on this site. It is still disabled by default, and users need to opt-in to use it.*
### Using a local mermaid library
In order to use a local version of the mermaid library instead of one provided by jsDelivr, you can specify a `path` key in the mermaid configuration instead of a `version` key.
```yaml
mermaid:
# To load mermaid from a local file use the `path` key to specify the location of the library instead; e.g.
path: "/assets/js/mermaid.min.js"
```
## Copy button
{: .d-inline-block }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment