Ver código fonte

feat: recognize env via -e argument in addition to HUGO_ENV

Also, see https://github.com/gohugoio/hugo/issues/6456#issuecomment-546524056
George Cushen 5 anos atrás
pai
commit
24bfa6fa4d

+ 1 - 1
layouts/partials/marketing/google_analytics.html

@@ -1,7 +1,7 @@
 {{ $ga := site.Params.marketing.google_analytics | default site.GoogleAnalytics | default "" }}
 {{ $gtm := site.Params.marketing.google_tag_manager | default "" }}
 
-{{ if eq (getenv "HUGO_ENV") "production" | and $ga | and (not $gtm) }}
+{{ if (in (slice (getenv "HUGO_ENV") hugo.Environment) "production") | and $ga | and (not $gtm) }}
 
 {{ $gtag_config := cond site.Params.privacy_pack "{ 'anonymize_ip': true }" "{}" }}
 <script async src="https://www.googletagmanager.com/gtag/js?id={{$ga}}"></script>

+ 1 - 1
layouts/partials/marketing/google_tag_manager.html

@@ -1,4 +1,4 @@
-{{ if eq (getenv "HUGO_ENV") "production" | and site.Params.marketing.google_tag_manager }}
+{{ if (in (slice (getenv "HUGO_ENV") hugo.Environment) "production") | and site.Params.marketing.google_tag_manager }}
 <script>
   (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
   new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],

+ 1 - 1
layouts/partials/site_head.html

@@ -103,7 +103,7 @@
   {{ $css_comment := printf "/*!* Source Themes Academic v%s (https://sourcethemes.com/academic/) */\n" site.Data.academic.version }}
   {{ $css_bundle_head := $css_comment | resources.FromString "css/bundle-head.css" }}
   {{ $css_options := dict "targetPath" "css/academic.css" }}
-  {{- if (eq (getenv "HUGO_ENV") "production") -}}
+  {{- if (in (slice (getenv "HUGO_ENV") hugo.Environment) "production") -}}
     {{- $css_options = merge $css_options (dict "outputStyle" "compressed") -}}
   {{- end -}}
   {{ $sass_template := resources.Get "scss/main.scss" }}