From f8b18a91bc5765bf0ae7e3d9f693d154aa5dc803 Mon Sep 17 00:00:00 2001 From: Devin Haska <2636402+wonderfulfrog@users.noreply.github.com> Date: Thu, 8 Feb 2024 21:09:53 -0800 Subject: [PATCH] fix: clean up loop implementations --- src/_includes/css/colorVariables.njk | 10 ++-------- src/_includes/css/fontVariables.njk | 9 ++------- src/_includes/css/spacing.njk | 7 ++----- src/_includes/partials/footer.html | 5 +---- src/_includes/partials/posts.html | 18 ++++++------------ 5 files changed, 13 insertions(+), 36 deletions(-) diff --git a/src/_includes/css/colorVariables.njk b/src/_includes/css/colorVariables.njk index bd68029..9a4b728 100644 --- a/src/_includes/css/colorVariables.njk +++ b/src/_includes/css/colorVariables.njk @@ -1,12 +1,6 @@ -{% set allColors = colors | entries %} - html { -{% for color in allColors %} - {% set colorName = color | first %} - {% set colorRanges = color | last | entries %} - {% for colorValue in colorRanges %} - {% set value = colorValue | first %} - {% set hex = colorValue | last %} +{% for colorName, colorValues in colors %} + {% for value, hex in colorValues %} --color-{{ colorName }}-{{ value }}: {{ hex }}; {% endfor %} {% endfor %} diff --git a/src/_includes/css/fontVariables.njk b/src/_includes/css/fontVariables.njk index d6868ef..9ed6652 100644 --- a/src/_includes/css/fontVariables.njk +++ b/src/_includes/css/fontVariables.njk @@ -1,15 +1,10 @@ {% set allFonts = fonts | entries %} html { -{% for font in allFonts %} - {% set fontType = font | first %} - {% set fontConfig = font | last %} +{% for fontType, fontConfig in fonts %} {% set fallbackFonts = fontConfig.fallbacks | join(", ") %} --font-family-{{ fontType }}: {{ fontConfig.family }}, {{ fallbackFonts }}; - {% set weights = fontConfig.weights | entries %} - {% for weight in weights %} - {% set weightName = weight | first %} - {% set weightConfig = weight | last %} + {% for weightName, weightConfig in fontConfig.weights %} {% if weightConfig.style != "italic" %} --font-weight-{{ fontType }}-{{ weightName | lower }}: {{ weightConfig.weight }}; {% endif %} diff --git a/src/_includes/css/spacing.njk b/src/_includes/css/spacing.njk index 26e5759..92e5f05 100644 --- a/src/_includes/css/spacing.njk +++ b/src/_includes/css/spacing.njk @@ -1,8 +1,5 @@ -{% set spacingValues = spacing | entries %} - -{% for spaceValue in spacingValues %} - {% set key = spaceValue | first | replace(".", "\\\.") | safe %} - {% set value = spaceValue | last %} +{% for keyRaw, value in spacing %} + {% set key = keyRaw | replace(".", "\\\.") | safe %} .gap-{{ key }} { gap: {{ value }}px; } diff --git a/src/_includes/partials/footer.html b/src/_includes/partials/footer.html index 335274f..42948ea 100644 --- a/src/_includes/partials/footer.html +++ b/src/_includes/partials/footer.html @@ -1,4 +1,3 @@ -{% set socialLinks = meta.social | entries %}