This repository has been archived by the owner on May 30, 2024. It is now read-only.
generated from distantcam/windty
-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy path.eleventy.js
56 lines (46 loc) · 1.38 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
const fs = require("fs");
const htmlmin = require("html-minifier");
const img = require("./shortcodes/img.js");
const { EleventyRenderPlugin } = require("@11ty/eleventy");
const CleanCSS = require("clean-css");
module.exports = function (eleventyConfig) {
eleventyConfig.addShortcode("img", img);
eleventyConfig.addPlugin(EleventyRenderPlugin);
eleventyConfig.addShortcode("replace", (value, search, replacement) =>
value.replaceAll(search, replacement)
);
eleventyConfig.addShortcode("jsonify", (value) =>
JSON.stringify(value, null, 2)
);
eleventyConfig.addFilter("cssmin", function (code) {
return new CleanCSS({}).minify(code).styles;
});
if (process.env.ELEVENTY_PRODUCTION) {
eleventyConfig.addTransform("htmlmin", htmlminTransform);
}
// Passthrough
eleventyConfig.addPassthroughCopy({ "src/static": "." });
// Watch targets
eleventyConfig.addWatchTarget("./src/styles/");
let pathPrefix = "";
// if (process.env.GITHUB_REPOSITORY) {
// pathPrefix = process.env.GITHUB_REPOSITORY.split("/")[1];
// }
return {
dir: {
input: "src",
},
pathPrefix,
};
};
function htmlminTransform(content, outputPath) {
if (outputPath.endsWith(".html")) {
let minified = htmlmin.minify(content, {
useShortDoctype: true,
removeComments: true,
collapseWhitespace: true,
});
return minified;
}
return content;
}