-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy patheleventy.config.js
70 lines (61 loc) · 2.16 KB
/
eleventy.config.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
const prettify = require("html-prettify");
const { EleventyRenderPlugin } = require("@11ty/eleventy");
const syntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
const browserslist = require("browserslist");
const { bundle, browserslistToTargets } = require("lightningcss");
const path = require("node:path");
module.exports = function (eleventyConfig) {
eleventyConfig.addPlugin(EleventyRenderPlugin);
eleventyConfig.addPlugin(syntaxHighlight);
eleventyConfig.addTemplateFormats("css");
eleventyConfig.addExtension("css", {
outputFileExtension: "css",
compile: async function (inputContent, inputPath) {
let parsed = path.parse(inputPath);
if (inputPath.startsWith("./src/static/design-system") || parsed.name.startsWith("_")) {
return;
}
let targets = browserslistToTargets(browserslist(">= 2%"));
return async () => {
let { code } = await bundle({
drafts: {
nesting: true
},
filename: inputPath,
minify: true,
sourceMap: false,
targets
});
return code;
};
}
});
eleventyConfig.addPassthroughCopy("./src/static/design-system");
eleventyConfig.addPassthroughCopy("./src/static/fonts");
eleventyConfig.addPassthroughCopy("./src/static/svg");
eleventyConfig.addPairedShortcode("prettify", (content) => {
return prettify(content);
});
eleventyConfig.addFilter("console", function (value) {
return JSON.stringify(value, null, 2);
});
eleventyConfig.addPairedShortcode("brace", function (content, type = "curly") {
const [opening, closing] = {
curly: ["{{", "}}"],
silent: ["{%-", "-%}"]
}[type];
return `${opening}${content}${closing}`;
});
return {
dir: {
input: "src",
output: "dist"
},
templateFormats: [
"html",
"md",
"njk"
],
passthroughFileCopy: true
};
};