fix: photo grid never rendered due to Nunjucks slice misuse

Nunjucks slice(0, 4) creates 0 chunks (not Array.slice behavior),
producing an empty array. Photos and categories were never rendered
in item-card and actor views. Also add image proxying to reader
controller matching the Microsub API.
This commit is contained in:
Ricardo
2026-02-26 10:54:31 +01:00
parent cdd4a58015
commit 6833f6f5f2
4 changed files with 22 additions and 5 deletions

View File

@@ -121,8 +121,10 @@
{# Tags #}
{% if item.category and item.category.length > 0 %}
<div class="item-card__categories">
{% for cat in item.category | slice(0, 5) %}
{% for cat in item.category %}
{% if loop.index0 < 5 %}
<span class="item-card__category">#{{ cat }}</span>
{% endif %}
{% endfor %}
</div>
{% endif %}
@@ -131,9 +133,11 @@
{% if item.photo and item.photo.length > 0 %}
{% set photoCount = item.photo.length if item.photo.length <= 4 else 4 %}
<div class="item-card__photos item-card__photos--{{ photoCount }}">
{% for photo in item.photo | slice(0, 4) %}
{% for photo in item.photo %}
{% if loop.index0 < 4 %}
<img src="{{ photo }}" alt="" class="item-card__photo" loading="lazy"
onerror="this.parentElement.removeChild(this)">
{% endif %}
{% endfor %}
</div>
{% endif %}

View File

@@ -111,8 +111,10 @@
{# Categories/Tags #}
{% if item.category and item.category.length > 0 %}
<div class="item-card__categories">
{% for cat in item.category | slice(0, 5) %}
{% for cat in item.category %}
{% if loop.index0 < 5 %}
<span class="item-card__category">#{{ cat | replace("#", "") }}</span>
{% endif %}
{% endfor %}
</div>
{% endif %}
@@ -121,12 +123,14 @@
{% if item.photo and item.photo.length > 0 %}
{% set photoCount = item.photo.length if item.photo.length <= 4 else 4 %}
<div class="item-card__photos item-card__photos--{{ photoCount }}">
{% for photo in item.photo | slice(0, 4) %}
{% for photo in item.photo %}
{% if loop.index0 < 4 %}
<img src="{{ photo }}"
alt=""
class="item-card__photo"
loading="lazy"
onerror="this.parentElement.removeChild(this)">
{% endif %}
{% endfor %}
</div>
{% endif %}