-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
78 lines (63 loc) · 1.98 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
const htmlmin = require('html-minifier')
const embedEverything = require("eleventy-plugin-embed-everything");
const embedYouTube = require("eleventy-plugin-youtube-embed");
const eleventyNavigationPlugin = require("@11ty/eleventy-navigation");
const { DateTime } = require("luxon");
module.exports = function(eleventyConfig) {
/**
* Upgrade helper
* Uncomment if you need help upgrading to new major version.
*/
//eleventyConfig.addPlugin(UpgradeHelper);
/**
* Files to copy
* https://www.11ty.dev/docs/copy/
*/
eleventyConfig.addPassthroughCopy("src/img");
eleventyConfig.addPassthroughCopy("img/fonts");
eleventyConfig.addPlugin(embedEverything);
eleventyConfig.addPlugin(embedYouTube);
eleventyConfig.addPlugin(eleventyNavigationPlugin);
/* adding date shortcode */
eleventyConfig.addFilter("postDate", (dateObj) => {
return DateTime.fromJSDate(dateObj).toLocaleString(DateTime.DATE_MED);
});
// Return all the tags used in a collection
eleventyConfig.addFilter("getAllTags", (collection) => {
let tagSet = new Set();
for (let item of collection) {
(item.data.tags || []).forEach((tag) => tagSet.add(tag));
}
return Array.from(tagSet);
});
eleventyConfig.addFilter("filterTagList", function filterTagList(tags) {
return (tags || []).filter(
(tag) => ["all", "nav", "post", "posts", "projects"].indexOf(tag) === -1
);
});
// eleventyConfig.hostname = "https://computationalmama.xyz";
/**
* HTML Minifier for production builds
*/
eleventyConfig.addTransform("htmlmin", function (content, outputPath) {
if (
process.env.ELEVENTY_ENV == "production" &&
outputPath &&
outputPath.endsWith(".html")
) {
let minified = htmlmin.minify(content, {
useShortDoctype: true,
removeComments: true,
collapseWhitespace: true,
});
return minified;
}
return content;
});
return {
dir: {
input: "src",
data: "../_data",
},
};
};