-
Notifications
You must be signed in to change notification settings - Fork 291
Expand file tree
/
Copy path.eleventy.js
More file actions
66 lines (56 loc) · 1.71 KB
/
.eleventy.js
File metadata and controls
66 lines (56 loc) · 1.71 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
64
65
66
const { DateTime } = require("luxon");
const pluginNavigation = require("@11ty/eleventy-navigation");
/**
* This is the JavaScript code that sets the config for your Eleventy site
*
* You can add customizations 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",
]);
eleventyConfig.addPlugin(pluginNavigation);
eleventyConfig.addPassthroughCopy("assets");
eleventyConfig.setBrowserSyncConfig({ ghostMode: false });
// Filters let you modify the content https://www.11ty.dev/docs/filters/
eleventyConfig.addFilter("htmlDateString", (dateObj) => {
return DateTime.fromJSDate(dateObj, { zone: "utc" }).toFormat(
"dd LLL yyyy"
);
});
// Build the collection of posts to list in the site
eleventyConfig.addCollection("posts", function (collection) {
/* The posts collection includes all posts that list 'posts' in the front matter 'tags'
- https://www.11ty.dev/docs/collections/
*/
const coll = collection
.getFilteredByTag("posts")
.sort((a, b) => b.data.date - a.data.date);
// 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: "source",
includes: "_layouts",
data: "_data",
output: "_site",
},
};
};