rothsandro / eleventy-notes

A template for Eleventy to publish your personal notes or docs.
https://eleventy-notes.sandroroth.com/
127 stars 14 forks source link

New collections.tags format breaks renderAsList #48

Closed zerodogg closed 5 months ago

zerodogg commented 5 months ago

Doing a rather large upgrade, from 0.9.0 to 0.23.1. This used to render a list of tags: {{ collections.tags | renderAsList | safe }}. It currently renders a list of links with no text.

v0.9.0 produces:

<ul data-link-list="">
    <li><a href="/tags/bookmarklet/">bookmarklet</a></li>
    <li><a href="/tags/shell/">shell</a></li>
    <li><a href="/tags/user-script/">user-script</a></li>
</ul>

v0.23.1 produces:

<ul data-link-list="">
    <li><a href="/tags/bookmarklet/"></a></li>
    <li><a href="/tags/shell/"></a></li>
    <li><a href="/tags/user-script/"></a></li>
</ul>

Complete example template:

---
title: Home
templateEngineOverride: njk, md
---
# snippets

Tags available:
{{ collections.tags | renderAsList | safe }}
rothsandro commented 5 months ago

You can fix it by specifying the titleProp:

{{ collections.tags | renderAsList({ titleProp: 'label' }) | safe }}

The property of the tags collection has been renamed from title to label in v0.18.0, that's why the default configuration of the renderAsList doesn't work anymore with the tags collection.

The code above should work so you can proceed with the update. But I will keep the issue open and either update the changelog page to mention this use case (the update of the collection is already mentioned) or extend the filter to support both collections out of the box.

zerodogg commented 5 months ago

Thanks! :)

rothsandro commented 5 months ago

Fixed in v0.23.2