Additional safety for head check

This commit is contained in:
Zach Leatherman 2021-07-28 08:57:25 -05:00
parent 6ac031cfa4
commit b63f9077ae

View File

@ -29,6 +29,9 @@ module.exports = function(eleventyConfig) {
// Get the first `n` elements of a collection. // Get the first `n` elements of a collection.
eleventyConfig.addFilter("head", (array, n) => { eleventyConfig.addFilter("head", (array, n) => {
if(!Array.isArray(array) || array.length === 0) {
return [];
}
if( n < 0 ) { if( n < 0 ) {
return array.slice(n); return array.slice(n);
} }