Version 3 of the RSS plugin comes with a notable breaking change in the form of the switch to ESM only (see https://github.com/11ty/eleventy-plugin-rss/releases/tag/v3.0.0). However, the plugin being distributed as ESM isn't the only breaking change that comes with it.
For my website project, this poses a challenge as it's not clear to me how the migration works. (I'll figure it out eventually through writing this issue though)
My configuration: https://github.com/kleinfreund/kleinfreund.de/blob/d73ca4ac2b7ebee1b345e668f24d4f75129b8480/eleventy.config.js#L75-L79
import pluginRss from '@11ty/eleventy-plugin-rss'
// ...
eleventyConfig.addPlugin(pluginRss)
eleventyConfig.addFilter('absoluteUrl', pluginRss.absoluteUrl)
eleventyConfig.addFilter('convertHtmlToAbsoluteUrls', pluginRss.convertHtmlToAbsoluteUrls)
eleventyConfig.addFilter('dateToRfc3339', pluginRss.dateToRfc3339)
eleventyConfig.addFilter('getNewestCollectionItemDate', pluginRss.getNewestCollectionItemDate)
feed.liquid:
---
permalink: feed.xml
---
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>{{ metadata.title }}</title>
<subtitle>{{ metadata.description }}</subtitle>
<id>{{ metadata.url }}/</id>
<link href="{{ metadata.url }}/" />
<link href="{{ permalink | absoluteUrl: metadata.url }}" rel="self"/>
<updated>{{ collections.posts | getNewestCollectionItemDate | dateToRfc3339 }}</updated>
<author>
<name>{{ metadata.author.name }}</name>
<email>{{ metadata.author.mail }}</email>
</author>
{%- for post in collections.posts reversed %}
{%- assign absolutePostUrl = post.url | absoluteUrl: metadata.url %}
<entry>
<title>{{ post.data.title | escape }}</title>
<id>{{ absolutePostUrl }}</id>
<link href="{{ absolutePostUrl }}"/>
<updated>{{ post.date | dateToRfc3339 }}</updated>
<content xml:lang="en" type="html">
{{ post.content | convertHtmlToAbsoluteUrls: absolutePostUrl | escape }}
</content>
</entry>
{%- endfor %}
</feed>
pluginRss.convertHtmlToAbsoluteUrls no longer exists. Due to how previously, the module.exports = pluginRss object was set first and then further properties where added like module.exports.convertHtmlToAbsoluteUrls = convertHtmlToAbsoluteUrls, the plugin object held references to those methods. That's no longer the case and the methods are now plain functions that can be imported like so:
import pluginRss, {
absoluteUrl,
convertHtmlToAbsoluteUrls,
dateToRfc3339,
getNewestCollectionItemDate,
} from '@11ty/eleventy-plugin-rss'
That's a breaking change that I don't suspect people will expect from the release note lines around ESM.
This isn't made easier to discover by the plugin types in my project being fetched out of the DefinitelyTyped types for the plugin which are some two years old: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/11ty__eleventy-plugin-rss
Unrelated to this, I also realized my RSS feed had already been broken much like has been reported in #6
Something seems to inject a bit of minimally valid HTML boilerplate at the top:
<!--?xml version="1.0" encoding="utf-8"?--><html><head></head><body><feed xmlns="http://www.w3.org/2005/Atom">
and links are <link> rather than <link /> leading to a XML Parsing Error: mismatched tag. Expected: </link>. error when loading the xml file.
I tried the following without success:
eleventyConfig.addFilter('convertHtmlToAbsoluteUrls', function (htmlContent, base) {
return convertHtmlToAbsoluteUrls(htmlContent, base, { closingSingleTag: 'slash' })
})
Ultimately, I realized I had a transformer that was transforming all content via cheerio load(content).html() to inject heading anchor markup. By ignoring all content not ending in .html, I could fix this issue.
Version 3 of the RSS plugin comes with a notable breaking change in the form of the switch to ESM only (see https://github.com/11ty/eleventy-plugin-rss/releases/tag/v3.0.0). However, the plugin being distributed as ESM isn't the only breaking change that comes with it.
For my website project, this poses a challenge as it's not clear to me how the migration works. (I'll figure it out eventually through writing this issue though)
My configuration: https://github.com/kleinfreund/kleinfreund.de/blob/d73ca4ac2b7ebee1b345e668f24d4f75129b8480/eleventy.config.js#L75-L79
feed.liquid:
pluginRss.convertHtmlToAbsoluteUrlsno longer exists. Due to how previously, themodule.exports = pluginRssobject was set first and then further properties where added likemodule.exports.convertHtmlToAbsoluteUrls = convertHtmlToAbsoluteUrls, the plugin object held references to those methods. That's no longer the case and the methods are now plain functions that can be imported like so:That's a breaking change that I don't suspect people will expect from the release note lines around ESM.
This isn't made easier to discover by the plugin types in my project being fetched out of the DefinitelyTyped types for the plugin which are some two years old: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/11ty__eleventy-plugin-rss
Unrelated to this, I also realized my RSS feed had already been broken much like has been reported in #6
Something seems to inject a bit of minimally valid HTML boilerplate at the top:
and
links are<link>rather than<link />leading to aXML Parsing Error: mismatched tag. Expected: </link>.error when loading the xml file.I tried the following without success:
Ultimately, I realized I had a transformer that was transforming all content via cheerio
load(content).html()to inject heading anchor markup. By ignoring all content not ending in.html, I could fix this issue.