mirror of
https://github.com/CaiJimmy/hugo-theme-stack.git
synced 2025-04-28 19:43:31 +08:00
feat: let users choose tag priority from data/tag_priorities.yaml
This commit is contained in:
parent
9e6b7b22a9
commit
db54cf4f9e
@ -1,16 +1,23 @@
|
||||
{{- $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 }}
|
||||
</a>
|
||||
{{ $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>
|
||||
</section>
|
Loading…
Reference in New Issue
Block a user