-
Notifications
You must be signed in to change notification settings - Fork 1
/
eleventy.config.js
101 lines (88 loc) · 2.88 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
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
98
99
100
101
//
// Keep the `.eleventy.js` file clean and uncluttered.
// Most adjustments must be made in:
// - `./config/filters/index.js`
// - `./config/shortcodes/index.js`
// environment variable handling
require("dotenv").config();
// module import filters
const {
readingTime,
formatPostDate,
getAllTags,
webmentionsByUrl,
plainDate,
} = require("./config/filters/index.js");
// module import shortcodes
const { imageShortcode, year } = require("./config/shortcodes/index.js");
// plugins
const postGraph = require("@rknightuk/eleventy-plugin-post-graph");
const syntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
const pluginRss = require("@11ty/eleventy-plugin-rss");
const bundlerPlugin = require("@11ty/eleventy-plugin-bundle");
const postcss = require("postcss");
const postcssMinify = require("postcss-minify");
module.exports = function (eleventyConfig) {
// generate the "posts" collection
eleventyConfig.addCollection("posts", (collection) => {
return [...collection.getFilteredByGlob("./src/posts/*.md")];
});
// add filters
eleventyConfig.addFilter("readingTime", readingTime);
eleventyConfig.addFilter("formatPostDate", formatPostDate);
eleventyConfig.addFilter("getAllTags", getAllTags);
eleventyConfig.addFilter("webmentionsByUrl", webmentionsByUrl);
eleventyConfig.addFilter("plainDate", plainDate);
// add shortcodes
eleventyConfig.addNunjucksAsyncShortcode("image", imageShortcode);
eleventyConfig.addShortcode("year", year);
// add plugins
eleventyConfig.addPlugin(postGraph, {
sort: "desc",
boxColor: "darkgrey",
highlightColor: "red",
textColor: "#fff",
});
eleventyConfig.addPlugin(syntaxHighlight);
eleventyConfig.addPlugin(pluginRss);
// Bundles CSS, not-minified
eleventyConfig.addPlugin(bundlerPlugin);
// bundle CSS with eleventy, use postcss to minify the bundles
// eleventyConfig.addPlugin(bundlerPlugin, {
// transforms: [
// async function (content) {
// // this.type returns the bundle name.
// if (this.type === "css") {
// // Same as Eleventy transforms, this.page is available here.
// let result = await postcss([postcssMinify]).process(content, {
// from: this.page.inputPath,
// to: null,
// });
// return result.css;
// }
// return content;
// },
// ],
// });
// turn off noisy eleventy output
eleventyConfig.setQuietMode(true);
// file and directory passthroughs
[
"src/assets/audio/",
{ "src/assets/favicon/*": "/" },
"src/assets/img/",
"src/assets/js/",
"src/robots.txt",
].forEach((path) => eleventyConfig.addPassthroughCopy(path));
return {
markdownTemplateEngine: "njk",
htmlTemplateEngine: "njk",
dir: {
input: "src",
output: "_site",
includes: "_includes",
layouts: "_layouts",
data: "_data",
},
};
};