@@ -3,30 +3,40 @@ import Layout from "@theme/Layout";
33import Head from "@docusaurus/Head" ;
44import { motion } from "framer-motion" ;
55import Link from "@docusaurus/Link" ;
6- import { useColorMode } from '@docusaurus/theme-common' ;
6+ // removed useColorMode import to avoid provider + SSR issues
77import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment' ;
88
99// Safe hook for color mode that handles SSR
1010function useSafeColorMode ( ) {
1111 const [ mounted , setMounted ] = useState ( false ) ;
12+ const [ colorMode , setColorMode ] = useState < 'light' | 'dark' > ( 'light' ) ;
13+ const [ isDark , setIsDark ] = useState ( false ) ;
1214
1315 useEffect ( ( ) => {
1416 setMounted ( true ) ;
15- } , [ ] ) ;
17+ if ( ! ExecutionEnvironment . canUseDOM ) return ;
1618
17- let colorMode = 'light' ;
18- let isDark = false ;
19+ const getThemeFromDOM = ( ) =>
20+ ( document . documentElement . getAttribute ( 'data-theme' ) as 'light' | 'dark' ) || 'light' ;
1921
20- if ( mounted && ExecutionEnvironment . canUseDOM ) {
21- try {
22- const { useColorMode : useColorModeHook } = require ( '@docusaurus/theme-common' ) ;
23- const colorModeResult = useColorModeHook ( ) ;
24- colorMode = colorModeResult . colorMode ;
25- isDark = colorMode === 'dark' ;
26- } catch ( error ) {
27- console . warn ( 'Failed to get color mode:' , error ) ;
28- }
29- }
22+ const applyTheme = ( ) => {
23+ const mode = getThemeFromDOM ( ) ;
24+ setColorMode ( mode ) ;
25+ setIsDark ( mode === 'dark' ) ;
26+ } ;
27+
28+ // set immediately on mount
29+ applyTheme ( ) ;
30+
31+ // watch for changes when navbar toggle is clicked
32+ const observer = new MutationObserver ( applyTheme ) ;
33+ observer . observe ( document . documentElement , {
34+ attributes : true ,
35+ attributeFilter : [ 'data-theme' ] ,
36+ } ) ;
37+
38+ return ( ) => observer . disconnect ( ) ;
39+ } , [ ] ) ;
3040
3141 return { colorMode, isDark, mounted } ;
3242}
@@ -515,7 +525,7 @@ function CareersContent() {
515525 variants = { fadeIn }
516526 >
517527 < div className = "testimonial-content text-center" >
518- < div className = "w-20 h-20 bg-gradient-to-br from-blue-400 to-purple-500 rounded-full mx-auto mb-6 flex items- center justify-center" >
528+ < div className = "w-20 h-20 bg-gradient-to-br from-blue-400 to-purple-500 rounded-full mx-auto mb-6 flex items center justify-center" >
519529 < span className = "text-2xl" > 👤</ span >
520530 </ div >
521531 < blockquote
@@ -611,4 +621,4 @@ function CareersContent() {
611621
612622export default function CareersPage ( ) {
613623 return < CareersContent /> ;
614- }
624+ }
0 commit comments