Skip to content

Conversation

@asokolsky
Copy link

#825

_config.yaml options added:

# Enable support for mermaid, defaults to true
mermaid_enabled: true
# pick from https://cdnjs.com/libraries/mermaid
mermaid_version: "9.0.0"
# choices: https://mermaid-js.github.io/mermaid/#/theming
mermaid_theme: "forest"

@pdmosses
Copy link
Contributor

pdmosses commented Apr 30, 2022

@asokolsky thanks for the PR! Unfortunately, Jekyll doesn't pick up your default settings from _config.yml when I use your branch as a remote theme. For building my test site, I have this in my _config.yml:

remote_theme: asokolsky/just-the-docs@issue825

For building locally, I have also this in my Gemfile:

gem "just-the-docs", github: "asokolsky/just-the-docs", branch: "issue825"

I haven't added any mermaid settings in _config.yml. The Javascript console reports:

Failed to load resource: the server responded with a status of 404 ()
https://cdnjs.cloudflare.com/ajax/libs/mermaid//mermaid.min.js

Also the variable mermaid wasn't found, and the graph in my test file doesn't appear.

I'm not sure how Jekyll determines just which settings from the theme's _config.yml to use. (For the search feature, it's enabled by default, but all further settings for it are optional, so it's irrelevant whether they have default settings.)

Unless any of the other @just-the-docs/maintainers have better suggestions, you should probably make mermaid_enabled false by default. That would also have the benefit of not loading the Mermaid JS on sites that don't use Mermaid.

@dougaitken
Copy link
Contributor

you should probably make mermaid_enabled false by default. That would also have the benefit of not loading the Mermaid JS on sites that don't use Mermaid.

Agreed - let's not ship a change like this to be on by default. This should be consciously toggled on by users.

@mattxwang
Copy link
Member

Definitely agree to keep it off by default. Could we also add a bit more to the documentation to explain what Mermaid is, and how to enable it / various configuration options?

@adfoster-r7
Copy link

This would be great functionality to add - let me know if there's any help needed 👍

@adfoster-r7
Copy link

adfoster-r7 commented May 20, 2022

This might be my fault, but when testing this locally it looks like we'd need to make the pre tag styling hidden by default otherwise there's a grey box that appears beneath the mermaid diagram:

image

Edit: Looks like it's the code block which has the styling by default:

code {
padding: 0.2em 0.15em;
font-weight: 400;
background-color: $code-background-color;
border: $border $border-color;
border-radius: $border-radius;
}

Potentially we could just add an extra rule to override the theme for mermaid diagrams:

code.language-mermaid {
  padding: 0;
  background-color: inherit;
  border: none
}

That combined with changing the theme to default would give:

image

# pick from https://cdnjs.com/libraries/mermaid
mermaid_version: "9.0.0"
# choices: https://mermaid-js.github.io/mermaid/#/theming
mermaid_theme: "forest"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mermaid_theme: "forest"
mermaid_theme: "default"

I think the default theme compliments the site's existing color set better 👀

Before

image

After

image

@nascosto nascosto mentioned this pull request Jun 8, 2022
@mattxwang
Copy link
Member

mattxwang commented Jul 5, 2022

For now, closing this in favour of #857. Feel free to reopen!

@mattxwang mattxwang closed this Jul 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants