mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
ensure homepage always uses yotsuba as theme
This commit is contained in:
+7
-2
@@ -1,11 +1,15 @@
|
|||||||
import { useEffect } from 'react';
|
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 Home from './views/home';
|
||||||
import styles from './app.module.css';
|
import styles from './app.module.css';
|
||||||
import useTheme from './hooks/use-theme';
|
import useTheme from './hooks/use-theme';
|
||||||
|
import Subplebbit from './views/subplebbit';
|
||||||
|
import { isHomeView } from './lib/utils/view-utils';
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const [theme] = useTheme();
|
const [theme] = useTheme();
|
||||||
|
const location = useLocation();
|
||||||
|
const isInHomeView = isHomeView(location.pathname);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
document.body.classList.forEach((className) => document.body.classList.remove(className));
|
document.body.classList.forEach((className) => document.body.classList.remove(className));
|
||||||
@@ -13,9 +17,10 @@ const App = () => {
|
|||||||
}, [theme]);
|
}, [theme]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={`${styles.app} ${theme}`}>
|
<div className={`${styles.app} ${isInHomeView ? 'yotsuba' : theme}`}>
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path='/' element={<Home />} />
|
<Route path='/' element={<Home />} />
|
||||||
|
<Route path='/p/:subplebbitAddress' element={<Subplebbit />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
export const isHomeView = (pathname: string): boolean => {
|
||||||
|
return pathname === '/';
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user