-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.eleventy.js
42 lines (34 loc) · 1.23 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
const { DateTime } = require("luxon");
const markdownLib = require('markdown-it')({html: true});
const mdAttrs = require('markdown-it-attrs');
module.exports = function (eleventyConfig) {
eleventyConfig.addPassthroughCopy("src/**/*.{css,png,gif,json,jpg,jpeg,js,webmanifest,xml,ttf,ico,webp,txt}");
eleventyConfig.setLibrary("md", markdownLib);
eleventyConfig.amendLibrary("md", (markdownLib) => markdownLib.use(mdAttrs));
eleventyConfig.addPairedShortcode("markdown", (content, inline = null) => {
return inline
? markdownLib.renderInline(content)
: markdownLib.render(content);
});
eleventyConfig.setLibrary("md", markdownLib);
// date filter
eleventyConfig.addFilter("date", (dateObj, format = "MMMM d, yyyy") => {
return DateTime.fromJSDate(dateObj, { zone: 'utc' }).toFormat(format);
});
eleventyConfig.addGlobalData("eleventyComputed", {
permalink: (data) => {
if (data.page.filePathStem.startsWith("/")) {
return `${data.page.filePathStem}.html`;
}
return data.permalink; // fallback to the current permalink if it's set
},
});
return {
passthroughFileCopy: true,
dir: {
input: "src",
output: "public",
includes: "_includes",
},
};
};