Added srcset to logo partial to improve compression and logo size on smaller devices.

This commit is contained in:
Jeremy Karst 2026-01-07 18:59:31 -05:00
parent 4cfcb45a7d
commit 7a464e60c6

View file

@ -2,26 +2,31 @@
{{- $logo := resources.Get .Site.Params.header.logo }} {{- $logo := resources.Get .Site.Params.header.logo }}
{{- $logo_dark := resources.Get .Site.Params.header.logoDark }} {{- $logo_dark := resources.Get .Site.Params.header.logoDark }}
{{- if $logo }} {{- if $logo }}
{{- $logoResized := $logo.Resize (printf "%dx" (div $logo.Width 2)) }} {{- $logoResized1x := $logo.Resize "160x webp" }}
{{- $logoDarkResized := "" }} {{- $logoResized2x := $logo.Resize "320x webp" }}
{{- $logoDarkResized1x := "" }}
{{- $logoDarkResized2x := "" }}
{{- if $logo_dark }} {{- if $logo_dark }}
{{- $logoDarkResized = $logo_dark.Resize (printf "%dx" (div $logo_dark.Width 2)) }} {{- $logoDarkResized1x = $logo_dark.Resize "160x webp" }}
{{- $logoDarkResized2x = $logo_dark.Resize "320x webp" }}
{{- end }} {{- end }}
<a href="{{ "" | relLangURL }}" class="mr-2"> <a href="{{ "" | relLangURL }}" class="mr-2">
<!-- prettier-ignore-attribute --> <!-- prettier-ignore-attribute -->
<img <img
src="{{ $logoResized.RelPermalink }}" src="{{ $logoResized1x.RelPermalink }}"
width="{{ $logoResized.Width }}" srcset="{{ $logoResized1x.RelPermalink }} 1x, {{ $logoResized2x.RelPermalink }} 2x"
height="{{ $logoResized.Height }}" width="{{ $logoResized1x.Width }}"
height="{{ $logoResized1x.Height }}"
class="max-h-[10rem] max-w-[10rem] object-scale-down object-left class="max-h-[10rem] max-w-[10rem] object-scale-down object-left
{{ if $logo_dark }}hidden dark:flex{{ end }}" {{ if $logo_dark }}hidden dark:flex{{ end }}"
alt="{{ .Site.Title }}" alt="{{ .Site.Title }}"
/> />
{{- if $logo_dark }} {{- if $logo_dark }}
<img <img
src="{{ $logoDarkResized.RelPermalink }}" src="{{ $logoDarkResized1x.RelPermalink }}"
width="{{ $logoDarkResized.Width }}" srcset="{{ $logoDarkResized1x.RelPermalink }} 1x, {{ $logoDarkResized2x.RelPermalink }} 2x"
height="{{ $logoDarkResized.Height }}" width="{{ $logoDarkResized1x.Width }}"
height="{{ $logoDarkResized1x.Height }}"
class="max-h-[10rem] max-w-[10rem] object-scale-down object-left dark:hidden" class="max-h-[10rem] max-w-[10rem] object-scale-down object-left dark:hidden"
alt="{{ .Site.Title }}" alt="{{ .Site.Title }}"
/> />