-
Notifications
You must be signed in to change notification settings - Fork 8
/
.eleventy.js
68 lines (58 loc) · 1.99 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
// Inseriment plugins
const eleventyNavigationPlugin = require("@11ty/eleventy-navigation");
const socialImages = require("@11tyrocks/eleventy-plugin-social-images");
const pluginRss = require("@11ty/eleventy-plugin-rss");
const readingTime = require("eleventy-plugin-reading-time");
// Helper packages
const htmlmin = require("html-minifier");
const { DateTime } = require("luxon");
// 11ty
module.exports = function (eleventyConfig) {
// Apri automaticamente il browser
eleventyConfig.setBrowserSyncConfig({ open: true });
// 11ty attivazione plugins
eleventyConfig.addPlugin(eleventyNavigationPlugin);
eleventyConfig.addPlugin(socialImages);
eleventyConfig.addPlugin(pluginRss);
eleventyConfig.addPlugin(readingTime);
// Non badare ai file di questa cartella
eleventyConfig.ignores.delete("src/_11ty/_social/**/*.*");
// Copia alcuni file statici
eleventyConfig
.addPassthroughCopy({ "src/_11ty/_static/app/*.*": "/" })
.addPassthroughCopy({ "src/_11ty/_static/favicon": "favicon" })
.addPassthroughCopy({ "src/_11ty/_static/img": "img" });
// Mostrare l'anno nel footer
eleventyConfig.addShortcode("year", () => `${new Date().getFullYear()}`);
// HTML minify
eleventyConfig.addTransform("htmlmin", (content, outputPath) => {
if (outputPath.endsWith(".html")) {
return htmlmin.minify(content, {
collapseWhitespace: true,
removeComments: true,
useShortDoctype: true,
});
}
return content;
});
// Data leggibile
eleventyConfig.addFilter("readableDate", (dateObj) => {
return DateTime.fromJSDate(dateObj, { zone: "utc" }).toFormat(
"dd LLL yyyy"
);
});
// Data Feed
eleventyConfig.addLiquidFilter("dateToRfc3339", pluginRss.dateToRfc3339);
// e alla fine
return {
passthroughFileCopy: true,
// Directory: in, out, etc...
dir: {
input: "./src/",
includes: "/_11ty/_includes/",
layouts: "/_11ty/_layouts/",
data: "/_11ty/_data/",
output: "./public/",
},
};
};