Skip to content

Commit 9d40d1e

Browse files
authored
feat: add the hb.blog.list_pinned_posts parameter, which is the number of posts pinned to the list, default to 1 (#1114)
1 parent a008ba3 commit 9d40d1e

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

hugo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ list_style = "" # available options: minimalist, cascade.
3030

3131
[params.hb.blog]
3232
list_style = "" # available options: minimalist, cascade.
33+
list_pinned_posts = 1
3334
full_width = false
3435
paginate = 12
3536
post_date_format = ':date_long'

layouts/_default/list.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{{- define "title" }}
22
{{- $pages := .RegularPagesRecursive }}
3+
{{- $pinned := first (default 1 .Site.Params.hb.blog.list_pinned_posts) (where $pages ".Params.pinned" true) }}
4+
{{- $pages = union $pinned $pages }}
35
{{- $paginator := .Paginate $pages (default 12 .Site.Params.hb.blog.paginate) }}
46
{{- .Store.Set "paginated" true }}
57
{{ partial "base/title" . }}

layouts/blog/list.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{{- define "title" }}
22
{{- $pages := .RegularPagesRecursive }}
3+
{{- $pinned := first (default 1 .Site.Params.hb.blog.list_pinned_posts) (where $pages ".Params.pinned" true) }}
4+
{{- $pages = union $pinned $pages }}
35
{{- $paginator := .Paginate $pages .Site.Params.hb.blog.paginate }}
46
{{- .Store.Set "paginated" true }}
57
{{ partial "base/title" . }}

0 commit comments

Comments
 (0)