From df5d839074ef3b81eb66c341896fde54a3834aa8 Mon Sep 17 00:00:00 2001 From: Sped0n Date: Wed, 1 Nov 2023 23:09:53 +0800 Subject: [PATCH] chore(link.html): update critical style source and options to improve performance and maintainability chore(link.html): update main style source and options to improve performance and maintainability chore(link.html): remove unused meta.html file chore(nav.html): update decrement and increment buttons to use Unicode characters for better accessibility chore(plugin/style.html): update style plugin to support inline styles for critical CSS chore(plugin/style.html): update style plugin to support minification and fingerprinting for main CSS chore(plugin/style.html): remove script plugin as it is no longer used chore(plugin/style.html): update style plugin to support inline styles for critical CSS chore(plugin/style.html): update style plugin to support minification and fingerprinting for main CSS chore(resources/imageJSON.html): update image resize options for better performance and quality --- layouts/partials/head/link.html | 20 ++++++----- layouts/partials/head/meta.html | 1 - layouts/partials/nav.html | 4 +-- layouts/partials/plugin/script.html | 41 ----------------------- layouts/partials/plugin/style.html | 7 ++-- layouts/partials/resources/imageJSON.html | 2 +- 6 files changed, 18 insertions(+), 57 deletions(-) delete mode 100644 layouts/partials/plugin/script.html diff --git a/layouts/partials/head/link.html b/layouts/partials/head/link.html index 6b1ee7e..3b28a7b 100644 --- a/layouts/partials/head/link.html +++ b/layouts/partials/head/link.html @@ -1,25 +1,27 @@ {{/* fingerprint */}} {{- $fingerprint := .Scratch.Get "fingerprint" | default "" -}} -{{/* main style */}} -{{- $style := dict "Source" "scss/style.scss" "Fingerprint" $fingerprint -}} -{{- $options := dict "targetPath" "css/style.css" "enableSourceMap" true -}} -{{- $style = dict "Context" . "ToCSS" $options "Minify" hugo.IsProduction | merge $style -}} +{{/* critical style */}} +{{- $style := dict "Source" "scss/critical.scss" "Fingerprint" $fingerprint -}} +{{- $options := dict "enableSourceMap" true "includePaths" (slice "node_modules") -}} +{{- $style = dict "Context" . "ToCSS" $options "Inline" true | merge $style -}} {{- partial "plugin/style.html" $style -}} +{{/* main style */}} +{{- $style := dict "Source" "scss/style.scss" "Fingerprint" $fingerprint -}} +{{- $options := dict "targetPath" "css/style.css" "enableSourceMap" true "includePaths" (slice "node_modules") -}} +{{- $style = dict "Context" . "ToCSS" $options "Minify" hugo.IsProduction "Defer" true | merge $style -}} {{- partial "plugin/style.html" $style -}} {{/* main js */}} -{{- $esBuildOpts := dict "minify" hugo.IsProduction "targetPath" "js/main.js" -}} -{{- $script := dict "Source" "ts/main.ts" "Fingerprint" $fingerprint "Defer" true -}} -{{- $script = dict "ToESBuild" $esBuildOpts "Minify" hugo.IsProduction | merge $script -}} -{{- partial "plugin/script.html" $script -}} + {{/* fonts */}} + diff --git a/layouts/partials/head/meta.html b/layouts/partials/head/meta.html index 8b13789..e69de29 100644 --- a/layouts/partials/head/meta.html +++ b/layouts/partials/head/meta.html @@ -1 +0,0 @@ - diff --git a/layouts/partials/nav.html b/layouts/partials/nav.html index ad2144d..9bfa0fd 100644 --- a/layouts/partials/nav.html +++ b/layouts/partials/nav.html @@ -19,10 +19,10 @@
Threshold: - + - +
diff --git a/layouts/partials/plugin/script.html b/layouts/partials/plugin/script.html deleted file mode 100644 index b5eb390..0000000 --- a/layouts/partials/plugin/script.html +++ /dev/null @@ -1,41 +0,0 @@ -{{- if .Content -}} - -{{- else if strings.HasPrefix .Source " -{{- end -}} diff --git a/layouts/partials/plugin/style.html b/layouts/partials/plugin/style.html index 8bf6d98..c5f426b 100644 --- a/layouts/partials/plugin/style.html +++ b/layouts/partials/plugin/style.html @@ -18,7 +18,7 @@ {{- $options := . | merge (dict "outputStyle" "compressed") -}} {{- $resource = $resource | toCSS $options -}} {{- end -}} - {{- if .Minify -}} + {{- if or .Minify .Inline -}} {{- $resource = $resource | minify -}} {{- end -}} {{- with .Fingerprint -}} @@ -27,7 +27,9 @@ {{- end -}} {{- $href = $resource.RelPermalink -}} {{- end -}} - {{- if .Defer -}} + {{- if .Inline -}} + + {{- else if .Defer -}} {{- end -}} {{- end -}} - diff --git a/layouts/partials/resources/imageJSON.html b/layouts/partials/resources/imageJSON.html index c1a92b8..e10069f 100644 --- a/layouts/partials/resources/imageJSON.html +++ b/layouts/partials/resources/imageJSON.html @@ -6,7 +6,7 @@ {{ $Page.Scratch.Add "img" slice }} {{ range . }} {{ $index = sub $index 1 }} - {{ $lores := .Resize "1000x webp Lanczos q70" }} + {{ $lores := .Resize "800x webp Lanczos q60" }} {{ $hires := .Resize "2500x webp Lanczos q75" }} {{ $Page.Scratch.Add "img" (dict "index" (int $index)