feat: let users choose tag priority from data/tag_priorities.yaml

This commit is contained in:
SenPie 2025-03-10 15:59:50 +01:00
parent 9e6b7b22a9
commit db54cf4f9e

View File

@ -1,15 +1,22 @@
{{- $context := .Context -}}
{{- $limit := default 10 .Params.limit -}}
<section class="widget tagCloud">
<div class="widget-icon">
{{ partial "helper/icon" "tag" }}
</div>
<h2 class="widget-title section-title">{{ T "widget.tagCloud.title" }}</h2>
<div class="tagCloud-tags">
{{ range first $limit $context.Site.Taxonomies.tags.ByCount }}
<a href="{{ .Page.RelPermalink }}" class="font_size_{{ .Count }}">
{{ .Page.Title }}
{{ $tagPriorities := site.Data.tag_priorities.priorities | default dict }}
{{ $sortedTags := slice }}
{{ range site.Taxonomies.tags }}
{{ $priority := default 999 (index $tagPriorities .Page.Title) }}
{{ $sortedTags = $sortedTags | append (dict "tag" . "priority" $priority) }}
{{ end }}
{{- $limit := default 10 .Params.limit -}}
{{ range first $limit (sort $sortedTags "priority") }}
{{ $tag := .tag }}
<a href="{{ $tag.Page.RelPermalink }}" class="font_size_{{ $tag.Count }}">
{{ $tag.Page.Title }}
</a>
{{ end }}
</div>