-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy path.eleventy.js
40 lines (32 loc) · 1.13 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
const YAML = require('js-yaml'); // eslint-disable-line import/no-extraneous-dependencies
const { getCategoriesWithCount } = require('./lib/site');
module.exports = (eleventyConfig) => {
eleventyConfig.addDataExtension('yaml', (contents) => YAML.load(contents));
eleventyConfig.addLayoutAlias('tool', 'tool.njk');
eleventyConfig.addPassthroughCopy({ 'src/images/favicon': '/' });
// Takes a list of objects and generates a unique list based on a given key
eleventyConfig.addFilter('uniqueValues', (list, key) => list
.reduce((output, member) => {
if (Array.isArray(member[key])) {
member[key]
.forEach((v) => {
if (output.indexOf(v) === -1) {
output.push(v);
}
});
return output;
}
if (output.indexOf(member[key]) === -1) {
return output.concat(member[key]);
}
return output;
}, []));
eleventyConfig.addFilter('categoriesWithCount', getCategoriesWithCount);
eleventyConfig.addGlobalData('hostedAt', process.env.HOSTED_AT || true);
return {
dir: {
input: 'src',
output: 'docs',
},
};
};