mermaid: refactor config to use mermaid_config.js include, only require mermaid.version in _config.yml (#909)

This PR has a bit of scope creep! This PR now:

- changes the mermaid opt-in logic to only check for the existence of a `mermaid` key instead of `mermaid != false`: this resolves the follow-up in #857
- changes the behaviour of mermaid configuration
    - instead of using `mermaid_init.html` with default settings, makes the include `mermaid_config.js`
    - the include is loaded directly into the contents of `mermaid_initialize`
    - by default, it is an empty object (i.e. `{}`), triggering the defaults
- updates docs
- adds an example to the markdown kitchen sink  

It does significantly change the interface provided in #857, and I apologize for the confusion. However, given the discussion in this PR, I think it's the best move forward!
This commit is contained in:
Matt Wang
2022-08-11 19:34:15 -07:00
committed by GitHub
parent 1d15ea3b84
commit e2f1546c61
8 changed files with 66 additions and 101 deletions

View File

@@ -51,26 +51,14 @@ 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
# To enable support for mermaid diagrams (https://mermaid-js.github.io/mermaid/),
# uncomment the `mermaid` and `version` keys below
# mermaid:
# # Version of mermaid library
# # Pick an available version from https://cdn.jsdelivr.net/npm/mermaid/
# version: "9.1.3"
# # Put any additional configuration, such as setting the theme, in _includes/mermaid_config.js
# # See also docs/ui-components/code
# Enable or disable heading anchors
heading_anchors: true