~xdavidwu/xdavidwu.link

ref: 1ccd5f6bf08082b17ca51e63a70c4b01db831b6c xdavidwu.link/_includes/page__taxonomy.html -rw-r--r-- 2.0 KiB
1ccd5f6b — Michael Rose Edit sidebar and page meta styles 9 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
{% include base_path %}

{% comment %}
  <!-- Sort page.tags alphabetically regardless of case e.g. a B c d E -->
  <!-- modified from http://www.codeofclimber.ru/2015/sorting-site-tags-in-jekyll/ -->
{% endcomment %}

{% if page.tags[0] %}
  {% if site.tags_archive_filename %}
    {% capture page_tags %}{% for tag in page.tags %}{{ tag | downcase }}#{{ tag }}{% unless forloop.last %},{% endunless %}{% endfor %}{% endcapture %}
    {% assign tag_hashes = (page_tags | split: ',' | sort:0) %}

    <p class="page__taxonomy"><strong>{{ site.data.ui-text[site.locale].tags_label }}</strong> <span itemprop="keywords">
    {% for hash in tag_hashes %}
      {% assign keyValue = hash | split: '#' %}
      {% capture tag_word %}{{ keyValue[1] | strip_newlines }}{% endcapture %}
        <a href="{{ base_path }}{{ tag_word | slugify | prepend: '/#' | prepend: site.tags_archive_filename | prepend: "/" }}" class="page__taxonomy-item" rel="tag">{{ tag_word }}</a>{% unless forloop.last %}, {% endunless %}
    {% endfor %}
    </span>
    </p>
  {% endif %}
{% endif %}

{% if page.categories[0] %}
  {% if site.categories_archive_filename %}
    {% capture page_categories %}{% for category in page.categories %}{{ category | downcase }}#{{ category }}{% unless forloop.last %},{% endunless %}{% endfor %}{% endcapture %}
    {% assign category_hashes = (page_categories | split: ',' | sort:0) %}

    <p class="page__taxonomy"><strong>{{ site.data.ui-text[site.locale].categories_label }}</strong> <span itemprop="keywords">
    {% for hash in category_hashes %}
      {% assign keyValue = hash | split: '#' %}
      {% capture category_word %}{{ keyValue[1] | strip_newlines }}{% endcapture %}
        <a href="{{ base_path }}{{ category_word | slugify | prepend: '/#' | prepend: site.categories_archive_filename | prepend: "/" }}" class="page__taxonomy-item" rel="tag">{{ category_word }}</a>{% unless forloop.last %}, {% endunless %}
    {% endfor %}
    </span>
    </p>
  {% endif %}
{% endif %}