From e67c9d0d28f02c5f7dd23d45ff67f0b8a3b29c71 Mon Sep 17 00:00:00 2001
From: James Panther <4462786+jpanther@users.noreply.github.com>
Date: Wed, 19 Jan 2022 11:28:20 +1100
Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Bundle=20css=20and=20js=20?=
=?UTF-8?q?assets=20using=20Hugo=20pipes?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
CHANGELOG.md | 7 +++---
layouts/partials/head.html | 47 +++++++++++++++-----------------------
2 files changed, 23 insertions(+), 31 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 91065d1d..313c9f88 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -20,12 +20,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Changed
+- ⚠️ Required Hugo version is now 0.87.0 or later
+- ⚠️ Author images are now Hugo assets
+- ⚠️ Overhauled `figure` shortcode which now resizes images
+- ⚠️ Renamed parameter: `darkToggle` -> `showDarkToggle`
- Upgrade to Tailwind v3.0.15
- Upgrade to KaTeX v0.15.2
- Inline Javascript moved to external files
-- Author images are now Hugo assets
-- Required Hugo version is now 0.87.0 or later
-- Overhauled `figure` shortcode which now resizes images
- Improved JSON-LD structured data
- Minor style and layout improvements
diff --git a/layouts/partials/head.html b/layouts/partials/head.html
index e5bd6cf3..046faf7d 100644
--- a/layouts/partials/head.html
+++ b/layouts/partials/head.html
@@ -32,41 +32,32 @@
{{ range .AlternativeOutputFormats -}}
{{ printf `` .Rel .MediaType.Type .RelPermalink $.Site.Title | safeHTML }}
{{ end -}}
- {{/* Styles */}}
- {{ $schemeCSS := resources.Get (printf "css/schemes/%s.css" (.Site.Params.colorScheme | default "congo")) }}
- {{ if not $schemeCSS }}
- {{ $schemeCSS = resources.Get "css/schemes/congo.css" }}
+ {{/* Asset bundles */}}
+ {{ $assets := newScratch }}
+ {{ $cssScheme := resources.Get (printf "css/schemes/%s.css" (.Site.Params.colorScheme | default "congo")) }}
+ {{ if not $cssScheme }}
+ {{ $cssScheme = resources.Get "css/schemes/congo.css" }}
{{ end }}
- {{ $schemeStyles := $schemeCSS | resources.Minify | resources.Fingerprint "sha512" }}
+ {{ $assets.Add "css" (slice $cssScheme) }}
+ {{ $cssMain := resources.Get "css/compiled/main.css" }}
+ {{ $assets.Add "css" (slice $cssMain) }}
+ {{ $cssCustom := resources.Get "css/custom.css" }}
+ {{ if $cssCustom }}
+ {{ $assets.Add "css" (slice $cssCustom) }}
+ {{ end }}
+ {{ $bundleCSS := $assets.Get "css" | resources.Concat "css/main.bundle.css" | resources.Minify | resources.Fingerprint "sha512" }}
- {{ $mainCSS := resources.Get "css/compiled/main.css" }}
- {{ $mainStyles := $mainCSS | resources.Minify | resources.Fingerprint "sha512" }}
-
- {{ $customCSS := resources.Get "css/custom.css" }}
- {{ if $customCSS }}
- {{ $customStyles := $customCSS | resources.Minify | resources.Fingerprint "sha512" }}
-
- {{ end }}
{{ if eq (.Site.Params.darkMode | default "auto") "auto" }}
- {{ $darkJS := resources.Get "js/dark.js" }}
- {{ $darkJS := $darkJS | resources.Minify | resources.Fingerprint "sha512" }}
-
+ {{ $jsDark := resources.Get "js/dark.js" }}
+ {{ $assets.Add "js" (slice $jsDark) }}
{{ end }}
+ {{ $bundleJS := $assets.Get "js" | resources.Concat "js/main.bundle.js" | resources.Minify | resources.Fingerprint "sha512" }}
+
{{/* Icons */}}
{{ if templates.Exists "partials/favicons.html" }}
{{ partialCached "favicons.html" .Site }}