-
Notifications
You must be signed in to change notification settings - Fork 87
/
.eleventy.js
64 lines (55 loc) · 1.93 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
// Plugins
const { EleventyRenderPlugin } = require("@11ty/eleventy");
const slugify = require("slugify");
module.exports = function(eleventyConfig) {
// Watch targets
eleventyConfig.addWatchTarget("./index.njk");
eleventyConfig.addWatchTarget("./**/*.njk");
eleventyConfig.addWatchTarget("./site.css");
// Passthrough
eleventyConfig.addPassthroughCopy("apple-touch-icon.png");
eleventyConfig.addPassthroughCopy("avatar.png");
eleventyConfig.addPassthroughCopy("favicon.ico");
eleventyConfig.addPassthroughCopy("favicon.svg");
eleventyConfig.addPassthroughCopy("fonts/basiersquare-bold.woff2");
eleventyConfig.addPassthroughCopy("fonts/basiersquare-regular.woff2");
eleventyConfig.addPassthroughCopy("fonts/basiersquare-semibold.woff2");
eleventyConfig.addPassthroughCopy("humans.txt");
eleventyConfig.addPassthroughCopy("icon-192.png");
eleventyConfig.addPassthroughCopy("icon-512.png");
eleventyConfig.addPassthroughCopy("manifest.webmanifest");
eleventyConfig.addPassthroughCopy("site.css");
eleventyConfig.addPassthroughCopy("robots.txt");
eleventyConfig.addPassthroughCopy("social-share-image.png");
// Eleventy config
eleventyConfig.setQuietMode(true);
eleventyConfig.addPlugin(EleventyRenderPlugin);
// sortDataByDate - Sort by data files `date` field
eleventyConfig.addFilter("sortDataByDate", (obj) => {
const sorted = {};
Object.keys(obj)
.sort((a, b) => {
return obj[a].date > obj[b].date ? 1 : -1;
})
.forEach((name) => (sorted[name] = obj[name]));
return sorted;
});
eleventyConfig.addFilter("slugify", function (str) {
return slugify(str.replace(/<\/?("[^"]*"|'[^']*'|[^>])*(>|$)/g, ""), {
lower: true,
replacement: "-",
remove: /[*+~.·,()'"`´%!?¿:@»]/g,
});
});
return {
// Supported formats
templateFormats: [
"njk"
],
// Preprocess
htmlTemplateEngine: "njk",
dir: {
data: "data"
}
};
};