diff --git a/src/virtualTemplate.js b/src/virtualTemplate.js index bda644a..a5246b5 100644 --- a/src/virtualTemplate.js +++ b/src/virtualTemplate.js @@ -142,18 +142,19 @@ async function eleventyFeedPlugin(eleventyConfig, options = {}) { }, layout: false, metadata: options.metadata, - // Get the first `n` elements of a collection. - head: function(array, n) { - if(!n || n === 0) { - return array; - } - if(n < 0) { - throw new Error("`collection.limit` option must be a positive number."); - } - return array.slice(0, n); - }, }; + // Get the first `n` elements of a collection. + eleventyConfig.addFilter('head', function(array, n) { + if(!n || n === 0) { + return array; + } + if(n < 0) { + throw new Error("`collection.limit` option must be a positive number."); + } + return array.slice(0, n); + }); + eleventyConfig.addTemplate(options.inputPath, getFeedContent(options), templateData); };