Add RSS plug-in and blog feed

This commit is contained in:
Helen Chong
2024-04-09 15:56:01 +08:00
parent f093e1d944
commit f1557c9b52
4 changed files with 47 additions and 2 deletions
BIN
View File
Binary file not shown.
+6 -1
View File
@@ -1,10 +1,15 @@
const pluginRss = require("@11ty/eleventy-plugin-rss");
const pluginImages = require("./eleventy.config.images.js");
module.exports = function(eleventyConfig) {
eleventyConfig.addPassthroughCopy("./src/assets/");
eleventyConfig.addWatchTarget("./src/assets/");
// Add plug-ins
// Installed Plug-ins
eleventyConfig.addPlugin(pluginRss);
// App plug-ins
eleventyConfig.addPlugin(pluginImages);
// Add short codes
+2 -1
View File
@@ -12,6 +12,7 @@
},
"dependencies": {
"@11ty/eleventy": "^2.0.1",
"@11ty/eleventy-img": "^4.0.2"
"@11ty/eleventy-img": "^4.0.2",
"@11ty/eleventy-plugin-rss": "^1.2.0"
}
}
+39
View File
@@ -0,0 +1,39 @@
---json
{
"permalink": "blog/feed.xml",
"eleventyExcludeFromCollections": true,
"metadata": {
"title": "Helen Chong's Blog",
"subtitle": "I am writing about stuff.",
"url": "https://helenclx.github.io/blog/",
"feedUrl": "https://helenclx.github.io/blog/feed.xml",
"author": {
"name": "Helen Chong",
"email": "helenclx@outlook.com"
}
}
}
---
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>{{ metadata.title }}</title>
<subtitle>{{ metadata.subtitle }}</subtitle>
<link href="{{ metadata.feedUrl }}" rel="self"/>
<link href="{{ metadata.url }}"/>
<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 | url | absoluteUrl(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 | htmlToAbsoluteUrls(absolutePostUrl) }}</content>
</entry>
{%- endfor %}
</feed>