-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eleventy.js
69 lines (57 loc) · 2.22 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
const { EleventyHtmlBasePlugin } = require("@11ty/eleventy");
const markdownIt = require("markdown-it");
const markdownItAnchor = require("markdown-it-anchor");
const pluginTOC = require("eleventy-plugin-toc");
const pluginRSS = require("@11ty/eleventy-plugin-rss");
module.exports = function(eleventyConfig) {
eleventyConfig.addPlugin(EleventyHtmlBasePlugin, {
baseHref: (process.env.NODE_ENV === "production" ? "https://developers.crowd4u.org" : "http://localhost:8080")
});
eleventyConfig.addPlugin(pluginTOC, {
tags: ["h2", "h3", "h4"],
wrapper: "aside"
});
eleventyConfig.addPlugin(pluginRSS);
eleventyConfig.setLibrary(
"md",
markdownIt().use(markdownItAnchor)
);
eleventyConfig.addPassthroughCopy("**/*.png");
//eleventyConfig.addPassthroughCopy("assets/img/**/*.png");
eleventyConfig.addFilter("getAllTags", collection => {
let tagset = new Set();
collection.forEach(post => {
(post.data.tags || []).forEach(tag => tagset.add(tag))
});
return Array.from(tagset);
});
eleventyConfig.addFilter("filterTagList", tags => {
return (tags || []).filter(tag => ["posts"].indexOf(tag) === -1);
});
eleventyConfig.addFilter("filterAuthor", (collections, author) => {
return collections.filter(post => post.data.author === author);
});
eleventyConfig.addFilter("readableDate", (date) => {
return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`;
})
eleventyConfig.addFilter("dateToRfc3339", pluginRSS.dateToRfc3339);
eleventyConfig.addFilter("getAuthorLink", (id) => {
let path = `/author/${id}`;
return eleventyConfig.getFilter("url")(path);
});
eleventyConfig.addFilter("getAuthorAvatarLink", (id) => {
let path = `/assets/img/avatars/${id}.png`;
return eleventyConfig.getFilter("url")(path);
});
eleventyConfig.addFilter("getTagLink", (tag) => {
let path = "/tag/" + eleventyConfig.getFilter("slugify")(tag);
return eleventyConfig.getFilter("url")(path);
});
return {
markdownTemplateEngine: "njk",
dir: {
input: "src",
output: "public"
}
}
}