-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patheleventy.config.js
More file actions
179 lines (157 loc) · 5.91 KB
/
eleventy.config.js
File metadata and controls
179 lines (157 loc) · 5.91 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
// Config
import paths from "./config/paths.js";
import site from "./src/_data/site.js";
// 11ty plugins
import { eleventyImageOnRequestDuringServePlugin } from "@11ty/eleventy-img";
import loggingPlugin from "@11ty/eleventy-plugin-directory-output";
import { feedPlugin } from "@11ty/eleventy-plugin-rss";
// Helpful functions that do stuff
import {
getArchiveYears,
getArchivePostsByYear,
} from "./config/blogArchive.js";
import {
getAllTags,
filterCommonTags,
formatAsTag,
} from "./config/blogTags.js";
import {
markdownConfig,
markdownFilter,
markdownFilterInline,
} from "./config/markdown.js";
import { urlizeOpenGraphImage } from "./config/opengraph.js";
import { compileStylesheets } from "./config/sass.js";
import { getTableOfContents } from "./config/tableOfContents.js";
import {
cachebustAssetUrl,
formatDate,
formatISODate,
getDomainFromURL,
getFirstNItems,
mergeArrays,
} from "./config/utils.js";
// Nunjucks shortcodes
import shortcodeCallout from "./config/shortcodes/callout.js";
import shortcodeCharacter from "./config/shortcodes/character.js";
import shortcodeFigure from "./config/shortcodes/figure.js";
import shortcodeImageDiffer from "./config/shortcodes/imageDiffer.js";
import shortcodeRedaction from "./config/shortcodes/redaction.js";
import shortcodeResponsiveImage from "./config/shortcodes/responsiveImages.js";
import shortcodeSocialEmbed from "./config/shortcodes/socialEmbed.js";
import shortcodeYouTube from "./config/shortcodes/youtube.js";
/**
* @param {import("@11ty/eleventy/src/UserConfig")} eleventyConfig
*/
export default function (eleventyConfig) {
const siteData = site();
// Turn off default log output
eleventyConfig.setQuietMode(true);
// Load plugins
eleventyConfig.addPlugin(eleventyImageOnRequestDuringServePlugin);
eleventyConfig.addPlugin(loggingPlugin);
eleventyConfig.addPlugin(feedPlugin, {
type: "atom",
outputPath: "/feed.xml",
stylesheet: "/assets/feed.xsl",
collection: {
name: "blog",
limit: 10,
},
metadata: {
language: "en",
title: siteData.blogName,
subtitle: siteData.blogDescription,
base: siteData.domain,
author: {
name: siteData.authorName,
email: siteData.authorEmail,
},
},
});
eleventyConfig.addPlugin(feedPlugin, {
type: "atom",
outputPath: "/stash/feed.xml",
stylesheet: "/assets/feed.xsl",
collection: {
name: "stash",
limit: 50,
},
metadata: {
language: "en",
title: siteData.stashName,
subtitle: siteData.stashDescription,
base: siteData.domain,
author: {
name: siteData.authorName,
email: siteData.authorEmail,
},
},
});
// Ignore the blog drafts directory if this is a production build
if (process.env.ENVIRONMENT === "prod") {
eleventyConfig.ignores.add(paths.src + "/blog/drafts/**/*");
}
// Copy JS and assets
eleventyConfig.addPassthroughCopy(paths.srcAssets + "/fonts");
eleventyConfig.addPassthroughCopy(paths.srcAssets + "/images");
eleventyConfig.addPassthroughCopy(paths.srcAssets + "/javascript");
eleventyConfig.addPassthroughCopy(paths.srcAssets + "/feed.xsl");
// Copy .htaccess
eleventyConfig.addPassthroughCopy(paths.src + "/.htaccess");
// Copy cow.txt - https://moooo.farm/
eleventyConfig.addPassthroughCopy(paths.src + "/cow.txt");
// Copy Google Search Console verification file, don't compile it
eleventyConfig.ignores.add(paths.src + "/googlea3140dc71dc0155f.html");
eleventyConfig.addPassthroughCopy(paths.src + "/googlea3140dc71dc0155f.html");
// Copy manual .well-known directory entries
eleventyConfig.addPassthroughCopy(paths.src + "/.well-known/**/*");
// Additionally copy favicon.ico to root, as some systems will look for it there
eleventyConfig.addPassthroughCopy({ "**/favicon.ico": "/" });
// Markdown configuration
eleventyConfig.setLibrary("md", markdownConfig);
// Watch and compile Sass files
eleventyConfig.addWatchTarget(paths.srcAssets + "/**/*.scss");
eleventyConfig.on("beforeBuild", compileStylesheets);
// Collections
eleventyConfig.addCollection("tags", getAllTags);
// Bundles
eleventyConfig.addBundle("css");
// Custom Nunjucks functions
eleventyConfig.addNunjucksGlobal("merge", mergeArrays);
eleventyConfig.addNunjucksGlobal("getTableOfContents", getTableOfContents);
// Custom Nunjucks Shortcodes
eleventyConfig.addPairedNunjucksShortcode("callout", shortcodeCallout);
eleventyConfig.addPairedNunjucksShortcode("character", shortcodeCharacter);
eleventyConfig.addPairedNunjucksShortcode("figure", shortcodeFigure);
eleventyConfig.addNunjucksAsyncShortcode("imageDiffer", shortcodeImageDiffer);
eleventyConfig.addPairedNunjucksShortcode("markdown", markdownFilter);
eleventyConfig.addNunjucksShortcode("redaction", shortcodeRedaction);
eleventyConfig.addNunjucksAsyncShortcode("image", shortcodeResponsiveImage);
eleventyConfig.addPairedNunjucksShortcode(
"socialEmbed",
shortcodeSocialEmbed,
);
eleventyConfig.addNunjucksShortcode("youtube", shortcodeYouTube);
// Filters
eleventyConfig.addFilter("cachebust", cachebustAssetUrl);
eleventyConfig.addFilter("filterTagList", filterCommonTags);
eleventyConfig.addFilter("formatDate", formatDate);
eleventyConfig.addFilter("formatISODate", formatISODate);
eleventyConfig.addFilter("head", getFirstNItems);
eleventyConfig.addFilter("tagify", formatAsTag);
eleventyConfig.addFilter("getArchiveYears", getArchiveYears);
eleventyConfig.addFilter("getArchivePostsByYear", getArchivePostsByYear);
eleventyConfig.addFilter("getDomainFromURL", getDomainFromURL);
eleventyConfig.addFilter("markdown", markdownFilter);
eleventyConfig.addFilter("markdownInline", markdownFilterInline);
eleventyConfig.addFilter("urlizeOpenGraphImage", urlizeOpenGraphImage);
return {
markdownTemplateEngine: "njk",
dir: {
input: paths.src,
includes: "_includes",
layouts: "_layouts",
},
};
}