Use Set instead of object in getTagList

This commit is contained in:
Mathias Bynens 2018-09-13 13:10:38 +02:00 committed by GitHub
parent f0b7f1d4db
commit 619538df79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,5 @@
module.exports = function(collection) {
let tagList = {};
let tagSet = new Set();
collection.getAllSorted().forEach(function(item) {
if( "tags" in item.data ) {
let tags = item.data.tags;
@ -18,12 +18,11 @@ module.exports = function(collection) {
}
return true;
}).forEach(function(tag) {
tagList[tag] = true;
});
tagSet.add(...tags);
}
});
// returning an array in addCollection works in Eleventy 0.5.3
return Object.keys(tagList);
return [...tagSet];
};