-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
100 lines (87 loc) · 2.82 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
const config = {
};
module.exports = function(eleventyConfig) {
// Customized Markdown Export.
let markdownIt = require("markdown-it");
let md = markdownIt({html: true})
md.use(require("markdown-it-deflist"));
md.use(require("markdown-it-anchor"));
md.use(require("markdown-it-mermaid-plugin"));
eleventyConfig.setLibrary("md", md);
eleventyConfig.addPairedShortcode("markdown", (content) => {
return md.render(content);
});
// Files to copy
eleventyConfig.addPassthroughCopy("favicon.ico");
eleventyConfig.addPassthroughCopy("gt.css");
eleventyConfig.addPassthroughCopy("w3.css");
// eleventyConfig.addPassthroughCopy("img/logo.png");
// eleventyConfig.addPassthroughCopy("img/GT-hexes.jpg");
// eleventyConfig.addPassthroughCopy("w3.css");
// Extensions to copy
// eleventyConfig.setTemplateFormats(["css", "js", "json", "png", "jpg"]);
eleventyConfig.addPassthroughCopy("img");
eleventyConfig.addPassthroughCopy("videos");
eleventyConfig.addLiquidFilter("fixDate", function(value){
value.setTime(value.getTime() + (5*60*60*1000));
return value; })
eleventyConfig.addFilter("andList", function(list){
if (list.length > 1){
return list.slice(0,-1).join(", ")+" and "+list.slice(-1)[0];
} else {
return list.join("");
}
})
eleventyConfig.addFilter("orList", function(list){
if (list.length > 1){
return list.slice(0,-1).join(", ")+" or "+list.slice(-1)[0];
} else {
return list.join("");
}
})
// Bibtex export.
let bibtexParse = require("bibtex-parse");
eleventyConfig.addDataExtension("bib",
contents => Object.assign({ layout: 'bib', tags: 'bib' },
bibtexParse.entries(contents)[0]))
eleventyConfig.addCollection("bibSort", function(collectionApi) {
return collectionApi.getFilteredByTag("bib").sort(function(a,b) {
if (a.data.YEAR == b.data.YEAR) {
if (a.data.AUTHOR < b.data.AUTHOR) {
return 1
} else {
return -1
}
} else {
return parseInt(a.data.YEAR) - parseInt(b.data.YEAR)
}
}).reverse()
})
// Strip newlines
eleventyConfig.addFilter("clean", function(value) {
if(value) {
return value
.replace(/\s+/g, " ") // Drop newlines.
.replace(/n'([^\ss])/g, "ń$1") // Accent characters
.replace(/r'([^\ss])/g, "ŕ$1")
.replace(/\\cc/g, "ç")
} else {
return ""
}
});
eleventyConfig.addFilter("xspace", function(value) {
if(value) {
return value + " ";
} else {
return ""
}
});
eleventyConfig.addFilter("listAnd", function(value) {
if(value) {
return value.split("and").map(function(it){ return it.trim(); })
} else {
return []
}
});
return config;
};