ensure homepage always uses yotsuba as theme

This commit is contained in:
plebeius.eth
2024-03-17 16:27:15 +01:00
parent 2fd2c9afec
commit 0df86ac59f
2 changed files with 10 additions and 2 deletions
+7 -2
View File
@@ -1,11 +1,15 @@
import { useEffect } from 'react';
import { Route, Routes } from 'react-router-dom';
import { Route, Routes, useLocation } from 'react-router-dom';
import Home from './views/home';
import styles from './app.module.css';
import useTheme from './hooks/use-theme';
import Subplebbit from './views/subplebbit';
import { isHomeView } from './lib/utils/view-utils';
const App = () => {
const [theme] = useTheme();
const location = useLocation();
const isInHomeView = isHomeView(location.pathname);
useEffect(() => {
document.body.classList.forEach((className) => document.body.classList.remove(className));
@@ -13,9 +17,10 @@ const App = () => {
}, [theme]);
return (
<div className={`${styles.app} ${theme}`}>
<div className={`${styles.app} ${isInHomeView ? 'yotsuba' : theme}`}>
<Routes>
<Route path='/' element={<Home />} />
<Route path='/p/:subplebbitAddress' element={<Subplebbit />} />
</Routes>
</div>
);
+3
View File
@@ -0,0 +1,3 @@
export const isHomeView = (pathname: string): boolean => {
return pathname === '/';
};