-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy path.eleventy.js
More file actions
65 lines (58 loc) · 1.72 KB
/
.eleventy.js
File metadata and controls
65 lines (58 loc) · 1.72 KB
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
import { EleventyHtmlBasePlugin } from "@11ty/eleventy";
import syntaxHighlight from "@11ty/eleventy-plugin-syntaxhighlight";
import markdownItAnchor from "markdown-it-anchor";
import markdownItToc from "markdown-it-toc-done-right";
import markdownIt from "markdown-it";
export default function (eleventyConfig) {
const processEnv = {
isPreview: process.env.ELEVENTY_PREVIEW,
}
eleventyConfig.addGlobalData('env', processEnv);
eleventyConfig.setLibrary("md", markdownIt({
html: true,
linkify: true,
typographer: true
}));
eleventyConfig.amendLibrary("md", (mdLib) => {
return mdLib.use(markdownItAnchor, { // add anchors to headings
level: '2',
permalink: markdownItAnchor.permalink.ariaHidden({
class: 'anchor',
symbol: '#',
placement: 'before'
})
});
});
eleventyConfig.amendLibrary("md", (mdLib) => {
return mdLib.use(markdownItToc, { // make a TOC with ${toc}
level: '2',
listType: 'ul'
});
});
const navigations = [
'turbo_handbook',
'turbo_reference',
'stimulus_handbook',
'stimulus_reference',
];
navigations.forEach((nav) => {
eleventyConfig.addCollection(nav, collectionApi => {
return collectionApi.getFilteredByTag(nav).sort((a, b) => {
return a.data.order - b.data.order;
});
});
});
eleventyConfig.addPlugin(EleventyHtmlBasePlugin);
eleventyConfig.addPlugin(syntaxHighlight);
eleventyConfig.addPassthroughCopy({'_assets': 'assets'});
eleventyConfig.setDataDeepMerge(true);
return {
dir: {
layouts: "layouts",
includes: "_includes",
},
templateFormats: ['html', 'md', 'liquid', 'njk'],
htmlTemplateEngine: 'liquid',
pathPrefix: "/",
}
};