This repository was archived by the owner on May 6, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.eleventy.js
More file actions
55 lines (44 loc) · 1.27 KB
/
.eleventy.js
File metadata and controls
55 lines (44 loc) · 1.27 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
import mermaid from "mermaid"
import { marked } from "marked"
import pugPlugin from "@11ty/eleventy-plugin-pug"
import fs from "fs"
import path from "path"
import os from "os"
import { execSync } from "child_process"
import { fileURLToPath } from "url"
function parseMermaid(text) {
const tmpInput = path.join(os.tmpdir(), `mermaid-${Date.now()}.mmd`)
const tmpOutput = path.join(os.tmpdir(), `mermaid-${Date.now()}.svg`)
fs.writeFileSync(tmpInput, text)
execSync(`mmdc -i "${tmpInput}" -o "${tmpOutput}"`)
const svg = fs.readFileSync(tmpOutput, "utf8")
fs.unlinkSync(tmpInput)
fs.unlinkSync(tmpOutput)
return svg
}
export default function (eleventyConfig) {
// Mermaid config
mermaid.initialize({ startOnLoad: false })
// Pug config
eleventyConfig.addPlugin(pugPlugin, {
filters: {
mermaid: parseMermaid,
markdown: function (text) { return marked.parse(text.replace(/^[\u200B\u200C\u200D\u200E\u200F\uFEFF]/,"")) }
}
})
// Site files
const siteFiles = [
"style/",
"js/",
"img/",
"favicon.png"
]
for (const path of siteFiles) eleventyConfig.addPassthroughCopy(`./src/${path}`)
// 11ty config
return {
dir: {
input: "src",
output: "docs"
}
}
}