Skip to content

Commit

Permalink
feat: add the hb.blog.list_style parameter, available option: `minima…
Browse files Browse the repository at this point in the history
…list`

feat: add the hb.terms.list_style parameter, available option: `minimalist`
  • Loading branch information
razonyang committed Jun 2, 2024
1 parent 20758ab commit 9bcc571
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 14 deletions.
2 changes: 2 additions & 0 deletions hugo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ path = "github.com/hugomods/images"
paginate = 12
profile = true
profile_metrics = true
list_style = "" # available options: minimalist.

[params.hb.blog]
list_style = "" # available options: minimalist.
full_width = false
paginate = 12
post_date_format = ':date_long'
Expand Down
37 changes: 27 additions & 10 deletions layouts/_default/term.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,34 @@
{{- if default true site.Params.hb.terms.profile }}
{{ partialCached "hb/modules/blog/term/profile" . . }}
{{- end }}
{{- $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 }}
<div class="hb-terms-posts row {{ $cols }}">
{{- range .Paginator.Pages }}
<div class="mb-3 mb-lg-4">
{{ partial "hb/modules/blog/post/card" (dict "Page" .) }}
</div>
{{- if eq site.Params.hb.terms.list_style "minimalist" }}
<div class="hb-blog-posts hb-terms-posts hb-module">
{{- range .Paginator.Pages }}
<div class="hb-blog-post hb-terms-post">
<a class="hb-blog-post-title-link d-flex" href="{{ .RelPermalink }}">
<span class="me-md-1">
{{ .Title }}
</span>
<span class="hb-blog-post-meta ms-auto d-none d-md-block text-body-secondary text-nowrap">
{{ .Date | time.Format site.Params.hb.blog.post_date_format }}
</span>
</a>
</div>
{{- end }}
</div>
{{- else }}
{{- $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 }}
</div>
<div class="hb-terms-posts row {{ $cols }}">
{{- range .Paginator.Pages }}
<div class="mb-3 mb-lg-4">
{{ partial "hb/modules/blog/post/card" (dict "Page" .) }}
</div>
{{- end }}
</div>
{{- end }}
{{ partial "hb/modules/pagination/index" .Paginator }}
{{ partial "hugopress/functions/render-hooks" (dict "Name" "hb-blog-main-end" "Page" .) }}
</div>
Expand Down
8 changes: 6 additions & 2 deletions layouts/partials/hb/modules/blog/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@
</div>
{{- end }}
{{- with .Paginator }}
{{- $cols := partialCached "hb/modules/blog/functions/list-cols" . }}
{{ partial "hb/modules/blog/posts" (dict "Pages" .Pages "Cols" $cols) }}
{{- if eq site.Params.hb.blog.list_style "minimalist" }}
{{ partial "hb/modules/blog/posts-minimalist" (dict "Pages" .Pages) }}
{{- else }}
{{- $cols := partialCached "hb/modules/blog/functions/list-cols" . }}
{{ partial "hb/modules/blog/posts" (dict "Pages" .Pages "Cols" $cols) }}
{{- end }}
{{ partial "hb/modules/pagination/index" . }}
{{- end }}
</div>
Expand Down
8 changes: 6 additions & 2 deletions layouts/partials/hb/modules/blog/list.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<div class="hb-blog-main-container">
<div class="hb-blog-main">
{{ partial "hugopress/functions/render-hooks" (dict "Name" "hb-blog-main-begin" "Page" .) }}
{{- $cols := partialCached "hb/modules/blog/functions/list-cols" . }}
{{ partial "hb/modules/blog/posts" (dict "Pages" .Paginator.Pages "Cols" $cols) }}
{{- if eq site.Params.hb.blog.list_style "minimalist" }}
{{ partial "hb/modules/blog/posts-minimalist" (dict "Pages" .Paginator.Pages) }}
{{- else }}
{{- $cols := partialCached "hb/modules/blog/functions/list-cols" . }}
{{ partial "hb/modules/blog/posts" (dict "Pages" .Paginator.Pages "Cols" $cols) }}
{{- end }}
{{ partial "hb/modules/pagination/index" .Paginator }}
{{ partial "hugopress/functions/render-hooks" (dict "Name" "hb-blog-main-end" "Page" .) }}
</div>
Expand Down
14 changes: 14 additions & 0 deletions layouts/partials/hb/modules/blog/posts-minimalist.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<div class="hb-blog-posts hb-module">
{{- range .Pages }}
<div class="hb-blog-post">
<a class="hb-blog-post-title-link d-flex" href="{{ .RelPermalink }}">
<span class="me-md-1">
{{ .Title }}
</span>
<span class="hb-blog-post-meta ms-auto d-none d-md-block text-body-secondary text-nowrap">
{{ .Date | time.Format site.Params.hb.blog.post_date_format }}
</span>
</a>
</div>
{{- end }}
</div>

0 comments on commit 9bcc571

Please sign in to comment.