generated from 5t3ph/11ty-sass-skeleton
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
54 lines (41 loc) · 1.29 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
module.exports = function (eleventyConfig) {
//make sass work
eleventyConfig.addWatchTarget("./src/sass/");
eleventyConfig.addWatchTarget("./src/admin/");
eleventyConfig.setTemplateFormats(["md", "njk", "html"]);
//add a filter to sort alphabetically in nunjucks
function sortAlpha(vals) {
return vals
.slice()
.sort((a, b) => a.data.title.localeCompare(b.data.title));
}
function ifEmpty(array) {
if(array.length > 1) {
return true;
}
return false;
}
eleventyConfig.addFilter("alpha", sortAlpha);
eleventyConfig.addFilter("ifempty", ifEmpty);
//syntax highlighting
const syntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
eleventyConfig.addPlugin(syntaxHighlight);
// Copy Static Files to /public
eleventyConfig.addPassthroughCopy({
"./src/admin/config.yml": "./config.yml",
"./src/img": "./img"
});
eleventyConfig.addPassthroughCopy("./src/admin");
eleventyConfig.addPassthroughCopy("./src/js");
// Add DateTime filter to get rid of time in {{ page.date }}
const { DateTime } = require("luxon");
eleventyConfig.addFilter("postDate", (dateObj) => {
return DateTime.fromJSDate(dateObj).toLocaleString(DateTime.DATE_MED);
});
return {
dir: {
input: "src",
output: "public"
}
};
};