From c26a6d6cc8e493499dd49364de5cbc126e334a01 Mon Sep 17 00:00:00 2001 From: Rohan Kumar Date: Tue, 26 Apr 2022 17:15:42 -0700 Subject: [PATCH] Re-introduce conservative minificaiton - Don't auto-minify HTML but minify other resources, inc. the RSS feed - Manually optimize whitespace a little to balance readability and compressed size --- config.toml | 9 +++++--- layouts/_default/_markup/render-heading.html | 23 +++++++++++--------- layouts/_default/baseof.html | 2 +- layouts/partials/head.html | 19 +++++++--------- layouts/shortcodes/codefigure.html | 2 +- layouts/shortcodes/indieweb-person.html | 2 +- layouts/shortcodes/picture.html | 2 +- 7 files changed, 31 insertions(+), 28 deletions(-) diff --git a/config.toml b/config.toml index 10953c3..1f34421 100644 --- a/config.toml +++ b/config.toml @@ -132,7 +132,10 @@ includeFields = "" # Regexp matching the Exif fields you want to exclude. This may be easier to use # than IncludeFields above, depending on what you want. -excludeFields = "" +excludeFields = ".*" -[minify.tdewolff.html] -keepWhitespace = true +# don't minify html but minify other resources, esp the fulltext rss feed +[minify] +minifyOutput = true +disableXML = false +disableHTML = true diff --git a/layouts/_default/_markup/render-heading.html b/layouts/_default/_markup/render-heading.html index ceefb56..e57b7ea 100644 --- a/layouts/_default/_markup/render-heading.html +++ b/layouts/_default/_markup/render-heading.html @@ -12,15 +12,18 @@ already copy heading anchor links in the TOC. This just makes some existing functionality slightly more easily. So it's less of a big deal + 4. This reliably hides them from certain reading-mode implementations + (e.g. Readability) Yeah I know, the situation isn't optimal. ---> -{{ .Text | safeHTML }} -{{ if and (gt .Level 1) (eq .Page.Section "posts") -}} - +-->{{- with . -}} +{{ .Text | safeHTML -}} +{{- if and (gt .Level 1) (eq .Page.Section "posts") -}} + {{- end }} - +{{ end }} diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 5a20221..7fb855f 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -1,5 +1,5 @@ - + {{ partial "head.html" . -}} {{ partial "header.html" . -}} diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 6dfea04..29427db 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -1,16 +1,17 @@ - - - - + {{ if or (eq site.BaseURL "https://seirdy.one/") (in site.BaseURL "wgq3bd2kqoybhstp77i3wrzbfnsyd27wt34psaja4grqiezqircorkyd.onion") -}} - {{ end -}} + + +{{ $webmanifest := resources.Get "/manifest.webmanifest" | resources.ExecuteAsTemplate "manifest.webmanifest" . | resources.Minify | resources.Fingerprint "md5" -}} +{{- printf `` $webmanifest.RelPermalink | safeHTML }} + {{ .Title }}{{ if and (lt (len .Title) 54) (ne .RelPermalink "/") }} - Seirdy{{ end }} - + {{ if gt .Date 0 -}} @@ -29,14 +30,10 @@ {{ $favicon_base64 := $favicon.Content | base64Encode }} {{ printf `` $favicon_base64 | safeHTML -}} - + - -{{- $webmanifest := resources.Get "/manifest.webmanifest" | resources.ExecuteAsTemplate "manifest.webmanifest" . | resources.Minify | resources.Fingerprint "md5" -}} -{{- printf `` $webmanifest.RelPermalink | safeHTML }} - {{- $resources := slice -}} {{- $resources = $resources | append (resources.Get "/css/main.css") -}} diff --git a/layouts/shortcodes/codefigure.html b/layouts/shortcodes/codefigure.html index 3b73421..7e4cb5c 100644 --- a/layouts/shortcodes/codefigure.html +++ b/layouts/shortcodes/codefigure.html @@ -8,5 +8,5 @@ just use the beginning for the label and the full thing for the aria description. -->
-{{ .Inner | markdownify }} +{{ .Inner | markdownify -}}
diff --git a/layouts/shortcodes/indieweb-person.html b/layouts/shortcodes/indieweb-person.html index a2497e7..d058767 100644 --- a/layouts/shortcodes/indieweb-person.html +++ b/layouts/shortcodes/indieweb-person.html @@ -5,7 +5,7 @@ {{- if (.Get "avatar") -}} {{- $avatar_img := (resources.GetRemote (.Get "avatar")).Resize "32x32" -}} - {{- end }} + {{- end -}} {{- if (.Get "first-name") -}}{{- .Get "first-name" -}}{{- end }} {{ if (.Get "last-name") -}}{{- .Get "last-name" -}}{{- end -}} diff --git a/layouts/shortcodes/picture.html b/layouts/shortcodes/picture.html index 5d36afe..ebd76d5 100644 --- a/layouts/shortcodes/picture.html +++ b/layouts/shortcodes/picture.html @@ -82,7 +82,7 @@