-
Notifications
You must be signed in to change notification settings - Fork 2
/
eleventy-book.config.js
71 lines (61 loc) · 1.63 KB
/
eleventy-book.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
// @ts-check
// @ts-ignore
const renderPDF = import("./book/to-pdf.js").then((m) => m.renderPDF);
process.on("unhandledRejection", (err) => {
console.log(err);
});
/**
* @type {(eleventyConfig: import("@11ty/eleventy/src/UserConfig")) => Partial<ReturnType<import("@11ty/eleventy/src/defaultConfig")>>}
*/
module.exports = (eleventyConfig) => {
eleventyConfig.addPlugin(require("./config"));
/**
* Data
*/
// don’t render any pages unless explicitly specified
eleventyConfig.addGlobalData("permalink", false);
// CHANGE THESE!
eleventyConfig.addGlobalData("book", {
// uncomment to instead make a huge PDF of all scripts
// allTheScripts: true,
extraYear: false,
graduationYear: 2024,
});
eleventyConfig.addPassthroughCopy({
"book/node_modules/pagedjs/dist/paged.polyfill.js":
"assets/vendor/paged.polyfill.js",
});
eleventyConfig.setServerOptions({
module: "@11ty/eleventy-server-browsersync",
snippet: false,
callbacks: {
async ready(err, bs) {
port = bs.server.address().port;
await (
await renderPDF
)(port);
if (process.env.BAND_BOOK_ONESHOT) {
process.exit(0);
}
},
},
});
let port;
eleventyConfig.on("eleventy.after", async () => {
if (port) {
(await renderPDF)(port);
}
});
return {
markdownTemplateEngine: "njk",
htmlTemplateEngine: "njk",
// configures the locations of various directories
dir: {
input: "pages/scripts",
includes: "../../includes",
layouts: "../../layouts",
data: "../../data",
output: "book-html",
},
};
};