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

53 lines
1.8 KiB
HTML
Raw Normal View History

2022-12-27 22:34:31 -05:00
<div class="gallery-con">
{{ with .Site.GetPage "/art" }}
{{ range .Param "featured" }}
<figure class="gallery-fig">
{{ $filename_without_ext := strings.TrimSuffix (path.Ext .filename) .filename }}
2023-09-24 22:36:17 -04:00
{{ $month := "1" }}
{{ $year := "1" }}
2022-12-27 22:34:31 -05:00
{{ if .date }}
{{ $split := split .date "-" }}
{{ $month = index $split 1 }}
{{ $year = index $split 0 }}
2022-12-27 22:34:31 -05:00
{{ end }}
2024-02-12 19:31:12 -05:00
{{ $use_newformat := false }}
{{ if ge (int $year) 2023 }}
{{ $use_newformat = true }}
{{ end }}
2023-09-24 22:39:52 -04:00
{{ $path := printf "/art/%s/%s/%s" $year $month $filename_without_ext}}
2022-12-27 22:34:31 -05:00
2024-02-12 19:31:12 -05:00
<a href="{{ $path }}" aria-label="Click to view details {{ $year }}" class="no-decoration">
2022-12-27 22:34:31 -05:00
{{ $title := .title }}
2024-02-12 19:31:12 -05:00
{{ if $use_newformat }}
{{ $full := printf "https://images.redstrate.com/thumb/%s.avif" $filename_without_ext }}
{{ $jpeg := printf "https://images.redstrate.com/thumb/%s.jpg" $filename_without_ext }}
<picture>
<source srcset="{{ $full }}" type="image/avif"/>
<img class="gallery-img featured-art" alt="{{ $title }}" src="{{ $jpeg }}">
</picture>
2022-12-27 22:34:31 -05:00
{{ else }}
2024-02-12 19:31:12 -05:00
{{ 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 }}
2022-12-27 22:34:31 -05:00
{{ end }}
</a>
<figcaption>
{{ with .title }}
2023-04-13 17:19:53 -04:00
<i>"{{ . }}"</i>
2022-12-27 22:34:31 -05:00
{{ end }}
</figcaption>
</figure>
{{ end }}
{{ end }}
</div>