-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
72 lines (57 loc) · 2.17 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
const moment = require('moment');
moment.locale('en');
const syntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
module.exports = function(eleventyConfig) {
eleventyConfig.addPlugin(syntaxHighlight);
eleventyConfig.setUseGitIgnore(false);
eleventyConfig.setTemplateFormats([ 'md', 'css' ]);
eleventyConfig.addLayoutAlias('page', 'layouts/page.njk');
eleventyConfig.addLayoutAlias('post', 'layouts/post.njk');
eleventyConfig.addLayoutAlias('status', 'layouts/post.njk');
eleventyConfig.addLayoutAlias('aside', 'layouts/post.njk');
eleventyConfig.addLayoutAlias('video', 'layouts/post.njk');
eleventyConfig.addLayoutAlias('audio', 'layouts/post.njk');
eleventyConfig.addLayoutAlias('image', 'layouts/post.njk');
eleventyConfig.addLayoutAlias('gallery', 'layouts/post.njk');
eleventyConfig.addLayoutAlias('chat', 'layouts/post.njk');
eleventyConfig.addLayoutAlias('quote', 'layouts/post.njk');
eleventyConfig.addLayoutAlias('link', 'layouts/post.njk');
eleventyConfig.addCollection('postsCollection', function(collection) {
const tmpCollection = collection.getAllSorted();
return tmpCollection.reverse().filter(function(tpl) {
if ( tpl.data.permalink && tpl.data.layout && 'post' === tpl.data.layout ) {
return true;
}
});
});
eleventyConfig.addCollection('bestOfCollection', function(collection) {
const tmpCollection = collection.getAllSorted();
return tmpCollection.reverse().filter(function(tpl) {
if ( tpl.data.permalink && tpl.data.tags && tpl.data.tags.includes('Best Of') ) {
return true;
}
});
});
eleventyConfig.addCollection('allTags', function(collection) {
let allTags = [];
collection.getAllSorted().forEach(function(el) {
allTags = allTags.concat(el.data.tags);
});
let tagDict = {};
allTags.sort().forEach(function(el) {
if (el) {
tagDict[el] = tagDict[el] ? tagDict[el] + 1 : 1;
}
});
return tagDict;
});
eleventyConfig.addFilter('dateformat', function(dateIn) {
return moment(dateIn).format('MMM DD, YYYY [at] h:mm a');
});
return {
dir: {
input: "content",
output: "_dist"
}
};
};