redstrate.com/themes/red/layouts/partials/featured-art.html

60 lines
2.4 KiB
HTML
Raw Normal View History

2024-09-30 17:40:46 -04:00
{{/* Partial used to display a list of featured artwork. */}}
{{ $art_config := index .Site.Data "art-config" }}
2022-12-27 22:34:31 -05:00
<div class="gallery-con">
2024-02-19 15:29:36 -05:00
<div style="display: flex; flex-wrap: wrap;">
{{ with .Site.GetPage "/art" }}
2024-09-30 17:40:46 -04:00
{{ range (where (where .RegularPagesRecursive "Type" "art") "Params.slug" "in" $art_config.featured) }}
<figure class="gallery-fig">
{{ $filename_without_ext := .Params.slug }}
{{ $month := "1" }}
{{ $year := "1" }}
{{ if .Date }}
{{ $split := split .Date "-" }}
{{ $month = index $split 1 }}
{{ $year = index $split 0 }}
2024-02-12 19:31:12 -05:00
{{ end }}
2022-12-27 22:34:31 -05:00
2024-09-30 17:40:46 -04:00
{{ $use_newformat := false }}
{{ if ge (int $year) 2023 }}
{{ $use_newformat = true }}
2024-02-19 15:29:36 -05:00
{{ end }}
2024-09-30 17:40:46 -04:00
{{ $path := printf "/art/%s/%s/%s" $year $month $filename_without_ext}}
<a href="{{ $path }}" aria-label="Click to view details {{ $year }}" class="no-decoration">
{{ $title := .Title }}
{{ if $use_newformat }}
2024-10-12 14:59:49 -04:00
{{ $full := printf "%s/thumb/%s.avif" $.Site.Params.image_host $filename_without_ext }}
{{ $jpeg := printf "%s/thumb/%s.jpg" $.Site.Params.image_host $filename_without_ext }}
2024-09-30 17:40:46 -04:00
<picture>
<source srcset="{{ $full }}" type="image/avif"/>
<img class="gallery-img featured-art" alt="{{ $title }}" src="{{ $jpeg }}">
</picture>
{{ else }}
{{ with resources.Get (printf "art/%s" .filename) }}
{{ $image := .Resize "500x" }}
<img class="gallery-img featured-art" alt="{{ $title }}" width="{{ $image.Width }}" height="{{ $image.Height }}" src="{{ $image.RelPermalink }}">
{{ else }}
<p>Thumbnail not found!</p>
{{ end }}
{{ end }}
</a>
<figcaption>
{{ with .Title }}
<i>"{{ . }}"</i>
{{ end }}
</figcaption>
</figure>
2024-02-19 15:29:36 -05:00
{{ end }}
2022-12-27 22:34:31 -05:00
{{ end }}
2024-02-19 15:29:36 -05:00
</div>
2024-09-30 17:40:46 -04:00
<a href="/art">View all art</a>
2022-12-27 22:34:31 -05:00
</div>