Skip to content

Commit

Permalink
fix: add post counter in taxonomy page
Browse files Browse the repository at this point in the history
  • Loading branch information
xianmin committed Nov 11, 2024
1 parent 17a6380 commit af8af2e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
4 changes: 2 additions & 2 deletions layouts/_default/section.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
{{ $title_block := printf `
<div class="archive-title">
<h1>%s</h1>
<span class="archive-post-counter">%s</span>
<span class="archive-post-counter">%d posts</span>
</div>
` (i18n "archive") (i18n "counter_archives" (len .Data.Pages)) }}
` (i18n "archive") (len .Data.Pages) }}

{{ partial "archive-list.html" (dict
"paginator" $paginator
Expand Down
15 changes: 12 additions & 3 deletions layouts/_default/taxonomy.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@
{{/* Generate title block for first page */}}
{{ if not $paginator.HasPrev }}
{{ if eq .Data.Plural "tags" }}
{{ $title_block = printf `<div class="archive-title tag"><h2 class="archive-name">%s%s</h2></div>` (i18n "tag") .Title }}
{{ $title_block = printf `<div class="archive-title tag">
<h2 class="archive-name">%s%s</h2>
<span class="archive-post-counter">%d posts</span>
</div>` (i18n "tag") .Title (len .Data.Pages) }}
{{ else if eq .Data.Plural "categories" }}
{{/* Get category display name */}}
{{- $category_key := lower .Title -}}
Expand All @@ -55,14 +58,20 @@
{{ end }}
{{ end }}
{{ end }}
{{ $title_block = printf `<div class="archive-title category"><h2 class="archive-name">%s%s</h2></div>` (i18n "category") $displayName }}
{{ $title_block = printf `<div class="archive-title category">
<h2 class="archive-name">%s%s</h2>
<span class="archive-post-counter">%d posts</span>
</div>` (i18n "category") $displayName (len .Data.Pages) }}
{{ $show_category_nav = true }}
{{ else if eq .Data.Singular "author" }}
{{/* Get author display name */}}
{{- $author := (index (.Site.Data.authors | default dict) .Title) -}}
{{- $author_lang := (index ($author | default dict) .Site.Language.Lang) -}}
{{- $displayName := $author_lang.name.display | default $author.name.display | default .Title -}}
{{ $title_block = printf `<div class="archive-title author"><h2 class="archive-name">%s%s</h2></div>` (i18n "author_item") $displayName }}
{{ $title_block = printf `<div class="archive-title author">
<h2 class="archive-name">%s%s</h2>
<span class="archive-post-counter">%d posts</span>
</div>` (i18n "author_item") $displayName (len .Data.Pages) }}
{{ end }}
{{ end }}

Expand Down

0 comments on commit af8af2e

Please sign in to comment.