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 cascade list style for posts list and terms list #915

Merged
merged 1 commit into from
Jun 21, 2024
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
7 changes: 5 additions & 2 deletions hugo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@ path = "github.com/hugomods/icons/vendors/bootstrap"
[[module.imports]]
path = "github.com/hugomods/images"

[[module.imports]]
path = "github.com/hugomods/masonry-js"

[params.hb.terms]
paginate = 12
profile = true
profile_metrics = true
list_style = "" # available options: minimalist.
list_style = "" # available options: minimalist, cascade.

[params.hb.blog]
list_style = "" # available options: minimalist.
list_style = "" # available options: minimalist, cascade.
full_width = false
paginate = 12
post_date_format = ':date_long'
Expand Down
14 changes: 11 additions & 3 deletions layouts/_default/term.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
{{- if default true site.Params.hb.terms.profile }}
{{ partialCached "hb/modules/blog/term/profile" . . }}
{{- end }}
{{- if eq site.Params.hb.terms.list_style "minimalist" }}
{{- $listStyle := site.Params.hb.terms.list_style }}
{{- if eq $listStyle "minimalist" }}
<div class="hb-blog-posts hb-terms-posts hb-module">
{{- range .Paginator.Pages }}
<div class="hb-blog-post hb-terms-post">
Expand All @@ -34,10 +35,17 @@
{{- if not (partialCached "hb/modules/blog/functions/has-sidebar" .) }}
{{- $cols = printf "%s row-cols-lg-3" $cols }}
{{- end }}
<div class="hb-terms-posts row {{ $cols }}">
{{- if eq $listStyle "cascade" }}
{{ partialCached "hugomods/masonry-js/assets/js" . }}
{{- end }}
<div
{{ if eq $listStyle "cascade" }}
data-masonry="{&quot;percentPosition&quot;: true }"
{{ end }}
class="hb-terms-posts row {{ $cols }}">
{{- range .Paginator.Pages }}
<div class="mb-3 mb-lg-4">
{{ partial "hb/modules/blog/post/card" (dict "Page" .) }}
{{ partial "hb/modules/blog/post/card" (dict "Page" . "ListStyle" $listStyle "Caller" "list") }}
</div>
{{- end }}
</div>
Expand Down
5 changes: 5 additions & 0 deletions layouts/partials/hb/modules/blog/post/card.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,15 @@
{{- $meta := default true .Meta }}
{{- $pageMeta := default dict $page.Params.meta }}
{{- $modularize := default true .Modularize }}
{{- $listStyle := default "" .ListStyle }}
{{- $thumbnail := true }}
{{- $thumbnailPos := "top" }}
{{- if eq .Caller "list" }}
{{- $thumbnail = default true site.Params.hb.blog.post_thumbnail }}
{{- $imgs := partialCached "_funcs/get-page-images" $page $page }}
{{- if eq $listStyle "cascade" }}
{{- $thumbnail = (gt (len $imgs) 0) }}
{{- end }}
{{- $thumbnailPos = site.Params.hb.blog.post_thumbnail_position }}
{{- end }}
<div
Expand Down
14 changes: 11 additions & 3 deletions layouts/partials/hb/modules/blog/posts.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
{{- $cols := default "row-cols-1 row-cols-lg-2 row-cols-xl-3" .Cols }}
{{- $readMore := default (default true site.Params.hb.blog.post_read_more) .ReadMore }}
{{- $readMore := default site.Params.hb.blog.post_read_more .ReadMore }}
{{- $modularize := default true .Modularize }}
<div class="hb-blog-posts row {{ $cols }} g-3 mb-3">
{{- $listStyle := site.Params.hb.blog.list_style }}
{{- if eq $listStyle "cascade" }}
{{ partialCached "hugomods/masonry-js/assets/js" . }}
{{- end }}
<div
{{ if eq $listStyle "cascade" }}
data-masonry="{&quot;percentPosition&quot;: true }"
{{ end }}
class="hb-blog-posts row {{ $cols }} g-3 mb-3">
{{ range .Pages }}
<div class="col">
{{- $ctx := dict "Page" . "ReadMore" $readMore "Modularize" $modularize "Caller" "list" }}
{{- $ctx := dict "Page" . "ReadMore" $readMore "Modularize" $modularize "Caller" "list" "ListStyle" $listStyle }}
{{ partial "hb/modules/blog/post/card" $ctx }}
</div>
{{ end }}
Expand Down