Skip to content

Commit

Permalink
Pull in latest mermaid version by default
Browse files Browse the repository at this point in the history
  • Loading branch information
deining committed Feb 13, 2023
1 parent ac1b9ca commit efde633
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
6 changes: 2 additions & 4 deletions layouts/partials/scripts/mermaid.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
{{ $version := "9.3.0" -}}
{{ $version := cond ( ge hugo.Version "0.90.0" ) "latest" "9.3.0" -}}
{{ with .Site.Params.mermaid.version -}}
{{ $version = . -}}
{{ end -}}

{{ $cdnurl := printf "https://cdn.jsdelivr.net/npm/mermaid@%s/dist/mermaid.min.js" $version -}}

{{ if ge hugo.Version "0.90.0" -}}
{{ warnf "Mermaid version %s" $version -}}
{{ $mermaidjs := resources.GetRemote $cdnurl -}}
{{ if eq $mermaidjs nil -}}
{{ errorf "Invalid Mermaid version %s, could not retrieve this version from CDN" $version -}}
Expand All @@ -16,6 +14,6 @@
</script>
{{ end }}
{{ else -}}
<script src="{{- $cdnurl -}}" integrity="sha512-IX+bU+wShHqfqaMHLMrtwi4nK6W/Z+QdZoL4kPNtRxI2wCLyHPMAdl3a43Fv1Foqv4AP+aiW6hg1dcrTt3xc+Q==" crossorigin="anonymous"></script>
<script src="{{- $cdnurl -}}" integrity="sha512-ku2nmBrzAXY5YwohzTqLYH1/lvyMrpTVxgQKrvTabd/b/uesqltLORdmpVapYv6QhZVCLUX6wkvFaKOAY4xpUA==" crossorigin="anonymous"></script>
{{ warnf "Outdated Hugo version %s, consider upgrading to make full use of all theme features" hugo.Version -}}
{{ end -}}
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ graph TD

With hugo version 0.93 or higher, support of Mermaid diagrams is automatically enabled as soon as you use a `mermaid` code block on your page.

Mermaid has a very active community and frequently releases new versions, making it difficult for docsy's dev team to catch up with. Fortunately, you can specify your desired mermaid version inside of your `hugo.toml`. Give either give a specific version number (e.g. `9.3.0`) or specify `latest` in order to use the latest released mermaid version.
By default, docsy pulls in the latest officially released version of Mermaid at build time. If that doesn't fit your needs, you can specify the wanted mermaid version inside your `hugo.toml`:

{{< tabpane persistLang=false >}}
{{< tab header="Hugo version >= 0.90 only:" disabled=true />}}
Expand Down
2 changes: 1 addition & 1 deletion userguide/hugo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ params:
markmap:
enable: true
mermaid:
version: latest
version: 9.3.0
theme: default
flowchart:
diagramPadding: 20
Expand Down

0 comments on commit efde633

Please sign in to comment.