From a31bd447d070cdfdac4db5275d404cfeb4ca5e72 Mon Sep 17 00:00:00 2001 From: Michael Rose Date: Thu, 10 Mar 2016 22:12:37 -0500 Subject: [PATCH] Properly detect if a page has tags or categories - Arrays are truthy, test on first item instead --- _includes/page__taxonomy.html | 48 +++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/_includes/page__taxonomy.html b/_includes/page__taxonomy.html index 6243638f..ad8376a5 100644 --- a/_includes/page__taxonomy.html +++ b/_includes/page__taxonomy.html @@ -5,30 +5,34 @@ {% endcomment %} -{% 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) %} +{% 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) %} -

{{ site.data.ui-text[site.locale].tags_label }} - {% for hash in tag_hashes %} - {% assign keyValue = hash | split: '#' %} - {% capture tag_word %}{{ keyValue[1] | strip_newlines }}{% endcapture %} - {% unless forloop.last %}, {% endunless %} - {% endfor %} - -

+

{{ site.data.ui-text[site.locale].tags_label }} + {% for hash in tag_hashes %} + {% assign keyValue = hash | split: '#' %} + {% capture tag_word %}{{ keyValue[1] | strip_newlines }}{% endcapture %} + {% unless forloop.last %}, {% endunless %} + {% endfor %} + +

+ {% endif %} {% endif %} -{% 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) %} +{% 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) %} -

{{ site.data.ui-text[site.locale].categories_label }} - {% for hash in category_hashes %} - {% assign keyValue = hash | split: '#' %} - {% capture category_word %}{{ keyValue[1] | strip_newlines }}{% endcapture %} - {% unless forloop.last %}, {% endunless %} - {% endfor %} - -

+

{{ site.data.ui-text[site.locale].categories_label }} + {% for hash in category_hashes %} + {% assign keyValue = hash | split: '#' %} + {% capture category_word %}{{ keyValue[1] | strip_newlines }}{% endcapture %} + {% unless forloop.last %}, {% endunless %} + {% endfor %} + +

+ {% endif %} {% endif %} \ No newline at end of file