-
Notifications
You must be signed in to change notification settings - Fork 2
/
eleventy.config.js
43 lines (35 loc) · 1.16 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
const pluginRss = require("@11ty/eleventy-plugin-rss");
const markdownIt = require("markdown-it");
module.exports = function (eleventyConfig) {
eleventyConfig.addPassthroughCopy("src/assets");
eleventyConfig.addPassthroughCopy("src/favicon.ico");
eleventyConfig.addPlugin(pluginRss);
eleventyConfig.setFrontMatterParsingOptions({
excerpt: true,
});
eleventyConfig.addFilter("md", function (content = "") {
return markdownIt({ html: true }).render(content);
});
eleventyConfig.addFilter("dateIso", (date) => {
return date.toISOString();
});
eleventyConfig.addFilter("dateReadable", (date) => {
return date.toDateString();
});
eleventyConfig.addCollection("posts", function (collection) {
return collection.getFilteredByGlob("src/news/*.md");
});
eleventyConfig.addFilter("getLatestVersion", function (collection) {
// Find the latest known version from the collection
return collection?.reduce((latest, item) => {
return !latest || item.data.version > latest ? item.data.version : latest;
}, null);
});
return {
dir: {
input: "src",
output: "dist",
includes: "_layouts",
},
};
};