-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
executable file
·72 lines (61 loc) · 1.89 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
const categories = require("./src/_data/gallery/categories")
const sass = require("sass");
const path = require("path")
module.exports = function(eleventyConfig) {
for (folder of ["pictures", "scripts", "fonts", "build", "sendnewsletter", "icons"]) {
eleventyConfig.addPassthroughCopy(`./src/${folder}`)
}
// Recognize Sass as a "template languages"
eleventyConfig.addTemplateFormats("scss");
// Compile Sass
eleventyConfig.addExtension("scss", {
outputFileExtension: "css",
compile: async function (inputContent, inputPath) {
// Skip files like _fileName.scss
let parsed = path.parse(inputPath);
if (parsed.name.startsWith("_")) {
return;
}
// Run file content through Sass
let result = sass.compileString(inputContent, {
loadPaths: [parsed.dir || "."],
sourceMap: false, // or true, your choice!
});
// Allow included files from @use or @import to
// trigger rebuilds when using --incremental
this.addDependencies(inputPath, result.loadedUrls);
return async () => {
return result.css;
};
},
});
eleventyConfig.addFilter("extractSubjects", function(col) {
let subjects = []
for (p of col) {
for (s of p.data.subject) {
if (!subjects.includes(s)) {subjects.push(s)}
}
}
return subjects
})
eleventyConfig.addFilter("reformatCalendarEntries", function(entries) {
let events = []
for (e of entries) {
date = e.date.split(".").map(parseInt)
events.push({ date : date[2] + ", " + (date[1]-1) + ", " + date[0], title: e.title, link: e.link })
}
return events
})
eleventyConfig.addFilter("removeLocale", function(url) {
return url.slice(4)
})
return {
markdownTemplateEngine: 'njk',
dataTemplateEngine: 'njk',
htmlTemplateEngine: 'njk',
dir: {
input: 'src',
output: '_site'
}
}
}