-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheleventy.config.cjs
More file actions
33 lines (28 loc) · 823 Bytes
/
Copy patheleventy.config.cjs
File metadata and controls
33 lines (28 loc) · 823 Bytes
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
const fs = require('fs');
function readFile(path) {
return fs.readFileSync(path);
}
function stripComments(data) {
return data.toString()
.replace(/\/\*[\s\S]*?\*\//gm, "")
.replace(/<!--[\s\S]*?-->/gm, "");
}
function dataUri(data, mimeType) {
return "data:" + mimeType + ";base64," + Buffer.from(data).toString("base64");
}
module.exports = function(eleventyConfig) {
eleventyConfig.addLiquidFilter(
"readFile", (path) => readFile(path));
eleventyConfig.addLiquidFilter(
"stripComments", (data) => stripComments(data));
eleventyConfig.addLiquidFilter(
"svgDataUri", (data) => dataUri(data, "image/svg+xml"));
return {
dir: {
input: "README.md",
output: ".eleventy/output",
includes: ".eleventy/includes",
data: ".eleventy/data",
},
};
};