File tree 1 file changed +4
-4
lines changed
1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -14,11 +14,11 @@ interface Props {
14
14
const CodeTabs = ( props : Props ) => {
15
15
const { children } = props ;
16
16
const theme = useContext ( ThemeContext ) ;
17
-
17
+ const hasMermaid = ! Array . isArray ( children ) && children . props ?. children . props . lang === 'mermaid' ;
18
18
19
19
// render Mermaid diagram
20
20
useEffect ( ( ) => {
21
- if ( typeof window !== 'undefined' ) {
21
+ if ( typeof window !== 'undefined' && hasMermaid ) {
22
22
import ( 'mermaid' ) . then ( module => {
23
23
mermaid = module . default ;
24
24
mermaid . initialize ( {
@@ -27,7 +27,7 @@ const CodeTabs = (props: Props) => {
27
27
mermaid . contentLoaded ( ) ;
28
28
} ) ;
29
29
}
30
- } , [ theme ] ) ;
30
+ } , [ hasMermaid , theme ] ) ;
31
31
32
32
function handleClick ( { target } , index : number ) {
33
33
const $wrap = target . parentElement . parentElement ;
@@ -42,7 +42,7 @@ const CodeTabs = (props: Props) => {
42
42
}
43
43
44
44
// render single Mermaid diagram
45
- if ( ! Array . isArray ( children ) && children . props ?. children . props . lang === 'mermaid' ) {
45
+ if ( hasMermaid ) {
46
46
const value = children . props . children . props . value ;
47
47
return < pre className = "mermaid mermaid_single" > { value } </ pre > ;
48
48
}
You can’t perform that action at this time.
0 commit comments