-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
82 lines (64 loc) · 2.11 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
const now = String(Date.now())
const htmlmin = require('html-minifier')
const { DateTime } = require("luxon");
module.exports = function (eleventyConfig) {
eleventyConfig.setUseGitIgnore(false)
eleventyConfig.addWatchTarget('./_tmp/style.css')
eleventyConfig.addPassthroughCopy({ './_tmp/style.css': './style.css' })
eleventyConfig.addPassthroughCopy({ './src/_includes/img' : './img' });
eleventyConfig.addShortcode('version', function () {
return now
})
eleventyConfig.addTransform('htmlmin', function (content, outputPath) {
if (
process.env.ELEVENTY_PRODUCTION &&
outputPath &&
outputPath.endsWith('.html')
) {
let minified = htmlmin.minify(content, {
useShortDoctype: true,
removeComments: true,
collapseWhitespace: true,
});
return minified
}
return content
})
eleventyConfig.addCollection("events", function(collection) {
return collection.getFilteredByGlob("./src/event/**/*.md");
});
eleventyConfig.addCollection("speakers", function(collection) {
return collection.getFilteredByGlob("./src/speaker/**/*.md");
});
eleventyConfig.addCollection("talks", function(collection) {
return collection.getFilteredByGlob("./src/talk/**/*.md");
});
eleventyConfig.addFilter('eventFilter', function(collection, event) {
if (!event) return collection;
const filtered = collection.filter(item => item.data.event == event)
return filtered;
});
eleventyConfig.addFilter('talkFilter', function(collection, speaker) {
if (!speaker) return collection;
const filtered = collection.filter(item => item.data.speaker == speaker)
return filtered;
});
eleventyConfig.addFilter('speakerFilter', function(collection, speaker) {
if (!speaker) return collection;
const filtered = collection.filter(item => item.fileSlug == speaker)
return filtered;
});
eleventyConfig.addFilter("neatDate", (dateObj) => {
return DateTime.fromJSDate(dateObj).toLocaleString(DateTime.DATE_HUGE);
});
return {
dir: {
input: "src",
output: "_site"
}
}
};