-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheleventy.config.js
More file actions
63 lines (54 loc) · 1.76 KB
/
eleventy.config.js
File metadata and controls
63 lines (54 loc) · 1.76 KB
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
const pluginRss = require("@11ty/eleventy-plugin-rss");
module.exports = function (eleventyConfig) {
eleventyConfig.addPlugin(pluginRss);
eleventyConfig.addGlobalData("site", {
name: "Colin Chang",
description: "Colin Chang's blog and project repository",
url: "https://colinchang.org",
});
eleventyConfig.addGlobalData("header", [
{ title: "About", url: "/" },
{ title: "Blog", url: "/blog" },
{ title: "Recommendations", url: "/recommendations" },
]);
eleventyConfig.ignores.add("README.md");
eleventyConfig.addPassthroughCopy("styles");
eleventyConfig.addPassthroughCopy("scripts");
eleventyConfig.addPassthroughCopy("assets");
eleventyConfig.addPassthroughCopy("CNAME");
eleventyConfig.addPassthroughCopy(".nojekyll");
eleventyConfig.addCollection("posts", (api) =>
api
.getFilteredByTag("posts")
.filter((post) => post.data.published !== false)
.reverse(),
);
eleventyConfig.addFilter("dateFormat", (date) =>
new Date(date).toISOString().slice(0, 10),
);
eleventyConfig.addGlobalData("eleventyComputed", {
permalink: (data) => {
if (data.published === false) {
return false;
}
if (data.page.inputPath.startsWith("./posts/")) {
const d = new Date(data.page.date);
const year = d.getUTCFullYear();
const month = String(d.getUTCMonth() + 1).padStart(2, "0");
const day = String(d.getUTCDate()).padStart(2, "0");
return `/${year}/${month}/${day}/${data.page.fileSlug}/`;
}
return data.permalink;
},
});
return {
dir: {
input: ".",
output: "_site",
includes: "_includes",
},
templateFormats: ["md", "html", "njk"],
markdownTemplateEngine: "njk",
htmlTemplateEngine: "njk",
};
};