From c780c727709f47f87ea62b0da62656bab4f8bbb8 Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Fri, 15 Jul 2022 14:42:48 -0500 Subject: [PATCH] Simplify the Atom and JSON feeds --- _data/metadata.json | 10 ---------- feed/feed.njk | 15 +++++++-------- feed/json.njk | 12 +++++------- 3 files changed, 12 insertions(+), 25 deletions(-) diff --git a/_data/metadata.json b/_data/metadata.json index 5b9517f..94ecf0e 100644 --- a/_data/metadata.json +++ b/_data/metadata.json @@ -3,16 +3,6 @@ "url": "https://example.com/", "language": "en", "description": "I am writing about my experiences as a naval navel-gazer.", - "feed": { - "subtitle": "I am writing about my experiences as a naval navel-gazer.", - "filename": "feed.xml", - "path": "/feed/feed.xml", - "id": "https://example.com/" - }, - "jsonfeed": { - "path": "/feed/feed.json", - "url": "https://example.com/feed/feed.json" - }, "author": { "name": "Your Name Here", "email": "youremailaddress@example.com", diff --git a/feed/feed.njk b/feed/feed.njk index 28e3c32..c856675 100755 --- a/feed/feed.njk +++ b/feed/feed.njk @@ -1,16 +1,15 @@ --- # Metadata comes from _data/metadata.json -permalink: "{{ metadata.feed.path }}" +permalink: /feed/feed.xml --- - + {{ metadata.title }} - {{ metadata.feed.subtitle }} - {% set absoluteUrl %}{{ metadata.feed.path | url | absoluteUrl(metadata.url) }}{% endset %} - + {{ metadata.description }} + - {{ collections.posts | rssLastUpdatedDate }} - {{ metadata.feed.id }} + {{ collections.posts | getNewestCollectionItemDate | dateToRfc3339 }} + {{ metadata.url }} {{ metadata.author.name }} {{ metadata.author.email }} @@ -20,7 +19,7 @@ permalink: "{{ metadata.feed.path }}" {{ post.data.title }} - {{ post.date | rssDate }} + {{ post.date | dateToRfc3339 }} {{ absolutePostUrl }} {{ post.templateContent | htmlToAbsoluteUrls(absolutePostUrl) }} diff --git a/feed/json.njk b/feed/json.njk index f822b12..b5971e5 100644 --- a/feed/json.njk +++ b/feed/json.njk @@ -1,13 +1,13 @@ --- # Metadata comes from _data/metadata.json -permalink: "{{ metadata.jsonfeed.path }}" +permalink: /feed/feed.json --- { "version": "https://jsonfeed.org/version/1.1", "title": "{{ metadata.title }}", "language": "{{ metadata.language }}", "home_page_url": "{{ metadata.url }}", - "feed_url": "{{ metadata.jsonfeed.url }}", + "feed_url": "{{ permalink | url | absoluteUrl(metadata.url) }}", "description": "{{ metadata.description }}", "author": { "name": "{{ metadata.author.name }}", @@ -15,17 +15,15 @@ permalink: "{{ metadata.jsonfeed.path }}" }, "items": [ {%- for post in collections.posts | reverse %} - {%- set absolutePostUrl %}{{ post.url | url | absoluteUrl(metadata.url) }}{% endset -%} + {%- set absolutePostUrl = post.url | url | absoluteUrl(metadata.url) %} { "id": "{{ absolutePostUrl }}", "url": "{{ absolutePostUrl }}", "title": "{{ post.data.title }}", "content_html": {% if post.templateContent %}{{ post.templateContent | htmlToAbsoluteUrls(absolutePostUrl) | dump | safe }}{% else %}""{% endif %}, - "date_published": "{{ post.date | rssDate }}" + "date_published": "{{ post.date | dateToRfc3339 }}" } - {%- if not loop.last -%} - , - {%- endif -%} + {% if not loop.last %},{% endif %} {%- endfor %} ] }