Properly detect if a page has tags or categories
- Arrays are truthy, test on first item instead
This commit is contained in:
parent
cf0db7c19a
commit
a31bd447d0
1 changed files with 26 additions and 22 deletions
|
@ -5,30 +5,34 @@
|
||||||
<!-- modified from http://www.codeofclimber.ru/2015/sorting-site-tags-in-jekyll/ -->
|
<!-- modified from http://www.codeofclimber.ru/2015/sorting-site-tags-in-jekyll/ -->
|
||||||
{% endcomment %}
|
{% endcomment %}
|
||||||
|
|
||||||
{% if site.tags_archive_filename %}
|
{% if page.tags[0] %}
|
||||||
{% capture page_tags %}{% for tag in page.tags %}{{ tag | downcase }}#{{ tag }}{% unless forloop.last %},{% endunless %}{% endfor %}{% endcapture %}
|
{% if site.tags_archive_filename %}
|
||||||
{% assign tag_hashes = (page_tags | split: ',' | sort:0) %}
|
{% 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><strong>{{ site.data.ui-text[site.locale].tags_label }}</strong> <span class="page__taxonomy-wrapper" itemprop="keywords">
|
<p><strong>{{ site.data.ui-text[site.locale].tags_label }}</strong> <span class="page__taxonomy-wrapper" itemprop="keywords">
|
||||||
{% for hash in tag_hashes %}
|
{% for hash in tag_hashes %}
|
||||||
{% assign keyValue = hash | split: '#' %}
|
{% assign keyValue = hash | split: '#' %}
|
||||||
{% capture tag_word %}{{ keyValue[1] | strip_newlines }}{% endcapture %}
|
{% 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 %}
|
<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 %}
|
{% endfor %}
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if site.categories_archive_filename %}
|
{% if page.categories[0] %}
|
||||||
{% capture page_categories %}{% for category in page.categories %}{{ category | downcase }}#{{ category }}{% unless forloop.last %},{% endunless %}{% endfor %}{% endcapture %}
|
{% if site.categories_archive_filename %}
|
||||||
{% assign category_hashes = (page_categories | split: ',' | sort:0) %}
|
{% 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><strong>{{ site.data.ui-text[site.locale].categories_label }}</strong> <span class="page__taxonomy-wrapper" itemprop="keywords">
|
<p><strong>{{ site.data.ui-text[site.locale].categories_label }}</strong> <span class="page__taxonomy-wrapper" itemprop="keywords">
|
||||||
{% for hash in category_hashes %}
|
{% for hash in category_hashes %}
|
||||||
{% assign keyValue = hash | split: '#' %}
|
{% assign keyValue = hash | split: '#' %}
|
||||||
{% capture category_word %}{{ keyValue[1] | strip_newlines }}{% endcapture %}
|
{% 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 %}
|
<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 %}
|
{% endfor %}
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
Loading…
Reference in a new issue