1
0
Fork 0
mirror of https://git.sr.ht/~seirdy/seirdy.one synced 2024-11-10 00:12:09 +00:00

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
This commit is contained in:
Rohan Kumar 2022-04-26 17:15:42 -07:00
parent 4f846cea91
commit c26a6d6cc8
No known key found for this signature in database
GPG key ID: 1E892DB2A5F84479
7 changed files with 31 additions and 28 deletions

View file

@ -132,7 +132,10 @@ includeFields = ""
# Regexp matching the Exif fields you want to exclude. This may be easier to use # Regexp matching the Exif fields you want to exclude. This may be easier to use
# than IncludeFields above, depending on what you want. # than IncludeFields above, depending on what you want.
excludeFields = "" excludeFields = ".*"
[minify.tdewolff.html] # don't minify html but minify other resources, esp the fulltext rss feed
keepWhitespace = true [minify]
minifyOutput = true
disableXML = false
disableHTML = true

View file

@ -12,15 +12,18 @@
already copy heading anchor links in the TOC. This just makes some already copy heading anchor links in the TOC. This just makes some
existing functionality slightly more easily. So it's less of a big existing functionality slightly more easily. So it's less of a big
deal deal
4. This reliably hides them from certain reading-mode implementations
(e.g. Readability)
Yeah I know, the situation isn't optimal. Yeah I know, the situation isn't optimal.
--> -->{{- with . -}}
<h{{ .Level }} id="{{ .Anchor | safeURL }}">{{ .Text | safeHTML }} <h{{ .Level }} id="{{ .Anchor | safeURL }}">{{ .Text | safeHTML -}}
{{ if and (gt .Level 1) (eq .Page.Section "posts") -}} {{- if and (gt .Level 1) (eq .Page.Section "posts") -}}
<a href="#{{ .Anchor | safeURL }}" aria-hidden="true" tabindex="-1"> <span aria-hidden="true"> <!--Wrap in a span so the whitespace before the link is also hidden-->
{{- $octothorpes := sub .Level 1 -}} <a href="#{{ .Anchor | safeURL }}" tabindex="-1">
{{- range $i, $sequence := (seq $octothorpes) -}} {{- $octothorpes := sub .Level 1 -}}
{{- print `#` -}} {{- range $i, $sequence := (seq $octothorpes) -}}
{{- end -}} {{- print `#` -}}
</a> {{- end -}}
</a></span>
{{- end }} {{- end }}
</h{{ .Level }}> </h{{ .Level }}>{{ end }}

View file

@ -1,5 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="{{- default "" .Site.LanguageCode -}}" prefix="og: https://ogp.me/ns# article: https://ogp.me/ns/article# cc: http://creativecommons.org/ns#"> <html lang={{- default "" .Site.LanguageCode }} prefix="og: https://ogp.me/ns# article: https://ogp.me/ns/article# cc: http://creativecommons.org/ns#">
{{ partial "head.html" . -}} {{ partial "head.html" . -}}
<body itemscope itemtype="https://schema.org/Blog https://schema.org/WebPage"> <body itemscope itemtype="https://schema.org/Blog https://schema.org/WebPage">
{{ partial "header.html" . -}} {{ partial "header.html" . -}}

View file

