11ty has tag filter

Also useful for syntax on passing 2 parameters to an 11ty filter

eleventyConfig.addFilter('hasTag', function(arr, str) {
return arr.includes(str);
});
{% if tags and tags | hasTag('learning') %}
...
{% endif %}

<!-- or output boolean value -->

{{ tags | hasTag('learning') }}

Original

https://alexcarpenter.me/posts/2019/11/eleventy-has-tag-filter/

Let me know what you think on twitter @rdallaire

← Return to blog