diff --git a/_config.yml b/_config.yml index b9571a0..68098e5 100644 --- a/_config.yml +++ b/_config.yml @@ -82,8 +82,6 @@ search: # For copy button on code enable_copy_code_button: true -# To disable support for mermaid diagrams (https://mermaid.js.org), -# comment out the `mermaid` and `version` keys below # By default, consuming the theme as a gem leaves mermaid disabled; it is opt-in mermaid: # Version of mermaid library @@ -91,8 +89,12 @@ 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. + # To load mermaid from a local library, also use the `path` key to specify the location of the library; e.g. + # for (v10+): + # path: "/assets/js/mermaid.esm.min.mjs" + # for (= 10; if not, we fall back to the previous init syntax. + +If a user is using a custom mermaid file and doesn't specify a version, we default to the < v10 behaviour. Users who use version v10 or above should specify this in the version key. +{% endcomment %} + +{% if site.mermaid.version %} + {% assign mermaid_major_version = site.mermaid.version | split: "." | first | plus: 0 %} +{% else %} + {% assign mermaid_major_version = 9 %} +{% endif %} + +{% if mermaid_major_version > 9 %} + + + +{% else %} + +{% if site.mermaid.path %} + +{% else %} + +{% endif %} + + +{% endif %} diff --git a/_includes/head.html b/_includes/head.html index 9f38d0f..d61f53f 100644 --- a/_includes/head.html +++ b/_includes/head.html @@ -22,14 +22,6 @@ {% endif %} - {% if site.mermaid %} - {% if site.mermaid.path %} - - {% else %} - - {% endif %} - {% endif %} - diff --git a/docs/ui-components/code.md b/docs/ui-components/code.md index 9a4df73..e907e2f 100644 --- a/docs/ui-components/code.md +++ b/docs/ui-components/code.md @@ -150,14 +150,24 @@ graph TD; ### 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. +To load a local version of mermaid, also use the `path` key to specify the location of the library; e.g. ```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" + version: "10.1.0" + # for (v10+) + path: "/assets/js/mermaid.esm.min.mjs" + # for (=10`, this file is imported directly as an ESM module (rather than as a plain `