From 7b0648024932255ba9ecdedea43cd917661d3423 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Tue, 28 Apr 2020 17:28:47 +0100 Subject: [PATCH] Add posts.json feed --- source/posts.json.twig | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 source/posts.json.twig diff --git a/source/posts.json.twig b/source/posts.json.twig new file mode 100644 index 00000000..1d820144 --- /dev/null +++ b/source/posts.json.twig @@ -0,0 +1,20 @@ +--- +permalink: posts.json +use: [posts] +--- + +{ + "posts": [ + {% for post in data.posts|reverse %} + { + "id": "{{ loop.index }}", + "title": {{ post.title|json_encode|raw }}, + "created": "{{ post.date }}", + "updated": "{{ post.date }}", + "path": "{{ post.url|trim('/', 'right') }}", + "content": {{ post.blocks.content|json_encode|raw }}, + "status": "{{ post.draft ? '0' : '1' }}" + }{% if not loop.last %},{% endif %} + {% endfor %} + ] +} \ No newline at end of file