-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheleventy.config.js
More file actions
92 lines (76 loc) · 2.74 KB
/
Copy patheleventy.config.js
File metadata and controls
92 lines (76 loc) · 2.74 KB
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
91
92
import paths from "./tasks/paths.js"
// Build tasks
import { compileSass } from "./tasks/compile-sass.js"
// Eleventy plugins
import pluginDirectoryLogging from "@11ty/eleventy-plugin-directory-output"
import pluginSvgContents from "eleventy-plugin-svg-contents"
import pluginTableOfContents from "eleventy-plugin-toc"
// Markdown parser and plugins
import markdownIt from "markdown-it"
import markdownItAnchorPlugin from "markdown-it-anchor"
import markdownItAttributesPlugin from "markdown-it-attrs"
// Custom shortcodes
import shortcodeIcon from "./app/shortcodes/icon.js"
import shortcodeImage from "./app/shortcodes/image.js"
import shortcodeMarkdown from "./app/shortcodes/markdown.js"
// Custom filters
import filterCachebust from "./app/filters/cachebust.js"
import filterFormatDate from "./app/filters/formatDate.js"
import removeNullOrUndefinedFromArray from "./app/filters/removeNullOrUndefinedFromArray.js"
export default function (config) {
// Turn off default log output
// config.setQuietMode(true)
// Eleventy plugins
config.addPlugin(pluginDirectoryLogging)
config.addPlugin(pluginSvgContents)
config.addPlugin(pluginTableOfContents, {
tags: ["h2"],
wrapper: "div",
wrapperClass: "bf-toc",
})
// Add bundle for per-page CSS
config.addBundle("css")
// Markdown-It configuration
config.setLibrary(
"md",
markdownIt({
html: true,
linkify: true,
typographer: true,
})
.use(markdownItAttributesPlugin)
.use(markdownItAnchorPlugin),
)
// Ignore files in these directories
config.ignores.add(paths.srcLayouts)
// Watch and compile Sass files
config.addWatchTarget(paths.srcAssets + "/**/*.scss")
config.on("beforeBuild", compileSass)
// Watch and reload on JS file changes
config.addWatchTarget(paths.srcAssets + "/**/*.mjs")
// Copy over static assets
config.addPassthroughCopy(paths.src + "/.htaccess")
config.addPassthroughCopy(paths.srcAssets + "/fonts")
config.addPassthroughCopy(paths.srcAssets + "/icons")
config.addPassthroughCopy(paths.srcAssets + "/images")
config.addPassthroughCopy(paths.srcAssets + "/all.mjs")
config.addPassthroughCopy(paths.srcAssets + "/javascript")
// Custom shortcodes
config.addShortcode("icon", shortcodeIcon)
config.addShortcode("image", shortcodeImage)
config.addPairedShortcode("markdown", shortcodeMarkdown)
// Custom filters
config.addFilter("cachebust", filterCachebust)
config.addFilter("formatDate", filterFormatDate)
config.addFilter("removeNullOrUndefinedFromArray", removeNullOrUndefinedFromArray)
return {
markdownTemplateEngine: "njk",
pathPrefix: "/",
dir: {
input: paths.src,
layouts: paths.srcLayouts,
includes: paths.srcIncludes,
output: paths.output,
},
}
}