diff --git a/hugo.toml b/hugo.toml index 7f2fc693..20785f27 100644 --- a/hugo.toml +++ b/hugo.toml @@ -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 diff --git a/layouts/partials/hb/modules/blog/functions/list-cols.html b/layouts/partials/hb/modules/blog/functions/list-cols.html new file mode 100644 index 00000000..32f9c9a5 --- /dev/null +++ b/layouts/partials/hb/modules/blog/functions/list-cols.html @@ -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 }} diff --git a/layouts/partials/hb/modules/blog/index.html b/layouts/partials/hb/modules/blog/index.html index 131bc455..9ccdf9fa 100644 --- a/layouts/partials/hb/modules/blog/index.html +++ b/layouts/partials/hb/modules/blog/index.html @@ -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 }} diff --git a/layouts/partials/hb/modules/blog/list.html b/layouts/partials/hb/modules/blog/list.html index 630e676e..003f2aae 100644 --- a/layouts/partials/hb/modules/blog/list.html +++ b/layouts/partials/hb/modules/blog/list.html @@ -1,10 +1,7 @@