Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add the site.Params.hb.blog.list_cols_md and site.Params.hb.blog.list_cols_lg #554

Merged
merged 1 commit into from
Dec 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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