-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eleventy.js
97 lines (90 loc) · 2.79 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
const path = require("path");
const pluginRSS = require("@11ty/eleventy-plugin-rss");
const pluginSyntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
const {
createInlineCss,
} = require("eleventy-google-fonts/eleventy-google-fonts");
const esbuild = require("esbuild");
const postcss = require("postcss");
const postcssPresetEnv = require("postcss-preset-env");
const postcssImport = require("postcss-import");
const cssnano = require("cssnano");
const pluginSvg = require("@jamshop/eleventy-plugin-svg");
const embedTwitter = require("eleventy-plugin-embed-twitter");
function getCategory(name) {
return (collection) => {
return collection
.getAllSorted()
.reverse()
.filter((post) => {
if (process.env.ELEVENTY_ENV === "production") return !post.data.draft;
return true;
})
.filter((post) => {
if (post.data.categories) {
return post.data.categories.includes(name);
}
return false;
});
};
}
module.exports = (config) => {
config.on("eleventy.after", () => {
return esbuild.build({
entryPoints: ["js/*.ts"],
bundle: true,
outdir: "_site/assets",
minify: process.env.ELEVENTY_ENV === "production",
sourcemap: process.env.ELEVENTY_ENV !== "production",
});
});
config.addPlugin(pluginRSS);
config.addPlugin(pluginSyntaxHighlight);
config.addPlugin(pluginSvg, {
input: "svg/",
});
config.addPlugin(embedTwitter, {
align: "center",
});
config.addLiquidShortcode("eleventyGoogleFonts", createInlineCss);
config.addTemplateFormats("scss");
config.addWatchTarget("./sass/");
config.addExtension("scss", {
outputFileExtension: "css",
compile: async function(input, inputPath) {
const compiler = postcss([
postcssImport(),
postcssPresetEnv({ stage: 0 }),
process.env.ELEVENTY_ENV === 'production' && cssnano()
].filter(Boolean))
const result = await compiler.process(input, {
from: inputPath,
parser: require("postcss-scss")
})
return async () => result.css;
},
});
config.addWatchTarget("./js/");
config.addPassthroughCopy("js");
config.addPassthroughCopy("css");
config.addPassthroughCopy("images");
config.addPassthroughCopy("videos");
config.addPassthroughCopy("admin/config.yml");
config.setFrontMatterParsingOptions({
excerpt: true,
});
config.setLiquidOptions({
dynamicPartials: true,
});
config.addCollection("musings", getCategory("musing"));
config.addCollection("faq", getCategory("faq"));
config.addCollection("bio", getCategory("bio"));
config.addCollection("projects", getCategory("project"));
config.addCollection("empathy", getCategory("empathy"));
return {
dir: {
includes: "_includes",
layouts: "_layouts",
},
};
};