-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
47 lines (38 loc) · 1.44 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
const eleventyNavigationPlugin = require("@11ty/eleventy-navigation");
const eleventySyntaxHighlightPlugin = require("@11ty/eleventy-plugin-syntaxhighlight");
const externalAnchorPlugin = require("@orchidjs/eleventy-plugin-ids");
const externalPicturePlugin = require("eleventy-plugin-img2picture");
module.exports = function(eleventyConfig) {
// Deploy
eleventyConfig.addPassthroughCopy("./CNAME");
// Plugins
eleventyConfig.addPlugin(eleventyNavigationPlugin);
eleventyConfig.addPlugin(eleventySyntaxHighlightPlugin);
// 3rd Party Plugins
eleventyConfig.addPlugin(externalAnchorPlugin);
eleventyConfig.addPlugin(externalPicturePlugin, {
eleventyInputDir: "posts",
imagesOutputDir: "_site/assets",
urlPath: "/assets/",
fetchRemote: true,
});
// Collections
eleventyConfig.addCollection("articles", (collection) => {
return collection.getFilteredByGlob("./articles/*.md");
});
eleventyConfig.addCollection("tags", (collections) => {
const tags = collections
.getAll()
.reduce((tags, item) => tags.concat(item.data.tags), [])
.filter((tag) => !!tag)
.filter((tag) => tag !== "post" || tag !== "articles");
return Array.from(new Set(tags));
});
// Filters
eleventyConfig.addFilter('date', function(value) {
const date = new Date(value);
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
return `${year}-${month}`;
});
};