Files
Gallery/themes/gallery/layouts/partials/featured.html
2024-11-13 22:27:02 +01:00

24 lines
1.1 KiB
HTML

{{ range where site.Pages.ByDate.Reverse "Params.featured" "=" true | first 1 }}
{{ $gallery := partial "get-gallery.html" . }}
{{ if $gallery }}
{{ $images := .Resources.ByType "image" }}
{{ $featured := ($images.GetMatch (.Params.featured_image | default "*feature*")) | default (index $images 0) }}
{{ $thumbnail := $featured.Filter (slice images.AutoOrient (images.Process "fit 1600x1600")) }}
{{ $color := index $thumbnail.Colors 0 | default "transparent" }}
<section class="featured">
<a class="featured-card" href="{{ .RelPermalink }}" style="background-color: {{ $color }}; background-image: url({{ $thumbnail.RelPermalink }})">
<div>
<h2>{{ .Title }}</h2>
<p>
{{ if gt $gallery.albumCount 0 }}
{{ T "albumCount" (dict "count" ($gallery.albumCount | lang.FormatNumber 0) "photoCount" ($gallery.imageCount | lang.FormatNumber 0 | lang.Translate "photoCount")) }}
{{ else }}
{{ T "photoCount" ($gallery.imageCount | lang.FormatNumber 0) }}
{{ end }}
</p>
</div>
</a>
</section>
{{ end }}
{{ end }}