-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eleventy.js
76 lines (62 loc) · 2.38 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
import {minify} from "html-minifier";
import shortcodes from "./cfg/shortcodes.js";
import plugins from "./cfg/plugins.js";
import filters from "./cfg/filters.js";
import {DateTime} from "luxon";
export default async function (eleventyConfig) {
Object.keys(plugins).forEach((pluginName) => {
plugins[pluginName](eleventyConfig);
});
Object.keys(shortcodes).forEach((shortcodeName) => {
shortcodes[shortcodeName](eleventyConfig);
});
Object.keys(filters).forEach((filterName) => {
eleventyConfig.addFilter(filterName, filters[filterName]);
});
/**
* HTML Minifier for production builds
*/
eleventyConfig.addTransform('htmlmin', function (content, outputPath) {
if (
process.env.ELEVENTY_ENV === "production" &&
this.page.outputPath &&
this.page.outputPath.endsWith(".html")
) {
return minify(content, {
useShortDoctype: true,
removeComments: true,
collapseWhitespace: true,
});
}
return content
})
eleventyConfig.addFilter("readableDate", (dateObj, format, zone) => {
return DateTime.fromJSDate(new Date(dateObj), {zone: zone || "utc"}).toFormat(format || "dd LLLL, yyyy");
});
return {
// Control which files Eleventy will process
// e.g.: *.md, *.njk, *.html, *.liquid
templateFormats: ["md", "njk"],
// Pre-process *.md files with: (default: `liquid`)
markdownTemplateEngine: "njk",
// Pre-process *.html files with: (default: `liquid`)
htmlTemplateEngine: "njk",
// These are all optional:
dir: {
input: "./src/content", // default: "."
output: "./_site", // default: "_site"
includes: "../_includes", // default: "_includes"
layouts: "../_includes/layouts", // default: "_layouts"
data: "../_data", // default: "_data"
},
// -----------------------------------------------------------------
// Optional items:
// -----------------------------------------------------------------
// If your site deploys to a subdirectory, change `pathPrefix`.
// Read more: https://www.11ty.dev/docs/config/#deploy-to-a-subdirectory-with-a-path-prefix
// When paired with the HTML <base> plugin https://www.11ty.dev/docs/plugins/html-base/
// it will transform any absolute URLs in your HTML to include this
// folder name and does **not** affect where things go in the output folder.
pathPrefix: "/",
};
}