-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
126 lines (104 loc) · 3.88 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
const Image = require("@11ty/eleventy-img");
const moment = require("moment");
const yaml = require("js-yaml");
const pluginRss = require("@11ty/eleventy-plugin-rss");
const eleventyPluginFilesMinifier = require("@sherby/eleventy-plugin-files-minifier");
module.exports = function (eleventyConfig) {
if (process.env.ELEVENTY_ENV === 'production') {
eleventyConfig.addPlugin(eleventyPluginFilesMinifier);
}
eleventyConfig.addPlugin(pluginRss);
eleventyConfig.addDataExtension("yaml", contents => yaml.load(contents));
eleventyConfig.addWatchTarget('./_tmp/style.css');
eleventyConfig.addWatchTarget('./src/projects/**/*');
eleventyConfig.addWatchTarget('./src/garden/**/*');
eleventyConfig.addWatchTarget('./src/games/**/*');
eleventyConfig.addPassthroughCopy('./src/projects/what-the-fanta/play/**/*');
eleventyConfig.addPassthroughCopy('./src/garden/**/*.webp');
eleventyConfig.addPassthroughCopy('./src/projects/**/*.webp');
eleventyConfig.addPassthroughCopy('./src/games/**/*.webp');
eleventyConfig.addPassthroughCopy('./src/games/**/*.zip');
eleventyConfig.addPassthroughCopy('./src/playdate.json')
eleventyConfig.addPassthroughCopy('./src/playdate-update.js')
eleventyConfig.addPassthroughCopy({ './_tmp/style.css': './style.css' });
eleventyConfig.addPassthroughCopy({ './src/media/': './media/' });
eleventyConfig.addPassthroughCopy({ './src/fontawesome/': './fontawesome/' });
eleventyConfig.addPassthroughCopy({ './src/favicon/': '.' });
eleventyConfig.addLiquidFilter("dateToRfc3339", pluginRss.dateToRfc3339);
eleventyConfig.addFilter("findPage", function find(slug, collection) {
let result = collection.find(page => page.fileSlug === slug);
if (result == null) {
console.error("Page not found!");
}
return result;
});
eleventyConfig.addLiquidFilter("prettyStatus", function (status) {
if (status == null) {
// no status = seedling
return "🌱 <i>Seedling</i>";
}
switch (status.toLowerCase()) {
default:
case "seedling":
return "🌱 <i>Seedling</i>";
case "budding":
return "🌿 <i>Budding</i>";
case "evergreen":
return "🌳 <i>Evergreen</i>";
}
});
eleventyConfig.addLiquidFilter("prettyStatusIcon", function(status) {
if (status == null) {
// no status = seedling
return "🌱";
}
switch (status.toLowerCase()) {
default:
case "seedling":
return "🌱";
case "budding":
return "🌿";
case "evergreen":
return "🌳";
}
});
eleventyConfig.addLiquidFilter("timeSince", function(utc) {
return moment.utc(utc).fromNow();
});
eleventyConfig.addLiquidFilter("formatDate", function(utc, format) {
return moment.utc(utc).format(format);
});
eleventyConfig.addLiquidFilter("length", function(array) {
return array.length
});
eleventyConfig.addLiquidFilter("withTag", function(collection, tag) {
return collection.filter((item) => item.data.tags.includes(tag));
});
eleventyConfig.addLiquidFilter("withoutTag", function(collection, tag) {
return collection.filter((item) => !item.data.tags.includes(tag));
});
eleventyConfig.addCollection("recentlyTended", function(collectionApi) {
return collectionApi.getFilteredByTag("garden")
.filter(function(item) {
return !item.data.tags.includes("hide-recently-tended")
}).sort(function(a, b) {
return b.data.tended - a.data.tended;
});
});
eleventyConfig.addCollection("recentlyPlanted", function(collectionApi) {
return collectionApi.getFilteredByTag("garden")
.filter(function(item) {
return !item.data.tags.includes("hide-recently-planted")
}).sort(function(a, b) {
return b.data.planted - a.data.planted;
});
});
return {
dir: {
input: "src",
output: "_site",
includes: "_includes",
layouts: "_layouts"
}
}
};