From 532e7ad451ce10d74d6f88e8e0f538567394666d Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Fri, 22 May 2020 18:02:28 +0800 Subject: [PATCH] Fixed a bug in the Categories hierarchy. (#48, #57) When one post have only one category will hit the bug. --- tabs/categories.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tabs/categories.md b/tabs/categories.md index 504a2fe..a224ae7 100644 --- a/tabs/categories.md +++ b/tabs/categories.md @@ -20,9 +20,11 @@ title: Categories {% for post in posts_of_category %} {% assign second_category = post.categories[1] %} - {% unless sub_categories contains second_category %} - {% assign sub_categories = sub_categories | push: second_category %} - {% endunless %} + {% if second_category %} + {% unless sub_categories contains second_category %} + {% assign sub_categories = sub_categories | push: second_category %} + {% endunless %} + {% endif %} {% endfor %} {% assign sub_categories = sub_categories | sort %}