-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheleventy.config.js
More file actions
41 lines (31 loc) · 977 Bytes
/
eleventy.config.js
File metadata and controls
41 lines (31 loc) · 977 Bytes
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
const { DateTime } = require("luxon");
/** @param {import("@11ty/eleventy").UserConfig} config */
module.exports = function (config) {
config.addCollection("posts", (collection) => {
let posts = collection
.getFilteredByGlob("content/posts/**/*.md")
.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime());
return posts;
});
config.addFilter("byYear", (posts) => {
let stats = new Map();
for (const post of posts) {
let year = new Date(post.date).getFullYear();
if (stats.has(year) === false) {
stats.set(year, 0);
}
let currentValue = stats.get(year);
let newValue = currentValue + 1;
stats.set(year, newValue);
}
return stats;
});
config.addFilter("simpleDate", (date) => {
const dt = DateTime.fromJSDate(date);
return dt.toFormat("dd LLL yyyy");
});
config.addPassthroughCopy("style.css");
return {
templateFormats: ["njk", "md"],
};
};