Using the Podcast Tools plugin
Just like the RSS plugin, we need to install this from npm and initialize it in the configuration file:
npm install eleventy-plugin-podcast-tools const pluginRss = require("@11ty/eleventy-plugin-rss"); const podcastTools = require ('eleventy-plugin-podcast-tools'); module.exports = function(eleventyConfig) { eleventyConfig.addPlugin(pluginRss); eleventyConfig.addPlugin(podcastTools); // ... The rest of the configuration file }
Now, we have access to the file size filter. This filter takes a path to a file and if it’s an audio file, it will return the size in bytes for valid RSS. Now we have everything we need for a valid enclosure
tag in our RSS feed. In the loop for each item, add the following code:
<enclosure url="{{absolutePostUrl}}" length="{{ audioPath | filesize }}" type...