Skip to content

Commit c9f12d2

Browse files
authored
Merge pull request #51 from jeanremy/patch-1
Add head filter to config in virtualTemplate.js
2 parents e1c9a3d + ba4e312 commit c9f12d2

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/virtualTemplate.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,18 +142,19 @@ async function eleventyFeedPlugin(eleventyConfig, options = {}) {
142142
},
143143
layout: false,
144144
metadata: options.metadata,
145-
// Get the first `n` elements of a collection.
146-
head: function(array, n) {
147-
if(!n || n === 0) {
148-
return array;
149-
}
150-
if(n < 0) {
151-
throw new Error("`collection.limit` option must be a positive number.");
152-
}
153-
return array.slice(0, n);
154-
},
155145
};
156146

147+
// Get the first `n` elements of a collection.
148+
eleventyConfig.addFilter('head', function(array, n) {
149+
if(!n || n === 0) {
150+
return array;
151+
}
152+
if(n < 0) {
153+
throw new Error("`collection.limit` option must be a positive number.");
154+
}
155+
return array.slice(0, n);
156+
});
157+
157158
eleventyConfig.addTemplate(options.inputPath, getFeedContent(options), templateData);
158159
};
159160

0 commit comments

Comments
 (0)