-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheleventy.config.js
62 lines (47 loc) · 1.65 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
const syntaxHighlightPlugin = require("@11ty/eleventy-plugin-syntaxhighlight");
const { DateTime } = require("luxon");
const { groupBy } = require("./utilities");
/** @param {import("@11ty/eleventy").UserConfig} config */
module.exports = function (config) {
config.addCollection("postsByYearAscVersion21", (collection) => {
let posts = collection.getFilteredByGlob("content/posts/**/*.md");
const postsByYear = Map.groupBy(posts, ({ date }) =>
new Date(date).getFullYear()
);
return postsByYear;
});
config.addCollection("postsByYearDescVersion21", (collection) => {
let posts = collection
.getFilteredByGlob("content/posts/**/*.md")
.sort((a, b) => b.date - a.date);
const postsByYear = groupBy(posts, (post) =>
new Date(post.date).getFullYear()
);
return postsByYear;
});
config.addCollection("postsByYearAsc", (collection) => {
let posts = collection.getFilteredByGlob("content/posts/**/*.md");
const postsByYear = groupBy(posts, (post) =>
new Date(post.date).getFullYear()
);
return postsByYear;
});
config.addCollection("postsByYearDesc", (collection) => {
let posts = collection
.getFilteredByGlob("content/posts/**/*.md")
.sort((a, b) => b.date - a.date);
const postsByYear = groupBy(posts, (post) =>
new Date(post.date).getFullYear()
);
return postsByYear;
});
config.addFilter("simpleDate", (date) => {
const dt = DateTime.fromJSDate(date);
return dt.toFormat("dd LLL yyyy");
});
config.addPassthroughCopy("style.css");
config.addPlugin(syntaxHighlightPlugin);
return {
templateFormats: ["njk", "md"],
};
};