Properly detect if a page has tags or categories

- Arrays are truthy, test on first item instead
This commit is contained in:
Michael Rose 2016-03-10 22:12:37 -05:00
parent cf0db7c19a
commit a31bd447d0

View file

@ -5,6 +5,7 @@
<!-- 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 page.tags[0] %}
{% if site.tags_archive_filename %} {% if site.tags_archive_filename %}
{% capture page_tags %}{% for tag in page.tags %}{{ tag | downcase }}#{{ tag }}{% unless forloop.last %},{% endunless %}{% endfor %}{% endcapture %} {% 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) %} {% assign tag_hashes = (page_tags | split: ',' | sort:0) %}
@ -18,7 +19,9 @@
</span> </span>
</p> </p>
{% endif %} {% endif %}
{% endif %}
{% if page.categories[0] %}
{% if site.categories_archive_filename %} {% if site.categories_archive_filename %}
{% capture page_categories %}{% for category in page.categories %}{{ category | downcase }}#{{ category }}{% unless forloop.last %},{% endunless %}{% endfor %}{% endcapture %} {% 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) %} {% assign category_hashes = (page_categories | split: ',' | sort:0) %}
@ -32,3 +35,4 @@
</span> </span>
</p> </p>
{% endif %} {% endif %}
{% endif %}