Skip to content

Commit

Permalink
feat: add the site.Params.hb.blog.list_cols_md and site.Params.hb.blo…
Browse files Browse the repository at this point in the history
…g.list_cols_lg parameter to specify cols for md and lg breakpoints respectively (#554)
  • Loading branch information
razonyang committed Dec 16, 2023
1 parent aa81cc0 commit f5be4a7
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 2 additions & 0 deletions hugo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ post_date_format = ':date_long'
post_thumbnail = true
post_thumbnail_placeholder = ""
post_thumbnail_default = "images/thumbnail.png"
list_cols_md = 2
list_cols_lg = 3 # won't work when sidebar was enabled.

[params.hb.blog.archives]
paginate = 30
Expand Down
5 changes: 5 additions & 0 deletions layouts/partials/hb/modules/blog/functions/list-cols.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{{- $cols := printf "row-cols-1 row-cols-md-%d" (default 2 site.Params.hb.blog.list_cols_md) }}
{{- if not (partialCached "hb/modules/blog/functions/has-sidebar" .) }}
{{- $cols = printf "%s row-cols-lg-%d" $cols (default 3 site.Params.hb.blog.list_cols_lg) }}
{{- end }}
{{- return $cols }}
5 changes: 1 addition & 4 deletions layouts/partials/hb/modules/blog/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@
{{ partialCached "hb/modules/blog/home/taxonomies" . }}
{{- end }}
{{- with .Paginator }}
{{- $cols := "row-cols-1 row-cols-md-2" }}
{{- if not (partialCached "hb/modules/blog/functions/has-sidebar" .) }}
{{- $cols = printf "%s row-cols-lg-3" $cols }}
{{- end }}
{{- $cols := partialCached "hb/modules/blog/functions/list-cols" . }}
{{ partial "hb/modules/blog/posts" (dict "Pages" .Pages "Cols" $cols) }}
{{ partial "hb/modules/pagination/index" . }}
{{- end }}
Expand Down
5 changes: 1 addition & 4 deletions layouts/partials/hb/modules/blog/list.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
<div class="hb-blog-main-container">
<div class="hb-blog-main">
{{ partial "hugopress/functions/render-hooks" (dict "Name" "hb-blog-main-begin" "Page" .) }}
{{- $cols := "row-cols-1 row-cols-md-2" }}
{{- if not (partialCached "hb/modules/blog/functions/has-sidebar" .) }}
{{- $cols = printf "%s row-cols-lg-3" $cols }}
{{- end }}
{{- $cols := partialCached "hb/modules/blog/functions/list-cols" . }}
{{ partial "hb/modules/blog/posts" (dict "Pages" .Paginator.Pages "Cols" $cols) }}
{{ partial "hb/modules/pagination/index" .Paginator }}
{{ partial "hugopress/functions/render-hooks" (dict "Name" "hb-blog-main-end" "Page" .) }}
Expand Down

0 comments on commit f5be4a7

Please sign in to comment.