From e5d538425f2674b987187f9714f71d1bb32a6db7 Mon Sep 17 00:00:00 2001 From: Sayak Mukhopadhyay Date: Tue, 14 Jan 2025 12:05:17 +0530 Subject: [PATCH] fix: attempt to ensure that mermaid works both in dev and preview envs --- layouts/partials/hooks/head-end.html | 10 ---------- layouts/partials/scripts.html | 13 +++++++++++-- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/layouts/partials/hooks/head-end.html b/layouts/partials/hooks/head-end.html index 9801b7cebe..1b48f6627c 100644 --- a/layouts/partials/hooks/head-end.html +++ b/layouts/partials/hooks/head-end.html @@ -25,16 +25,6 @@ {{- end -}} {{- end -}} -{{ if .HasShortcode "mermaid" }} - - {{- with resources.Get "js/mermaid-10.6.1.min.js" -}} - - {{- else -}} - - {{- errorf "No Mermaid helper script found" -}} - {{- end -}} -{{- end -}} - {{- if eq .Layout "glossary" -}} {{- with resources.Get "js/glossary.js" -}} diff --git a/layouts/partials/scripts.html b/layouts/partials/scripts.html index 9ff402139f..9e6e32603d 100644 --- a/layouts/partials/scripts.html +++ b/layouts/partials/scripts.html @@ -1,14 +1,23 @@ +{{/* 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" -}} + +{{- 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 -}}