mirror of
https://github.com/CaiJimmy/hugo-theme-stack.git
synced 2025-02-06 20:03:31 +08:00
4be110e540
* Add link to navbar sections and refactor names * Prevent duplicate tags and categories information * Add style to the widget links * refactor: add `taxonomy` widget Replaces `categories` and `tag-cloud` widget. * style: remove unused `font_size_{{ .Count }}` in `taxonomy` widget --------- Co-authored-by: Jimmy Cai <hi@jimmycai.com>
35 lines
1.5 KiB
HTML
35 lines
1.5 KiB
HTML
{{- $query := first 1 (where .Context.Site.Pages "Layout" "==" "archives") -}}
|
|
{{- $context := .Context -}}
|
|
{{- $limit := default 5 .Params.limit -}}
|
|
{{- 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">
|
|
<a class="widget-link" href="{{ $archivesPage.RelPermalink }}">{{ T "widget.archives.title" }}</a>
|
|
</h2>
|
|
|
|
{{ $pages := where $context.Site.RegularPages "Type" "in" $context.Site.Params.mainSections }}
|
|
{{ $archives := $pages.GroupByDate "2006" }}
|
|
|
|
<div class="widget-archive--list">
|
|
{{ range $index, $item := first (add $limit 1) ($archives) }}
|
|
{{- $id := lower (replace $item.Key " " "-") -}}
|
|
<div class="archives-year">
|
|
<a href="{{ $archivesPage.RelPermalink }}#{{ $id }}">
|
|
{{ if eq $index $limit }}
|
|
<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 -}} |