html Alphabetizing Jekyll页面标签

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html Alphabetizing Jekyll页面标签相关的知识,希望对你有一定的参考价值。

<!--
On line 11 you’ll notice an unless forloop.last. This is because it’s a quick an easy way to keep the array index in bounds. The following lines show how you can use a tag’s name to pull the tag from site.tags. I checked for post.title != null because I don’t want to display pages without titles.
-->
<div id="tags">
  <h1>Tags</h1>
  <ul class="tag-box inline">
    {% for item in (0..site.tags.size) %}
      {% unless forloop.last %} 
        {% capture this_word %}{{ tag_words[item] | strip_newlines }}{% endcapture %}
        <li><a href="#{{ this_word | cgi_escape }}">{{ this_word }} <span>{{ site.tags[this_word].size }}</span></a></li>
      {% endunless %}
    {% endfor %}
  </ul>
  
  {% for item in (0..site.tags.size) %}
    {% unless forloop.last %} 
      {% capture this_word %}{{ tag_words[item] | strip_newlines }}{% endcapture %}
      <h2 id="{{ this_word | cgi_escape }}">{{ this_word }}</h2>
      <ul class="posts">
        {% for post in site.tags[this_word] %}
          {% if post.title != null %}
            <li itemscope><span class="entry-date"><time datetime="{{ post.date | date_to_xmlschema }}" itemprop="datePublished">{{ post.date | date: "%B %d, %Y" }}</time></span> &raquo; <a href="{{ post.url }}">{{ post.title }}</a></li>
          {% endif %}
        {% endfor %}
      </ul>
    {% endunless %}
  {% endfor %}
</div>
<!--
Line 1 above will get the tag name for every tag on the site and set them to the site_tags variable. Each tag object contains both the tag name and a list of the associated posts. This capture statement is all on one line so that the commas can reliably be used as delimiters. Line 2 creates the tag_words variable that is a sorted array of the tag names.
-->

{% capture site_tags %}
  {% for tag in site.tags %}
    {{ tag | first }}
    {% unless forloop.last %},{% endunless %}
  {% endfor %}
{% endcapture %}
{% assign tag_words = site_tags | split:',' | sort %}

以上是关于html Alphabetizing Jekyll页面标签的主要内容,如果未能解决你的问题,请参考以下文章

ruby [Jekyll补充数据模块]将jekyll post的补充数据文件复制到帖子的内置html附近的位置#data #jekyll

html Jekyll运行jekyll-lunr-js-search插件的示例搜索页面。

[Html]Jekyll 代码高亮的几种选择

html Jekyll上的条形图HTML

Jekyll 博客高亮代码生成无效的 html

在 Jekyll HTML 中嵌入 Markdown