{{- $query := first 1 (where .Context.Site.Pages "Layout" "==" "archives") -}} {{- $context := .Context -}} {{- $limit := default 5 .Params.limit -}} {{- if $query -}} {{- $archivesPage := index $query 0 -}}
{{ partial "helper/icon" "infinity" }}

{{ T "widget.archives.title" }}

{{ $pages := where $context.Site.RegularPages "Type" "in" $context.Site.Params.mainSections }} {{ $notHidden := where $context.Site.RegularPages "Params.hidden" "!=" true }} {{ $filtered := ($pages | intersect $notHidden) }} {{ $archives := $filtered.GroupByDate "2006" }}
{{ range $index, $item := first (add $limit 1) ($archives) }} {{- $id := lower (replace $item.Key " " "-") -}} {{ end }}
{{- else -}} {{- warnf "Archives page not found. Create a page with layout: archives." -}} {{- end -}}