-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eleventy.js
55 lines (46 loc) · 1.38 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
import { inspect } from "util";
import { readFile } from "fs/promises";
const eleventyPackage = JSON.parse(
await readFile("./node_modules/@11ty/eleventy/package.json", "utf8"),
);
export default async function (eleventyConfig) {
// Copy `assets/css` to `_site/assets/css`
eleventyConfig.addPassthroughCopy("src/assets/css");
eleventyConfig.addPassthroughCopy("src/assets/img");
eleventyConfig.addPassthroughCopy("src/assets/font");
eleventyConfig.addPassthroughCopy("src/assets/js");
eleventyConfig.addPassthroughCopy("src/.ht*");
eleventyConfig.addPassthroughCopy("src/CNAME");
eleventyConfig.addCollection("sections", function (collectionApi) {
// get unsorted items
const posts = collectionApi.getAll().filter((input) => {
if (input.inputPath.match("/_section/")) {
return input;
}
});
posts.sort((a, b) => {
return a.data.position - b.data.position;
});
return posts;
});
eleventyConfig.addShortcode("11ty_meta", function (field) {
if (eleventyPackage[field]) {
return eleventyPackage[field];
}
return "";
});
eleventyConfig.addFilter(
"debug",
(content) => `<pre>${inspect(content)}</pre>`,
);
eleventyConfig.addPairedShortcode(
"note",
(content) => `<div class="note">${inspect(content)}</div>`,
);
return {
dir: {
input: "src",
output: "docs",
},
};
}