-
-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathgatsby-browser.js
More file actions
21 lines (19 loc) · 671 Bytes
/
gatsby-browser.js
File metadata and controls
21 lines (19 loc) · 671 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import "./src/styles/all.scss";
require("prismjs/themes/prism-tomorrow.min.css");
export const onRouteUpdate = async () => {
const elements = document.querySelectorAll(".language-mermaid");
if (elements.length > 0) {
const { default: mermaid } = await import("mermaid");
mermaid.initialize({ startOnLoad: false });
elements.forEach((element) => {
const parent = element.parentElement;
if (parent && parent.tagName === "PRE") {
const div = document.createElement("div");
div.className = "mermaid";
div.textContent = element.textContent;
parent.replaceWith(div);
}
});
await mermaid.run();
}
};