-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
83 lines (67 loc) · 2.47 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
83
const htmlMinifier = require("html-minifier");
const filters = require("./src/_filters/filters.js");
const syntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
const componentsDir = `./src/_includes/component`;
const photoCard = require(`${componentsDir}/photography/photoCard.js`);
const photoTags = require(`${componentsDir}/photography/photoTags.js`);
const photoPicture = require(`${componentsDir}/photography/photoPicture.js`);
function configurePassThroughCopy(eleventyConfig) {
eleventyConfig.addPassthroughCopy("src/assets/images");
if (process.env.ELEVENTY_ENV === "development") {
eleventyConfig.addPassthroughCopy({ "src/assets/_dev/css": "assets/css" });
eleventyConfig.addPassthroughCopy({ "src/assets/_dev/scripts": "assets/scripts" });
}
}
function configureTransform(eleventyConfig) {
eleventyConfig.addTransform("htmlMinifier", (content, outputPath) => {
if (outputPath.endsWith(".html")) {
return htmlMinifier.minify(content, {
useShortDoctype: true,
removeComments: true,
collapseWhitespace: process.env.ELEVENTY_ENV !== "development",
minifyJS: true
});
}
return content;
});
}
function configureFilters(eleventyConfig) {
Object.keys(filters).forEach(x => {
eleventyConfig.addFilter(x, filters[x])
});
}
function configureShortcodes(eleventyConfig) {
eleventyConfig.addShortcode("photoCard", photoCard);
eleventyConfig.addShortcode("photoTags", photoTags);
eleventyConfig.addShortcode("photoPicture", photoPicture);
}
function configureCollections(eleventyConfig) {
eleventyConfig.addCollection("posts", function (collection) {
return collection.getFilteredByGlob("src/posts/*.md").reverse();
});
}
function configurePlugins(eleventyConfig) {
eleventyConfig.addPlugin(syntaxHighlight, {
templateFormats: ["njk", "md"]
});
}
module.exports = function (eleventyConfig) {
configurePassThroughCopy(eleventyConfig);
configureTransform(eleventyConfig);
configureFilters(eleventyConfig);
configureShortcodes(eleventyConfig);
configureCollections(eleventyConfig);
configurePlugins(eleventyConfig);
eleventyConfig.setWatchThrottleWaitTime(100);
eleventyConfig.setUseGitIgnore(false);
return {
dir: {
input: "src",
output: "www",
includes: "_includes",
data: "_data"
},
templateFormats: ["njk", "html", "md"],
htmlTemplateEngine: "njk"
}
};