fix: clean up loop implementations

This commit is contained in:
Devin Haska 2024-02-08 21:09:53 -08:00
parent 5f6a1a8d33
commit f8b18a91bc
5 changed files with 13 additions and 36 deletions

View file

@ -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 %}

View file

@ -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 %}

View file

@ -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;
}

View file

@ -1,4 +1,3 @@
{% set socialLinks = meta.social | entries %}
<footer class="[ footer ] [ mt-1.5 py-1.5 ]">
<div class="[ footer-grid ] [ wrapper gap-0.5 ]">
<p>&copy; {{ meta.author }} 2018-2024.</p>
@ -17,9 +16,7 @@
<span class="[ visually-hidden ]">RSS</span>
<a href="#" target="_blank">{% include "svgs/rss.svg" %}</a>
</li>
{% for link in socialLinks %}
{% set key = link | first %}
{% set url = link | last %}
{% for key, url in meta.social %}
{% set alt = key | capitalize %}
<li>
<span class="[ visually-hidden ]">{{ alt }}</span>

View file

@ -1,16 +1,10 @@
{% set postsByDate = posts | entries %}
<section>
{% for postsGroupedByYear in postsByDate %}
{% set year = postsGroupedByYear | first %}
{% set postsGroupedByMonth = postsGroupedByYear | last | entries %}
{% for postsInMonth in postsGroupedByMonth %}
{% set isFirstMonthOfList = loop.index0 === 0 %}
{% set month = postsInMonth | first %}
{% for year, postsByYear in posts %}
<div class="[ flex ]">
{% if isFirstMonthOfList %}<h2>{{ year }}</h2>{% endif %}
<h2>{{ year }}</h2>
</div>
{% set allPosts = postsInMonth | last %}
{% for post in allPosts %}
{% for month, postsByMonth in postsByYear %}
{% for post in postsByMonth %}
<div class="[ flex items-center justify-between ]">
<a href="{{ post.url }}">{{ post.data.title }}</a>
<div class="[ archive-divider ] [ mx-0.5 ]"></div>