-
Notifications
You must be signed in to change notification settings - Fork 0
/
eleventy.config.js
40 lines (31 loc) · 1.06 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
const eleventyNavigationPlugin = require("@11ty/eleventy-navigation")
module.exports = function (eleventyConfig) {
eleventyConfig.addFilter("getAllTags", function (collection) {
let tags = new Set()
for (let item of collection) {
;(item.data.tags ?? []).forEach((tag) => tags.add(tag))
}
tags.delete("post")
return Array.from(tags)
})
eleventyConfig.addFilter("tagSortByMaxPosts", function (collection) {
let tags = new Map()
for (let item of collection) {
;(item.data.tags ?? []).forEach((tag) =>
tags.set(tag, (tags.get(tag) ?? 0) + 1)
)
}
tags.delete("post")
tags = new Map([...tags.entries()].sort((a, b) => b[1] - a[1]))
return Array.from(tags.keys())
})
eleventyConfig.addFilter("getTags", function (tags) {
return tags.filter((tag) => !tag.includes("post"))
})
eleventyConfig.addPlugin(eleventyNavigationPlugin)
return {
dir: {
input: "contents",
},
}
}