diff --git a/tabs/categories.md b/tabs/categories.md index c720ff5..504a2fe 100644 --- a/tabs/categories.md +++ b/tabs/categories.md @@ -13,17 +13,19 @@ title: Categories {% for category in sort_categories %} {% assign category_name = category | first %} {% assign posts_of_category = category | last %} - {% assign first_post = posts_of_category[0] %} + {% assign first_post = posts_of_category | first %} {% if category_name == first_post.categories[0] %} - {% assign sub_categories = "" %} + {% assign sub_categories = "" | split: "" %} + {% for post in posts_of_category %} - {% if post.categories.size > 1 %} - {% assign sub_categories = sub_categories | append: post.categories[1] | append: "|" %} - {% endif %} + {% assign second_category = post.categories[1] %} + {% unless sub_categories contains second_category %} + {% assign sub_categories = sub_categories | push: second_category %} + {% endunless %} {% endfor %} - {% assign sub_categories = sub_categories | split: "|" | uniq | sort %} + {% assign sub_categories = sub_categories | sort %} {% assign sub_categories_size = sub_categories | size %}