-
Notifications
You must be signed in to change notification settings - Fork 12
/
eleventy.config.cjs
66 lines (57 loc) · 2.02 KB
/
eleventy.config.cjs
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
// External imports
require("dotenv").config();
// Internal imports
/** @param {import('@11ty/eleventy').UserConfig} eleventyConfig */
module.exports = (eleventyConfig) => {
// Plugins
eleventyConfig.addPlugin(require("./src/_11ty/plugins/plugins.cjs"));
// Collections
eleventyConfig.addCollection("allSortedByDate", (collectionApi) =>
collectionApi
.getAll()
.sort((a, b) => new Date(b.data.date) - new Date(a.data.date))
);
["Blog", "Bookmarks", "Garden", "Projects", "TIL"].forEach((collection) => {
eleventyConfig.addCollection(
`${collection}SortedByDate`,
(collectionApi) => {
return collectionApi
.getFilteredByTag(collection)
.sort((a, b) => new Date(b.data.date) - new Date(a.data.date));
}
);
});
eleventyConfig.addCollection("postsSortedByDate", (collectionApi) => {
const collection = [];
collection.push(...collectionApi.getFilteredByTag("Blog"));
collection.push(...collectionApi.getFilteredByTag("Bookmarks"));
collection.push(...collectionApi.getFilteredByTag("Garden"));
collection.push(...collectionApi.getFilteredByTag("Projects"));
collection.push(...collectionApi.getFilteredByTag("TIL"));
collection.sort((a, b) => new Date(b.data.date) - new Date(a.data.date));
return collection;
});
// Filters
eleventyConfig.addPlugin(require("./src/_11ty/filters/filters.cjs"));
// Shortcodes
eleventyConfig.addPlugin(require("./src/_11ty/shortcodes/shortcodes.cjs"));
// Transforms
eleventyConfig.addPlugin(require("./src/_11ty/transforms/transforms.cjs"));
// Copy/pass-through files
eleventyConfig.addPassthroughCopy({ "src/assets": "assets" });
// Watch targets
eleventyConfig.addWatchTarget("src/input/css");
eleventyConfig.addWatchTarget("src/input/js");
return {
dir: {
data: "../_data", // Relative to input
includes: "../_includes", // Relative to input
input: "src/input",
layouts: "../_layouts", // Relative to input
output: "_site",
},
htmlTemplateEngine: "njk",
markdownTemplateEngine: "njk",
templateFormats: ["njk", "md", "11ty.js"],
};
};