chore: Disable mermaid in SSR

This commit is contained in:
Sidharth Vinod
2024-09-02 16:11:33 +05:30
parent f5cc0dcaea
commit 69c9a564f2
4 changed files with 19 additions and 8 deletions

View File

@@ -127,7 +127,7 @@ Error.prepareStackTrace
#### Defined in
node_modules/@types/node/globals.d.ts:28
node_modules/@types/node/globals.d.ts:98
---
@@ -141,7 +141,7 @@ Error.stackTraceLimit
#### Defined in
node_modules/@types/node/globals.d.ts:30
node_modules/@types/node/globals.d.ts:100
## Methods
@@ -168,4 +168,4 @@ Error.captureStackTrace
#### Defined in
node_modules/@types/node/globals.d.ts:21
node_modules/@types/node/globals.d.ts:91

View File

@@ -267,5 +267,7 @@ const main = async () => {
document.getElementById('arch-example').innerHTML = svg;
};
setTimeout(main, 100)
if (!import.meta.env.SSR) {
setTimeout(main, 100);
}
</script>

View File

@@ -17,7 +17,14 @@ declare global {
mermaid: typeof mermaid;
render: typeof render;
}
}
window.mermaid = mermaid;
window.render = render;
interface ImportMeta {
env: {
SSR: boolean;
};
}
}
if (!import.meta.env.SSR) {
window.mermaid = mermaid;
window.render = render;
}

View File

@@ -229,5 +229,7 @@ const main = async () => {
document.getElementById('arch-example').innerHTML = svg;
};
setTimeout(main, 100)
if (!import.meta.env.SSR) {
setTimeout(main, 100);
}
</script>