-
Notifications
You must be signed in to change notification settings - Fork 1
/
.eleventy.cjs
47 lines (39 loc) · 1.05 KB
/
.eleventy.cjs
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
const markdownIt = require("markdown-it");
const anchor = require("markdown-it-anchor");
const pluginTOC = require("eleventy-plugin-toc");
const { globSync } = require("glob");
module.exports = eleventyConfig => {
let data = {
layout: "page.njk",
permalink: "{{ page.filePathStem | replace('README', '') | replace('index', '') }}/index.html",
tests: globSync("./test/*.js").map(path => path.replace(/^.+\/|\.m?js$/g, "")).filter(name => !name.startsWith("index")),
};
for (let p in data) {
eleventyConfig.addGlobalData(p, data[p]);
}
eleventyConfig.setDataDeepMerge(true);
eleventyConfig.setLibrary("md", markdownIt({
html: true,
})
.disable("code")
.use(anchor, {
permalink: anchor.permalink.headerLink()
})
);
eleventyConfig.addFilter(
"relative",
page => {
let path = page.url.replace(/[^/]+$/, "");
let ret = require("path").relative(path, "/");
return ret || ".";
}
);
eleventyConfig.addPlugin(pluginTOC);
return {
markdownTemplateEngine: "njk",
templateFormats: ["md", "njk"],
dir: {
output: "."
}
};
};