-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
76 lines (62 loc) · 1.92 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
65
66
67
68
69
70
71
72
73
74
75
76
const { DateTime } = require("luxon");
const pluginSEO = require("eleventy-plugin-seo");
/**
* This is the JavaScript code that determines the config for your Eleventy site
*
* You can add lost of customization here to define how the site builds your content
* Try extending it to suit your needs!
*/
module.exports = function(eleventyConfig) {
eleventyConfig.setTemplateFormats([
// Templates:
"html",
"njk",
"md",
// Static Assets:
"css",
"jpeg",
"jpg",
"png",
"svg",
"woff",
"woff2"
]);
eleventyConfig.addPassthroughCopy("public");
/* From: https://github.com/artstorm/eleventy-plugin-seo
Adds SEO settings to the top of all pages
*/
const seo = require("./src/seo.json");
eleventyConfig.addPlugin(pluginSEO, seo);
// Filters let you modify the content https://www.11ty.dev/docs/filters/
eleventyConfig.addFilter("htmlDateString", dateObj => {
return DateTime.fromJSDate(dateObj, { zone: "utc" }).toFormat("yyyy-LL-dd");
});
eleventyConfig.setBrowserSyncConfig({ ghostMode: false });
/* Build the collection of posts to list in the site
- Read the Next Steps post to learn how to extend this
*/
eleventyConfig.addCollection("posts", addCollection("posts"))
function addCollection(collectionName){
return function(collection){
const coll = collection
.getFilteredByTag(collectionName)
.sort((a, b) => b.data.date - a.data.date);
// From: https://github.com/11ty/eleventy/issues/529#issuecomment-568257426
// Adds {{ prevPost.url }} {{ prevPost.data.title }}, etc, to our njks templates
for (let i = 0; i < coll.length; i++) {
const prevPost = coll[i - 1];
const nextPost = coll[i + 1];
coll[i].data["prevPost"] = prevPost;
coll[i].data["nextPost"] = nextPost;
}
return coll;
}
}
return {
dir: {
input: "src",
includes: "_includes",
output: "build"
}
};
};