-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
51 lines (42 loc) · 1.58 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
const { DateTime } = require("luxon");
const markdownIt = require('markdown-it');
const markdownItAttrs = require('markdown-it-attrs');
const pluginSyntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
module.exports = async function(eleventyConfig) {
// Add plugins
eleventyConfig.addPlugin(pluginSyntaxHighlight, {
alwaysWrapLineHighlights: true,
});
eleventyConfig.setLibrary('md', markdownIt({
html: true,
}).use(markdownItAttrs));
// https://www.11ty.dev/docs/data-deep-merge/
eleventyConfig.setDataDeepMerge(true);
// Alias `layout: post` to `layout: layouts/post.njk`
eleventyConfig.addLayoutAlias("post", "layouts/post.njk");
eleventyConfig.addFilter("readableDate", dateObj => {
return DateTime.fromJSDate(dateObj, {zone: 'utc'}).toFormat("dd LLL yyyy");
});
// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-date-string
eleventyConfig.addFilter('htmlDateString', (dateObj) => {
return DateTime.fromJSDate(dateObj, {zone: 'utc'}).toFormat('yyyy-LL-dd');
});
eleventyConfig.addCollection("posts", function(collectionApi) {
return collectionApi.getFilteredByTag("posts");
});
eleventyConfig.addPassthroughCopy("css");
eleventyConfig.addPassthroughCopy("fonts");
eleventyConfig.addPassthroughCopy("img");
eleventyConfig.addPassthroughCopy("code");
eleventyConfig.addPassthroughCopy({ "well-known": ".well-known" });
return {
templateFormats: [
"md",
"njk",
"txt"
],
markdownTemplateEngine: "njk",
htmlTemplateEngine: "njk",
dataTemplateEngine: false
};
};