From 4b19aa97d0a051bfb690e4948a27f85497ae3276 Mon Sep 17 00:00:00 2001 From: "Mr.J" <116749895@qq.com> Date: Sat, 13 Jul 2019 00:02:43 +0800 Subject: [PATCH] Revert "Avoid recalculating the number of tags and categories (#954)" (#969) This reverts commit a8e2aefd75d5b270cb6131ac8a00b443b1718849. --- layout/_macro/menu/menu-badge.swig | 4 ++-- layout/_macro/sidebar.swig | 16 ++++++++++++---- layout/page.swig | 16 ++++++++++++++-- scripts/merge-configs.js | 16 ---------------- 4 files changed, 28 insertions(+), 24 deletions(-) diff --git a/layout/_macro/menu/menu-badge.swig b/layout/_macro/menu/menu-badge.swig index 6547969f6d..b2dcce135d 100644 --- a/layout/_macro/menu/menu-badge.swig +++ b/layout/_macro/menu/menu-badge.swig @@ -2,8 +2,8 @@ {% set badges = { archives: site.posts.length, - categories: theme.visibleCategories, - tags: theme.visibleTags } + categories: site.categories.length, + tags: site.tags.length } %} {% for menu, count in badges %} {% if name == menu %} diff --git a/layout/_macro/sidebar.swig b/layout/_macro/sidebar.swig index b458ff4217..589f149bb7 100644 --- a/layout/_macro/sidebar.swig +++ b/layout/_macro/sidebar.swig @@ -50,7 +50,7 @@ {% endif %} - {% if theme.visibleCategories > 0 %} + {% if site.categories.length > 0 %} {% set categoriesPageQuery = site.pages.find({type: 'categories'}, {lean: true}) %} {% set hasCategoriesPage = categoriesPageQuery.length > 0 %}
{% endif %} - {% if theme.visibleTags > 0 %} + {% if site.tags.length > 0 %} {% set tagsPageQuery = site.pages.find({type: 'tags'}, {lean: true}) %} {% set hasTagsPage = tagsPageQuery.length > 0 %} diff --git a/layout/page.swig b/layout/page.swig index 2358b6e404..b2c08712cc 100644 --- a/layout/page.swig +++ b/layout/page.swig @@ -33,7 +33,13 @@ {% if page.type === 'tags' %}