-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy path.eleventy.js
66 lines (59 loc) · 1.7 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
// const { DateTime } = require("luxon");
const pluginRss = require("@11ty/eleventy-plugin-rss");
const svgSprite = require("eleventy-plugin-svg-sprite");
const dateFilter = require("./src/filters/dateFilter.js");
const cleanCSS = require("clean-css");
module.exports = function (config) {
config.setServerOptions({
// Whether the live reload snippet is used
liveReload: true,
port: 3456,
watch: ["dist/**/*.css"],
showAllHosts: true,
});
// PASSTHROUGHS
config.addPassthroughCopy("src/assets/images/");
// LAYOUTS //
config.addLayoutAlias("base", "layouts/base.njk");
config.addLayoutAlias("post", "layouts/post.njk");
// FILTERS //
// date filter
config.addFilter("dateFilter", dateFilter);
// clean and inline CSS
config.addFilter("cssmin", function (code) {
return new cleanCSS({}).minify(code).styles;
});
// TRANSFORMS //
// minify HTML
const htmlMinTransform = require("./src/transforms/html-min.js");
const isProduction = process.env.ELEVENTY_ENV === "production";
// html min only in production
if (isProduction) {
config.addTransform("htmlmin", htmlMinTransform);
}
// PLUG-INS //
config.addPlugin(pluginRss);
config.addPlugin(svgSprite, {
path: "./src/assets/icons",
svgShortcode: "icon",
globalClasses: "icon",
});
// EXTRAS //
// Post List Excerpts
config.setFrontMatterParsingOptions({
excerpt: true,
excerpt_separator: "<!-- excerpt -->",
});
// BASE CONFIGURATION //
return {
dir: {
input: "src",
output: "dist",
includes: "includes",
data: "data",
},
templateFormats: ["html", "njk", "md", "11ty.js"],
htmlTemplateEngine: "njk",
markdownTemplateEngine: "njk",
};
};