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

58 lines
2.2 KiB
HTML
Raw Normal View History

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" }}
{{ range .Param "featured" }}
<figure class="gallery-fig">
{{ $filename_without_ext := strings.TrimSuffix (path.Ext .filename) .filename }}
{{ $month := "1" }}
{{ $year := "1" }}
{{ if .date }}
{{ $split := split .date "-" }}
{{ $month = index $split 1 }}
{{ $year = index $split 0 }}
{{ end }}
2022-12-27 22:34:31 -05:00
2024-02-19 15:29:36 -05:00
{{ $use_newformat := false }}
{{ if ge (int $year) 2023 }}
{{ $use_newformat = true }}
{{ end }}
2024-02-12 19:31:12 -05:00
2024-02-19 15:29:36 -05:00
{{ $path := printf "/art/%s/%s/%s" $year $month $filename_without_ext}}
2022-12-27 22:34:31 -05:00
2024-02-19 15:29:36 -05:00
<a href="{{ $path }}" aria-label="Click to view details {{ $year }}" class="no-decoration">
{{ $title := .title }}
2024-02-12 19:31:12 -05:00
2024-02-19 15:29:36 -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 }}
2024-02-12 19:31:12 -05:00
2024-02-19 15:29:36 -05:00
<picture>
<source srcset="{{ $full }}" type="image/avif"/>
<img class="gallery-img featured-art" alt="{{ $title }}" src="{{ $jpeg }}">
</picture>
2024-02-12 19:31:12 -05:00
{{ else }}
2024-02-19 15:29:36 -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 }}
2024-02-12 19:31:12 -05:00
{{ end }}
2024-02-19 15:29:36 -05:00
</a>
2022-12-27 22:34:31 -05:00
2024-02-19 15:29:36 -05:00
<figcaption>
{{ with .title }}
<i>"{{ . }}"</i>
{{ end }}
</figcaption>
</figure>
{{ end }}
2022-12-27 22:34:31 -05:00
{{ end }}
2024-02-19 15:29:36 -05:00
</div>
2024-02-21 17:54:24 -05:00
{{ if not (eq (.Scratch.Get "skip_all") "true") }}
<a href="/art">View all art</a>
{{ end }}
2022-12-27 22:34:31 -05:00
</div>