From 8d19b3b48438f21cd750779ec5cd61bd50acecf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Sat, 9 Jul 2022 19:46:39 +0200 Subject: [PATCH] theme: avoid JS errors if an output format loaded not all files #308 --- exampleSite/content/basics/generator/_index.en.md | 2 +- layouts/partials/footer.html | 4 ++-- layouts/partials/menu.html | 4 ++-- layouts/partials/stylesheet.html | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/exampleSite/content/basics/generator/_index.en.md b/exampleSite/content/basics/generator/_index.en.md index 3058b3f39e..a52834226f 100644 --- a/exampleSite/content/basics/generator/_index.en.md +++ b/exampleSite/content/basics/generator/_index.en.md @@ -33,5 +33,5 @@ This only works in modern browsers. {{% button style="warning" icon="trash" %}}Reset variant{{% /button %}} diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index 928c3810bd..fcff21a9d2 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -69,7 +69,7 @@ function useMermaid( config ){ if (typeof mermaid != 'undefined' && typeof mermaid.mermaidAPI != 'undefined') { mermaid.initialize( Object.assign( { "securityLevel": "antiscript", "startOnLoad": false }, config ) ); - if( config.theme ){ + if( config.theme && variants ){ var write_style = variants.findLoadedStylesheet( 'variant-style' ); write_style.setProperty( '--CONFIG-MERMAID-theme', config.theme ); } @@ -96,7 +96,7 @@ {{- end }} +
  • {{ T "Clear-History" }}
  • diff --git a/layouts/partials/stylesheet.html b/layouts/partials/stylesheet.html index 6fe7ace0aa..2b1435054c 100644 --- a/layouts/partials/stylesheet.html +++ b/layouts/partials/stylesheet.html @@ -40,6 +40,6 @@ {{- range $themevariants }} {{- $quotedthemevariants = $quotedthemevariants | append (printf "'%s'" .) }} {{- end }} - variants.init( [ {{ delimit $quotedthemevariants ", " | safeJS }} ] ); + window.variants && variants.init( [ {{ delimit $quotedthemevariants ", " | safeJS }} ] ); \ No newline at end of file