forked from color-js/color.js
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eleventy.cjs
56 lines (47 loc) · 1.09 KB
/
.eleventy.cjs
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
module.exports = config => {
let data = {
"layout": "page.njk",
"permalink": "{{ page.filePathStem }}.html",
};
for (let p in data) {
config.addGlobalData(p, data[p]);
}
config.setDataDeepMerge(true);
config.setFrontMatterParsingOptions({
excerpt: true,
// Optional, default is "---"
excerpt_separator: "<!-- more -->",
});
// config.addFilter("readable_date", date => {
// return new Date(date).toLocaleString("en-US", {
// dateStyle: "full",
// timeStyle: "short"
// });
// });
config.addFilter(
"relative",
page => {
let path = page.url.replace(/[^/]+$/, "");
let ret = require("path").relative(path, "/");
return ret || ".";
},
);
config.addFilter(
"unslugify",
slug => slug.replace(/(^|-)([a-z])/g, ($0, $1, $2) => ($1 ? " " : "") + $2.toUpperCase()),
);
config.addFilter(
"first_heading",
content => {
// console.log(content);
return content ? content.match(/^#+\s*(.+)/)?.[1] ?? "NO_HEADING_FOUND" : "EMPTY_CONTENT";
},
);
return {
markdownTemplateEngine: "njk",
templateFormats: ["md", "njk"],
dir: {
output: ".",
},
};
};