chore: remove code duplication and clean up

This commit is contained in:
Cory Dransfeldt 2024-05-28 10:25:38 -07:00
parent 5a402c4def
commit 694dae0b06
No known key found for this signature in database
34 changed files with 246 additions and 292 deletions

View file

@ -1,6 +1,6 @@
{% assign media = data | normalizeMedia %}
{% assign media = data.items | default: data | normalizeMedia %}
<div class="media-grid {% if shape == 'square' %}square{% else %}vertical{% endif %}">
{% for item in media limit: count %}
{% for item in media limit: count | default: media.size %}
{% assign alt = item.alt | strip | escape %}
<a href="{{ item.url | stripUtm }}" title="{{ alt }}">
<div class="item-wrapper shadow">
@ -8,21 +8,22 @@
{% if item.title %}
<div class="header">{{ item.title }}</div>
{% endif %}
{% if item.subtext %}
<div class="subheader">
{{ item.subtext }}
</div>
{% if item.plays %}
<div class="subheader">{{ item.plays }} plays</div>
{% elsif item.subtext %}
<div class="subheader">{{ item.subtext }}</div>
{% endif %}
</div>
{%- capture loadingStrategy -%}
{%- if loading -%}{{ loading }}{%- else -%}lazy{%- endif -%}
{%- endcapture -%}
{% assign loadingStrategy = loading | default: 'lazy' %}
{% if shape == 'square' %}
<img src="https://coryd.dev/.netlify/images/?url={{ item.image }}&fit=cover&w=240&h=240&fm=webp&q=85"{% if alt %} alt="{{ alt }}"{% endif %} loading="{{ loadingStrategy }}" decoding="async" width="240" height="240" />
<img src="https://coryd.dev/.netlify/images/?url={{ item.image }}&fit=cover&w=240&h=240&fm=webp&q=85" alt="{{ alt }}" loading="{{ loadingStrategy }}" decoding="async" width="240" height="240" />
{% else %}
<img src="https://coryd.dev/.netlify/images/?url={{ item.image }}&fit=cover&w=200&h=307&fm=webp&q=85"{% if alt %} alt="{{ alt }}"{% endif %} loading="{{ loadingStrategy }}" decoding="async" width="200" height="307" />
<img src="https://coryd.dev/.netlify/images/?url={{ item.image }}&fit=cover&w=200&h=307&fm=webp&q=85" alt="{{ alt }}" loading="{{ loadingStrategy }}" decoding="async" width="200" height="307" />
{% endif %}
</div>
</a>
{% endfor %}
</div>
</div>
{% unless count %}
{% render "partials/widgets/paginator.liquid", pagination:data %}
{% endunless %}