-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
52 lines (43 loc) · 1.55 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
import prettier from "prettier";
import { createRequire } from "node:module";
const require = createRequire(import.meta.url);
import plugins from "./config/plugins.js";
import filters, { readableDate } from "./config/filters.js";
import markdown from "./config/markdown.js";
const PRETTIER_CONFIG = require("./.prettierrc.json");
export default function conf(config) {
const md = markdown();
config.addPassthroughCopy("./_redirects");
config.addPassthroughCopy({ "./public": "/" });
config.addPassthroughCopy({ "./style": "/style" });
config.addWatchTarget("content/**/*.{svg,png,jpeg,webp}");
config.addWatchTarget("style/**/*.css");
plugins(config);
filters(config);
config.setLibrary("md", md);
config.addShortcode("buildDate", () => readableDate(new Date()));
config.addTransform("prettier", async function (content) {
if (
[".html", ".css", ".js", ".json"].some((x) =>
this.page.outputPath.endsWith(x),
)
) {
return await prettier.format(content, {
filepath: this.page.outputPath,
...PRETTIER_CONFIG,
});
}
return content;
});
return {
templateFormats: ["md", "njk", "html", "11ty.js"],
markdownTemplateEngine: "njk",
htmlTemplateEngine: "njk",
dir: {
input: "content",
output: "./dist/",
includes: "../include", // top-level include directory
data: "../data", // top-level data directory
},
};
}