-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path.eleventy.js
76 lines (62 loc) · 1.95 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
const htmlmin = require("html-minifier");
const syntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
const CleanCSS = require("clean-css");
module.exports = function(eleventyConfig) {
eleventyConfig.setUseGitIgnore(false);
// Use a tmp for live reload with tailwind
eleventyConfig.addWatchTarget("./_tmp/style.css");
eleventyConfig.addPassthroughCopy({
"./_tmp/style.css": "./styles/style.css",
});
// CSS Min for minifying inline CSS
eleventyConfig.addFilter("cssmin", function(code) {
return new CleanCSS({}).minify(code).styles;
});
// Build CSS
eleventyConfig.addPassthroughCopy("src/css");
// Build fonts
eleventyConfig.addPassthroughCopy("src/fonts");
// Build images
eleventyConfig.addPassthroughCopy("src/img");
// Build JS
eleventyConfig.addPassthroughCopy("src/js");
// Add posts collection
eleventyConfig.addCollection("posts", (collection) => {
return collection.getFilteredByGlob("./src/posts/**/*.md");
});
// Add blips collection
eleventyConfig.addCollection("blips", (collection) => {
return collection.getFilteredByGlob("./src/blips/*.md");
});
// Add blips collection
eleventyConfig.addCollection("tinkerings", (collection) => {
return collection.getFilteredByGlob("./src/tinkerings/*.md");
});
// No clue why this is here
eleventyConfig.addShortcode("version", function() {
return String(Date.now());
});
// Syntax highlighting
eleventyConfig.addPlugin(syntaxHighlight);
// Minify HTML except it's not working
eleventyConfig.addTransform("htmlmin", function(content, outputPath) {
if (
process.env.ELEVENTY_PRODUCTION &&
outputPath &&
outputPath.endsWith(".html")
) {
let minified = htmlmin.minify(content, {
useShortDoctype: true,
removeComments: true,
collapseWhitespace: true,
});
return minified;
}
return content;
});
return {
dir: {
input: "src",
},
};
};