Add atom feed

This commit is contained in:
arne 2022-04-16 08:38:54 +02:00
commit 4d880b836d
5 changed files with 149 additions and 3 deletions

View file

@ -6,6 +6,7 @@
<title>{% if title %}{{ title }} | {% endif %}{{ page.title }}</title>
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🌌</text></svg>">
<link rel="stylesheet" href="{{ '/assets/style.css' | url }}" />
<link rel="alternate" type="application/atom+xml" href="{{ 'feed.xml' | url }}" />
</head>
<body>
<main class="{{ page.url | pageClasses }}">

38
src/feed.njk Normal file
View file

@ -0,0 +1,38 @@
---json
{
"permalink": "feed.xml",
"eleventyExcludeFromCollections": true,
"metadata": {
"subtitle": "I am by no means an expert in any of this.",
"author": {
"name": "arne",
"email": "feed at arnes.space"
}
}
}
---
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>{{ page.title }}</title>
<subtitle>{{ metadata.subtitle }}</subtitle>
<link href="{{ '/feed.xml' | url | absoluteUrl(page.baseUrl) }}" rel="self"/>
<link href="{{ page.baseUrl }}"/>
<updated>{{ collections.posts | getNewestCollectionItemDate | dateToRfc3339 }}</updated>
<id>{{ '/feed.xml' | url | absoluteUrl(page.baseUrl) }}</id>
<author>
<name>{{ metadata.author.name }}</name>
<email>{{ metadata.author.email }}</email>
</author>
{%- for post in collections.posts %}
{%- if not post.data.draft %}
{% set absolutePostUrl %}{{ post.url | url | absoluteUrl(page.baseUrl) }}{% endset %}
<entry>
<title>{{ post.data.title }}</title>
<link href="{{ absolutePostUrl }}"/>
<updated>{{ post.date | dateToRfc3339 }}</updated>
<id>{{ absolutePostUrl }}</id>
<content type="html">{{ post.templateContent | htmlToAbsoluteUrls(absolutePostUrl) }}</content>
</entry>
{%- endif %}
{%- endfor %}
</feed>