clean up feeds

This commit is contained in:
James Walker 2022-11-13 20:24:03 -05:00
parent 2592e84d07
commit 0853782914
Signed by: walkah
GPG Key ID: 3C127179D6086E93
4 changed files with 27 additions and 10 deletions

View File

@ -45,6 +45,8 @@ module.exports = function (eleventyConfig) {
// Convert publish date into a Date object
post.date = new Date(post.published_at);
post.published_at = new Date(post.published_at);
post.updated_at = new Date(post.updated_at);
});
// Bring featured post to the top of the list

View File

@ -5,7 +5,7 @@
"feed": {
"filename": "feed.xml",
"path": "/feed.xml",
"id": "https://walkah.blog/"
"id": "https://walkah.blog/feed.xml"
},
"jsonfeed": {
"path": "/feed.json",

View File

@ -3,12 +3,11 @@ permalink: "{{ metadata.feed.path | url }}"
eleventyExcludeFromCollections: true
---
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/">
<title>{{ metadata.title }}</title>
<subtitle>{{ metadata.feed.subtitle }}</subtitle>
{% set absoluteUrl %}{{ metadata.feed.path | url | absoluteUrl(metadata.url) }}{% endset %}
<link href="{{ absoluteUrl }}" rel="self"/>
<link href="{{ metadata.url }}"/>
<link href="{{ absoluteUrl }}" rel="self" type="application/atom+xml" />
<link href="{{ metadata.url }}" type="text/html" />
<updated>{{ collections.posts | rssLastUpdatedDate }}</updated>
<id>{{ metadata.feed.id }}</id>
<author>
@ -19,10 +18,22 @@ eleventyExcludeFromCollections: true
{% set absolutePostUrl %}{{ post.url | url | absoluteUrl(metadata.url) }}{% endset %}
<entry>
<title>{{ post.title }}</title>
<link href="{{ absolutePostUrl }}"/>
<updated>{{ post.date | rssDate }}</updated>
<link href="{{ absolutePostUrl }}" rel="alternate" type="text/html" title="{{ post.title }}" />
<pubdate>{{ post.published_at | rssDate }}</pubdate>
<updated>{{ post.updated_at | rssDate }}</updated>
<id>{{ absolutePostUrl }}</id>
<summary type="html">{{ post.excerpt | htmlToAbsoluteUrls(absolutePostUrl) }}</summary>
<content type="html">{{ post.html | htmlToAbsoluteUrls(absolutePostUrl) }}</content>
<author>
<name>{{ metadata.author.name }}</name>
</author>
{% if post.primary_tag %}
<category term="{{ post.primary_tag.name }}" />
{% endif %}
{% if post.feature_image %}
<media:thumbnail url="{{ post.feature_image }}" />
<media:content medium="image" url="{{ post.feature_image }}"/>
{% endif %}
</entry>
{%- endfor %}
</feed>

View File

@ -8,10 +8,11 @@ eleventyExcludeFromCollections: true
"home_page_url": "{{ metadata.url }}",
"feed_url": "{{ metadata.jsonfeed.url }}",
"description": "{{ metadata.description }}",
"author": {
"authors": [{
"name": "{{ metadata.author.name }}",
"url": "{{ metadata.author.url }}"
},
}],
"language": "en",
"items": [
{%- for post in collections.posts | reverse %}
{%- set absolutePostUrl %}{{ post.url | url | absoluteUrl(metadata.url) }}{% endset -%}
@ -19,8 +20,11 @@ eleventyExcludeFromCollections: true
"id": "{{ absolutePostUrl }}",
"url": "{{ absolutePostUrl }}",
"title": "{{ post.title }}",
"summary": "{{ post.excerpt }}",
"content_html": {% if post.html %}{{ post.html | dump | safe }}{% else %}""{% endif %},
"date_published": "{{ post.date | rssDate }}"
{% if post.feature_image %}"image": "{{ post.feature_image }}",{% endif %}
"date_published": "{{ post.published_at | rssDate }}",
"date_modified": "{{ post.updated_at | rssDate }}"
}
{%- if not loop.last -%}
,