fix: attempt to ensure that mermaid works both in dev and preview envs
parent
214eda5088
commit
e5d538425f
|
@ -25,16 +25,6 @@
|
|||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{ if .HasShortcode "mermaid" }}
|
||||
<!-- Copied from https://unpkg.com/mermaid@10.6.1/dist/mermaid.min.js -->
|
||||
{{- with resources.Get "js/mermaid-10.6.1.min.js" -}}
|
||||
<script src="{{ .RelPermalink }}" integrity="sha384-toDgDinNQVuBBJdT9Q9AnvM4szGg0g7BSEy/yLPRkkQylpeePcz8Mx/JLOFf33o+"></script>
|
||||
{{- else -}}
|
||||
<!-- without Mermaid, the site won't appear right -->
|
||||
{{- errorf "No Mermaid helper script found" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if eq .Layout "glossary" -}}
|
||||
{{- with resources.Get "js/glossary.js" -}}
|
||||
<script defer src="{{ .RelPermalink }}"></script>
|
||||
|
|
|
@ -1,14 +1,23 @@
|
|||
<script src="{{ "js/script.js" | relURL }}"></script>
|
||||
|
||||
{{/* Handle legacy Kubernetes shortcode for Mermaid diagrams */}}
|
||||
{{- if (.HasShortcode "mermaid") -}}
|
||||
{{ .Page.Store.Set "hasmermaid" true -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* future Docsy versions move this to partials/mermaid.html */}}
|
||||
{{- if .Page.Store.Get "hasmermaid" -}}
|
||||
<script src="https://cdn.jsdelivr.net/npm/mermaid@9.2.2/dist/mermaid.min.js" integrity="sha512-IX+bU+wShHqfqaMHLMrtwi4nK6W/Z+QdZoL4kPNtRxI2wCLyHPMAdl3a43Fv1Foqv4AP+aiW6hg1dcrTt3xc+Q==" crossorigin="anonymous"></script>
|
||||
{{- end }}
|
||||
|
||||
{{ $jsBs := resources.Get "vendor/bootstrap/dist/js/bootstrap.bundle.js" -}}
|
||||
{{ $jsBase := resources.Get "js/base.js" }}
|
||||
{{ $jsAnchor := resources.Get "js/anchor.js" }}
|
||||
{{ $jsSearch := resources.Get "js/search.js" | resources.ExecuteAsTemplate "js/search.js" .Site.Home }}
|
||||
{{ $jsMermaid := resources.Get "js/mermaid.js" | resources.ExecuteAsTemplate "js/mermaid.js" . }}
|
||||
{{ if .Site.Params.offlineSearch }}
|
||||
{{ $jsSearch = resources.Get "js/offline-search.js" }}
|
||||
{{ end }}
|
||||
{{ $js := (slice $jsBs $jsBase $jsAnchor $jsSearch $jsMermaid) | resources.Concat "js/main.js" -}}
|
||||
{{ $js := (slice $jsBs $jsBase $jsAnchor $jsSearch) | resources.Concat "js/main.js" -}}
|
||||
{{ if hugo.IsProduction -}}
|
||||
{{ $js := $js | minify | fingerprint -}}
|
||||
<script src="{{ $js.RelPermalink }}" integrity="{{ $js.Data.Integrity }}" crossorigin="anonymous"></script>
|
||||
|
|
Loading…
Reference in New Issue