From e66ea68e47910d228e41a33b9ad56ec46dabe75f Mon Sep 17 00:00:00 2001 From: Frankie Roberto Date: Sat, 5 Oct 2024 15:04:11 +0100 Subject: [PATCH] Use an if condition instead of slice --- layouts/feed.njk | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/layouts/feed.njk b/layouts/feed.njk index a5dc737..3d44004 100644 --- a/layouts/feed.njk +++ b/layouts/feed.njk @@ -5,29 +5,31 @@ {{ collections[collection] | getNewestCollectionItemDate | dateToRfc3339 }} {{ options.url }}/ - {%- for item in (collections[collection] | sort(true, false, "date") | slice(size)) %} - {%- set absolutePostUrl = item.url | canonicalUrl %} - - {{ item.data.title }} - - {{ item.date | dateToRfc3339 }} - {{ absolutePostUrl }} - {% if item.data.authors %} - {% for author in item.data.authors %} + {%- for item in (collections[collection] | sort(true, false, "date") %} + {%- if loop.index0 < size %} + {%- set absolutePostUrl = item.url | canonicalUrl %} + + {{ item.data.title }} + + {{ item.date | dateToRfc3339 }} + {{ absolutePostUrl }} + {% if item.data.authors %} + {% for author in item.data.authors %} + + {{ author.name }} + {% if author.url %}{{ author.url }}{% endif %} + + {% endfor %} + {% elif item.data.author %} - {{ author.name }} - {% if author.url %}{{ author.url }}{% endif %} + {{ item.data.author.name }} + {% if item.data.author.url %}{{ item.data.author.url }}{% endif %} - {% endfor %} - {% elif item.data.author %} - - {{ item.data.author.name }} - {% if item.data.author.url %}{{ item.data.author.url }}{% endif %} - - {% endif %} - - - - + {% endif %} + + + + + {%- endif %} {%- endfor %}