forked from 18F/handbook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eleventy.js
72 lines (61 loc) · 2.15 KB
/
.eleventy.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
const { EleventyRenderPlugin } = require("@11ty/eleventy");
const markdownIt = require("markdown-it");
const markdownItAnchor = require("markdown-it-anchor");
const markdownItAttrs = require("markdown-it-attrs");
const yaml = require("js-yaml");
const svgSprite = require("eleventy-plugin-svg-sprite");
const { headingLinks } = require("./config/headingLinks");
const baseurl = require("./config/baseurl");
const HandbookPlugin = require("./config/HandbookPlugin.js");
module.exports = function (config) {
// Add plugins
config.addPlugin(EleventyRenderPlugin);
config.addPlugin(HandbookPlugin);
// Copy USWDS init JS so we can load it in HEAD to prevent banner flashing
config.addPassthroughCopy({
"node_modules/@uswds/uswds/dist/js/uswds-init.js":
"assets/js/uswds-init.js",
});
// Copy the favicon
config.addPassthroughCopy({
"favicon.ico": "favicon.ico",
});
// SVG Sprite Plugin for USWDS USWDS icons
config.addPlugin(svgSprite, {
path: "./node_modules/@uswds/uswds/dist/img/uswds-icons",
svgSpriteShortcode: "uswds_icons_sprite",
svgShortcode: "uswds_icons",
});
// SVG Sprite Plugin for USWDS USA icons
config.addPlugin(svgSprite, {
path: "./node_modules/@uswds/uswds/dist/img/usa-icons",
svgSpriteShortcode: "usa_icons_sprite",
svgShortcode: "usa_icons",
});
// Allow yaml to be used in the _data dir
config.addDataExtension("yaml", (contents) => yaml.load(contents));
config.addDataExtension("yml", (contents) => yaml.load(contents));
// Customize Markdown library and settings:
let markdownLibrary = markdownIt({
html: true,
})
.use(markdownItAnchor, {
permalink: headingLinks, // use our custom heading links
slugify: config.getFilter("slugify"),
})
.use(markdownItAttrs);
config.setLibrary("md", markdownLibrary);
config.setServerOptions({ liveReload: true, domDiff: true, port: 8080 });
return {
templateFormats: ["md", "html", "njk"],
markdownTemplateEngine: "liquid",
htmlTemplateEngine: "liquid",
pathPrefix: baseurl,
dir: {
input: "pages",
includes: "../_includes",
data: "../_data",
output: "_site",
},
};
};