Add a badge to the photo list items that have multiple photos in them

This commit is contained in:
Eryn Wells 2023-04-02 18:34:43 -07:00
parent baad04e7a4
commit 00d2e9263d
2 changed files with 39 additions and 2 deletions

View file

@ -1,6 +1,11 @@
{{- $thumbnail := partial "photos/thumbnail.html" (dict "Page" . "Width" 600 "Height" 600) -}}
{{- $thumbnail = $thumbnail.Crop "600x600" -}}
{{- $altText := $thumbnail.Params.alt -}}
{{- $numberOfImages := len (partial "photos/list.html" .) -}}
{{- $hasMultipleImages := gt $numberOfImages 1 -}}
<a href="{{ .RelPermalink }}" title="{{ .Title }}">
{{ if $hasMultipleImages }}
<div class="badge">{{ $numberOfImages }}</div>
{{ end }}
<img src="{{ $thumbnail.RelPermalink }}"{{ with $altText }} alt="{{ . }}"{{ end }}>
</a>