-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
57 lines (46 loc) · 1.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
const yaml = require('js-yaml');
const htmlmin = require('html-minifier');
const markdownIt = require('markdown-it');
const minHtml = (content, outputPath) => {
if (outputPath && outputPath.endsWith('.html')) {
let minified = htmlmin.minify(content, {
useShortDoctype: true,
removeComments: true,
collapseWhitespace: true
});
return minified;
}
return content;
};
module.exports = function (config) {
// copy images dir to _site
config.addPassthroughCopy('src/img');
config.addPassthroughCopy('src/css');
config.addPassthroughCopy('src/js');
config.addLayoutAlias('page', 'page.html');
config.addDataExtension('yml', (contents) => yaml.safeLoad(contents));
const md = new markdownIt();
config.addFilter('markdownify', (content) => {
return md.renderInline(content);
});
config.addFilter('markdown', (content) => {
return md.render(content);
});
config.setBrowserSyncConfig({
open: true
});
config.addCollection('nav', (collection) => {
const col = collection.getFilteredByTags('page');
return col.sort((a, b) => a.data.sort - b.data.sort);
});
if (process.env.NODE_ENV == 'production') {
config.addTransform('htmlmin', minHtml);
}
return {
// site will live at middlebury.edu/senior-celebration
pathPrefix: '/senior-celebration',
dir: {
input: 'src'
}
};
};