Browse Source

optional featured images; article title also contains link

master
Alexander Avery 3 weeks ago
parent
commit
4561579f2f
  1. 10
      layouts/partials/article.html
  2. 2
      layouts/partials/image.html

10
layouts/partials/article.html

@ -1,9 +1,13 @@
{{- $alt := .Params.featured.alt }}
{{- $img := .Resources.GetMatch "featured" }}
<article class="index float-on-hover shadow">
<a href=" {{ .Permalink }}">
{{- $image := (.Resources.GetMatch "featured").Resize "256x webp q90" }}
<img src={{ $image.RelPermalink }} alt="{{ .Params.featured.alt }}">
</a>
{{- with $img }}
{{- $resized := .Resize "256x webp q90" }}
<img src={{ $resized.RelPermalink }} alt="{{ $alt }}">
{{- end }}
<h3 class="title">{{ .Title | markdownify }}</h3>
</a>
{{- if not (.Params.hideDate) }}
{{- with .Date }}
<p>{{ .Format "2006/01/02" }}</p>

2
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 }}

Loading…
Cancel
Save