-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheleventy.config.js
More file actions
63 lines (49 loc) · 1.62 KB
/
eleventy.config.js
File metadata and controls
63 lines (49 loc) · 1.62 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
import pluginWebc from "@11ty/eleventy-plugin-webc";
import yaml from "js-yaml";
import { DateTime } from "luxon";
import inflection from "inflection";
import { getReadingData } from "./scripts/getReadingData.js";
import { downloadCovers } from "./scripts/downloadCovers.js";
export default function (eleventyConfig) {
eleventyConfig.on("eleventy.before", async () => {
if (process.env.ELEVENTY_RUN_MODE === "build") {
await downloadCovers();
}
});
eleventyConfig.addPlugin(pluginWebc, {
components: "_components/**/*.webc",
});
eleventyConfig.addDataExtension("yaml", (contents) => {
return yaml.load(contents);
});
eleventyConfig.addCollection("sortedYears", (collectionApi) => {
const { sortedYears } = getReadingData(collectionApi);
return sortedYears;
});
eleventyConfig.addCollection("readingData", (collectionApi) => {
const { allBooks, bucketedByYear, latestYear } =
getReadingData(collectionApi);
return { allBooks, bucketedByYear, latestYear };
});
eleventyConfig.addFilter("formatDate", (dateObj) => {
return DateTime.fromJSDate(new Date(dateObj)).toLocaleString({
month: "short",
day: "numeric",
});
});
eleventyConfig.addFilter("pluralize", (string, count) => {
return inflection.inflect(string, count);
});
eleventyConfig.addPassthroughCopy({
"./_assets/favicon.ico": "/favicon.ico",
});
eleventyConfig.addPassthroughCopy({ "./_assets": "/assets" });
eleventyConfig.addPassthroughCopy({ ".cache/covers": "/covers" });
return {
dir: {
input: ".",
output: "_site",
includes: "_includes",
},
};
}