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');
|
||||
contents.forEach(p => {
|
||||
let cats = p.data.categories;
|
||||
if (cats) {
|
||||
cats.forEach(c => categories.add(c));
|
||||
}
|
||||
});
|
||||
return Array.from(categories).sort();
|
||||
});
|
||||
@ -15,7 +17,9 @@ export default function(eleventyConfig) {
|
||||
cat = cat.toLowerCase();
|
||||
let result = contents.filter(item => {
|
||||
let cats = item.data.categories.map(c => c.toLowerCase());
|
||||
if (cats) {
|
||||
return cats.includes(cat);
|
||||
}
|
||||
});
|
||||
return result;
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user