Merge pull request #16 from mathiasbynens/patch-2
Use Set instead of object in `getTagList`
This commit is contained in:
commit
002f4e2f2a
@ -1,5 +1,5 @@
|
|||||||
module.exports = function(collection) {
|
module.exports = function(collection) {
|
||||||
let tagList = {};
|
let tagSet = new Set();
|
||||||
collection.getAllSorted().forEach(function(item) {
|
collection.getAllSorted().forEach(function(item) {
|
||||||
if( "tags" in item.data ) {
|
if( "tags" in item.data ) {
|
||||||
let tags = item.data.tags;
|
let tags = item.data.tags;
|
||||||
@ -7,7 +7,7 @@ module.exports = function(collection) {
|
|||||||
tags = [tags];
|
tags = [tags];
|
||||||
}
|
}
|
||||||
|
|
||||||
tags.filter(function(item) {
|
tags = tags.filter(function(item) {
|
||||||
switch(item) {
|
switch(item) {
|
||||||
// this list should match the `filter` list in tags.njk
|
// this list should match the `filter` list in tags.njk
|
||||||
case "all":
|
case "all":
|
||||||
@ -18,12 +18,12 @@ module.exports = function(collection) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}).forEach(function(tag) {
|
|
||||||
tagList[tag] = true;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
tagSet.add(...tags);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// returning an array in addCollection works in Eleventy 0.5.3
|
// returning an array in addCollection works in Eleventy 0.5.3
|
||||||
return Object.keys(tagList);
|
return [...tagSet];
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user