Skip to content

Commit 0affe8c

Browse files
feat: allow highlighting the images and display them in parent section (#97)
Co-authored-by: Paul Traina <[email protected]>
1 parent 1b0395b commit 0affe8c

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

hugo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ paginate = 24
1818
# - x[height]: resize to a height of [height]px and preserve aspect ratio, such as x640.
1919
thumbnail_size = "x640"
2020
date_sort_order = "desc"
21+
highlight_images_count = 10
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{{- if .IsSection }}
2+
{{- $imgs := slice }}
3+
{{- range .RegularPages }}
4+
{{- $imgs = $imgs | append (partialCached "hb/modules/gallery/functions/page-imgs" . .) }}
5+
{{- end }}
6+
{{- $imgs = where $imgs ".Image.Params.highlight" true }}
7+
{{- $imgs = partial "hb/modules/gallery/functions/sort-imgs" $imgs }}
8+
{{- range first (default 10 site.Params.hb.gallery.highlight_images_count) $imgs }}
9+
<div class="hb-gallery-album-item hb-gallery-album-item-highlight flex-grow-1 position-relative">
10+
{{- partialCached "hb/modules/gallery/img" .Image .Image }}
11+
{{- partialCached "hb/modules/gallery/info" .Image .Image }}
12+
<p
13+
class="hb-gallery-title position-absolute bottom-0 mb-0 px-1 text-white text-center w-100 text-truncate">
14+
{{- default .Image.Name .Image.Title -}}
15+
</p>
16+
</div>
17+
{{- end }}
18+
{{- end }}

layouts/partials/hb/modules/gallery/list.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<div class="hb-gallery-albums">
55
<div
66
class="hb-gallery-album hb-gallery-album-items d-flex flex-wrap hb-module">
7+
{{- partial "hb/modules/gallery/highlight" . }}
78
{{- range .Paginator.Pages }}
89
{{- $page := . }}
910
{{- $imgs := slice }}

0 commit comments

Comments
 (0)