aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2024-04-05 03:25:54 +0200
committerLibravatar Kristóf Marussy <kristof@marussy.com>2024-04-05 03:25:54 +0200
commitc687eed8905c468b4965d9869d3453acbd98daf6 (patch)
tree08757a7f95ae6afb2d3ceee9e3749bd55519ea4a
parentFirst post (diff)
downloadblog-c687eed8905c468b4965d9869d3453acbd98daf6.tar.gz
blog-c687eed8905c468b4965d9869d3453acbd98daf6.tar.zst
blog-c687eed8905c468b4965d9869d3453acbd98daf6.zip
Fix code block color after hydration
-rw-r--r--blog/2024-04-05/VariableAxisSettings.tsx5
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';
15import styles from './VariableAxisSettings.module.css'; 15import styles from './VariableAxisSettings.module.css';
16import useIsBrowser from '@docusaurus/useIsBrowser';
16 17
17function PreviewEditor({ 18function PreviewEditor({
18 editorClassName, 19 editorClassName,
@@ -72,6 +73,9 @@ const highlightingTypes = [
72]; 73];
73 74
74function CodeBlockBox({ children }: { children: React.ReactNode }) { 75function 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,