forked from CSS-Tricks/conferences
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
60 lines (51 loc) · 1.71 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 { DateTime } = require('luxon');
const CleanCSS = require('clean-css');
const pluginRss = require('@11ty/eleventy-plugin-rss');
module.exports = function(config) {
config.addCollection('conferences', function(collection) {
let allConferences = collection.getFilteredByGlob('site/conferences/*.md');
let futureConferences = allConferences.filter(conf => {
return conf.data.date >= new Date();
});
return futureConferences;
});
config.addFilter('getMonthName', dateObj => {
return DateTime.fromJSDate(dateObj, {
zone: 'utc'
}).toFormat('MMMM');
});
config.addFilter('doesConfExist', (conferences, monthToTest) => {
let length = conferences.filter(conf => {
let month = DateTime.fromJSDate(conf.data.date, {
zone: 'utc'
}).toFormat('MMMM');
return month === monthToTest;
}).length;
return length;
});
config.addFilter('readableDate', dateObj => {
return DateTime.fromJSDate(dateObj, {
zone: 'utc'
}).toFormat('LLLL d, y');
});
config.addFilter('htmlTime', dateObj => {
return DateTime.fromJSDate(dateObj, {
zone: 'utc'
}).toFormat('yyyy-MM-dd');
});
config.addFilter('cssmin', function(code) {
return new CleanCSS({}).minify(code).styles;
});
config.addPlugin(pluginRss);
config.addPassthroughCopy('site/script');
config.addPassthroughCopy('site/admin');
config.addPassthroughCopy('apple-touch-icon.png');
config.addPassthroughCopy('favicon.ico');
return {
dir: { input: 'site', output: 'dist', includes: '_includes' },
passthroughFileCopy: true,
templateFormats: ['njk', 'md', 'css', 'js', 'html', 'yml'],
htmlTemplateEngine: 'njk',
markdownTemplateEngine: 'njk'
};
};