@ -1,16 +1,17 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="disabled-adaptations" content="watch"> <meta name="disabled-adaptations" content="watch"><meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://seirdy.one{{ .RelPermalink }}" rel="canonical">
<link href="https://seirdy.one/webmentions/receive" rel="webmention">
{{ if or (eq site.BaseURL "https://seirdy.one/") (in site.BaseURL "wgq3bd2kqoybhstp77i3wrzbfnsyd27wt34psaja4grqiezqircorkyd.onion") -}} {{ if or (eq site.BaseURL "https://seirdy.one/") (in site.BaseURL "wgq3bd2kqoybhstp77i3wrzbfnsyd27wt34psaja4grqiezqircorkyd.onion") -}}
<!-- IDC how much content is extracted from my pages, go knock yourself out. huge images, long snippets, whatever. -->
<meta name="robots" content="index,follow,max-image-preview:large,max-snippet=-1"> <meta name="robots" content="index,follow,max-image-preview:large,max-snippet=-1">
{{ end -}} {{ end -}}
<link href="https://seirdy.one{{ .RelPermalink }}" rel="canonical">
<link href="https://seirdy.one/webmentions/receive" rel="webmention">
{{ $webmanifest := resources.Get "/manifest.webmanifest" | resources.ExecuteAsTemplate "manifest.webmanifest" . | resources.Minify | resources.Fingerprint "md5" -}}
{{- printf `<link href="%s" rel="manifest">` $webmanifest.RelPermalink | safeHTML }}
<link rel="alternate" type="application/rss+xml" href="{{ site.BaseURL }}posts/index.xml" title="{{ $.Site.Title }}">
<title>{{ .Title }}{{ if and (lt (len .Title) 54) (ne .RelPermalink "/") }} - Seirdy{{ end }}</title> <title>{{ .Title }}{{ if and (lt (len .Title) 54) (ne .RelPermalink "/") }} - Seirdy{{ end }}</title>
<meta name="description" content="{{ if .Params.description }}{{ .Params.description }}{{ else }}{{ .Site.Params.Description }}{{ end }}"> <meta name="description" content="{{ if .Params.description }}{{ .Params.description }}{{ else }}{{ .Site.Params.Description }}{{ end }}">
<meta content="{{ .Site.Author.name }}" name="author"> <meta name="author" content="{{ .Site.Author.name }}">
<meta property="article:author" content="{{ .Site.Author.name }}"> <meta property="article:author" content="{{ .Site.Author.name }}">
{{ if gt .Date 0 -}} {{ if gt .Date 0 -}}
<meta property="article:published_time" content="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}"> <meta property="article:published_time" content="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}">
@ -29,14 +30,10 @@
{{ $favicon_base64 := $favicon.Content | base64Encode }} {{ $favicon_base64 := $favicon.Content | base64Encode }}
{{ printf `<link rel="icon" sizes="32x32" href="data:image/png;base64,%s" type="image/png">` $favicon_base64 | safeHTML -}} {{ printf `<link rel="icon" sizes="32x32" href="data:image/png;base64,%s" type="image/png">` $favicon_base64 | safeHTML -}}
<!-- Why does apple do this --> <!-- Why does apple do this -->
<meta name="format-detection" content="telephone=no">
<meta name="color-scheme" content="light dark"> <meta name="color-scheme" content="light dark">
<meta name="format-detection" content="telephone=no">
<meta name="theme-color" content="#0f0f0b" media="(prefers-color-scheme:dark)"> <meta name="theme-color" content="#0f0f0b" media="(prefers-color-scheme:dark)">
<meta name="theme-color" content="#fff" media="(prefers-color-scheme:light)"> <meta name="theme-color" content="#fff" media="(prefers-color-scheme:light)">
<!-- webmanifest defines even more icons. This is getting ridiculous -->
{{- $webmanifest := resources.Get "/manifest.webmanifest" | resources.ExecuteAsTemplate "manifest.webmanifest" . | resources.Minify | resources.Fingerprint "md5" -}}
{{- printf `<link href="%s" rel="manifest">` $webmanifest.RelPermalink | safeHTML }}
<link rel="alternate" type="application/rss+xml" href="{{ site.BaseURL }}posts/index.xml" title="{{ $.Site.Title }}">
<!-- inline CSS; remember to allow it with a hash in the CSP --> <!-- inline CSS; remember to allow it with a hash in the CSP -->
{{- $resources := slice -}} {{- $resources := slice -}}
{{- $resources = $resources | append (resources.Get "/css/main.css") -}} {{- $resources = $resources | append (resources.Get "/css/main.css") -}}

View file

@ -8,5 +8,5 @@
just use the beginning for the label and the full thing for the aria description. just use the beginning for the label and the full thing for the aria description.
--> -->
<figure aria-labelledby="{{ $id }}" itemscope itemtype="https://schema.org/SoftwareSourceCode"> <figure aria-labelledby="{{ $id }}" itemscope itemtype="https://schema.org/SoftwareSourceCode">
{{ .Inner | markdownify }} {{ .Inner | markdownify -}}
</figure> </figure>

View file

@ -5,7 +5,7 @@
{{- if (.Get "avatar") -}} {{- if (.Get "avatar") -}}
{{- $avatar_img := (resources.GetRemote (.Get "avatar")).Resize "32x32" -}} {{- $avatar_img := (resources.GetRemote (.Get "avatar")).Resize "32x32" -}}
<img itemprop="image" class="u-photo photo" src="{{ $avatar_img.RelPermalink }}" alt="" width="16" height="16"> <img itemprop="image" class="u-photo photo" src="{{ $avatar_img.RelPermalink }}" alt="" width="16" height="16">
{{- end }} {{- end -}}
<span itemprop="name" class="p-name fn n"> <span itemprop="name" class="p-name fn n">
{{- if (.Get "first-name") -}}<span itemprop="givenName" class="p-given-name given-name">{{- .Get "first-name" -}}</span>{{- end }} {{- if (.Get "first-name") -}}<span itemprop="givenName" class="p-given-name given-name">{{- .Get "first-name" -}}</span>{{- end }}
{{ if (.Get "last-name") -}}<span itemprop="familyName" class="p-family-name family-name">{{- .Get "last-name" -}}</span>{{- end -}} {{ if (.Get "last-name") -}}<span itemprop="familyName" class="p-family-name family-name">{{- .Get "last-name" -}}</span>{{- end -}}

View file

@ -82,7 +82,7 @@
<img <img
width="{{ $img_width }}" height="{{ $img_height }}" width="{{ $img_width }}" height="{{ $img_height }}"
src="{{ $light_png.RelPermalink }}" alt='{{ .Get "alt" }}' src="{{ $light_png.RelPermalink }}" alt='{{ .Get "alt" }}'
{{ with .Parent -}} {{- with .Parent -}}
{{- with .Get "id" -}} {{- with .Get "id" -}}
aria-describedby="transcript-{{ . }}" aria-describedby="transcript-{{ . }}"
{{- end -}} {{- end -}}