forked from cagov/news
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
29 lines (26 loc) · 853 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
const pluginRss = require("@11ty/eleventy-plugin-rss");
module.exports = function(eleventyConfig) {
eleventyConfig.addPassthroughCopy({ "src/css": "css" });
eleventyConfig.addPassthroughCopy({ "src/img": "img" });
eleventyConfig.addPassthroughCopy({ "src/CNAME": "CNAME" });
eleventyConfig.addPassthroughCopy({ "src/cms": "cms" });
eleventyConfig.addCollection("mySort", function(collection) {
let posts = [];
collection.getAll().forEach( (item) => {
if(item.data.tags[0] == 'news') {
posts.push(item);
}
})
return posts.sort(function(a, b) {
return new Date(a.data.publishdate) - new Date(b.data.publishdate);
}).reverse();
});
eleventyConfig.addPlugin(pluginRss);
return {
templateFormats: ["html", "md", "njk"],
dir: {
input: "posts",
output: "_site",
}
};
};