-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
58 lines (47 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
const htmlmin = require("html-minifier");
module.exports = function (eleventyConfig) {
// Include all content in the common folder and copy it to the build root
eleventyConfig.addPassthroughCopy({ "src/assets/common": "/" });
// Include all content in the images folder
eleventyConfig.addPassthroughCopy("src/assets/images");
// Include all content in the videos folder
eleventyConfig.addPassthroughCopy("src/assets/videos");
// Include all content in the fonts folder
eleventyConfig.addPassthroughCopy("src/assets/fonts");
// Include all content in the js folder
eleventyConfig.addPassthroughCopy("src/assets/js");
// Include all content in the docs folder
eleventyConfig.addPassthroughCopy("src/assets/docs");
// Remove the soft hyphen from strings (in our case used for the titles)
eleventyConfig.addFilter("removeSoftHyphen", function (value) {
return value.replace("­", "");
});
// Module collection (custom sort by fileSlug)
eleventyConfig.addCollection("sortedModules", function (collectionApi) {
const sortedModules = collectionApi
.getFilteredByTag("module")
.sort((a, b) => {
return a.fileSlug - b.fileSlug;
});
return sortedModules;
});
// Minify HTML
eleventyConfig.addTransform("htmlmin", function (content) {
if (this.outputPath && this.outputPath.endsWith(".html")) {
return htmlmin.minify(content, {
useShortDoctype: true,
removeComments: true,
collapseWhitespace: true,
});
}
return content;
});
return {
dir: {
// Eleventy will only process files within src
input: "src",
// Defining _site is optional (it's already the default)
output: "_site",
},
};
};