-
Notifications
You must be signed in to change notification settings - Fork 1
/
.eleventy.js
64 lines (54 loc) · 1.91 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
52
53
54
55
56
57
58
59
60
61
62
63
64
const pluginRSS = require('@11ty/eleventy-plugin-rss');
const { DateTime } = require('luxon');
module.exports = function(eleventyConfig) {
// allows templates to add additional data
eleventyConfig.setDataDeepMerge(true);
// copy static files directly, with same directory structure
eleventyConfig.addPassthroughCopy("src/assets");
// parse excerpts on posts
eleventyConfig.setFrontMatterParsingOptions({
excerpt: true,
excerpt_separator: "<!-- excerpt -->",
excerpt_alias: "post_excerpt"
});
// filter to return a date as ISO string objects
eleventyConfig.addFilter('dateISO', date => {
return DateTime.fromJSDate(date).toISO();
});
// filter to return a date for prettier display. Uses UTC to avoid timezone differences
eleventyConfig.addFilter('datePretty', date => {
return DateTime.fromJSDate(date).toUTC().toLocaleString(DateTime.DATE_FULL); // e.g. May 16, 2020
});
// filter to sort a list of posts by date desc
// https://stackoverflow.com/q/10123953
eleventyConfig.addFilter('sortDesc', posts => {
posts.sort(function(a,b){
a = new Date(a.date);
b = new Date(b.date);
return a > b ? -1 : a < b ? 1 : 0;
});
return posts;
});
// add collection of all tags
eleventyConfig.addCollection("tagList", require("./js/tag-list.js"));
// create custom collection of posts
eleventyConfig.addCollection("posts", collection => {
return collection.getFilteredByGlob('./src/posts/*.md');
});
// add plugins
eleventyConfig.addPlugin(pluginRSS);
return {
dir: {
input: "src",
output: "dist",
includes: "_includes",
data: "_data"
},
templateFormats: [
"md",
"html",
"njk"
],
markdownTemplateEngine: "njk"
};
};