joshua.seigler.net/site/_includes/components/collectionList.njk
2025-07-06 00:59:01 -04:00

26 lines
No EOL
1 KiB
Text

{%- from "components/tagList.njk" import tagList with context -%}
{% macro collectionList(tagName, limit=0) %}
<ul class="collection">
{%- for item in collections[tagName] | reverse -%}
{%- if (limit === 0 or loop.index <= limit) -%}
<li>
{% if item.data.cover %}
{% image item.data.cover, "", "(min-width: 60rem) calc(0.5 * var(--content-width)), var(--content-width)", "lazy", "collection-cover", item.page.inputPath %}
{% endif %}
<a href="{{item.url}}">{{item.data.title}}</a>
{%- if item.data.date -%}
<aside>{{item.data.date | formatDate("MMMM DD, YYYY") }}</aside>
{%- endif -%}
<aside>{{ tagList(item.data.tags.slice(1)) }}</aside>
<p>{{item.data.description | safe}}</p>
</li>
{%- endif -%}
{%- if (limit !== 0 and loop.index == limit + 1) -%}
<li>
<a href="/{{tagName}}/">More {{tagName}}&hellip;</a>
</li>
{%- endif -%}
{%- endfor -%}
</ul>
{% endmacro %}