Hugo-theme-stack/layouts/partials/widget/archive.html
Jimmy Cai 2451b194dc
refactor: use relLangURL to build relative links
For better i18n support

Fixes archive page path
Remove tag cloud term exclusion

closes https://github.com/CaiJimmy/hugo-theme-stack/issues/8
2020-09-13 10:14:17 +02:00

30 lines
1.2 KiB
HTML

<section class="widget archive">
<div class="widget-icon">
{{ (resources.Get "icons/infinity.svg").Content | safeHTML }}
</div>
<h1 class="widget-title">{{ T "widgetArchiveTitle" }}</h1>
{{ $pages := where .Site.RegularPages "Type" "in" .Site.Params.mainSections }}
{{ $notHidden := where .Site.RegularPages "Params.hidden" "!=" true }}
{{ $filtered := ($pages | intersect $notHidden) }}
{{ $archive := $filtered.GroupByDate "2006" }}
{{ range first .Site.Params.widgets.archive.limit ($archive) }}
{{ $id := lower (replace .Key " " "-") }}
<div class="archive-year">
<a href="{{ $.Site.Params.widgets.archive.path | relLangURL }}#{{ $id }}">
<span class="year">{{ .Key }}</span>
<span class="count">{{ len .Pages }}</span>
</a>
</div>
{{ end }}
{{ if gt (len $archive) .Site.Params.widgets.archive.limit }}
<div class="archive-year">
<a href="{{ $.Site.Params.widgets.archive.path | relLangURL }}">
<span class="year">{{ T "widgetArchiveMore" }}</span>
</a>
</div>
{{ end }}
</section>