-
Notifications
You must be signed in to change notification settings - Fork 45
/
eleventy.config.js
85 lines (71 loc) · 3.07 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
/*
Copyright 2014-2022 OCAD University
Copyright 2017 Raising the Floor, International
Licensed under the Educational Community License (ECL), Version 2.0 or the New
BSD license. You may not use this file except in compliance with one these
Licenses.`
You may obtain a copy of the ECL 2.0 License and BSD License at
https://github.com/fluid-project/infusion/raw/main/Infusion-LICENSE.txt
*/
"use strict";
var githubSlugify = require("github-slugger").slug;
require("./index.js");
var hljs = require("highlight.js");
var parseTransform = require("./src/transforms/parse.js");
var navigationPlugin = require("@11ty/eleventy-navigation");
module.exports = function (eleventyConfig) {
var markdownit = require("markdown-it")({
html: true,
highlight: function (str, lang) {
if (lang && hljs.getLanguage(lang)) {
try {
return "<pre class=\"highlight\"><code class=\"hljs " + lang + "\">" +
hljs.highlight(str, {language: lang, ignoreIllegals: true}).value +
"</code></pre>";
} catch (__) {}
}
return "<pre class=\"highlight\"><code class=\"hljs " + lang + "\">" + markdownit.utils.escapeHtml(str) + "</code></pre>";
}
});
var markdownItAnchor = require("markdown-it-anchor");
var markdownItLibrary = markdownit.use(markdownItAnchor, { slugify: githubSlugify });
eleventyConfig.setLibrary("md", markdownItLibrary);
eleventyConfig.addTransform("parse", parseTransform);
eleventyConfig.addPlugin(navigationPlugin);
eleventyConfig.addPassthroughCopy({
"node_modules/infusion/dist": "lib/infusion/dist",
"node_modules/infusion/src": "lib/infusion/src",
"node_modules/foundation-sites/css": "lib/foundation",
"node_modules/lunr": "lib/lunr",
"node_modules/fluid-express/src/js/lib": "lib/fluid-express",
"node_modules/fluid-binder/src/js": "lib/fluid-binder",
"node_modules/fluid-location-bar-relay/src/js": "lib/fluid-location-bar-relay",
"src/static/css": "css",
"src/static/fonts": "fonts",
"src/static/images": "images",
"src/static/js": "js",
"src/scripts": "js",
"src/documents/images": "images",
"src/icons": "/"
});
// Helper function to rewrite *.md links to *.html:
// With this helper, we can write links to *.md files in our source files but
// generate links to *.html in the DocPad output. This arrangement gives us
// links that work both on the GitHub website and in the generated HTML.
eleventyConfig.addFilter("rewriteMdLinks", function (content) {
return content.replace(/(<a\s[^>]*href="[\w-/\.]+)\.md(["#])/gm, "$1.html$2");
});
// Helper function to add a prefix to a relative URL.
eleventyConfig.addFilter("addPrefix", function (href) {
return "/infusion/development" + href;
});
eleventyConfig.on("afterBuild", () => {
require("./src/scripts/create-search-digest");
});
return {
dir: {
input: "src",
output: "dist"
}
};
};