-
Notifications
You must be signed in to change notification settings - Fork 155
/
.eleventy.js
82 lines (70 loc) · 2.58 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import htmlmin from "html-minifier";
import syntaxHighlight from "@11ty/eleventy-plugin-syntaxhighlight";
import {Liquid} from "liquidjs";
import markdownIt from "markdown-it";
import octiconTag from "./js/octicons-liquid/tag.js";
function watchAndPass(file, config) {
config.addWatchTarget(file);
config.addPassthroughCopy(file);
}
export default function (eleventyConfig) {
watchAndPass("./assets/js", eleventyConfig);
watchAndPass("./assets/dist", eleventyConfig);
watchAndPass("./assets/img", eleventyConfig);
watchAndPass("./api", eleventyConfig);
watchAndPass("./favicon.ico", eleventyConfig);
watchAndPass("./favicon-16x16.png", eleventyConfig);
watchAndPass("./favicon-32x32.png", eleventyConfig);
watchAndPass("./android-chrome-192x192.png", eleventyConfig);
watchAndPass("./android-chrome-256x256.png", eleventyConfig);
watchAndPass("./safari-pinned-tab.svg", eleventyConfig);
watchAndPass("./apple-touch-icon.png", eleventyConfig);
eleventyConfig.addWatchTarget("./docs");
eleventyConfig.addPlugin(syntaxHighlight);
// Reduce HTML output size
eleventyConfig.addTransform("htmlmin", (content, outputPath) => {
if(outputPath && outputPath.endsWith(".html") ) {
let minified = htmlmin.minify(content, {
useShortDoctype: true,
removeComments: true,
collapseWhitespace: true
});
return minified;
}
return content;
});
eleventyConfig.addCollection("apps", (collectionApi) => {
return collectionApi.getFilteredByGlob("_apps/*.md").sort((a, b) => b.data.stars - a.data.stars);
});
eleventyConfig.addCollection("docs", (collectionApi) => {
return collectionApi.getFilteredByGlob("_docs/*.md");
});
// Pass custom options to liquid
let options = {
extname: ".liquid",
dynamicPartials: true,
strict_filters: true,
root: ["_includes"]
};
const liquid = new Liquid(options);
liquid.registerTag('octicon', octiconTag);
eleventyConfig.setLibrary("liquid", liquid);
// Customize markdown-it settings
let markdown = markdownIt({
html: true,
breaks: true,
linkify: true
});
eleventyConfig.addFilter('markdown', (value) => {
return markdown.render(value);
});
eleventyConfig.setLibrary("md", markdown);
// Speed up dev builds by not watching JS deps for changes
eleventyConfig.setWatchJavaScriptDependencies(false);
return {
passthroughFileCopy: true,
dir: {
layouts: "_layouts"
}
}
}