Add RSS (Atom) feed

This commit is contained in:
Neil Brommer 2023-07-10 14:22:04 -07:00
parent 26f900ccee
commit dea39db556
6 changed files with 80 additions and 52 deletions

View file

@ -13,5 +13,10 @@
"name": "LinkedIn",
"icon": "linkedin",
"url": "https://www.linkedin.com/in/neilbrommer/"
},
{
"name": "RSS Feed",
"icon": "rss",
"url": "/feed.xml"
}
]

View file

@ -5,6 +5,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="Neil Brommer">
<meta name="description" content="The personal website of Neil Brommer">
<link rel="alternate" type="application/atom+xml" title="Neil Brommer's Personal Site"
href="/feed.xml">
<title>
{% if (title is defined) and (page.url != "/") %}

31
src/feed.njk Normal file
View file

@ -0,0 +1,31 @@
---
permalink: feed.xml,
eleventyExcludeFromCollections: true,
metadata:
title: Neil Brommer's Personal Website,
language: en,
url: https://neilbrommer.com/,
author:
name: Neil Brommer
---
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:base="{{ metadata.url }}">
<title>{{ metadata.title }}</title>
<link href="{{ permalink | absoluteUrl(metadata.url) }}" rel="self"/>
<link href="{{ metadata.url }}"/>
<updated>{{ collections.posts | getNewestCollectionItemDate | dateToRfc3339 }}</updated>
<id>{{ metadata.url }}</id>
<author>
<name>{{ metadata.author.name }}</name>
</author>
{%- for post in collections.posts | filterDrafts | IsNotPage("/posts/") | reverse %}
{%- set absolutePostUrl = post.url | absoluteUrl(metadata.url) %}
<entry>
<title>{{ post.data.title }}</title>
<link href="{{ absolutePostUrl }}"/>
<updated>{{ post.date | dateToRfc3339 }}</updated>
<id>{{ absolutePostUrl }}</id>
<content xml:lang="{{ metadata.language }}" type="html">{{ post.templateContent | htmlToAbsoluteUrls(absolutePostUrl) }}</content>
</entry>
{%- endfor %}
</feed>