Skip to content

Commit e5d5384

Browse files
fix: attempt to ensure that mermaid works both in dev and preview envs
1 parent 214eda5 commit e5d5384

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

layouts/partials/hooks/head-end.html

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,6 @@
2525
{{- end -}}
2626
{{- end -}}
2727

28-
{{ if .HasShortcode "mermaid" }}
29-
<!-- Copied from https://unpkg.com/[email protected]/dist/mermaid.min.js -->
30-
{{- with resources.Get "js/mermaid-10.6.1.min.js" -}}
31-
<script src="{{ .RelPermalink }}" integrity="sha384-toDgDinNQVuBBJdT9Q9AnvM4szGg0g7BSEy/yLPRkkQylpeePcz8Mx/JLOFf33o+"></script>
32-
{{- else -}}
33-
<!-- without Mermaid, the site won't appear right -->
34-
{{- errorf "No Mermaid helper script found" -}}
35-
{{- end -}}
36-
{{- end -}}
37-
3828
{{- if eq .Layout "glossary" -}}
3929
{{- with resources.Get "js/glossary.js" -}}
4030
<script defer src="{{ .RelPermalink }}"></script>

layouts/partials/scripts.html

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
<script src="{{ "js/script.js" | relURL }}"></script>
22

3+
{{/* Handle legacy Kubernetes shortcode for Mermaid diagrams */}}
4+
{{- if (.HasShortcode "mermaid") -}}
5+
{{ .Page.Store.Set "hasmermaid" true -}}
6+
{{- end -}}
7+
8+
{{/* future Docsy versions move this to partials/mermaid.html */}}
9+
{{- if .Page.Store.Get "hasmermaid" -}}
10+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/mermaid.min.js" integrity="sha512-IX+bU+wShHqfqaMHLMrtwi4nK6W/Z+QdZoL4kPNtRxI2wCLyHPMAdl3a43Fv1Foqv4AP+aiW6hg1dcrTt3xc+Q==" crossorigin="anonymous"></script>
11+
{{- end }}
12+
313
{{ $jsBs := resources.Get "vendor/bootstrap/dist/js/bootstrap.bundle.js" -}}
414
{{ $jsBase := resources.Get "js/base.js" }}
515
{{ $jsAnchor := resources.Get "js/anchor.js" }}
616
{{ $jsSearch := resources.Get "js/search.js" | resources.ExecuteAsTemplate "js/search.js" .Site.Home }}
7-
{{ $jsMermaid := resources.Get "js/mermaid.js" | resources.ExecuteAsTemplate "js/mermaid.js" . }}
817
{{ if .Site.Params.offlineSearch }}
918
{{ $jsSearch = resources.Get "js/offline-search.js" }}
1019
{{ end }}
11-
{{ $js := (slice $jsBs $jsBase $jsAnchor $jsSearch $jsMermaid) | resources.Concat "js/main.js" -}}
20+
{{ $js := (slice $jsBs $jsBase $jsAnchor $jsSearch) | resources.Concat "js/main.js" -}}
1221
{{ if hugo.IsProduction -}}
1322
{{ $js := $js | minify | fingerprint -}}
1423
<script src="{{ $js.RelPermalink }}" integrity="{{ $js.Data.Integrity }}" crossorigin="anonymous"></script>

0 commit comments

Comments
 (0)