-
Notifications
You must be signed in to change notification settings - Fork 2
/
.eleventy.js
241 lines (235 loc) · 9.28 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
const pluginSEO = require("eleventy-plugin-seo");
const xmlFiltersPlugin = require('eleventy-xml-plugin');
const CleanCSS = require("clean-css");
module.exports = function(eleventyConfig) {
eleventyConfig.addPassthroughCopy('styles');
eleventyConfig.addPassthroughCopy('js');
eleventyConfig.addPassthroughCopy('static');
eleventyConfig.addPassthroughCopy('favicon.ico');
eleventyConfig.addPlugin(xmlFiltersPlugin);
eleventyConfig.addPlugin(pluginSEO, {
title: "Ethical Design Guide",
description: "Tech is always political. The way data is collected and handled is often biased, and many products are neither accessible nor inclusive. Ethical Design Guide is made to share resources on how to create ethical products that don't cause harm.",
url: "https://ethicaldesign.guide",
author: "Sarah L. Fossheim",
image: "https://ethicaldesign.guide/styles/img/shared.png",
options: {
titleStyle: "minimalistic",
titleDivider: "|",
imageWithBaseUrl: true,
twitterCardType: "summary_large_image"
}
});
eleventyConfig.addFilter("minify", css => {
return new CleanCSS({}).minify(css).styles;
});
eleventyConfig.addCollection("resources", collection => {
return collection.getFilteredByGlob('library/*/*.md').sort((a, b) => {
return b.date - a.date;
});
});
eleventyConfig.addCollection("books", collection => {
return collection.getFilteredByGlob('library/books/*.md').sort((a, b) => {
return b.date - a.date;
});
});
eleventyConfig.addCollection("articles", collection => {
return collection.getFilteredByGlob('library/articles/*.md').sort((a, b) => {
return b.date - a.date;
});
});
eleventyConfig.addCollection("tools", collection => {
return collection.getFilteredByGlob('library/tools/*.md').sort((a, b) => {
return b.date - a.date;
});
});
eleventyConfig.addCollection("courses", collection => {
return collection.getFilteredByGlob('library/courses/*.md').sort((a, b) => {
return b.date - a.date;
});
});
eleventyConfig.addCollection("other", collection => {
let other = collection.getFilteredByGlob('library/*/*.md');
other = other.filter((resource) => {
let category = resource.filePathStem.split("/library/")[1].split("/")[0];
return !["books", "articles", "courses", "tools"].includes(category);
}).sort((a, b) => {
return b.date - a.date;
});
return other;
});
eleventyConfig.addCollection("a11y", collection => {
let a11y = collection.getFilteredByGlob('library/*/*.md');
a11y = a11y.filter((resource) => {
return resource.data.categories
&& (resource.data.categories.includes("a11y")
|| resource.data.categories.includes("accessibility")
|| resource.data.categories.includes("disabilities")
|| resource.data.categories.includes("disabled"));
}).sort((a, b) => {
return b.date - a.date;
});
return a11y;
});
eleventyConfig.addCollection("biasai", collection => {
let biasai = collection.getFilteredByGlob('library/*/*.md');
biasai = biasai.filter((resource) => {
return resource.data.categories
&& (
(
(
resource.data.categories.includes("bias")
|| resource.data.categories.includes("racist")
|| resource.data.categories.includes("race")
|| resource.data.categories.includes("racism")
|| resource.data.categories.includes("anti-racism")
|| resource.data.categories.includes("antiracism")
|| resource.data.categories.includes("transphobia")
|| resource.data.categories.includes("gender")
|| resource.data.categories.includes("queer")
|| resource.data.categories.includes("LGBTQIA+")
|| resource.data.categories.includes("sexuality")
|| resource.data.categories.includes("sexism")
|| resource.data.categories.includes("biased")
)
&& (
resource.data.categories.includes("ai")
|| resource.data.categories.includes("AI")
|| resource.data.categories.includes("artificial intelligence")
|| resource.data.categories.includes("algorithms")
|| resource.data.categories.includes("machine learning")
|| resource.data.categories.includes("deep learning")
|| resource.data.categories.includes("image recognition")
)
|| resource.data.categories.includes("biased ai")
|| resource.data.categories.includes("bias in ai")
)
);
}).sort((a, b) => {
return b.date - a.date;
});
return biasai;
});
eleventyConfig.addCollection("inclusive", collection => {
let inclusive = collection.getFilteredByGlob('library/*/*.md');
inclusive = inclusive.filter((resource) => {
return resource.data.categories
&& (resource.data.categories.includes("inclusive design")
|| resource.data.categories.includes("cultural design")
|| (
(
resource.data.categories.includes("inclusive")
|| resource.data.categories.includes("cultural")
|| resource.data.categories.includes("race")
|| resource.data.categories.includes("racism")
|| resource.data.categories.includes("diversity")
|| resource.data.categories.includes("equity")
|| resource.data.categories.includes("inclusion")
|| resource.data.categories.includes("ethics")
|| resource.data.categories.includes("queer")
|| resource.data.categories.includes("gender")
|| resource.data.categories.includes("sexuality")
|| resource.data.categories.includes("accessible")
|| resource.data.categories.includes("accessibility")
|| resource.data.categories.includes("disabilities")
|| resource.data.categories.includes("disabled")
|| resource.data.categories.includes("a11y")
)
&& resource.data.categories.includes("design")
));
}).sort((a, b) => {
return b.date - a.date;
});
return inclusive;
});
eleventyConfig.addCollection("queer", collection => {
let queer = collection.getFilteredByGlob('library/*/*.md');
queer = queer.filter((resource) => {
return resource.data.categories
&& (resource.data.categories.includes("queer")
|| resource.data.categories.includes("queer issues")
|| resource.data.categories.includes("LGBTQIA+")
|| resource.data.categories.includes("gay")
|| resource.data.categories.includes("trans")
|| resource.data.categories.includes("transgender")
|| resource.data.categories.includes("non-binary")
|| resource.data.categories.includes("non-binary issues")
|| resource.data.categories.includes("gender")
|| resource.data.categories.includes("sexuality"));
}).sort((a, b) => {
return b.date - a.date;
});
return queer;
});
eleventyConfig.addCollection("race", collection => {
let race = collection.getFilteredByGlob('library/*/*.md');
race = race.filter((resource) => {
return resource.data.categories
&& (resource.data.categories.includes("race")
|| resource.data.categories.includes("racism")
|| resource.data.categories.includes("white supremacy")
|| resource.data.categories.includes("anti-racism")
|| resource.data.categories.includes("antiracism")
|| resource.data.categories.includes("anti-racist")
|| resource.data.categories.includes("racial justice")
|| resource.data.categories.includes("racial inequality"));
}).sort((a, b) => {
return b.date - a.date;
});
return race;
});
eleventyConfig.addCollection("categoryList", collection => {
let categoryList = [];
collection.getAll().forEach((item) => {
if("categories" in item.data){
const categories = item.data.categories;
for(let category of categories){
category = category.toLowerCase();
if(!categoryList.includes(category) && !categoryList.includes(category.replace(" ", ""))){
categoryList.push(category);
}
}
}
})
return categoryList;
});
eleventyConfig.addFilter("consolePrint", content => {
console.log(content);
});
eleventyConfig.addFilter("removeSpaces", content => {
return content.replace(" ", "");
});
eleventyConfig.addFilter("getDescription", content => {
let description = content.type + " about ";
content.categories.forEach((category, index) => {
description += category;
if (index <= content.categories.length - 2) {
description += ", ";
if (index === content.categories.length - 2) {
description += "and "
}
} else {
description += ".";
}
});
return description;
});
eleventyConfig.addFilter("getAuthors", content => {
let authors = "By ";
content.authors.forEach((author, index) => {
authors += author;
if (index <= content.authors.length - 2) {
authors += ", ";
if (index === content.authors.length - 2) {
authors += "and "
}
} else {
authors += ".";
}
});
return authors;
});
return {
passthroughFileCopy: true
}
}