/
.eleventy.js
60 lines (49 loc) · 2.2 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
// import filters
const {jsmin, cssmin} = require('./config/filters/index.js');
// import shortcodes
const {img, imgResponsive, svgIcon, svgImage} = require('./config/shortcodes/index.js');
// plugins
const svgSprite = require("eleventy-plugin-svg-sprite");
module.exports = function (eleventyConfig) {
// -- Layout aliases ------------------------------------------
eleventyConfig.addLayoutAlias('base', 'base.njk');
eleventyConfig.addLayoutAlias('feed', 'feed.njk');
// -- Custom Watch Targets -----------------------------------
eleventyConfig.addWatchTarget("./src/sass");
// eleventyConfig.addWatchTarget("./src/js");
eleventyConfig.addWatchTarget("./src/assets");
eleventyConfig.addWatchTarget("./src/posts");
// -- Pass-through copy for static assets --------------------
eleventyConfig.addPassthroughCopy("./src/assets/fonts");
eleventyConfig.addPassthroughCopy("./src/assets/images");
eleventyConfig.addPassthroughCopy({"./src/_includes/css/style.css": "css/style.css"});
// eleventyConfig.addPassthroughCopy("./src/js/vendors");
// -- Custom collections -------------------------------------
eleventyConfig.addCollection('blog', collection => {
// Returns a collection of blog posts in reverse date order
return collection.getFilteredByGlob('./src/posts/*.md').reverse();
});
// -- Custom filters -----------------------------------------
eleventyConfig.addNunjucksAsyncFilter("jsmin", jsmin);
eleventyConfig.addFilter("cssmin", cssmin);
// -- Custom shortcodes --------------------------------------
eleventyConfig.addShortcode("img", img);
eleventyConfig.addShortcode("imgResponsive", imgResponsive);
eleventyConfig.addShortcode("svgIcon", svgIcon);
eleventyConfig.addShortcode("svgImage", svgImage);
// -- Plugins ------------------------------------------------
eleventyConfig.addPlugin(svgSprite, {
path: "./src/assets/svg", // relative path to SVG directory
// (MUST be defined when initialising plugin)
});
// -- General config -----------------------------------------
return {
dir: {
input: "src",
output: "public",
includes: '_includes',
layouts: '_layouts'
},
markdownTemplateEngine: "njk"
};
};