-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
51 lines (40 loc) · 1.48 KB
/
.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const { DateTime } = require("luxon");
const pluginRss = require("@11ty/eleventy-plugin-rss");
const timeToRead = require("eleventy-plugin-time-to-read");
const syntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
module.exports = function (eleventyConfig) {
eleventyConfig.addPassthroughCopy("./src/css");
eleventyConfig.addPassthroughCopy("./src/js");
eleventyConfig.addPassthroughCopy("./src/assets");
eleventyConfig.addPassthroughCopy("./src/admin");
eleventyConfig.addPassthroughCopy("./src/robots.txt");
eleventyConfig.addPlugin(timeToRead);
eleventyConfig.addPlugin(syntaxHighlight);
eleventyConfig.addFilter("postDate", (dateObj) => {
return DateTime.fromJSDate(dateObj).toLocaleString(DateTime.DATE_MED);
});
eleventyConfig.addPlugin(pluginRss);
eleventyConfig.addLiquidFilter("dateToRfc3339", pluginRss.dateToRfc3339);
function filterTagList(tags) {
return (tags || []).filter(
(tag) => ["all", "nav", "post", "posts"].indexOf(tag) === -1
);
}
eleventyConfig.addFilter("filterTagList", filterTagList);
// Create an array of all tags
eleventyConfig.addCollection("tagList", function (collection) {
let tagSet = new Set();
collection.getAll().forEach((item) => {
(item.data.tags || []).forEach((tag) => tagSet.add(tag));
});
return filterTagList([...tagSet]);
});
return {
markdownTemplateEngine: "md",
htmlTemplateEngine: "njk",
dir: {
input: "src",
output: "public",
},
};
};