-
Notifications
You must be signed in to change notification settings - Fork 3
/
.eleventy.js
62 lines (53 loc) · 2.64 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
const fs = require("fs"); // Used by BrowserSync
module.exports = function(eleventyConfig) {
// Libraries
eleventyConfig.setLibrary("md", require('./lib/parsers/markdown/markdown.js'));
// 11ty Plugins
eleventyConfig.addPlugin(require('@11ty/eleventy-plugin-syntaxhighlight'));
eleventyConfig.addPlugin(require('@11ty/eleventy-plugin-rss'));
// Collections
eleventyConfig.addCollection("articles", require('./lib/collections/articles.js'));
eleventyConfig.addCollection("notes", require('./lib/collections/notes.js'));
eleventyConfig.addCollection("lifestream", require('./lib/collections/lifestream.js')); //Builds everything in to a date ordered list
// Copy to site
eleventyConfig.addPassthroughCopy('src/css');
eleventyConfig.addPassthroughCopy('src/images');
eleventyConfig.addPassthroughCopy('src/humans.txt');
eleventyConfig.addPassthroughCopy('src/robots.txt');
eleventyConfig.addPassthroughCopy('src/favicon.ico');
eleventyConfig.addPassthroughCopy('src/browserconfig.xml');
eleventyConfig.addPassthroughCopy('src/manifest.webmanifest');
eleventyConfig.addPassthroughCopy('src/downloads');
eleventyConfig.addPassthroughCopy('src/.well-known');
// Nunjucks Filters
eleventyConfig.addFilter("limit", (array, limit) => array.slice(0, limit)); // limit array to first X items
eleventyConfig.addFilter("lastly", (array, limit) => array.slice(-limit)); //limit array to last X items
eleventyConfig.addNunjucksFilter("jsonify", require('./lib/parsers/nunjucks/filters/jsonify.js')); //Make it JSON friendly
eleventyConfig.addNunjucksFilter("doubleToSingleQuotes", require('./lib/parsers/nunjucks/filters/double-to-single-quotes.js')); //Swap double quotes to singles so JSON remains valid
eleventyConfig.addNunjucksFilter("niceDate", require('./lib/parsers/nunjucks/filters/nice-date.js')); // UTC Date formatter for pretty dates
// Enable Deep Merge
eleventyConfig.setDataDeepMerge(true);
// Browser Sync Redirect for 404 testing.
eleventyConfig.setBrowserSyncConfig({
callbacks: {
ready: function(err, bs) {
const content_404 = fs.readFileSync('_site/404.html');
bs.addMiddleware("*", (req, res) => {
// Provides the 404 content without redirect.
res.write(content_404);
res.end();
});
}
}
});
// Config
return {
dir: {
input: 'src',
output: '_site',
layouts: '_layouts'
},
templateFormats: ['njk', 'md'],
passthroughFileCopy: true
};
};