-
Notifications
You must be signed in to change notification settings - Fork 7
/
.eleventy.js
46 lines (40 loc) · 1.36 KB
/
.eleventy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
module.exports = function(config) {
config.addPassthroughCopy("./static");
config.addCollection("tagList", function(collection){
let tagSet = new Set();
collection.getAll().forEach(function(item) {
if( "tags" in item.data ) {
let tags = item.data.tags;
tags = tags.filter(function(item) {
switch(item) {
// this list should match the `filter` list in tags.njk
case "all":
case "nav":
case "post":
case "posts":
return false;
}
return true;
});
for (const tag of tags) {
tagSet.add(tag);
}
}
});
// returning an array in addCollection works in Eleventy 0.5.3
return [...tagSet];
});
config.addCollection("videos", function(collection) {
// get unsorted items
let videos = collection.getAll().filter((col)=>col.data.layout == "video");
let sorted = videos.sort(function(a,b){
return new Date(b.date) - new Date(a.date);
});
// console.log(videos);
return sorted;
});
// eleventyConfig.addShortcode("getAllTags", function(all) {
// console.log(all);
// return [];
// });
}