-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
.eleventy.js
70 lines (55 loc) · 1.78 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
const path = require("path");
const filters = require("./utils/filters.js");
const markdown = require("./utils/markdown.js");
const sass = require("@binyamin/eleventy-plugin-sass");
/**
* @param {import("@11ty/eleventy/src/UserConfig")} eleventyConfig
* @returns {ReturnType<import("@11ty/eleventy/src/defaultConfig")>}
*/
module.exports = function (eleventyConfig) {
eleventyConfig.addPlugin(markdown);
eleventyConfig.addPlugin(sass, {
dir: "sass",
file: "main.scss",
outDir: path.resolve("dist", "css"),
outFile: "style.min.css",
minify: 2
});
// filters
for (const [key, value] of Object.entries(filters)) {
eleventyConfig.addFilter(key, value);
}
eleventyConfig.addNunjucksFilter("date", require("./utils/date-njk"));
// Shortcodes
eleventyConfig.addPlugin(require("./utils/shortcodes"));
// Collections
const collections = ['blog', 'wiki', 'micro'];
collections.forEach(collectionName => {
eleventyConfig.addCollection(collectionName, function (collectionApi) {
return collectionApi.getAllSorted().filter(d => d.data.category === collectionName)
})
})
eleventyConfig.addCollection('posts', function (collectionApi) {
return collectionApi.getAllSorted().filter(d => {
return ["blog", "micro"].includes(d.data.category)
});
})
eleventyConfig.addGlobalData("postTypes", ["blog", "micro"]);
// Important, since the gitignore lists "src/posts/wiki/**/*"
eleventyConfig.setUseGitIgnore(false);
eleventyConfig.addPassthroughCopy({ 'static': '/' });
// Ignore draft wiki posts
eleventyConfig.ignores.add('src/posts/wiki/**/_*.md');
return {
dir: {
input: "src",
output: "dist",
layouts: "templates",
includes: "templates/includes",
data: "data"
},
htmlTemplateEngine: "njk",
markdownTemplateEngine: "njk",
dataTemplateEngine: "njk"
};
};