Jekyll 杰基尔,展示收藏中的前5个流行标签';s职位

Jekyll 杰基尔,展示收藏中的前5个流行标签';s职位,jekyll,liquid,Jekyll,Liquid,我已经有了一个工作代码,可以显示收集帖子中的所有标签,并统计所有帖子中的标签数量 在这里: {% assign tags = site.blog | map: 'tags' | uniq %} {% assign postInTagCount = 0 %} <div class="blog-tags__tags-wrapper"> {% for tag in tags %} <a href="/blog/tags/#{'#'}{{ tag | downcase }}"

我已经有了一个工作代码,可以显示收集帖子中的所有标签,并统计所有帖子中的标签数量

在这里:

{% assign tags =  site.blog | map: 'tags' | uniq %}
{% assign postInTagCount = 0 %}
<div class="blog-tags__tags-wrapper">
{% for tag in tags %}
    <a href="/blog/tags/#{'#'}{{ tag | downcase }}">
        <div class="tags_wrapper__tag">
            {{ tag }}
            {% for post in site.blog %}
                {% if post.tags contains tag %}
                    {% capture postInTagCount %}{{ postInTagCount | plus:1 }}{% endcapture %}
                {% endif %}
            {% endfor %}
            {% if postInTagCount <> 0 %} [{{ postInTagCount }}]{% endif %}
            {% capture postInTagCount %}0{% endcapture %}
        </div>
    </a>
{% endfor %}
{%assign tags=site.blog | map:'tags'| uniq%}
{%assign postInTagCount=0%}
{标记%中的标记的%s}
{%endfor%}
但是我想展示在所选收藏的帖子中发现的5个最流行的标签

我有一个例子:
但我不确定这个网站上是否使用了Jekyll。在作者储存库的Gitkhab上,我没有找到他的网站


我请求你的帮助。谢谢。

该网站的作者确实使用了Jekyll.)


查看他的,看看他是如何使用定制液体过滤器的,或者直接通过SO@hal与他联系。

可能通过捕获循环并在其中写入: 首先是var PostInTagCount,您选择的一个不能出现在标记名中的分隔符,然后是标记,然后是辅助分隔符


完成后,通过辅助分隔符分割捕获,并通过a..B创建新的循环排序。由于第一个字符是您的var PostInTagCount,它应该可以完成这项工作。

他使用一个用Ruby编写的插件。我一点也不认识鲁比。。。如果可以的话,我想不用他。@VostokSisters我不相信没有插件就可以做你想做的事。也许我会。。。但我还是能在所有标签中找到最受欢迎的。不。。。我宁愿从对象{tag:{{tagName}},count:{{{tagCount}}}形成json,然后在JS中排序并在html中显示。它会更快。