From 97a6de3c42edc948ac5abad28cf8efb089a87f47 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Tue, 5 May 2020 17:32:24 +0100 Subject: [PATCH] Add tags.json feed --- source/tags.json.twig | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 source/tags.json.twig diff --git a/source/tags.json.twig b/source/tags.json.twig new file mode 100644 index 00000000..e89c4dab --- /dev/null +++ b/source/tags.json.twig @@ -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 %} + ] +} \ No newline at end of file