-
Notifications
You must be signed in to change notification settings - Fork 1
/
.eleventy.js
73 lines (62 loc) · 2.26 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
const rssPlugin = require("@11ty/eleventy-plugin-rss");
const syntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
// Import filters
const dateFilter = require("./site/filters/date-filter.js");
const markdownFilter = require("./site/filters/markdown-filter.js");
const w3DateFilter = require("./site/filters/w3-date-filter.js");
// Import transforms
const htmlMinTransform = require("./site/transforms/html-min-transform.js");
const parseTransform = require("./site/transforms/parse-transform.js");
const criticalCSSTransform = require("./site/transforms/critical-css-transform.js");
// Import data files
const site = require("./site/_data/site.js");
module.exports = function(config) {
// Filters
config.addFilter("dateFilter", dateFilter);
config.addFilter("markdownFilter", markdownFilter);
config.addFilter("w3DateFilter", w3DateFilter);
// Transforms
config.addTransform("parse", parseTransform);
if (site.criticalCSS) {
config.addTransform("critical-css", criticalCSSTransform);
} else {
// Critical will also minify
config.addTransform("htmlmin", htmlMinTransform);
}
// Custom collections
const now = new Date();
const liveEpisodes = episode => episode.date <= now && !episode.data.draft;
config.addCollection("episodes", collection => {
return [
...collection.getFilteredByGlob("./site/episodes/*.md").filter(liveEpisodes)
].reverse();
});
config.addCollection("episodeFeed", collection => {
return [
...collection.getFilteredByGlob("./site/episodes/*.md").filter(liveEpisodes)
]
.reverse()
.slice(0, site.episodesPerPage);
});
// Passthrough
config.addPassthroughCopy({ "site/static": "/" });
// Plugins
config.addPlugin(rssPlugin);
config.addPlugin(syntaxHighlight);
// Watch for changes to my source files
if (config.addWatchTarget) {
config.addWatchTarget("site/src/scss");
config.addWatchTarget("site/src/js");
} else {
console.log(
"A future version of 11ty will allow live-reloading of JS and Sass. You can update 11ty with the next release to get these features."
);
}
return {
dir: {
input: "site",
output: "dist"
},
passthroughFileCopy: true
};
};