File tree 4 files changed +2419
-1
lines changed
4 files changed +2419
-1
lines changed Original file line number Diff line number Diff line change @@ -7,9 +7,12 @@ title = "youbet-tutorial"
7
7
8
8
[output .html ]
9
9
additional-css = [" custom.css" ]
10
- additional-js = [" custom.js" ]
10
+ additional-js = [" custom.js" , " mermaid.min.js " , " mermaid-init.js " ]
11
11
git-repository-url = " https://github.com/youbetdao/epf-protocol-cn/"
12
12
git-repository-icon = " fa-github"
13
13
14
14
[preprocessor .katex ]
15
15
after = [" links" ]
16
+
17
+ [preprocessor .mermaid ]
18
+ command = " mdbook-mermaid"
Original file line number Diff line number Diff line change
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
+ } ) ( ) ;
You can’t perform that action at this time.
0 commit comments