-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.ts
96 lines (79 loc) · 2.88 KB
/
.eleventy.ts
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
import * as luxon from "luxon";
import * as eleventyNavigationPlugin from "@11ty/eleventy-navigation";
import * as eleventyPluginRss from "@11ty/eleventy-plugin-rss";
import * as markdownIt from "markdown-it";
import * as numberString from "number-string";
import {budgetAddon} from './src/addons/budget/budget-addon';
import {projectAddon} from './src/addons/project/project-addon';
import {playgroundAddon} from './src/addons/playground/playground-addon';
import {grantAddon} from './src/addons/grant/grant-addon';
const conf = function (eleventyConfig: any) {
eleventyConfig.addPlugin(eleventyNavigationPlugin);
eleventyConfig.addPlugin(eleventyPluginRss);
eleventyConfig.addFilter("readableDate", (dateObj: Date) => {
return luxon.DateTime.fromJSDate(dateObj, { zone: "utc" }).toFormat("dd LLL yyyy");
});
eleventyConfig.addFilter("json", (object: any) => {
console.log(object);
return JSON.stringify(object);
});
eleventyConfig.addFilter("htmlDateString", (dateObj: Date) => {
return luxon.DateTime.fromJSDate(dateObj, { zone: "utc" }).toFormat("yyyy-LL-dd");
});
eleventyConfig.addFilter("postDate", (dateObj: string) => {
const dateTime = luxon.DateTime.fromString(dateObj, "yyyy-LL-dd");
return dateTime.toFormat("dd.LL.yyyy");
});
eleventyConfig.addFilter("date", (timeline: luxon.DateTime) => {
return timeline.toFormat("dd.LL.yyyy");
});
eleventyConfig.addFilter("value", (value: number) => {
const number = numberString.toMoney(value, {
decimalMark: ",",
thousandSeperator: " ",
maxPrecision: 2,
minPrecision: 0,
symbol: "",
symbolBehind: false,
useParens: true,
});
return number;
});
eleventyConfig.addFilter("log", (object: any) => {
console.log(object);
return object;
});
eleventyConfig.addFilter("head", (array, n) => {
if (n < 0) {
return array.slice(n);
}
return array.slice(0, n);
});
budgetAddon(eleventyConfig);
playgroundAddon(eleventyConfig);
projectAddon(eleventyConfig);
grantAddon(eleventyConfig);
const markdownItOptions: markdownIt.Options = {
html: true,
breaks: false,
linkify: true,
};
// dont neet to copy everything every time
// enable it only if something in here change
eleventyConfig.addPassthroughCopy({ "eleventy/static/css": "css" });
eleventyConfig.addPassthroughCopy({ "eleventy/static/fonts": "fonts" });
eleventyConfig.addPassthroughCopy({ "eleventy/static/webfonts": "webfonts" });
eleventyConfig.addPassthroughCopy({ "eleventy/static/img": "img" });
eleventyConfig.addPassthroughCopy({ "eleventy/static/js": "js" });
eleventyConfig.setLibrary("md", markdownIt(markdownItOptions).disable("code"));
return {
templateFormats: ["11ty.js", "md", "njk", "html"],
dir: {
input: "eleventy",
includes: "_includes",
data: "_data",
output: "_site",
},
};
};
export = conf;