mirror of
https://github.com/JustAnimeCore/JustAnime.git
synced 2026-04-17 13:51:44 +00:00
freshhhh
This commit is contained in:
73
src/App.jsx
73
src/App.jsx
@@ -1,73 +0,0 @@
|
||||
import { useLocation } from "react-router-dom";
|
||||
import { useEffect } from "react";
|
||||
import { Routes, Route } from "react-router-dom";
|
||||
import { HomeInfoProvider } from "./context/HomeInfoContext";
|
||||
import Home from "./pages/Home/Home";
|
||||
import AnimeInfo from "./pages/animeInfo/AnimeInfo";
|
||||
import Navbar from "./components/navbar/Navbar";
|
||||
import Footer from "./components/footer/Footer";
|
||||
import Error from "./components/error/Error";
|
||||
import Category from "./pages/category/Category";
|
||||
import AtoZ from "./pages/a2z/AtoZ";
|
||||
import { azRoute, categoryRoutes } from "./utils/category.utils";
|
||||
import "./App.css";
|
||||
import Search from "./pages/search/Search";
|
||||
import Watch from "./pages/watch/Watch";
|
||||
import Producer from "./components/producer/Producer";
|
||||
import SplashScreen from "./components/splashscreen/SplashScreen";
|
||||
|
||||
function App() {
|
||||
const location = useLocation();
|
||||
|
||||
// Scroll to top on location change
|
||||
useEffect(() => {
|
||||
window.scrollTo(0, 0);
|
||||
}, [location]);
|
||||
|
||||
// Check if the current route is for the splash screen
|
||||
const isSplashScreen = location.pathname === "/";
|
||||
|
||||
return (
|
||||
<HomeInfoProvider>
|
||||
<div className="app-container">
|
||||
<main className="content">
|
||||
{!isSplashScreen && <Navbar />}
|
||||
<Routes>
|
||||
<Route path="/" element={<SplashScreen />} />
|
||||
<Route path="/home" element={<Home />} />
|
||||
<Route path="/:id" element={<AnimeInfo />} />
|
||||
<Route path="/watch/:id" element={<Watch />} />
|
||||
<Route path="/random" element={<AnimeInfo random={true} />} />
|
||||
<Route path="/404-not-found-page" element={<Error error="404" />} />
|
||||
<Route path="/error-page" element={<Error />} />
|
||||
{/* Render category routes */}
|
||||
{categoryRoutes.map((path) => (
|
||||
<Route
|
||||
key={path}
|
||||
path={`/${path}`}
|
||||
element={
|
||||
<Category path={path} label={path.split("-").join(" ")} />
|
||||
}
|
||||
/>
|
||||
))}
|
||||
{/* Render A to Z routes */}
|
||||
{azRoute.map((path) => (
|
||||
<Route
|
||||
key={path}
|
||||
path={`/${path}`}
|
||||
element={<AtoZ path={path} />}
|
||||
/>
|
||||
))}
|
||||
<Route path="/producer/:id" element={<Producer />} />
|
||||
<Route path="/search" element={<Search />} />
|
||||
{/* Catch-all route for 404 */}
|
||||
<Route path="*" element={<Error error="404" />} />
|
||||
</Routes>
|
||||
{!isSplashScreen && <Footer />}
|
||||
</main>
|
||||
</div>
|
||||
</HomeInfoProvider>
|
||||
);
|
||||
}
|
||||
|
||||
export default App;
|
||||
Reference in New Issue
Block a user