-
Notifications
You must be signed in to change notification settings - Fork 1
/
eleventy.config.js
90 lines (77 loc) · 2.53 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
79
80
81
82
83
84
85
86
87
88
89
90
const { DateTime } = require("luxon")
const fs = require("node:fs")
const { EleventyHtmlBasePlugin } = require("@11ty/eleventy")
const { EleventyRenderPlugin } = require("@11ty/eleventy")
const pluginRss = require("@11ty/eleventy-plugin-rss")
const pluginNavigation = require("@11ty/eleventy-navigation")
const bundlerPlugin = require("@11ty/eleventy-plugin-bundle")
const svgSprite = require("eleventy-plugin-svg-sprite")
module.exports = function (eleventyConfig) {
// PassThroughCopy
eleventyConfig.addPassthroughCopy({
"./public/": "/",
"node_modules/magic-grid/dist/magic-grid.min.js": "js/magic-grid.min.js",
})
eleventyConfig.addPassthroughCopy("./content/**/*.jpg")
// Watch content images for the image pipeline.
eleventyConfig.addWatchTarget("content/**/*.{svg,webp,png,jpeg,jpg}")
// App plugins
eleventyConfig.addPlugin(require("./eleventy.config.drafts.js"))
eleventyConfig.addPlugin(require("./eleventy.config.images.js"))
// Official plugins
eleventyConfig.addPlugin(pluginRss)
eleventyConfig.addPlugin(pluginNavigation)
eleventyConfig.addPlugin(EleventyHtmlBasePlugin)
eleventyConfig.addPlugin(EleventyRenderPlugin)
eleventyConfig.addPlugin(bundlerPlugin)
// Community plugins
eleventyConfig.addPlugin(svgSprite, {
path: "./public/img/sprite",
})
// Filters
eleventyConfig.addFilter("readableDate", (date) => {
const dateObj = new Date(date)
return dateObj.toLocaleDateString("en-US", {
year: "numeric",
month: "long",
day: "numeric",
})
})
eleventyConfig.addFilter("htmlDateString", (dateObj) => {
return DateTime.fromJSDate(dateObj, { zone: "utc" }).toFormat("yyyy-LL-dd")
})
// Return all the tags used in a collection
eleventyConfig.addFilter("getAllTags", (collection) => {
let tagSet = new Set()
for (let item of collection) {
;(item.data.tags || []).forEach((tag) => tagSet.add(tag))
}
return Array.from(tagSet)
})
eleventyConfig.addFilter("filterTagList", function filterTagList(tags) {
return (tags || []).filter(
(tag) => ["all", "nav", "post", "posts"].indexOf(tag) === -1,
)
})
eleventyConfig.addFilter(
"filterTagSeries",
function filterTagSeries(tags, series) {
return (tags || []).filter((tag) => series.indexOf(tag) === -1)
},
)
eleventyConfig.addFilter("fsExists", function (filename) {
return fs.existsSync(filename)
})
return {
templateFormats: ["md", "njk", "html"],
markdownTemplateEngine: "njk",
htmlTemplateEngine: "njk",
dir: {
input: "content",
includes: "../_includes",
data: "../_data",
output: "_site",
},
pathPrefix: "/",
}
}