-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
67 lines (52 loc) · 1.78 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
63
64
65
66
67
// Plugins
const pluginPWA = require('eleventy-plugin-pwa');
const inclusiveLangPlugin = require("@11ty/eleventy-plugin-inclusive-language");
// Transforms
const htmlMinTransform = require('./src/transforms/html-min-transform.js');
// Libraries
const markdownIt = require("markdown-it");
const markdownItAnchor = require("markdown-it-anchor");
// Data extensions
const yaml = require("js-yaml");
// Create a helpful production flag.
const isProduction = process.env.NODE_ENV === 'production';
module.exports = config => {
// Pass static assets through to build folder.
config.addPassthroughCopy({'src/assets/static': 'assets'});
// Markdown overrides.
let markdownLibrary = markdownIt({
html: true,
xhtmlOut: true
}).use(markdownItAnchor, {
level: 1
});
config.setLibrary("md", markdownLibrary);
// Add yaml support for data files.
config.addDataExtension("yaml", contents => yaml.load(contents));
// Check for inclusive language.
config.addPlugin(inclusiveLangPlugin, {
templateFormats: ["md","html"],
words: "crazy,insane,lame,simply,obviously,basically,of course,clearly,just,everyone knows,however,easy"
});
// If building for the production environment...
if (isProduction) {
// Minify HTML
config.addTransform('htmlmin', htmlMinTransform);
// Configure progressive web app.
config.addPlugin(pluginPWA);
// Passthrough .htaccess Apache configuration.
config.addPassthroughCopy('./src/.htaccess');
}
// Configure 11ty to use the .eleventyignore instead of .gitignore to enable
// inlining of compiled critical.css.
config.setUseGitIgnore(false);
return {
markdownTemplateEngine: 'njk',
dataTemplateEngine: 'njk',
htmlTemplateEngine: 'njk',
dir: {
input: 'src',
output: 'dist'
}
};
};