mirror of
https://github.com/tiennm99/HugoBlox-kit.git
synced 2026-10-13 04:14:41 +00:00
feat: CLS - preconnect to Google Fonts earlier
Also, allow disabling Isotope on a specifc page, such as home
This commit is contained in:
1 parent
922e22cca5
commit
6d382a393a
2 files changed
+21
-23
No files matched your search
@@ -12,6 +12,26 @@
|
||||
<meta name="robots" content="noindex" />
|
||||
{{- end -}}
|
||||
|
||||
{{/* Parse theme and font */}}
|
||||
{{ partial "functions/parse_theme" . }}
|
||||
|
||||
{{/* Pre-connect to Google Fonts if the site's Font Theme uses them. */}}
|
||||
{{ with ($scr.Get "google_fonts") }}
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||
{{ end }}
|
||||
|
||||
{{/* Load Google Fonts if the site's Font Theme uses them. */}}
|
||||
{{/* Note: we cannot use SRI with Google Fonts because the CSS is dynamically generated according to the user agent. */}}
|
||||
{{ with ($scr.Get "google_fonts") }}
|
||||
{{ if hasPrefix . "family=" }}
|
||||
{{/* If `google_fonts` starts with "family=", use API v2 (https://developers.google.com/fonts/docs/css2) */}}
|
||||
<link rel="preload" as="style" {{ printf "href=\"https://fonts.googleapis.com/css2?%s&display=swap\"" . | safeHTMLAttr }}>
|
||||
<link rel="stylesheet" {{ printf "href=\"https://fonts.googleapis.com/css2?%s&display=swap\"" . | safeHTMLAttr }} media="print" onload="this.media='all'">
|
||||
{{ else }}
|
||||
{{ errorf "There is a new version of Google Fonts. Learn how to upgrade your font pack at https://wowchemy.com/docs/customization/#custom-font" }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ if site.Params.marketing.google_optimize | and hugo.IsProduction }}
|
||||
<script src="https://www.googleoptimize.com/optimize.js?id={{ site.Params.marketing.google_optimize }}"></script>
|
||||
{{- end -}}
|
||||
@@ -61,13 +81,6 @@
|
||||
{{ end }}
|
||||
<link rel="alternate" hreflang="{{ site.LanguageCode | default "en-us" }}" href="{{ .Permalink }}" />
|
||||
|
||||
{{ partial "functions/parse_theme" . }}
|
||||
|
||||
{{/* Pre-connect to Google Fonts if the site's Font Theme uses them. */}}
|
||||
{{ with ($scr.Get "google_fonts") }}
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||
{{ end }}
|
||||
|
||||
{{ $css := site.Data.assets.css }}
|
||||
{{ $js := site.Data.assets.js }}
|
||||
{{ if ne ($scr.Get "primary") "#fff" }}
|
||||
@@ -179,21 +192,6 @@
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{/* Load Google Fonts if the site's Font Theme uses them. */}}
|
||||
{{/* Note: we cannot use SRI with Google Fonts because the CSS is dynamically generated according to the user agent. */}}
|
||||
{{ with ($scr.Get "google_fonts") }}
|
||||
{{ if hasPrefix . "family=" }}
|
||||
{{/* If `google_fonts` starts with "family=", use API v2 (https://developers.google.com/fonts/docs/css2) */}}
|
||||
<link rel="preload" as="style" {{ printf "href=\"https://fonts.googleapis.com/css2?%s&display=swap\"" . | safeHTMLAttr }}>
|
||||
<link rel="stylesheet" {{ printf "href=\"https://fonts.googleapis.com/css2?%s&display=swap\"" . | safeHTMLAttr }} media="print" onload="this.media='all'">
|
||||
{{ else }}
|
||||
{{/* Otherwise, use API v1 */}}
|
||||
{{/* Hugo's htmlEscape cannot escape "|" in Google Font URIs so we implement our own escape functionality. */}}
|
||||
<link rel="stylesheet" {{ printf "href=\"https://fonts.googleapis.com/css?family=%s&display=swap\"" . | replaceRE "\\|" "%7C" | safeHTMLAttr }}>
|
||||
{{ warnf "There is a new version of Google Fonts. Learn how to upgrade your font pack at https://wowchemy.com/docs/customization/#custom-font" }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ $license := printf "/*! Wowchemy v%s | https://wowchemy.com/ */\n" site.Data.wowchemy.version }}
|
||||
{{ $license := $license | printf "%s/*! Copyright 2016-present George Cushen (https://georgecushen.com/) */\n" }}
|
||||
{{ $license := $license | printf "%s/*! License: https://github.com/wowchemy/wowchemy-hugo-themes/blob/main/LICENSE.md */\n" }}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
{{ if not ($scr.Get "use_cdn") }}
|
||||
<script src="{{ printf "/js/vendor/%s" ($scr.Get "vendor_js_filename") | relURL }}"></script>
|
||||
{{ else }}
|
||||
{{ $require_isotope := site.Params.require_isotope | default true }}
|
||||
{{ $require_isotope := .Params.require_isotope | default site.Params.require_isotope | default true }}
|
||||
{{ if $require_isotope }}
|
||||
{{ printf "<script src=\"%s\" integrity=\"%s\" crossorigin=\"anonymous\"></script>" (printf $js.imagesLoaded.url $js.imagesLoaded.version) $js.imagesLoaded.sri | safeHTML }}
|
||||
{{ printf "<script src=\"%s\" integrity=\"%s\" crossorigin=\"anonymous\"></script>" (printf $js.isotope.url $js.isotope.version) $js.isotope.sri | safeHTML }}
|
||||
|
||||
Reference in new issue
Block a user