Add checks if categories exist
This commit is contained in:
parent
e4dc17266e
commit
453d797298
@ -5,7 +5,9 @@ export default function(eleventyConfig) {
|
|||||||
let contents = collectionApi.getFilteredByTag('contents');
|
let contents = collectionApi.getFilteredByTag('contents');
|
||||||
contents.forEach(p => {
|
contents.forEach(p => {
|
||||||
let cats = p.data.categories;
|
let cats = p.data.categories;
|
||||||
cats.forEach(c => categories.add(c));
|
if (cats) {
|
||||||
|
cats.forEach(c => categories.add(c));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return Array.from(categories).sort();
|
return Array.from(categories).sort();
|
||||||
});
|
});
|
||||||
@ -15,7 +17,9 @@ export default function(eleventyConfig) {
|
|||||||
cat = cat.toLowerCase();
|
cat = cat.toLowerCase();
|
||||||
let result = contents.filter(item => {
|
let result = contents.filter(item => {
|
||||||
let cats = item.data.categories.map(c => c.toLowerCase());
|
let cats = item.data.categories.map(c => c.toLowerCase());
|
||||||
return cats.includes(cat);
|
if (cats) {
|
||||||
|
return cats.includes(cat);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user