-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheleventy.config.js
More file actions
40 lines (32 loc) · 1.09 KB
/
eleventy.config.js
File metadata and controls
40 lines (32 loc) · 1.09 KB
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
const syntaxHighlightPlugin = require("@11ty/eleventy-plugin-syntaxhighlight");
const { DateTime } = require("luxon");
/** @param {import("@11ty/eleventy").UserConfig} config */
module.exports = function (config) {
config.addCollection("posts", (collection) => {
let localPosts = collection.getFilteredByGlob("content/posts/**/*.md");
let externalPosts = transformExternalPosts(
collection.getAll()[0].data.externalPosts
);
let allPosts = [...localPosts, ...externalPosts];
let sortedPosts = allPosts.sort(
(a, b) => new Date(b.date).getTime() - new Date(a.date).getTime()
);
return sortedPosts;
});
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"],
};
};
function transformExternalPosts(posts) {
return posts.map((post) => {
let transformedPost = post;
transformedPost.date = new Date(post.date);
return transformedPost;
});
}