2022-02-26 17:45:25 -05:00
|
|
|
{{- $query := first 1 (where .Context.Site.Pages "Layout" "==" "archives") -}}
|
|
|
|
{{- $context := .Context -}}
|
|
|
|
{{- $limit := default 5 .Params.limit -}}
|
2021-01-01 07:16:11 -05:00
|
|
|
{{- if $query -}}
|
|
|
|
{{- $archivesPage := index $query 0 -}}
|
|
|
|
<section class="widget archives">
|
|
|
|
<div class="widget-icon">
|
|
|
|
{{ partial "helper/icon" "infinity" }}
|
|
|
|
</div>
|
|
|
|
<h2 class="widget-title section-title">{{ T "widget.archives.title" }}</h2>
|
2020-08-22 07:20:08 -04:00
|
|
|
|
2022-02-26 17:45:25 -05:00
|
|
|
{{ $pages := where $context.Site.RegularPages "Type" "in" $context.Site.Params.mainSections }}
|
2022-10-29 11:14:19 -04:00
|
|
|
{{ $notHidden := where $context.Site.RegularPages "Params.hidden" "!=" true }}
|
|
|
|
{{ $filtered := ($pages | intersect $notHidden) }}
|
|
|
|
{{ $archives := $filtered.GroupByDate "2006" }}
|
2021-01-01 07:16:11 -05:00
|
|
|
|
|
|
|
<div class="widget-archive--list">
|
2022-02-26 17:45:25 -05:00
|
|
|
{{ range $index, $item := first (add $limit 1) ($archives) }}
|
2021-01-01 07:16:11 -05:00
|
|
|
{{- $id := lower (replace $item.Key " " "-") -}}
|
|
|
|
<div class="archives-year">
|
|
|
|
<a href="{{ $archivesPage.RelPermalink }}#{{ $id }}">
|
2022-02-26 17:45:25 -05:00
|
|
|
{{ if eq $index $limit }}
|
2021-01-01 07:16:11 -05:00
|
|
|
<span class="year">{{ T "widget.archives.more" }}</span>
|
|
|
|
{{ else }}
|
|
|
|
<span class="year">{{ .Key }}</span>
|
|
|
|
<span class="count">{{ len $item.Pages }}</span>
|
|
|
|
{{ end }}
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
{{ end }}
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
{{- else -}}
|
|
|
|
{{- warnf "Archives page not found. Create a page with layout: archives." -}}
|
|
|
|
{{- end -}}
|