Write on the margins of the internet. Powered by the AT Protocol.
at main 91 lines 3.2 kB view raw
1import { Routes, Route } from "react-router-dom"; 2import { useEffect } from "react"; 3import { AuthProvider, useAuth } from "./context/AuthContext"; 4import Sidebar from "./components/Sidebar"; 5import RightSidebar from "./components/RightSidebar"; 6import MobileNav from "./components/MobileNav"; 7import Feed from "./pages/Feed"; 8import Url from "./pages/Url"; 9import UserUrl from "./pages/UserUrl"; 10import Profile from "./pages/Profile"; 11import Login from "./pages/Login"; 12import New from "./pages/New"; 13import Bookmarks from "./pages/Bookmarks"; 14import Highlights from "./pages/Highlights"; 15import Notifications from "./pages/Notifications"; 16import AnnotationDetail from "./pages/AnnotationDetail"; 17import Collections from "./pages/Collections"; 18import CollectionDetail from "./pages/CollectionDetail"; 19import Privacy from "./pages/Privacy"; 20import Terms from "./pages/Terms"; 21import ScrollToTop from "./components/ScrollToTop"; 22import { ThemeProvider } from "./context/ThemeContext"; 23 24function AppContent() { 25 const { user } = useAuth(); 26 27 useEffect(() => { 28 if (user) { 29 fetch("/api/sync", { method: "POST" }).catch(console.error); 30 } 31 }, [user]); 32 33 return ( 34 <div className="layout"> 35 <ScrollToTop /> 36 <Sidebar /> 37 <div className="main-layout"> 38 <main className="main-content-wrapper"> 39 <Routes> 40 <Route path="/" element={<Feed />} /> 41 <Route path="/url" element={<Url />} /> 42 <Route path="/new" element={<New />} /> 43 <Route path="/bookmarks" element={<Bookmarks />} /> 44 <Route path="/highlights" element={<Highlights />} /> 45 <Route path="/notifications" element={<Notifications />} /> 46 <Route path="/profile/:handle" element={<Profile />} /> 47 <Route path="/login" element={<Login />} /> 48 <Route path="/at/:did/:rkey" element={<AnnotationDetail />} /> 49 <Route path="/annotation/:uri" element={<AnnotationDetail />} /> 50 <Route path="/collections" element={<Collections />} /> 51 <Route path="/collections/:rkey" element={<CollectionDetail />} /> 52 <Route 53 path="/:handle/collection/:rkey" 54 element={<CollectionDetail />} 55 /> 56 <Route 57 path="/:handle/annotation/:rkey" 58 element={<AnnotationDetail />} 59 /> 60 <Route 61 path="/:handle/highlight/:rkey" 62 element={<AnnotationDetail />} 63 /> 64 <Route 65 path="/:handle/bookmark/:rkey" 66 element={<AnnotationDetail />} 67 /> 68 <Route path="/:handle/url/*" element={<UserUrl />} /> 69 <Route path="/collection/*" element={<CollectionDetail />} /> 70 <Route path="/privacy" element={<Privacy />} /> 71 <Route path="/terms" element={<Terms />} /> 72 </Routes> 73 </main> 74 </div> 75 <RightSidebar /> 76 <MobileNav /> 77 </div> 78 ); 79} 80 81export default function App() { 82 return ( 83 <ThemeProvider> 84 <AuthProvider> 85 <Routes> 86 <Route path="/*" element={<AppContent />} /> 87 </Routes> 88 </AuthProvider> 89 </ThemeProvider> 90 ); 91}