From 8f6e091a6533ee830be643f290c3194e65ec6f36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Sun, 17 Jul 2022 19:42:07 +0200 Subject: [PATCH] mermaid: header is showing up in FF #311 --- layouts/partials/footer.html | 21 +++------------------ static/js/theme.js | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index f9e57d380b..74ba9d0f4e 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -18,7 +18,7 @@ {{- end }} {{- end }} {{- $wantsSwagger := or (.Page.Store.Get "hasSwagger") (and (.Page.Store.Get (printf "%sIsNested" (partial "output-format.hugo" .Page))) (.Page.Store.Get "nestedHasSwagger")) }} @@ -95,13 +86,7 @@ {{- $.Scratch.Set "swaggerInitialize" "{}" }} {{- end }} {{- end }} diff --git a/static/js/theme.js b/static/js/theme.js index 0d609049a3..2534fa7bf5 100644 --- a/static/js/theme.js +++ b/static/js/theme.js @@ -894,3 +894,26 @@ jQuery.fn.highlight = function(words, options) { jQuery.highlight(this, re, settings.element, settings.className); }); }; + +function useMermaid( config ){ + if (typeof mermaid != 'undefined' && typeof mermaid.mermaidAPI != 'undefined') { + mermaid.initialize( Object.assign( { "securityLevel": "antiscript", "startOnLoad": false }, config ) ); + if( config.theme && variants ){ + var write_style = variants.findLoadedStylesheet( 'variant-style' ); + write_style.setProperty( '--CONFIG-MERMAID-theme', config.theme ); + } + } +} +if( themeUseMermaid ){ + useMermaid( themeUseMermaid ); +} + +function useSwagger( config ){ + if( config.theme && variants ){ + var write_style = variants.findLoadedStylesheet( 'variant-style' ); + write_style.setProperty( '--CONFIG-SWAGGER-theme', config.theme ); + } +} +if( themeUseSwagger ){ + useSwagger( themeUseSwagger ); +}