-
Notifications
You must be signed in to change notification settings - Fork 1
/
.eleventy.js
175 lines (152 loc) · 6.89 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
/**
* I strive to keep the `.eleventy.js` file clean and uncluttered. Most adjustments must be made in:
* - `./config/collections/index.js`
* - `./config/filters/index.js`
* - `./config/plugins/index.js`
* - `./config/shortcodes/index.js`
* - `./config/transforms/index.js`
*/
// JSDoc comment: Hint VS Code for eleventyConfig autocompletion. © Henry Desroches - https://gist.github.com/xdesro/69583b25d281d055cd12b144381123bf
/**
* @param {import("@11ty/eleventy/src/UserConfig")} eleventyConfig
*/
// get package.json
const packageVersion = require('./package.json').version;
// module import filters
const {
limit,
toHtml,
where,
toISOString,
formatDate,
toAbsoluteUrl,
stripHtml,
minifyCss,
minifyJs,
mdInline,
splitlines
} = require('./config/filters/index.js');
// module import shortcodes
const {
imageShortcodePlaceholder,
includeRaw,
liteYoutube
} = require('./config/shortcodes/index.js');
// module import collections
const {getAllPosts} = require('./config/collections/index.js');
const {getAllNewsAndJobs} = require('./config/collections/index.js');
const {getAllNews} = require('./config/collections/index.js');
const {getAllJobs} = require('./config/collections/index.js');
const {getPastEvents} = require('./config/collections/index.js');
const {getFutureEvents} = require('./config/collections/index.js');
const {getAllGalleryItems} = require('./config/collections/index.js');
const {onlyMarkdown} = require('./config/collections/index.js');
// module import events
const {svgToJpeg} = require('./config/events/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 inclusiveLangPlugin = require('@11ty/eleventy-plugin-inclusive-language');
const bundlerPlugin = require('@11ty/eleventy-plugin-bundle');
module.exports = eleventyConfig => {
// --------------------- 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('news', 'news.njk');
eleventyConfig.addLayoutAlias('post', 'post.njk');
// eleventyConfig.addLayoutAlias('scenario', 'scenario.njk');
// --------------------- Custom filters -----------------------
eleventyConfig.addFilter('limit', limit);
eleventyConfig.addFilter('where', where);
eleventyConfig.addFilter('escape', escape);
eleventyConfig.addFilter('toHtml', toHtml);
eleventyConfig.addFilter('toIsoString', toISOString);
eleventyConfig.addFilter('formatDate', formatDate);
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('keys', Object.keys);
eleventyConfig.addFilter('values', Object.values);
eleventyConfig.addFilter('entries', Object.entries);
// --------------------- Custom shortcodes ---------------------
eleventyConfig.addNunjucksAsyncShortcode('imagePlaceholder', imageShortcodePlaceholder);
eleventyConfig.addShortcode('youtube', liteYoutube);
eleventyConfig.addShortcode('include_raw', includeRaw);
eleventyConfig.addShortcode('year', () => `${new Date().getFullYear()}`); // current year, stephanie eckles
eleventyConfig.addShortcode('packageVersion', () => `v${packageVersion}`);
// --------------------- Custom transforms ---------------------
eleventyConfig.addPlugin(require('./config/transforms/html-config.js'));
// --------------------- Custom Template Languages ---------------------
eleventyConfig.addPlugin(require('./config/template-languages/css-config.js'));
eleventyConfig.addPlugin(require('./config/template-languages/js-config.js'));
// --------------------- Custom collections -----------------------
eleventyConfig.addCollection('posts', getAllPosts);
eleventyConfig.addCollection('newsAndJobs', getAllNewsAndJobs);
eleventyConfig.addCollection('news', getAllNews);
eleventyConfig.addCollection('jobs', getAllJobs);
eleventyConfig.addCollection('pastEvents', getPastEvents);
eleventyConfig.addCollection('futureEvents', getFutureEvents);
eleventyConfig.addCollection('galleryItems', getAllGalleryItems);
eleventyConfig.addCollection('onlyMarkdown', onlyMarkdown);
// --------------------- Events ---------------------
eleventyConfig.on('afterBuild', svgToJpeg);
// --------------------- Plugins ---------------------
eleventyConfig.addPlugin(EleventyRenderPlugin);
eleventyConfig.addPlugin(syntaxHighlight, {
preAttributes: {
class: ({ language }) => `group/code animate-fade rounded-lg bg-slate-900/80 language-${language || 'plain'}`,
},
});
eleventyConfig.setLibrary('md', markdownLib);
eleventyConfig.addPlugin(pluginRss);
eleventyConfig.addPlugin(inclusiveLangPlugin);
eleventyConfig.addPlugin(bundlerPlugin);
// --------------------- Passthrough File Copy -----------------------
// same path
['src/assets/fonts/', 'src/assets/images/'].forEach(path =>
eleventyConfig.addPassthroughCopy(path)
);
// Copy any .jpg/.png/.gif/etc file to `_site`, via Glob pattern
// Keeps the same directory structure.
eleventyConfig.addPassthroughCopy("src/**/*.jpg");
eleventyConfig.addPassthroughCopy("src/**/*.jpeg");
eleventyConfig.addPassthroughCopy("src/**/*.png");
eleventyConfig.addPassthroughCopy("src/**/*.gif");
eleventyConfig.addPassthroughCopy("src/**/*.webp");
eleventyConfig.addPassthroughCopy("src/**/*.pdf");
eleventyConfig.addPassthroughCopy("src/**/*.ppt");
eleventyConfig.addPassthroughCopy("src/**/*.pptx");
// favicons to root directory
eleventyConfig.addPassthroughCopy({
'src/assets/images/favicon/*': '/'
});
// --------------------- general config -----------------------
return {
// Pre-process *.md, *.html and global data files files with: (default: `liquid`)
markdownTemplateEngine: 'njk',
htmlTemplateEngine: 'njk',
dataTemplateEngine: 'njk',
// Optional (default is set): If your site deploys to a subdirectory, change `pathPrefix`, for example with with GitHub pages
pathPrefix: '/',
dir: {
output: 'dist',
input: 'src',
includes: '_includes',
layouts: '_layouts'
}
};
};