refactor(widget/archives): remove .widgets.archives.path config

The theme will automatically detect the permalink to the archives page.
This commit is contained in:
Jimmy Cai 2021-01-01 13:16:11 +01:00
parent 5ac2552e7c
commit efa3452cdb
No known key found for this signature in database
GPG Key ID: 3EA408E527F37B18
2 changed files with 33 additions and 28 deletions

View File

@ -60,7 +60,6 @@ params:
archives:
limit: 5
path: archives
tagCloud:
limit: 10

View File

@ -1,4 +1,7 @@
<section class="widget archives">
{{- $query := first 1 (where .Site.Pages "Layout" "==" "archives") -}}
{{- if $query -}}
{{- $archivesPage := index $query 0 -}}
<section class="widget archives">
<div class="widget-icon">
{{ partial "helper/icon" "infinity" }}
</div>
@ -13,7 +16,7 @@
{{ 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 }}">
<a href="{{ $archivesPage.RelPermalink }}#{{ $id }}">
{{ if eq $index $.Site.Params.widgets.archives.limit }}
<span class="year">{{ T "widget.archives.more" }}</span>
{{ else }}
@ -24,4 +27,7 @@
</div>
{{ end }}
</div>
</section>
</section>
{{- else -}}
{{- warnf "Archives page not found. Create a page with layout: archives." -}}
{{- end -}}