From a34bf51ce1a3a2e193736c31c64e15336f44c2a1 Mon Sep 17 00:00:00 2001 From: Benji Encalada Mora Date: Wed, 30 Oct 2019 13:26:42 -0500 Subject: [PATCH] Add jsonfeed template --- feed/json.njk | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 feed/json.njk diff --git a/feed/json.njk b/feed/json.njk new file mode 100644 index 0000000..85200d0 --- /dev/null +++ b/feed/json.njk @@ -0,0 +1,38 @@ +--- +permalink: feed/feed.json +eleventyExcludeFromCollections: true +--- +{ + "version": "https://jsonfeed.org/version/1", + "title": "{{ metadata.title }}", + "home_page_url": "{{ metadata.url }}", + "feed_url": "{{ metadata.jsonfeed.url }}", + "description": "{{ metadata.description }}", + "author": { + "name": "{{ metadata.author.name }}", + "url": "{{ metadata.author.url }}" + }, + "items": [ + {%- for post in collections.posts %} + {% set absolutePostUrl %}{{ post.url | url | absoluteUrl(metadata.url) }}{% endset -%} + { + "id": "{{ absolutePostUrl }}", + "url": "{{ absolutePostUrl }}", + "title": "{{ post.data.title }}", + "content_html": "{{ post.templateContent | jsonContent | safe }}", + "date_published": "{{ post.date | rssDate }}", + "tags": [ + {%- for c in post.data.category %} + "{{ c }}" + {%- if not loop.last -%} + , + {%- endif -%} + {%- endfor %} + ] + } + {%- if not loop.last -%} + , + {%- endif -%} + {%- endfor %} + ] +}