-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for theme switching when jumping between docs pages and marketing…
… pages. Change default theme to light.
- Loading branch information
1 parent
e8d4e63
commit 290c8f1
Showing
4 changed files
with
52 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React, { useEffect } from "react"; | ||
import { composeProviders, useColorMode } from "@docusaurus/theme-common"; | ||
import { useLocation } from "@docusaurus/router"; | ||
import { | ||
ColorModeProvider, | ||
AnnouncementBarProvider, | ||
DocsPreferredVersionContextProvider, | ||
ScrollControllerProvider, | ||
NavbarProvider, | ||
PluginHtmlClassNameProvider, | ||
} from "@docusaurus/theme-common/internal"; | ||
const Provider = composeProviders([ | ||
ColorModeProvider, | ||
AnnouncementBarProvider, | ||
ScrollControllerProvider, | ||
DocsPreferredVersionContextProvider, | ||
PluginHtmlClassNameProvider, | ||
NavbarProvider, | ||
]); | ||
|
||
function RestoreTheme() { | ||
const { setColorMode } = useColorMode(); | ||
useEffect(() => { | ||
const storedTheme = localStorage.getItem("theme"); | ||
setColorMode(storedTheme); | ||
}, []); | ||
return <></>; | ||
} | ||
|
||
export default function LayoutProvider({ children }) { | ||
const location = useLocation(); | ||
let isDocsPage = location.pathname.startsWith("/docs"); | ||
|
||
return ( | ||
<Provider> | ||
{isDocsPage ? <RestoreTheme></RestoreTheme> : null} | ||
{children} | ||
</Provider> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters