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) }}
{{ $archives := $filtered.GroupByDate "2006" }}
{{ range first .Site.Params.widgets.archives.limit ($archives) }}
{{ $id := lower (replace .Key " " "-") }}
{{ range $index, $item := first (add .Site.Params.widgets.archives.limit 1) ($archives) }}
{{- $id := lower (replace $item.Key " " "-") -}}
<div class="archives-year">
<a href="{{ $.Site.Params.widgets.archives.path | relLangURL }}#{{ $id }}">
<span class="year">{{ .Key }}</span>
<span class="count">{{ len .Pages }}</span>
</a>
</div>
{{ 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>
{{ if eq $index $.Site.Params.widgets.archives.limit }}
<span class="year">{{ T "widgetArchivesMore" }}</span>
{{ else }}
<span class="year">{{ .Key }}</span>
<span class="count">{{ len $item.Pages }}</span>
{{ end }}
</a>
</div>
{{ end }}