-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eleventy.js
44 lines (37 loc) · 933 Bytes
/
.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
const SOURCE_DIR = 'src';
export default (eleventyConfig) => {
/* Static files */
const staticFiles = [
'fonts/',
'images/',
'meta/',
'scripts/',
'style/',
'apple-touch-icon.png',
'favicon.ico',
'humans.txt',
'robots.txt',
];
for (const file of staticFiles) {
eleventyConfig.addPassthroughCopy(`${SOURCE_DIR}/${file}`);
}
/* Collections */
eleventyConfig.addCollection('notes', (collection) =>
collection.getFilteredByGlob(`${SOURCE_DIR}/notes/*.md`),
);
/* Filters */
eleventyConfig.addFilter('hostname', (url) => {
const hostname = new URL(url).hostname;
return hostname.startsWith('www.') ? hostname.slice(4) : hostname;
});
eleventyConfig.addFilter('isoDateString', (date) =>
date.toISOString().slice(0, 10),
);
eleventyConfig.addFilter('stringify', (o) => JSON.stringify(o, null, '\t'));
return {
dir: {
input: SOURCE_DIR,
templateFormats: ['liquid', 'md'],
},
};
};