diff --git a/wowchemy/assets/js/wowchemy-init.js b/wowchemy/assets/js/wowchemy-init.js index 203b5263..670b737d 100644 --- a/wowchemy/assets/js/wowchemy-init.js +++ b/wowchemy/assets/js/wowchemy-init.js @@ -27,3 +27,6 @@ if (window.netlifyIdentity) { // Initialize theme variation and set body theme class. initThemeVariation(); + +// For Plotly compatibility with MathJax (must appear prior to loading Plotly). +window.PlotlyConfig = {MathJaxConfig: 'local'}; diff --git a/wowchemy/layouts/_default/baseof.html b/wowchemy/layouts/_default/baseof.html index a8e5142d..52a4ca27 100644 --- a/wowchemy/layouts/_default/baseof.html +++ b/wowchemy/layouts/_default/baseof.html @@ -17,11 +17,11 @@ {{ $wcIsSiteThemeDark := not (.Scratch.Get "light") | default false }} {{ $js_params := dict "wcDarkLightEnabled" $wcDarkLightEnabled "wcIsSiteThemeDark" $wcIsSiteThemeDark }} {{ $js_bundle := resources.Get "js/wowchemy-init.js" | js.Build (dict "params" $js_params) }} - {{- if eq hugo.Environment "production" -}} + {{- if hugo.IsProduction -}} {{ $js_bundle = $js_bundle | minify }} {{- end -}} {{ $js_bundle := slice $js_bundle_head $js_bundle | resources.Concat "js/wowchemy-init.min.js" }} - {{- if eq hugo.Environment "production" -}} + {{- if hugo.IsProduction -}} {{- $js_bundle = $js_bundle | fingerprint "md5" -}} {{- end -}} diff --git a/wowchemy/layouts/partials/marketing/google_analytics.html b/wowchemy/layouts/partials/marketing/google_analytics.html index 580db22c..be8c5c88 100644 --- a/wowchemy/layouts/partials/marketing/google_analytics.html +++ b/wowchemy/layouts/partials/marketing/google_analytics.html @@ -1,7 +1,6 @@ {{ $ga := site.Params.marketing.google_analytics | default site.GoogleAnalytics | default "" }} -{{ $gtm := site.Params.marketing.google_tag_manager | default "" }} -{{ if (in (slice (getenv "HUGO_ENV") hugo.Environment) "production") | and $ga | and (not $gtm) }} +{{ if hugo.IsProduction | and $ga }} {{ $gtag_config := cond site.Params.privacy_pack "{ 'anonymize_ip': true }" "{}" }} diff --git a/wowchemy/layouts/partials/marketing/google_tag_manager.html b/wowchemy/layouts/partials/marketing/google_tag_manager.html index 6ae3abc6..d413cb4c 100644 --- a/wowchemy/layouts/partials/marketing/google_tag_manager.html +++ b/wowchemy/layouts/partials/marketing/google_tag_manager.html @@ -1,4 +1,4 @@ -{{ if (in (slice (getenv "HUGO_ENV") hugo.Environment) "production") | and site.Params.marketing.google_tag_manager }} +{{ if hugo.IsProduction | and site.Params.marketing.google_tag_manager }} + {{- end -}} + {{ with site.Params.marketing.google_site_verification }} {{- end -}} diff --git a/wowchemy/layouts/partials/site_js.html b/wowchemy/layouts/partials/site_js.html index 82901a30..41f4fbcf 100644 --- a/wowchemy/layouts/partials/site_js.html +++ b/wowchemy/layouts/partials/site_js.html @@ -93,9 +93,6 @@ {{/* Charts */}} {{ if .HasShortcode "chart" }} - {{ printf "" (printf $js.plotly.url $js.plotly.version) $js.plotly.sri | safeHTML }} {{ end }} @@ -104,6 +101,12 @@ {{ end }} + {{ $js_bootstrap := resources.Get "js/_vendor/bootstrap.bundle.js" }} + {{- if hugo.IsProduction -}} + {{ $js_bootstrap = $js_bootstrap | minify | fingerprint "md5" }} + {{- end -}} + + {{ $js_search_params := dict }} {{ if ne site.Params.search.engine 0 }} {{/* Configure search engine. */}} @@ -119,11 +122,9 @@ {{ $js_license := $js_license | printf "%s/*! Copyright 2016-present George Cushen (https://georgecushen.com/) */\n" }} {{ $js_license := $js_license | printf "%s/*! License: https://github.com/wowchemy/wowchemy-hugo-modules/blob/master/LICENSE.md */\n" }} {{ $js_bundle_head := $js_license | resources.FromString "js/bundle-head.js" }} - {{ $js_linebreak := "\n" | resources.FromString "js/linebreak.js" }}{{/* Fix no line break after Bootstrap JS causing error. */}} {{ $js_params := dict "hugoEnvironment" hugo.Environment "codeHighlighting" ($scr.Get "highlight_enabled" | default false) "searchEnabled" (ne site.Params.search.engine 0) }} {{ $js_academic := resources.Get "js/wowchemy.js" | js.Build (dict "targetPath" (printf "%s/js/wow-core.js" .Lang ) "params" $js_params) }} - {{ $js_bootstrap := resources.Get "js/_vendor/bootstrap.bundle.js" }} - {{ $js_bundle := slice $js_bootstrap $js_linebreak $js_academic }} + {{ $js_bundle := slice $js_academic }} {{ if eq site.Params.search.engine 1 }} {{ $js_academic_search := resources.Get "js/wowchemy-search.js" | js.Build (dict "targetPath" (printf "%s/js/wow-search-built.js" .Lang) "params" $js_search_params) }} {{ $js_bundle = $js_bundle | append $js_academic_search }} @@ -135,11 +136,11 @@ {{ $js_bundle = $js_bundle | append (resources.Get (printf "js/%s.js" .)) }} {{ end }} {{ $js_bundle := $js_bundle | resources.Concat (printf "%s/js/wowchemy-bundle.js" .Lang) }} - {{- if eq hugo.Environment "production" -}} + {{- if hugo.IsProduction -}} {{ $js_bundle = $js_bundle | minify }} {{- end -}} {{ $js_bundle := slice $js_bundle_head $js_bundle | resources.Concat (printf "%s/js/wowchemy.min.js" .Lang) }} - {{- if eq hugo.Environment "production" -}} + {{- if hugo.IsProduction -}} {{- $js_bundle = $js_bundle | fingerprint "md5" -}} {{- end -}}