feat(archive widget): improve "more" link

Link it to the next available year
This commit is contained in:
Jimmy Cai 2020-09-20 13:26:10 +02:00
parent 75f5c209e1
commit 9d76ab371f
No known key found for this signature in database
GPG Key ID: 3EA408E527F37B18

View File

@ -9,20 +9,16 @@
{{ $filtered := ($pages | intersect $notHidden) }} {{ $filtered := ($pages | intersect $notHidden) }}
{{ $archives := $filtered.GroupByDate "2006" }} {{ $archives := $filtered.GroupByDate "2006" }}
{{ range first .Site.Params.widgets.archives.limit ($archives) }} {{ range $index, $item := first (add .Site.Params.widgets.archives.limit 1) ($archives) }}
{{ $id := lower (replace .Key " " "-") }} {{- $id := lower (replace $item.Key " " "-") -}}
<div class="archives-year"> <div class="archives-year">
<a href="{{ $.Site.Params.widgets.archives.path | relLangURL }}#{{ $id }}"> <a href="{{ $.Site.Params.widgets.archives.path | relLangURL }}#{{ $id }}">
<span class="year">{{ .Key }}</span> {{ if eq $index $.Site.Params.widgets.archives.limit }}
<span class="count">{{ len .Pages }}</span> <span class="year">{{ T "widgetArchivesMore" }}</span>
</a> {{ else }}
</div> <span class="year">{{ .Key }}</span>
{{ end }} <span class="count">{{ len $item.Pages }}</span>
{{ end }}
{{ if gt (len $archives) .Site.Params.widgets.archives.limit }}
<div class="archives-year">
<a href="{{ $.Site.Params.widgets.archives.path | relLangURL }}">
<span class="year">{{ T "widgetArchivesMore" }}</span>
</a> </a>
</div> </div>
{{ end }} {{ end }}