-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy patheleventy.config.js
139 lines (119 loc) · 5.01 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
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
/*
Copyright the Inclusive Learning Design Handbook copyright holders.
See the AUTHORS.md file at the top-level directory of this distribution and at
https://github.com/fluid-project/handbook.floeproject.org/raw/main/AUTHORS.md.
Licensed under the New BSD license. You may not use this file except in compliance with this License.
You may obtain a copy of the New BSD License at
https://github.com/fluid-project/handbook.floeproject.org/raw/main/LICENSE.md.
*/
"use strict";
const fluidPlugin = require("eleventy-plugin-fluid");
const navigationPlugin = require("@11ty/eleventy-navigation");
const syntaxHighlightPlugin = require("@11ty/eleventy-plugin-syntaxhighlight");
// Import transforms
const parseTransform = require("./src/_transforms/parse-transform.js");
// Import data files
const getResourceLinks = require("./src/_utils/getResourceLinks.js");
const getArticleContents = require("./src/_utils/getArticleContents.js");
const getContentsFromNavKey = require("./src/_utils/getContentsFromNavKey.js");
const slugify = require("@sindresorhus/slugify");
module.exports = function (eleventyConfig) {
eleventyConfig.setUseGitIgnore(false);
// Transforms
eleventyConfig.addTransform("parse", parseTransform);
// Passthrough copy
eleventyConfig.addPassthroughCopy("src/_redirects");
eleventyConfig.addPassthroughCopy({"src/assets/fonts": "assets/fonts"});
eleventyConfig.addPassthroughCopy({"src/assets/icons": "/"});
eleventyConfig.addPassthroughCopy({"src/assets/images": "assets/images"});
// Plugins
eleventyConfig.addPlugin(fluidPlugin, {
defaultLanguage: "en-CA",
localesDirectory: "src/_locales",
supportedLanguages: {
"en-CA": {
slug: "en",
name: "English"
},
"fr-CA": {
slug: "fr",
name: "Français",
dir: "ltr",
uioSlug: "fr"
}
},
markdown: {
plugins: [
["markdown-it-anchor", { slugify: s => slugify(s) }]
]
},
css: {
enabled: false
},
sass: {
enabled: true
}
});
eleventyConfig.addPlugin(navigationPlugin);
eleventyConfig.addPlugin(syntaxHighlightPlugin);
// Shortcodes
eleventyConfig.addShortcode("svg_sprite", (sprite, altText, ariaHidden = true) => {
const altTextMarkup = altText ? `<title>${altText}</title>` : "";
const ariaHiddenMarkup = ariaHidden ? " aria-hidden=\"true\"" : "";
return `<svg class="ildh-${sprite}"${ariaHiddenMarkup}>${altTextMarkup}<use xlink:href="/assets/images/sprites.svg#${sprite}"></use></svg>`;
});
eleventyConfig.addShortcode("extract_resource_links", (content, sideContentHeadings, lang) => {
return getResourceLinks(content, sideContentHeadings, lang);
});
eleventyConfig.addShortcode("article_contents", (content, summary, headingsSelector, containerCssClass) => {
return getArticleContents(content, summary, headingsSelector, containerCssClass);
});
eleventyConfig.addShortcode("content_from_nav_key", (collection, navigationKey) => {
return getContentsFromNavKey(collection, navigationKey.toString());
});
/*
Provide a custom duplicate of eleventy-plugin-fluid's uioInit shortcode in
order to run it without the text-size preference until issue #57 is solved
This is called from base.njk and home.njk
https://github.com/fluid-project/handbook.floeproject.org/issues/57
*/
eleventyConfig.addShortcode("uioCustomInit", (locale, direction) => {
let options = {
preferences: [
"fluid.prefs.lineSpace",
"fluid.prefs.textFont",
"fluid.prefs.contrast",
"fluid.prefs.tableOfContents",
"fluid.prefs.enhanceInputs"
],
auxiliarySchema: {
terms: {
templatePrefix: "/lib/infusion/src/framework/preferences/html",
messagePrefix: "/lib/infusion/src/framework/preferences/messages"
},
"fluid.prefs.tableOfContents": {
enactor: {
tocTemplate: "/lib/infusion/src/components/tableOfContents/html/TableOfContents.html",
tocMessage: "/lib/infusion/src/framework/preferences/messages/tableOfContents-enactor.json",
ignoreForToC: {
ignoreClass: ".flc-toc-ignore"
}
}
}
},
prefsEditorLoader: {
lazyLoad: true
},
locale: locale,
direction: direction
};
return `<script>fluid.uiOptions.multilingual(".flc-prefsEditor-separatedPanel", ${JSON.stringify(options)});</script>`;
});
return {
dir: {
input: "src"
},
passthroughFileCopy: true,
markdownTemplateEngine: "njk"
};
};