The headings jumped when Jersey 10 arrived after the first paint: the monospace fallback is much wider, so the heading chips changed their width, and the page transition made it visible on every language switch. Reproduced with revalidated or slow fonts (hugo server sends no cache headers, so it revalidates them on every navigation) in Chromium, WebKit and, on cold loads, Firefox. In Safari the body text shifted as well, because its ui-monospace is the wider SF Mono. - Embeds the Latin subset of Jersey 10 in the fonts stylesheet. - Preloads Hack Regular and Bold. - Generates the @font-face rules and the preload links from one fingerprinted template (assets/css/fonts.css.tmpl, head/fonts.html), so their URLs match and also work below a sub path like the PR previews. - Drops ui-monospace and SF Mono from the body font stack: Menlo has the same width as Hack. Frames with shifted elements while switching language on the tours page, with revalidated or slow fonts: 9 to 92 before, none after (Chromium and WebKit, desktop and mobile). Firefox cold loads: up to 48 before, none painted after. Rendering after loading is unchanged. Trade-off: the first paint of a cold load on a slow connection (Slow 4G) is about 0.26 s later; later navigations are not affected. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
55 lines
2.4 KiB
HTML
55 lines
2.4 KiB
HTML
{{ partial "head/fonts.html" . }}
|
|
{{- /* Browser UI colours, the same as the page backgrounds in assets/css/_custom.css. */ -}}
|
|
<meta name="theme-color" media="(prefers-color-scheme: light)" content="#ebedf0">
|
|
<meta name="theme-color" media="(prefers-color-scheme: dark)" content="#001300">
|
|
{{- /*
|
|
Open Graph image for link previews. The theme's head/meta.html writes og:image only for the
|
|
"image" param; without it, this uses the first image in the page, a Markdown image or a
|
|
gallery-image shortcode, scaled down to at most 1200 pixels wide, with its alt text as
|
|
og:image:alt.
|
|
*/ -}}
|
|
{{- if not ($.Param "image") -}}
|
|
{{- /* Whichever comes first: a Markdown image or a gallery-image shortcode (src and alt in "…" or `…`). */ -}}
|
|
{{- with findRESubmatch `!\[([^\]]*)\]\(\s*<?([^\s)>]+)|\{\{<\s*gallery-image\s([^}]*)>\}\}` .RawContent 1 -}}
|
|
{{- $alt := index . 0 1 -}}
|
|
{{- $dest := index . 0 2 -}}
|
|
{{- with index . 0 3 -}}
|
|
{{- $dest = "" -}}
|
|
{{- $alt = "" -}}
|
|
{{- with findRESubmatch "\\bsrc=(?:\"([^\"]*)\"|`([^`]*)`)" . 1 }}{{ $dest = or (index . 0 1) (index . 0 2) }}{{ end -}}
|
|
{{- with findRESubmatch "\\balt=(?:\"([^\"]*)\"|`([^`]*)`)" . 1 }}{{ $alt = or (index . 0 1) (index . 0 2) }}{{ end -}}
|
|
{{- end -}}
|
|
{{- $url := "" -}}
|
|
{{- $width := 0 -}}
|
|
{{- $height := 0 -}}
|
|
{{- $resource := false -}}
|
|
{{- if findRE `^https?://` $dest -}}
|
|
{{- $url = $dest -}}
|
|
{{- else -}}
|
|
{{- $resource = or ($.Resources.Get (strings.TrimPrefix "./" $dest)) (resources.Get $dest) -}}
|
|
{{- end -}}
|
|
{{- with $resource -}}
|
|
{{- $image := . -}}
|
|
{{- if and (eq .ResourceType "image") (ne .MediaType.SubType "svg") -}}
|
|
{{- /* Turned as its EXIF orientation says; Hugo doesn't do that when it resizes. */ -}}
|
|
{{- $image = .Filter images.AutoOrient -}}
|
|
{{- if gt $image.Width 1200 }}{{ $image = $image.Resize "1200x" }}{{ end -}}
|
|
{{- $width = $image.Width -}}
|
|
{{- $height = $image.Height -}}
|
|
{{- end -}}
|
|
{{- $url = $image.Permalink -}}
|
|
{{- end -}}
|
|
{{- with $url }}
|
|
<meta property="og:image" content="{{ . }}">
|
|
{{- with $width }}
|
|
<meta property="og:image:width" content="{{ . }}">
|
|
<meta property="og:image:height" content="{{ $height }}">
|
|
{{- end }}
|
|
{{- with $alt }}
|
|
<meta property="og:image:alt" content="{{ . }}">
|
|
{{- end }}
|
|
<meta name="twitter:card" content="summary_large_image">
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|