-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheleventy.config.js
82 lines (66 loc) · 2.3 KB
/
eleventy.config.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
77
78
79
80
81
82
const navigation = require('@11ty/eleventy-navigation');
const dates = require('./utilities/filters/dates');
const helpers = require('./utilities/filters/helpers');
const path = require('path');
module.exports = (config) => {
// navigation plugin
config.addPlugin(navigation);
// Human readable date for posts
config.addFilter('dateDisplay', dates.friendly);
// Timestamp for datetime element
config.addFilter('timestamp', dates.timestamp);
// Remove whitespace from a string
config.addNunjucksFilter('spaceless', helpers.spaceless);
// Minify our HTML
config.addTransform(
'htmlminify',
require('./utilities/transforms/htmlminify')
);
// Collections
config.addCollection('blog', (collection) => {
const blogs = collection.getFilteredByTag('blog');
for (let i = 0; i < blogs.length; i++) {
const previous_post = blogs[i - 1];
const next_post = blogs[i + 1];
blogs[i].data['previous_post'] = previous_post;
blogs[i].data['next_post'] = next_post;
}
return blogs.reverse();
});
// Categories collection
config.addCollection('categories', (collection) => {
const list = new Set();
collection.getAll().forEach((item) => {
if (!item.data.tags) return;
item.data.tags
.filter((category) => !['blog', 'all'].includes(category))
.forEach((category) => list.add(category));
});
return Array.from(list).sort();
});
// Layout aliases
config.addLayoutAlias('base', 'layouts/base.njk');
config.addLayoutAlias('home', 'layouts/home.njk');
config.addLayoutAlias('page', 'layouts/page.njk');
config.addLayoutAlias('blog', 'layouts/blog.njk');
config.addLayoutAlias('post', 'layouts/post.njk');
config.addLayoutAlias('contact', 'layouts/contact.njk');
config.addLayoutAlias('category', 'layouts/category.njk');
config.addLayoutAlias('default', 'layouts/default.njk');
// Include our static assets
config.addPassthroughCopy('css');
config.addPassthroughCopy('js');
config.addPassthroughCopy('images');
config.addPassthroughCopy('favicon.png');
config.addPassthroughCopy('favicon.svg');
config.addPassthroughCopy('favicon.ico');
return {
markdownTemplateEngine: 'njk',
dir: {
input: 'site',
output: 'public',
includes: 'includes',
data: 'globals',
},
};
};