forked from madrilene/lenesaile.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eleventy.js
215 lines (188 loc) · 7.36 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
/**
* I strive to keep the `.eleventy.js` file clean and uncluttered. Most adjustments must be made in:
* - `src/config/collections.js`
* - `src/config/filters.js`
* - `src/config/plugins.js`
* - `src/config/shortcodes.js`
* - `src/config/transforms.js`
*/
// get package.json
const packageVersion = require('./package.json').version;
// module import filters
const {
limit,
where,
every,
some,
truncate,
categoryFilter,
toHtml,
toAbsoluteUrl,
stripHtml,
toISOString,
readingTime,
formatDate,
formatDateES,
formatDateDE,
minifyCss,
minifyJs,
mdInline,
splitlines,
getWebmentionsForUrl,
webmentionSize,
webmentionsByType,
isOwnWebmention,
sortWebmentions
} = require('./config/filters/index.js');
// module import collections
const {
allMarkdown,
getProjectsEN,
getBlogsEN,
getProjectsES,
getBlogsES,
getProjectsDE,
getBlogsDE,
getBlogsAllFullLang,
getBlogsAllLang
} = require('./config/collections/index.js');
// module import shortcodes
const {
asideShortcode,
breakoutShortcode,
insertionShortcode,
imageShortcode,
imageShortcodePlaceholder,
liteYoutube,
codePen
} = require('./config/shortcodes/index.js');
// module import transforms
// const {
// ...
// } = require('./config/transforms/index.js');
// plugins
const markdownLib = require('./config/plugins/markdown.js');
const {EleventyRenderPlugin} = require('@11ty/eleventy');
const syntaxHighlight = require('@11ty/eleventy-plugin-syntaxhighlight');
const {slugifyString} = require('./config/utils');
const {escape} = require('lodash');
const pluginRss = require('@11ty/eleventy-plugin-rss');
const {EleventyI18nPlugin} = require('@11ty/eleventy');
const bundlerPlugin = require('@11ty/eleventy-plugin-bundle');
// module import events
const {afterBuild} = require('./config/events/index.js');
module.exports = eleventyConfig => {
// Tell 11ty to use the .eleventyignore and ignore our .gitignore file
eleventyConfig.setUseGitIgnore(false);
// --------------------- Custom Watch Targets -----------------------
eleventyConfig.addWatchTarget('./src/assets');
eleventyConfig.addWatchTarget('./utils/*.js');
// --------------------- layout aliases -----------------------
eleventyConfig.addLayoutAlias('base', 'base.njk');
eleventyConfig.addLayoutAlias('page', 'page.njk');
eleventyConfig.addLayoutAlias('home', 'home.njk');
eleventyConfig.addLayoutAlias('about', 'about.njk');
eleventyConfig.addLayoutAlias('services', 'services.njk');
eleventyConfig.addLayoutAlias('projects', 'projects.njk');
eleventyConfig.addLayoutAlias('blog', 'blog.njk');
eleventyConfig.addLayoutAlias('post', 'post.njk');
eleventyConfig.addLayoutAlias('feed', 'feed.njk');
eleventyConfig.addLayoutAlias('naked', 'naked.njk');
eleventyConfig.addLayoutAlias('error404', 'error404.njk');
// --------------------- Custom filters -----------------------
eleventyConfig.addFilter('limit', limit);
eleventyConfig.addFilter('where', where);
eleventyConfig.addFilter('every', every);
eleventyConfig.addFilter('some', some);
eleventyConfig.addFilter('truncate', truncate);
eleventyConfig.addFilter('categoryFilter', categoryFilter);
eleventyConfig.addFilter('escape', escape);
eleventyConfig.addFilter('readingTime', readingTime);
eleventyConfig.addFilter('toHtml', toHtml);
eleventyConfig.addFilter('toIsoString', toISOString);
eleventyConfig.addFilter('formatDate', formatDate);
eleventyConfig.addFilter('formatDateES', formatDateES);
eleventyConfig.addFilter('formatDateDE', formatDateDE);
eleventyConfig.addFilter('toAbsoluteUrl', toAbsoluteUrl);
eleventyConfig.addFilter('stripHtml', stripHtml);
eleventyConfig.addFilter('slugify', slugifyString);
eleventyConfig.addFilter('toJson', JSON.stringify);
eleventyConfig.addFilter('fromJson', JSON.parse);
eleventyConfig.addFilter('cssmin', minifyCss);
eleventyConfig.addNunjucksAsyncFilter('jsmin', minifyJs);
eleventyConfig.addFilter('md', mdInline);
eleventyConfig.addFilter('splitlines', splitlines);
eleventyConfig.addFilter('getWebmentionsForUrl', getWebmentionsForUrl);
eleventyConfig.addFilter('webmentionSize', webmentionSize);
eleventyConfig.addFilter('webmentionsByType', webmentionsByType);
eleventyConfig.addFilter('isOwnWebmention', isOwnWebmention);
eleventyConfig.addFilter('sortWebmentions', sortWebmentions);
eleventyConfig.addFilter('keys', Object.keys);
eleventyConfig.addFilter('values', Object.values);
eleventyConfig.addFilter('entries', Object.entries);
// --------------------- Custom shortcodes ---------------------
eleventyConfig.addPairedShortcode('aside', asideShortcode);
eleventyConfig.addPairedShortcode('breakout', breakoutShortcode);
eleventyConfig.addPairedShortcode('insertion', insertionShortcode);
eleventyConfig.addNunjucksAsyncShortcode('image', imageShortcode);
eleventyConfig.addNunjucksAsyncShortcode('imagePlaceholder', imageShortcodePlaceholder);
eleventyConfig.addShortcode('youtube', liteYoutube);
eleventyConfig.addPairedShortcode('codepen', codePen);
eleventyConfig.addShortcode('year', () => `${new Date().getFullYear()}`); // current year, by Stephanie Eckles
eleventyConfig.addShortcode('packageVersion', () => `v${packageVersion}`);
// --------------------- Custom collections -----------------------
eleventyConfig.addCollection('allMarkdown', allMarkdown);
eleventyConfig.addCollection('projects_en', getProjectsEN);
eleventyConfig.addCollection('blog_en', getBlogsEN);
eleventyConfig.addCollection('projects_es', getProjectsES);
eleventyConfig.addCollection('blog_es', getBlogsES);
eleventyConfig.addCollection('projects_de', getProjectsDE);
eleventyConfig.addCollection('blog_de', getBlogsDE);
eleventyConfig.addCollection('blog_all_full', getBlogsAllFullLang);
eleventyConfig.addCollection('blog_all', getBlogsAllLang);
// --------------------- Transforms ---------------------
// --------------------- Custom Template Languages, partial imported as plugin ---------------------
eleventyConfig.addPlugin(require('./config/template-formats/js-config.js'));
// --------------------- Plugins ---------------------
eleventyConfig.addPlugin(EleventyRenderPlugin);
eleventyConfig.addPlugin(syntaxHighlight);
eleventyConfig.setLibrary('md', markdownLib);
eleventyConfig.addPlugin(pluginRss);
eleventyConfig.addPlugin(EleventyI18nPlugin, {
defaultLanguage: 'en',
errorMode: 'allow-fallback'
});
eleventyConfig.addPlugin(bundlerPlugin);
// --------------------- Passthrough copies ---------------------
// keep directory
[
'src/assets/images/avatar.jpg',
'src/assets/images/image-placeholder.png',
'src/assets/images/opengraph-default.jpg',
'src/assets/images/svg/',
'src/assets/fonts/',
'src/assets/sounds/'
].forEach(path => eleventyConfig.addPassthroughCopy(path));
// social icons and manifest to root directory
eleventyConfig.addPassthroughCopy({
'src/assets/images/favicon/*': '/'
});
// web components
eleventyConfig.addPassthroughCopy({
'src/_includes/components/*': 'assets/scripts/components/'
});
// --------------------- Events ---------------------
eleventyConfig.on('afterBuild', afterBuild);
// testing js in frontmatter
return {
dir: {
input: 'src',
output: 'dist',
includes: '_includes',
layouts: '_layouts'
},
markdownTemplateEngine: 'njk',
dataTemplateEngine: 'njk',
htmlTemplateEngine: 'njk'
};
};