feat: allow sorting tags based on post count (#344)

Co-authored-by: welpo <welpo@users.noreply.github.com>
This commit is contained in:
Phil Schumann
2024-06-29 17:39:31 +02:00
committed by GitHub
parent a907f56bd5
commit 3d3f62cf20
7 changed files with 49 additions and 1 deletions

View File

@@ -7,6 +7,11 @@
{{ macros_page_header::page_header(title=title)}}
{% set tag_count = terms | length %}
{% if config.extra.tag_sorting == "frequency" %}
{% set terms = terms | sort(attribute="pages") | reverse %}
{% elif config.extra.tag_sorting != "name" %}
{{ throw (message="Invalid tag_sorting option: " ~ config.extra.tag_sorting ~ ". Valid options are 'name' and 'frequency'.") }}
{% endif %}
<div id="tag-cloud" class="{% if tag_count > 16 %}three-columns{% elif tag_count > 8 %}two-columns{% endif %}">
<ul class="tags">
{%- for term in terms -%}