-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheleventy.config.js
78 lines (74 loc) · 2.22 KB
/
eleventy.config.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import { feedPlugin } from "@11ty/eleventy-plugin-rss";
import embeds from "eleventy-plugin-embed-everything"
import { eleventyImageTransformPlugin } from "@11ty/eleventy-img"
import { DateTime } from "luxon";
import syntaxHighlight from "@11ty/eleventy-plugin-syntaxhighlight";
export default async function(eleventyConfig) {
// this shows dates on posts
eleventyConfig.addFilter("postDate", dateObj => {
return DateTime.fromJSDate(dateObj).toLocaleString(DateTime.DATE_MED)
})
// create a posts collection
eleventyConfig.addCollection("posts", (collectionApi) =>
collectionApi.getFilteredByGlob("src/posts/*.md")
);
// tags configuration
eleventyConfig.addCollection("tagsList", function(collectionApi) {
let tagsSet = new Set();
collectionApi.getAll().forEach(item => {
if ("tags" in item.data) {
let tags = item.data.tags;
tags.forEach(tag => tagsSet.add(tag));
}
});
return [...tagsSet].sort();
});
eleventyConfig.addFilter("filterByTag", (posts, tag) => {
return posts.filter(post => post.data.tags && post.data.tags.includes(tag));
});
// copy assets
eleventyConfig.addPassthroughCopy("src/img");
eleventyConfig.addPassthroughCopy("src/css");
eleventyConfig.addPassthroughCopy("src/favicon/");
eleventyConfig.addPassthroughCopy({ 'src/robots.txt': '/robots.txt' });
eleventyConfig.addPassthroughCopy({ 'src/CNAME': '/CNAME' });
// plugins
eleventyConfig.addPlugin(embeds);
eleventyConfig.addPlugin(syntaxHighlight);
eleventyConfig.addPlugin(feedPlugin, {
type: "atom",
outputPath: "/feed.xml",
collection: {
name: "posts",
limit: 25,
},
metadata: {
language: "en",
title: "Mijndert Stuij",
subtitle: "Senior DevOps Engineer. Runner. Minimalist.",
base: "https://mijndertstuij.nl/",
author: {
name: "Mijndert Stuij",
email: "[email protected]",
}
}
});
eleventyConfig.addPlugin(eleventyImageTransformPlugin, {
extensions: "html",
widths: [800, 500, 300],
defaultAttributes: {
sizes: "90vw",
loading: "lazy",
decoding: "async",
},
});
return {
markdownTemplateEngine: "njk",
dataTemplateEngine: "njk",
htmlTemplateEngine: "njk",
dir: {
input: "src",
output: "dist",
},
};
};