From 619538df79db73d85d1747ce5c33d0ba41dc6f6e Mon Sep 17 00:00:00 2001 From: Mathias Bynens Date: Thu, 13 Sep 2018 13:10:38 +0200 Subject: [PATCH 1/2] Use Set instead of object in `getTagList` --- _11ty/getTagList.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/_11ty/getTagList.js b/_11ty/getTagList.js index 6b2882a..60077c1 100644 --- a/_11ty/getTagList.js +++ b/_11ty/getTagList.js @@ -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]; }; From 0012d51d9bbf224bd9ce6c1ecce89066eaa746f6 Mon Sep 17 00:00:00 2001 From: Mathias Bynens Date: Thu, 13 Sep 2018 13:12:49 +0200 Subject: [PATCH 2/2] Update getTagList.js --- _11ty/getTagList.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/_11ty/getTagList.js b/_11ty/getTagList.js index 60077c1..f7f68a1 100644 --- a/_11ty/getTagList.js +++ b/_11ty/getTagList.js @@ -7,7 +7,7 @@ module.exports = function(collection) { tags = [tags]; } - tags.filter(function(item) { + tags = tags.filter(function(item) { switch(item) { // this list should match the `filter` list in tags.njk case "all": @@ -19,6 +19,7 @@ module.exports = function(collection) { return true; }); + tagSet.add(...tags); } });