-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eleventy.js
68 lines (57 loc) · 1.95 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
const { DateTime } = require("luxon");
// Plugins
const syntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
const readingTime = require('eleventy-plugin-reading-time');
const readingBar = require('eleventy-plugin-reader-bar')
const pluginRss = require("@11ty/eleventy-plugin-rss");
module.exports = function (eleventyConfig) {
// OPT-OUT OF USING .gitignore to prevent reload issue when css change
eleventyConfig.setUseGitIgnore(false);
// Merge data instead of overriding
// https://www.11ty.dev/docs/data-deep-merge/
eleventyConfig.setDataDeepMerge(true);
// Layout aliases for convenience
eleventyConfig.addLayoutAlias("default", "layouts/base.njk");
// Shortcode
eleventyConfig.addShortcode("external", function(text, href) {
return `<a rel="external" target="_blank" href="${href}">${text}</a>`;
});
// Date helpers
eleventyConfig.addFilter("readableDate", (dateObj) => {
return DateTime.fromJSDate(dateObj, {
zone: "utc",
}).toFormat("dd LLLL yyyy");
});
eleventyConfig.addFilter("htmlDate", (dateObj) => {
return DateTime.fromJSDate(dateObj, {
zone: "utc",
}).toFormat("y-MM-dd");
});
// compress and combine js files
eleventyConfig.addFilter("jsmin", require("./src/_utils/minify-js.js"));
// minify the html output when running in prod
if (process.env.ELEVENTY_ENV == "production") {
eleventyConfig.addTransform(
"htmlmin",
require("./src/_utils/minify-html.js")
);
}
// Plugins
eleventyConfig.addPlugin(syntaxHighlight);
eleventyConfig.addPlugin(readingTime);
eleventyConfig.addPlugin(readingBar);
eleventyConfig.addPlugin(pluginRss);
// Static assets to pass through
eleventyConfig.addPassthroughCopy("src/assets");
return {
dir: {
input: "src",
includes: "_includes",
output: "dist",
},
passthroughFileCopy: true,
templateFormats: ["njk", "md"],
htmlTemplateEngine: "njk",
markdownTemplateEngine: "njk",
};
};