-
Notifications
You must be signed in to change notification settings - Fork 0
/
eleventy.config.js
78 lines (63 loc) · 1.88 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
import {minify as minifyHtml} from 'html-minifier';
import {codes, filters} from './11ty/index.js';
const environment = {
production: (process.env.ELEVENTY_RUN_MODE || 'development') === 'build',
};
const now = new Date();
const options = {
browser: {
port: 4567,
},
html: {
collapseWhitespace: true,
decodeEntities: true,
removeComments: true,
},
};
export default (config) => {
config.addGlobalData(
'canonicalUrl',
environment.production ? 'https://oscarpalmer.se' : 'http://localhost:4567',
);
config.addGlobalData('production', environment.production);
config.addGlobalData('timestamp', {
iso: now.toISOString(),
unix: now.getTime(),
});
config.addGlobalData('version', process.env.ELEVENTY_VERSION || '???');
config.addFilter('altLocale', filters.getAlternateLocale);
config.addFilter('ariaCurrent', filters.getAriaCurrentFromUrl);
config.addFilter('icon', filters.icon);
config.addFilter('i18n', filters.internationalise);
config.addFilter('locale', filters.getLocale);
config.addFilter('markdown', filters.renderMarkdown);
config.addShortcode('getDescription', codes.getDescription);
config.addShortcode('getTitle', codes.getTitle);
config.addPassthroughCopy({
'source/assets/images': 'assets/images',
'source/assets/javascript': 'assets/javascript',
'source/robots.txt': 'robots.txt',
'source/site.webmanifest': 'site.webmanifest',
});
config.addWatchTarget('source');
config.setServerOptions(options.browser);
if (environment.production) {
config.addTransform('html', (content, path) => {
return path.endsWith('.html')
? minifyHtml(content, options.html)
: content;
});
}
return {
dir: {
data: '../../data',
includes: '../layouts/partials',
input: 'source/pages',
layouts: '../layouts',
output: 'build',
},
htmlTemplateEngine: 'liquid',
markdownTemplateEngine: 'liquid',
passthroughFileCopy: true,
};
};