From 2e1ff9eeb12669313c0886c72491e2c2f2d10284 Mon Sep 17 00:00:00 2001 From: Michael Rose Date: Mon, 4 Jun 2018 11:58:26 -0400 Subject: [PATCH] DRY `categories_max` calculation in categories.html layout --- _layouts/categories.html | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/_layouts/categories.html b/_layouts/categories.html index 0c7521f3..aa2c6e80 100644 --- a/_layouts/categories.html +++ b/_layouts/categories.html @@ -4,13 +4,14 @@ layout: archive {{ content }} +{% assign categories_max = 0 %} +{% for category in site.categories %} + {% if category[1].size > categories_max %} + {% assign categories_max = category[1].size %} + {% endif %} +{% endfor %} + -{% assign categories_max = 0 %} -{% for category in site.categories %} - {% if category[1].size > categories_max %} - {% assign categories_max = category[1].size %} - {% endif %} -{% endfor %} - {% for i in (1..categories_max) reversed %} {% for category in site.categories %} {% if category[1].size == i %}