Skip to content

Commit c0ba701

Browse files
📦 NEW: Force dark mode on home page (#13)
1 parent a1d1fa2 commit c0ba701

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

‎apps/baseai.dev/src/app/providers.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
import { useEffect } from 'react';
44
import { ThemeProvider, useTheme } from 'next-themes';
55
import { RecoilRoot } from 'recoil';
6+
import { usePathname } from 'next/navigation';
7+
8+
const FORCE_DARK_MODE_PAGES = ['/'];
69

710
function ThemeWatcher() {
811
let { resolvedTheme, setTheme } = useTheme();
@@ -29,8 +32,14 @@ function ThemeWatcher() {
2932
}
3033

3134
export function Providers({ children }: { children: React.ReactNode }) {
35+
const pathname = usePathname();
36+
const website = FORCE_DARK_MODE_PAGES.includes(pathname);
3237
return (
33-
<ThemeProvider attribute="class" disableTransitionOnChange>
38+
<ThemeProvider
39+
attribute="class"
40+
disableTransitionOnChange
41+
forcedTheme={website ? 'dark' : undefined}
42+
>
3443
<ThemeWatcher />
3544
<RecoilRoot>{children}</RecoilRoot>
3645
</ThemeProvider>

0 commit comments

Comments
 (0)