Hugo-theme-stack/layouts/partials/widget/archives.html

27 lines
1.2 KiB
HTML
Raw Normal View History

2020-09-13 05:22:47 -04:00
<section class="widget archives">
2020-08-22 07:20:08 -04:00
<div class="widget-icon">
2020-10-09 18:27:56 -04:00
{{ partial "helper/icon" "infinity" }}
2020-08-22 07:20:08 -04:00
</div>
<h2 class="widget-title section-title">{{ T "widget.archives.title" }}</h2>
2020-08-22 07:20:08 -04:00
{{ $pages := where .Site.RegularPages "Type" "in" .Site.Params.mainSections }}
{{ $notHidden := where .Site.RegularPages "Params.hidden" "!=" true }}
{{ $filtered := ($pages | intersect $notHidden) }}
2020-09-13 05:22:47 -04:00
{{ $archives := $filtered.GroupByDate "2006" }}
2020-10-17 04:34:36 -04:00
<div class="widget-archive--list">
{{ 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 }}">
{{ if eq $index $.Site.Params.widgets.archives.limit }}
<span class="year">{{ T "widget.archives.more" }}</span>
2020-10-17 04:34:36 -04:00
{{ else }}
<span class="year">{{ .Key }}</span>
<span class="count">{{ len $item.Pages }}</span>
{{ end }}
</a>
</div>
{{ end }}
</div>
</section>