diff options
author | Kristóf Marussy <kristof@marussy.com> | 2024-04-05 03:25:54 +0200 |
---|---|---|
committer | Kristóf Marussy <kristof@marussy.com> | 2024-04-05 03:25:54 +0200 |
commit | c687eed8905c468b4965d9869d3453acbd98daf6 (patch) | |
tree | 08757a7f95ae6afb2d3ceee9e3749bd55519ea4a | |
parent | First post (diff) | |
download | blog-c687eed8905c468b4965d9869d3453acbd98daf6.tar.gz blog-c687eed8905c468b4965d9869d3453acbd98daf6.tar.zst blog-c687eed8905c468b4965d9869d3453acbd98daf6.zip |
Fix code block color after hydration
-rw-r--r-- | blog/2024-04-05/VariableAxisSettings.tsx | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/blog/2024-04-05/VariableAxisSettings.tsx b/blog/2024-04-05/VariableAxisSettings.tsx index b288767..8e327dd 100644 --- a/blog/2024-04-05/VariableAxisSettings.tsx +++ b/blog/2024-04-05/VariableAxisSettings.tsx | |||
@@ -13,6 +13,7 @@ import { | |||
13 | useVariableAxes, | 13 | useVariableAxes, |
14 | } from './VariableAxisProvider'; | 14 | } from './VariableAxisProvider'; |
15 | import styles from './VariableAxisSettings.module.css'; | 15 | import styles from './VariableAxisSettings.module.css'; |
16 | import useIsBrowser from '@docusaurus/useIsBrowser'; | ||
16 | 17 | ||
17 | function PreviewEditor({ | 18 | function PreviewEditor({ |
18 | editorClassName, | 19 | editorClassName, |
@@ -72,6 +73,9 @@ const highlightingTypes = [ | |||
72 | ]; | 73 | ]; |
73 | 74 | ||
74 | function CodeBlockBox({ children }: { children: React.ReactNode }) { | 75 | function CodeBlockBox({ children }: { children: React.ReactNode }) { |
76 | // Force re-render in browser. | ||
77 | // https://github.com/facebook/docusaurus/blob/e012e0315862b2ca02cad40c58d11d31c319ff75/packages/docusaurus-theme-classic/src/theme/CodeBlock/index.tsx#L32-L36 | ||
78 | const isBrowser = useIsBrowser(); | ||
75 | const theme = usePrismTheme(); | 79 | const theme = usePrismTheme(); |
76 | 80 | ||
77 | const customProps: Record<string, string> = {}; | 81 | const customProps: Record<string, string> = {}; |
@@ -89,6 +93,7 @@ function CodeBlockBox({ children }: { children: React.ReactNode }) { | |||
89 | 93 | ||
90 | return ( | 94 | return ( |
91 | <div | 95 | <div |
96 | key={String(isBrowser)} | ||
92 | className={styles.code} | 97 | className={styles.code} |
93 | style={{ | 98 | style={{ |
94 | backgroundColor: theme.plain.backgroundColor, | 99 | backgroundColor: theme.plain.backgroundColor, |