generated from maxboeck/eleventastic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
122 lines (108 loc) · 3.21 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
const pluginRss = require('@11ty/eleventy-plugin-rss');
const pluginNavigation = require('@11ty/eleventy-navigation');
const markdownIt = require('markdown-it');
const moment = require('moment');
const filters = require('./utils/filters.js');
const transforms = require('./utils/transforms.js');
const shortcodes = require('./utils/shortcodes.js');
const iconsprite = require('./utils/iconsprite.js');
const syntaxHighlight = require('@11ty/eleventy-plugin-syntaxhighlight');
module.exports = function (eleventyConfig) {
// Plugins
eleventyConfig.addPlugin(pluginRss);
eleventyConfig.addPlugin(pluginNavigation);
eleventyConfig.addPlugin(syntaxHighlight);
// Dynamic Permalinks
// eleventyConfig.setDynamicPermalinks(false);
// Filters
Object.keys(filters).forEach(filterName => {
eleventyConfig.addFilter(filterName, filters[filterName]);
});
// Transforms
Object.keys(transforms).forEach(transformName => {
eleventyConfig.addTransform(transformName, transforms[transformName]);
});
// Shortcodes
Object.keys(shortcodes).forEach(shortcodeName => {
eleventyConfig.addShortcode(shortcodeName, shortcodes[shortcodeName]);
});
// Icon Sprite
eleventyConfig.addNunjucksAsyncShortcode('iconsprite', iconsprite);
// Asset Watch Targets
eleventyConfig.addWatchTarget('./src/assets');
// Markdown
eleventyConfig.setLibrary(
'md',
markdownIt({
html: true,
breaks: true,
linkify: true,
typographer: true
})
);
eleventyConfig.addFilter('dateString', date => {
return moment(date).format('DD MMMM, YYYY');
});
eleventyConfig.addFilter('projectDate', date => {
return moment(date).format('MMM YYYY');
});
// Tags
eleventyConfig.addCollection('tagList', collection => {
const tagsSet = {};
collection.getAll().forEach(item => {
if (!item.data.tags) return;
item.data.tags
.filter(tag => !['posts', 'all'].includes(tag))
.forEach(tag => {
if (!tagsSet[tag]) {
tagsSet[tag] = [];
}
tagsSet[tag].push(item);
});
});
return tagsSet;
});
// Categories
eleventyConfig.addCollection('categoryList', collection => {
let catSet = {};
collection.getAll().forEach(item => {
if (!item.data.categories) return;
item.data.categories
.filter(cat => !['posts', 'all'].includes(cat))
.forEach(cat => {
if (!catSet[cat]) {
catSet[cat] = [];
}
catSet[cat].push(item);
});
});
return catSet;
});
// Layouts
eleventyConfig.addLayoutAlias('base', 'base.njk');
eleventyConfig.addLayoutAlias('post', 'post.njk');
eleventyConfig.addLayoutAlias('page', 'page.njk');
// Pass-through files
eleventyConfig.addPassthroughCopy('src/robots.txt');
eleventyConfig.addPassthroughCopy('src/site.webmanifest');
eleventyConfig.addPassthroughCopy('src/assets/images');
eleventyConfig.addPassthroughCopy('src/assets/fonts');
eleventyConfig.addPassthroughCopy('src/assets/audio');
eleventyConfig.addPassthroughCopy('src/admin');
// Deep-Merge
eleventyConfig.setDataDeepMerge(true);
// Base Config
return {
dir: {
input: 'src',
output: 'dist',
includes: 'includes',
layouts: 'layouts',
data: 'data',
admin: 'admin'
},
templateFormats: ['njk', 'md', '11ty.js'],
htmlTemplateEngine: 'njk',
markdownTemplateEngine: 'njk'
};
};