-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eleventy.js
55 lines (48 loc) · 1.49 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
const fs = require("fs");
const Path = require("path");
module.exports = function (eleventyConfig) {
eleventyConfig.addWatchTarget("./content")
eleventyConfig.setWatchThrottleWaitTime(1000);
eleventyConfig.addPassthroughCopy({ "static-root": "/" });
eleventyConfig.addPassthroughCopy({ "data": "data" });
eleventyConfig.addShortcode("formatDate", function (date) {
return "" + date.toLocaleDateString(
"en-US",
{ weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' }
) + "";
});
eleventyConfig.addShortcode("copyImages", function (page, img) {
const files = fs.readdirSync(Path.dirname(page.inputPath))
for (file of files) {
if (
file.endsWith(".png") ||
file.endsWith(".jpeg") ||
file.endsWith(".jpg") ||
file.endsWith(".gif")
) {
fs.mkdirSync(Path.dirname(page.outputPath), { recursive: true });
fs.copyFileSync(
Path.join(Path.dirname(page.inputPath), file),
Path.join(Path.dirname(page.outputPath), file)
)
}
}
return ""
});
eleventyConfig.addShortcode("copyAirtableImages", function (page, images) {
for (image of images) {
fs.mkdirSync(Path.dirname(page.outputPath), { recursive: true });
fs.copyFileSync(
Path.join(image.newFilePath),
Path.join(Path.dirname(page.outputPath), Path.basename(image.newFilePath))
)
}
return ""
});
return {
dir: {
output: "dist",
data: "data"
}
}
};