Skip to content

Commit 5f47839

Browse files
authored
Merge pull request #32 from YoubetDao/feature/rlp
feat: Add RLP translation
2 parents fdcdb19 + f80d0bf commit 5f47839

File tree

4 files changed

+2419
-1
lines changed

4 files changed

+2419
-1
lines changed

book.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@ title = "youbet-tutorial"
77

88
[output.html]
99
additional-css = ["custom.css"]
10-
additional-js = ["custom.js"]
10+
additional-js = ["custom.js", "mermaid.min.js", "mermaid-init.js"]
1111
git-repository-url = "https://github.com/youbetdao/epf-protocol-cn/"
1212
git-repository-icon = "fa-github"
1313

1414
[preprocessor.katex]
1515
after = ["links"]
16+
17+
[preprocessor.mermaid]
18+
command = "mdbook-mermaid"

mermaid-init.js

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
(() => {
2+
const darkThemes = ['ayu', 'navy', 'coal'];
3+
const lightThemes = ['light', 'rust'];
4+
5+
const classList = document.getElementsByTagName('html')[0].classList;
6+
7+
let lastThemeWasLight = true;
8+
for (const cssClass of classList) {
9+
if (darkThemes.includes(cssClass)) {
10+
lastThemeWasLight = false;
11+
break;
12+
}
13+
}
14+
15+
const theme = lastThemeWasLight ? 'default' : 'dark';
16+
mermaid.initialize({ startOnLoad: true, theme });
17+
18+
// Simplest way to make mermaid re-render the diagrams in the new theme is via refreshing the page
19+
20+
for (const darkTheme of darkThemes) {
21+
document.getElementById(darkTheme).addEventListener('click', () => {
22+
if (lastThemeWasLight) {
23+
window.location.reload();
24+
}
25+
});
26+
}
27+
28+
for (const lightTheme of lightThemes) {
29+
document.getElementById(lightTheme).addEventListener('click', () => {
30+
if (!lastThemeWasLight) {
31+
window.location.reload();
32+
}
33+
});
34+
}
35+
})();

0 commit comments

Comments
 (0)