Sort tags by popularity in blog

This commit is contained in:
el00ruobuob 2019-03-19 18:11:43 +01:00
parent 0f25ac80a1
commit 8a6aff790f
No known key found for this signature in database
GPG Key ID: 8794A50E11FE51A0

View File

@ -59,10 +59,21 @@ layout: custom
<h2>Popular Tags</h2>
</div>
</div>
{% for tag in site.data.tags limit:4 %}
{% capture taglist %}
{% for site_tag in site.tags %}
{% for data_tag in site.data.tags %}
{% if data_tag.slug == site_tag[0] %}
;{{ site_tag[1].size | plus: 100000 }}#{{ data_tag.name }}#{{ data_tag.slug }}
{% endif %}
{% endfor %}
{% endfor %}
{% endcapture %}
{% assign sortedtags = taglist | strip | remove_first: ';' | split:';' | sort | reverse %}
{% for tagitem in sortedtags limit: 6 %}
{% assign pop_tag = tagitem | strip | split: '#' %}
<div class="row start-xs">
<div class="col">
<p><a href="/blog/tags/{{ tag.slug }}.html">{{ tag.name }}</a></p>
<p><a href="/blog/tags/{{ pop_tag[2] }}.html">{{ pop_tag[1] }}</a></p>
</div>
</div>
{% endfor %}