-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.eleventy.js
53 lines (45 loc) · 1.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
const CleanCSS = require("clean-css");
const { minify } = require("terser");
const markdownIt = require("markdown-it");
const markdownItDecorate = require("markdown-it-decorate");
const syntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
const markdownSlides = require("./markdown-it-slides");
const markdownTableCaptions = require("./markdown-it-table-captions");
module.exports = (config) => {
config.addWatchTarget("assets");
// in prod we inline CSS/JS into the HTML files
if (process.env.ELEVENTY_ENV === "development") {
config.addPassthroughCopy({ "src/_includes/assets": "assets" });
} else {
config.addPassthroughCopy({ "src/_includes/assets/fonts": "assets/fonts" });
}
// passthrough any images included in slides
//so they can be referenced as relative URLs
config.addPassthroughCopy("src/slides/**/*.{jpg,png,svg,gif,mp4}");
config.addFilter("cssmin", (code) => new CleanCSS({}).minify(code).styles);
config.addNunjucksAsyncFilter("jsmin", (code, cb) =>
minify(code)
.then((minified) => cb(null, minified.code))
.catch((err) => {
console.error("Terser error: ", err);
cb(null, code);
})
);
const md = markdownIt({
html: true, // passthrough raw html in md files
linkify: true, // auto-link URLs
typographer: true, // smartquotes, other nicer symbols
});
md.use(markdownSlides);
md.use(markdownItDecorate);
md.use(markdownTableCaptions);
config.setLibrary("md", md);
config.addPlugin(syntaxHighlight);
return {
dir: {
// configure Eleventy to look in src/ for everything
input: "src",
},
markdownTemplateEngine: "njk",
};
};