From 9bbf6fa2a69895a505cd30588b195bba8a333b6e Mon Sep 17 00:00:00 2001 From: George Cushen Date: Tue, 2 Feb 2021 23:55:30 +0000 Subject: [PATCH] feat: support Params.marketing.google_site_verification Also trial self-closing tags over void tags as Prettier doesn't support void tags: https://github.com/prettier/prettier/issues/5246 --- wowchemy/.prettierrc.js | 10 +++ wowchemy/layouts/partials/site_head.html | 92 ++++++++++++------------ wowchemy/package.json | 1 + wowchemy/yarn.lock | 5 ++ 4 files changed, 64 insertions(+), 44 deletions(-) diff --git a/wowchemy/.prettierrc.js b/wowchemy/.prettierrc.js index 446a6303..1d80ed49 100644 --- a/wowchemy/.prettierrc.js +++ b/wowchemy/.prettierrc.js @@ -6,4 +6,14 @@ module.exports = { jsxBracketSameLine: true, trailingComma: 'all', printWidth: 120, + overrides: [ + { + files: [ + "*.html" + ], + options: { + parser: "go-template" + } + } + ], }; diff --git a/wowchemy/layouts/partials/site_head.html b/wowchemy/layouts/partials/site_head.html index 3d566b96..2f8fc246 100644 --- a/wowchemy/layouts/partials/site_head.html +++ b/wowchemy/layouts/partials/site_head.html @@ -1,13 +1,15 @@ - - - - + + + {{ $is_sponsor := site.Params.i_am_a_sponsor | default false }} {{ $hide_generator := site.Params.power_ups.hide_generator | default false }} {{ if not (and $is_sponsor $hide_generator) }} - + {{ end }} + {{ with site.Params.marketing.google_site_verification }} + + {{- end -}} {{ $scr := .Scratch }} @@ -25,7 +27,7 @@ {{ end }} {{ $scr.Set "superuser_username" $superuser_username }}{{/* Set superuser globally for page_author.html. */}} - {{ with $superuser_name }}{{ end }} + {{ with $superuser_name }}{{ end }} {{/* Generate page description. */}} {{ $desc := "" }} @@ -40,30 +42,30 @@ {{ else }} {{ $desc = $superuser_role }} {{ end }} - + {{ range .Translations }} - + {{ end }} - + {{ partial "functions/parse_theme" . }} {{/* Pre-connect to Google Fonts if the site's Font Theme uses them. */}} {{ with ($scr.Get "google_fonts") }} - - {{end}} + + {{ end }} {{ $css := site.Data.assets.css }} {{ $js := site.Data.assets.js }} {{ if ne ($scr.Get "primary") "#fff" }} - + {{ end }} {{/* Config LaTeX math rendering. */}} {{ if or .Params.math site.Params.math }} - {{ $mathjax_config := resources.Get "js/mathjax-config.js" }} - + {{ $mathjax_config := resources.Get "js/mathjax-config.js" }} + {{ end }} {{/* Attempt to load local vendor CSS, otherwise load from CDN. */}} @@ -71,7 +73,7 @@ {{ $scr.Set "vendor_js_filename" "main.min.js" }} {{ if and (fileExists (printf "static/css/vendor/%s" ($scr.Get "vendor_css_filename"))) (fileExists (printf "static/js/vendor/%s" ($scr.Get "vendor_js_filename"))) }} {{ $scr.Set "use_cdn" 0 }} - + {{ else }} {{ $scr.Set "use_cdn" 1 }} {{ if site.Params.icon.pack.ai }} @@ -105,7 +107,7 @@ {{ end }} {{ if or (eq site.Params.map.engine 2) (eq site.Params.map.engine 3) }} - {{ printf "" (printf $css.leaflet.url $css.leaflet.version) $css.leaflet.sri | safeHTML }} + {{ printf "" (printf $css.leaflet.url $css.leaflet.version) $css.leaflet.sri | safeHTML }} {{ end }} {{ if eq site.Params.search.engine 2 }} @@ -114,19 +116,19 @@ {{ end }} {{/* Load async scripts. */}} - {{ range $k, $v := site.Data.assets.js }}{{/* TODO: investigate why `where ... "async" true` does not work. */}} + {{ range $k, $v := site.Data.assets.js }} + {{/* TODO: investigate why `where ... "async" true` does not work. */}} {{ $load := $v.async }} {{/* Only load MathJax if required. */}} {{ if (eq $k "mathJax") | and (not (or $.Params.math site.Params.math)) }} {{ $load = false }} - {{end}} + {{ end }} {{ if $load }} {{ printf "" (printf $v.url $v.version) $v.sri | safeHTML }} - {{end}} - {{end}} - + {{ end }} + {{ end }} {{ end }} {{/* Load Google Fonts if the site's Font Theme uses them. */}} @@ -164,7 +166,7 @@ {{- if eq hugo.Environment "production" -}} {{- $style = $style | fingerprint "md5" -}} {{- end -}} - + {{ partial "marketing/google_analytics" . }} {{ partial "marketing/google_tag_manager" . }} @@ -172,21 +174,21 @@ {{/* Netlify Identity integration. */}} {{ if .IsHome | and (site.Params.cms.netlify_cms | default false) }} - + {{ end }} {{ with .OutputFormats.Get "RSS" }} - + {{ end }} {{ if site.Home.OutputFormats.Get "WebAppManifest" }} - + {{ end }} - - + + - + {{/* Get page image for sharing. */}} {{ $featured_image := (.Resources.ByType "image").GetMatch "*featured*" }} @@ -212,37 +214,39 @@ {{ $twitter_card = "summary" }} {{ end }} {{ $scr.Set "og_image" $og_image }}{{/* Set `og_image` globally for `rss.xml`. */}} - + {{ with site.Params.twitter }} - - + + {{ end }} - - - - + + + + {{- with $og_image -}} - - + + {{- end -}} - + {{ if .IsPage }} {{ if not .PublishDate.IsZero }} - + {{ else if not .Date.IsZero }} - + {{ end }} {{ if not .Lastmod.IsZero }}{{ end }} {{ else }} - {{ if not .Date.IsZero }}{{ end }} + {{ if not .Date.IsZero }} + + {{ end }} {{ end }} {{ partial "jsonld/main" (dict "page" . "summary" $desc) }} - {{ partial "cookie_consent" . }} - {{ partial "custom_head" . }} {{ if not .IsHome }}{{ .Title }} | {{ end }}{{ site.Title }} - diff --git a/wowchemy/package.json b/wowchemy/package.json index 5d37df43..1188d1d3 100644 --- a/wowchemy/package.json +++ b/wowchemy/package.json @@ -21,6 +21,7 @@ "eslint": "^7.17.0", "eslint-config-prettier": "^7.1.0", "prettier": "2.2.1", + "prettier-plugin-go-template": "0.0.11-beta.4", "stylelint": "^13.8.0", "stylelint-config-prettier": "^8.0.2", "stylelint-config-standard": "^20.0.0", diff --git a/wowchemy/yarn.lock b/wowchemy/yarn.lock index 9384da1c..5583f4ed 100644 --- a/wowchemy/yarn.lock +++ b/wowchemy/yarn.lock @@ -1560,6 +1560,11 @@ prelude-ls@^1.2.1: resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g== +prettier-plugin-go-template@0.0.11-beta.4: + version "0.0.11-beta.4" + resolved "https://registry.yarnpkg.com/prettier-plugin-go-template/-/prettier-plugin-go-template-0.0.11-beta.4.tgz#abf833f3e959c070518b0eb4975993271de3217e" + integrity sha512-QiyZoCUsksSF3pVDcc2iNG3i0bFpwAws+9zUUnK89BK4lkUnwF/DW0d4uSEhEFt06+GLomWgR7pkMI+xvkVuRA== + prettier@2.2.1: version "2.2.1" resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.2.1.tgz#795a1a78dd52f073da0cd42b21f9c91381923ff5"