From 9e1e7783b385b670bec774cbad604fbf4581d079 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Sat, 14 Nov 2020 11:03:12 -0300 Subject: Use "eu_categories" frontmatter attribute Jekyll treats names like "category" and "categories" differently, so I chose to name it "eu_categories" in order to avoid inheriting the special treatment, and have full control of what a category means and how it behaves. The _includes/category.html was changed to reflect that, with an extra coupled change that makes it not specific to articles, but any collection type. --- _includes/categories.html | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to '_includes/categories.html') diff --git a/_includes/categories.html b/_includes/categories.html index 60a6ed6..22e5df3 100644 --- a/_includes/categories.html +++ b/_includes/categories.html @@ -1,18 +1,18 @@ -{% assign articles_with_categories = "" | split:"" %} -{% for article in site.articles %} - {% if article.lang == page.lang %} - {% if article.category %} - {% assign articles_with_categories = articles_with_categories | push:article %} +{% assign entries_with_categories = "" | split:"" %} +{% for entry in site[include.kind] %} + {% if entry.lang == page.lang %} + {% if entry.eu_categories %} + {% assign entries_with_categories = entries_with_categories | push:entry %} {% endif %} {% endif %} {% endfor %} -{% assign articles_with_categories = articles_with_categories | reverse %} +{% assign entries_with_categories = entries_with_categories | reverse %} {% assign categories = "" | split:"" %} -{% for article in articles_with_categories %} - {% assign article_categories = article.category | split:"," %} - {% for article_category in article_categories %} - {% assign categories = categories | push:article_category %} +{% for entry in entries_with_categories %} + {% assign entry_categories = entry.eu_categories | split:"," %} + {% for entry_category in entry_categories %} + {% assign categories = categories | push:entry_category %} {% endfor %} {% endfor %} @@ -22,12 +22,12 @@ {{ category }}: