Additional safety for head check
This commit is contained in:
parent
6ac031cfa4
commit
b63f9077ae
@ -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);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user