styled rss feed

This commit is contained in:
Nycki 2024-12-13 19:40:32 -08:00
parent b593eb1968
commit 1a0665d84b
6 changed files with 107 additions and 33 deletions

View file

View file

@ -1 +0,0 @@
export const eleventyExcludeFromCollections = true;

View file

@ -1,27 +0,0 @@
---
# Metadata comes from _data/metadata.js
permalink: /blog/feed.xml
---
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:base="{{ metadata.language }}">
<title>{{ metadata.title }}</title>
<subtitle>{{ metadata.description }}</subtitle>
<link href="{{ permalink | htmlBaseUrl(metadata.url) }}" rel="self"/>
<link href="{{ metadata.url | htmlBaseUrl }}"/>
<updated>{{ collections.posts | getNewestCollectionItemDate | dateToRfc3339 }}</updated>
<id>{{ metadata.url }}</id>
<author>
<name>{{ metadata.author.name }}</name>
<email>{{ metadata.author.email }}</email>
</author>
{%- for post in collections.posts | reverse %}
{% set absolutePostUrl %}{{ post.url | htmlBaseUrl(metadata.url) }}{% endset %}
<entry>
<title>{{ post.data.title }}</title>
<link href="{{ absolutePostUrl }}"/>
<updated>{{ post.date | dateToRfc3339 }}</updated>
<id>{{ absolutePostUrl }}</id>
<content type="html">{{ post.templateContent | transformWithHtmlBase(absolutePostUrl, post.url) }}</content>
</entry>
{%- endfor %}
</feed>

View file

@ -1,12 +1,10 @@
import { DateTime } from "luxon";
import pluginSyntaxHighlight from "@11ty/eleventy-plugin-syntaxhighlight";
import { EleventyHtmlBasePlugin } from "@11ty/eleventy";
import pluginRss from '@11ty/eleventy-plugin-rss';
import { feedPlugin } from '@11ty/eleventy-plugin-rss';
/** @param {import('@11ty/eleventy').UserConfig} eleventyConfig */
export default function(eleventyConfig) {
console.log(process.env);
if (process.env.NODE_ENV === 'localhost') {
console.log('metadata override');
eleventyConfig.addGlobalData('metadata.url', 'http://localhost:8080');
@ -37,7 +35,22 @@ export default function(eleventyConfig) {
preAttributes: { tabindex: 0 }
});
eleventyConfig.addPlugin(EleventyHtmlBasePlugin);
eleventyConfig.addPlugin(pluginRss);
// RSS Feed
eleventyConfig.addPlugin(feedPlugin, {
type: 'atom',
outputPath: '/blog/feed.xml',
stylesheet: '/pretty-atom-feed.xml',
collection: { name: 'posts' },
metadata: {
language: 'en',
title: 'nycki.net',
base: 'https://nycki.net/',
author: {
name: 'nycki.net',
},
},
});
// Filters
eleventyConfig.addFilter("readableDate", (dateObj, format, zone) => {

View file

@ -35,7 +35,7 @@
"homepage": "https://github.com/11ty/eleventy-base-blog#readme",
"devDependencies": {
"@11ty/eleventy": "^3.0.0",
"@11ty/eleventy-plugin-rss": "^1.2.0",
"@11ty/eleventy-plugin-rss": "^2.0.2",
"@11ty/eleventy-plugin-syntaxhighlight": "^5.0.0",
"cross-env": "^7.0.3",
"luxon": "^3.3.0",

File diff suppressed because one or more lines are too long