forked from ILUGD/planet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eleventy.js
43 lines (38 loc) · 1.26 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
const pluginTailwindCSS = require("eleventy-plugin-tailwindcss");
const pluginMetagen = require("eleventy-plugin-metagen");
const _ = require("lodash");
const moment = require("moment");
const { fetchFeed, sortFeedByLatestPost, movePinFeedsToTop } = require("./.eleventy.modules");
module.exports = function (eleventyConfig) {
// passthrough copy
eleventyConfig.addPassthroughCopy({ "./src/images": "assets", "./src/js": "assets" });
// plugins
eleventyConfig.addPlugin(pluginMetagen);
eleventyConfig.addPlugin(pluginTailwindCSS, {
src: "src/css/*.css",
dest: "assets",
keepFolderStructure: false,
minify: false,
});
// filters
eleventyConfig.addFilter("prettyDate", (date) => {
return moment(date).format("Do MMM, YYYY");
});
// collections
eleventyConfig.addCollection("feeds", async (collection) => {
const allFeeds = await _.chain(collection.getAllSorted())
.filter((post) => _.startsWith(post.filePathStem, "/feeds"))
.map(async (page) =>
_.set(page, "data.feedData", await fetchFeed(page.data.feed))
)
.value();
const res = await Promise.all(allFeeds);
return movePinFeedsToTop(sortFeedByLatestPost(res));
});
return {
dir: {
input: "src",
output: "public",
},
};
};