-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eleventy.js
56 lines (51 loc) · 1.84 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
const CleanCSS = require("clean-css");
const fs = require("fs");
const pluginRss = require("@11ty/eleventy-plugin-rss");
const footnotes = require('eleventy-plugin-footnotes');
module.exports = function(eleventyConfig) {
eleventyConfig.addPassthroughCopy("assets");
eleventyConfig.addPassthroughCopy({"favicon/*": "/"});
eleventyConfig.addPassthroughCopy("robots.txt");
eleventyConfig.addPassthroughCopy({
"nord.css": "nord.css"
});
eleventyConfig.addFilter("cssmin", function(code) {
return new CleanCSS({}).minify(code).styles;
});
eleventyConfig.setBrowserSyncConfig({
callbacks: {
ready: function(err, bs) {
bs.addMiddleware("*", (req, res) => {
const content_404 = fs.readFileSync('_site/404.html');
// Provides the 404 content without redirect.
res.write(content_404);
// Add 404 http status code in request header.
// res.writeHead(404, { "Content-Type": "text/html" });
res.writeHead(404);
res.end();
});
}
}
});
eleventyConfig.addPlugin(pluginRss);
eleventyConfig.addPlugin(footnotes, { /* … */ })
eleventyConfig.setLiquidOptions({
dynamicPartials: false,
strictFilters: false, // renamed from `strict_filters` in Eleventy 1.0
});
const markdownit = require("markdown-it");
const markdownitanchor = require("markdown-it-anchor");
const markdownitfootnote = require("markdown-it-footnote");
const markdownlib = markdownit({ html: true, breaks: true, linkify: true }).use(markdownitanchor).use(markdownitfootnote);
eleventyConfig.setLibrary("md", markdownlib);
eleventyConfig.addCollection("posts", function (collection) {
const coll = collection.getFilteredByTag("post");
for(let i = 0; i < coll.length ; i++) {
const prevPost = coll[i-1];
const nextPost = coll[i + 1];
coll[i].data["prevPost"] = prevPost;
coll[i].data["nextPost"] = nextPost;
}
return coll;
});
};