-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
60 lines (55 loc) · 1.57 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
const dev = require('./docs/config/tasks/dev');
const dates = require('./docs/config/tasks/date-labels');
module.exports = function async(eleventyConfig) {
// watch task
eleventyConfig.on('beforeWatch', () => {
dev();
});
// date labels
if (process.env.SITE_ENV === 'workspace') {
eleventyConfig.on('afterBuild', () => {
dates();
});
}
eleventyConfig.setQuietMode(true);
eleventyConfig.addWatchTarget('**/*.scss');
eleventyConfig.addWatchTarget('./assets/scss/**/*.html');
// filters
eleventyConfig.addNunjucksFilter('toPx', (value) => {
let rems = value.replace(/(rem|em)$/, '');
rems = Number(rems);
return `${rems * 16}px`;
});
eleventyConfig.addNunjucksFilter('getSize', (value) => {
return value.replace('$size-', '');
});
eleventyConfig.addFilter('usageKey', (value, usage) => {
const usageObj = usage[value];
if (typeof usageObj === 'object') {
return usageObj.data;
} else {
return [];
}
});
eleventyConfig.addFilter('modifierKey', (value, modifiers) => {
return modifiers[value];
});
eleventyConfig.addFilter('cleanSlug', (value) => {
return value.replace(/[^-0-9A-Za-z]/gi, '').toLowerCase();
});
eleventyConfig.addFilter('cleanName', (value) => {
return value.replace(/\(([^)]+)\)/gi, '').trim();
});
// settings
return {
dir: {
input: 'docs/src/',
output: 'docs/dist',
data: 'data',
layouts: 'layouts',
},
passthroughFileCopy: true,
templateFormats: ['njk', 'md', 'css', 'html', 'yml'],
htmlTemplateEngine: 'njk',
};
};