From 64b8e9554b5d93563b23dc95c46d1973f35a0ebf Mon Sep 17 00:00:00 2001 From: DidierRLopes Date: Sun, 15 Sep 2024 16:55:29 -0400 Subject: [PATCH] try to fix action --- src/theme/BlogPostItem/index.js | 48 +++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/src/theme/BlogPostItem/index.js b/src/theme/BlogPostItem/index.js index 64c787d966..367abdd1be 100644 --- a/src/theme/BlogPostItem/index.js +++ b/src/theme/BlogPostItem/index.js @@ -1,32 +1,46 @@ import { useBlogPost } from '@docusaurus/theme-common/internal'; import BlogPostItem from '@theme-original/BlogPostItem'; -import React from 'react'; +import React, { useEffect, useState } from 'react'; +import BrowserOnly from '@docusaurus/BrowserOnly'; +import useIsBrowser from '@docusaurus/useIsBrowser'; export default function BlogPostItemWrapper(props) { const { metadata, isBlogPostPage } = useBlogPost(); + const isBrowser = useIsBrowser(); + const [theme, setTheme] = useState('light'); + + useEffect(() => { + if (isBrowser) { + setTheme(document.documentElement.getAttribute('data-theme') !== 'dark' ? 'light' : 'dark'); + } + }, [isBrowser]); return ( <> {props.children} {isBlogPostPage && ( -
-