-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
85 lines (74 loc) · 2.23 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
77
78
79
80
81
82
83
84
85
const syntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
// Eleventy config
module.exports = function(eleventyConfig) {
// ---
// Aliases
// ---
eleventyConfig.addLayoutAlias('base', 'layouts/base.liquid');
eleventyConfig.addLayoutAlias('default', 'layouts/default.liquid');
eleventyConfig.addLayoutAlias('index', 'layouts/index.liquid');
eleventyConfig.addLayoutAlias('typography', 'layouts/typography.liquid');
// ---
// Collections
// ---
// Articles > sorted by date
// eleventyConfig.addCollection('articles', collection => {
// return collection.getFilteredByGlob('src/_articles/*.md').sort(function(a, b) {
// return b.date - a.date;
// });
// });
// // Cases > sorted by id
// eleventyConfig.addCollection('cases', collection => {
// return collection.getFilteredByGlob('src/_cases/*.md').sort((a, b) => {
// return a.data.display_order - b.data.display_order;
// });;
// });
// ---
// Plugins
// ---
eleventyConfig.addPlugin(syntaxHighlight);
// ---
// Copy files to the compiled site folder
// ---
eleventyConfig.addPassthroughCopy('src/assets/img');
eleventyConfig.addPassthroughCopy('src/robots.txt');
eleventyConfig.addPassthroughCopy('src/favicon.png');
eleventyConfig.addPassthroughCopy('src/favicon.ico');
eleventyConfig.addPassthroughCopy('src/apple-touch-icon-precomposed.png');
// ---
// Filters
// ---
// {{ variable | jsonify }}
eleventyConfig.addFilter('jsonify', function (variable) {
return JSON.stringify(variable);
});
// {{ array | where: key,value }}
eleventyConfig.addFilter('where', function (array, key, value) {
return array.filter(item => {
const keys = key.split('.');
const reducedKey = keys.reduce((object, key) => {
return object[key];
}, item);
return (reducedKey === value ? item : false);
});
});
// ---
// Liquid config
// ---
eleventyConfig.setLiquidOptions({
dynamicPartials: true,
strict_filters: true
});
// ---
// Config
// ---
return {
dir: {
input: "./src", // Source
output: "./_site" // Destination
},
passthroughFileCopy: true,
htmlTemplateEngine: "liquid",
dataTemplateEngine: "liquid"
};
};