-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
31 lines (24 loc) · 915 Bytes
/
.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
const { DateTime } = require("luxon");
module.exports = function (eleventyConfig) {
eleventyConfig.addPassthroughCopy("src/scripts");
eleventyConfig.addPassthroughCopy("src/images");
eleventyConfig.addPassthroughCopy("src/admin");
eleventyConfig.setDataDeepMerge(true);
eleventyConfig.addCollection("heroPost", function (collectionApi) {
// the latest post with featured tag becomes the Hero Post
let featuredPosts = collectionApi.getFilteredByTag("Featured");
return featuredPosts.reverse()[0];
});
eleventyConfig.addFilter("readableDate", (dateObj) => {
return DateTime.fromJSDate(dateObj, { zone: "utc" }).toFormat("dd LLL yyyy");
});
eleventyConfig.addFilter("onlyTags", (collections) => {
return Object.keys(collections).filter((tag) => tag !== "all" || tag !== "post");
});
return {
dir: {
input: "src",
},
htmlTemplateEngine: "njk",
};
};