forked from inclusive-design/standards.inclusivedesign.ca
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheleventy.config.js
77 lines (65 loc) · 2.4 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
import { EleventyRenderPlugin, IdAttributePlugin } from "@11ty/eleventy";
import eleventyNavigationPlugin from "@11ty/eleventy-navigation";
import brokenLinksPlugin from "eleventy-plugin-broken-links";
import fluidPlugin from "eleventy-plugin-fluid";
import footnotesPlugin from "eleventy-plugin-footnotes";
import parse from "./src/_transforms/parse.js";
export default function eleventy(eleventyConfig) {
eleventyConfig.addPlugin(eleventyNavigationPlugin);
eleventyConfig.addPlugin(EleventyRenderPlugin);
eleventyConfig.addPlugin(footnotesPlugin);
eleventyConfig.addPlugin(fluidPlugin, {
defaultLanguage: "en",
supportedLanguages: {
en: {
slug: "en",
name: "English"
},
fr: {
slug: "fr",
name: "Français",
dir: "ltr",
uioSlug: "fr"
}
}
});
["en", "fr"].forEach((lang) => {
eleventyConfig.addCollection(`pages_${lang}`, (collection) => {
return collection.getFilteredByGlob(`src/collections/pages/${lang}/*.md`);
});
eleventyConfig.addCollection(`projects_${lang}`, (collection) => {
return collection.getFilteredByGlob(`src/collections/projects/${lang}/*.md`);
});
});
eleventyConfig.addFilter("findTranslation", function find(page, collection = [], lang, desiredLang) {
const expectedFilePathStem = page.filePathStem.replace(lang, desiredLang);
let translationUrl = false;
collection.forEach((el) => {
if (el.filePathStem === expectedFilePathStem) {
translationUrl = el.url;
}
});
return translationUrl;
});
eleventyConfig.addTransform("parse", parse);
eleventyConfig.addPassthroughCopy({
"src/admin/config.yml": "admin/config.yml"
});
eleventyConfig.addPassthroughCopy({ "src/assets/fonts": "assets/fonts" });
eleventyConfig.addPlugin(brokenLinksPlugin, {
forbidden: "error",
broken: "error",
cacheDuration: "60s",
loggingLevel: 1,
excludeInputs: ["**/*/*.css"]
});
eleventyConfig.addPlugin(IdAttributePlugin);
return {
dir: {
input: "src"
},
templateFormats: ["njk", "md", "css", "png", "jpg", "svg"],
htmlTemplateEngine: "njk",
markdownTemplateEngine: "njk"
};
}