-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
70 lines (58 loc) · 1.69 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
const { DateTime } = require('luxon');
const pluginSEO = require('eleventy-plugin-seo');
module.exports = function (eleventyConfig) {
eleventyConfig.addPassthroughCopy('CNAME');
eleventyConfig.addPassthroughCopy('.nojekyll');
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
*/
const seo = require('./src/seo.json');
eleventyConfig.addPlugin(pluginSEO, seo);
eleventyConfig.addFilter('htmlDateString', (dateObj) => {
return DateTime.fromJSDate(dateObj, { zone: 'utc' }).toFormat('yyyy-LL-dd');
});
eleventyConfig.setBrowserSyncConfig({ ghostMode: false });
/*
From: https://github.com/11ty/eleventy/issues/529#issuecomment-568257426
Adds {{ prevPost.url }} {{ prevPost.data.title }}, etc, to our njks templates
*/
eleventyConfig.addCollection('pagesAscending', (collection) =>
collection.getFilteredByTag('pages').sort((a, b) => {
if (a.data.title < b.data.title) return -1;
else if (a.data.title > b.data.title) return 1;
else return 0;
}),
);
eleventyConfig.addCollection('posts', function (collection) {
const coll = collection.getFilteredByTag('posts');
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',
},
};
};