Add tags.json feed

This commit is contained in:
Oliver Davies 2020-05-05 17:32:24 +01:00
parent a798306315
commit 97a6de3c42

24
source/tags.json.twig Normal file
View file

@ -0,0 +1,24 @@
---
permalink: tags.json
use: [posts]
---
{% set tags = [] %}
{% for post in data.posts %}
{% for tag in post.tags %}
{% if tag not in tags %}
{% set tags = tags|merge([ tag ]) %}
{% endif %}
{% endfor %}
{% endfor %}
{
"tags": [
{% for i, tag in tags|sort %}
{
"id": "{{ i }}",
"name": "{{ tag }}"
}{% if not loop.last %},{% endif %}
{% endfor %}
]
}