-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
53 lines (45 loc) · 1.42 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
const eleventyNavigationPlugin = require("@11ty/eleventy-navigation");
const {minify} = require("terser");
module.exports = function(eleventyConfig) {
// Pages to ignore.
eleventyConfig.ignores.add("./src/pages/our-staff.njk");
eleventyConfig.ignores.add("./src/pages/blog.njk");
eleventyConfig.ignores.add("./src/blog/posts/*.md");
// Get alpineJs code into assets folder.
eleventyConfig.addPassthroughCopy({
'./node_modules/alpinejs/dist/cdn.js': './assets/alpine.js',
})
eleventyConfig.addPlugin(eleventyNavigationPlugin);
eleventyConfig.addPassthroughCopy('src/img')
// Add js minification filter.
eleventyConfig.addNunjucksAsyncFilter("jsmin", async function (
code,
callback
) {
try {
const minified = await minify(code);
callback(null, minified.code);
} catch (err) {
console.error("Terser error: ", err);
// Fail gracefully.
callback(null, code);
}
});
const {
DateTime
} = require("luxon");
// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-date-string
eleventyConfig.addFilter('htmlDateString', (dateObj) => {
return DateTime.fromJSDate(dateObj, {
zone: 'utc'
}).toFormat('yy-MM-dd');
});
eleventyConfig.addFilter("readableDate", dateObj => {
return DateTime.fromJSDate(dateObj, {
zone: 'utc'
}).toFormat("dd-MM-yy");
});
return {
dir: { input: 'src', output: '_site' }
};
};