From 4561579f2f368ed72132239b75a85f31580f9740 Mon Sep 17 00:00:00 2001 From: Alexander Avery Date: Fri, 30 May 2025 20:45:39 -0400 Subject: [PATCH] optional featured images; article title also contains link --- layouts/partials/article.html | 10 +++++++--- layouts/partials/image.html | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/layouts/partials/article.html b/layouts/partials/article.html index 4e290a7..570371e 100644 --- a/layouts/partials/article.html +++ b/layouts/partials/article.html @@ -1,9 +1,13 @@ +{{- $alt := .Params.featured.alt }} +{{- $img := .Resources.GetMatch "featured" }}
- {{- $image := (.Resources.GetMatch "featured").Resize "256x webp q90" }} - {{ .Params.featured.alt }} - + {{- with $img }} + {{- $resized := .Resize "256x webp q90" }} + {{ $alt }} + {{- end }}

{{ .Title | markdownify }}

+ {{- if not (.Params.hideDate) }} {{- with .Date }}

{{ .Format "2006/01/02" }}

diff --git a/layouts/partials/image.html b/layouts/partials/image.html index cfd8d7d..6dc8b1d 100644 --- a/layouts/partials/image.html +++ b/layouts/partials/image.html @@ -15,6 +15,7 @@ Renders an image with the given class, alt, and sizes. {{- $sizesParts := slice }} {{- $len := len $sizes }} +{{- if .image }} {{/* Loop through widths to resize images and build attributes */}} {{- range $index, $width := $sizes }} {{- $resizeSpec := printf "%dx webp q90" $width }} @@ -41,3 +42,4 @@ Renders an image with the given class, alt, and sizes. sizes="{{ delimit $sizesParts ", " }}" alt="{{ $alt }}" > +{{- end }}