Spaces:
Running
Running
File size: 2,678 Bytes
227c43a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | import React, { useEffect } from 'react';
import { Routes, Route, useLocation } from 'react-router-dom';
import Home from './pages/Home';
import Plugin from './pages/Plugin';
import EnhancedPlugin from './pages/EnhancedPlugin';
import Glossary from './pages/Glossary';
import Category from './pages/Category';
import CircuitDesigner from './pages/CircuitDesigner';
import Error from './pages/Error';
import Navbar from './components/Navbar';
import Footer from './components/Footer';
import FloatingActionButton from './components/FloatingActionButton';
import ErrorBoundary from './components/ErrorBoundary';
import analytics from './services/analytics';
function App() {
const location = useLocation();
// Initialize Google Analytics
useEffect(() => {
analytics.initialize();
}, []);
// Track page views on route changes
useEffect(() => {
const getPageTitle = (pathname) => {
const routes = {
'/': 'Home - GXS QuantumNexus',
'/glossary': 'Glossary - GXS QuantumNexus',
'/circuit-designer': 'Circuit Designer - GXS QuantumNexus'
};
// Handle dynamic routes
if (pathname.startsWith('/plugin/')) {
const pluginKey = pathname.split('/')[2];
return `${pluginKey} Plugin - GXS QuantumNexus`;
}
if (pathname.startsWith('/legacy-plugin/')) {
const pluginKey = pathname.split('/')[2];
return `${pluginKey} Legacy Plugin - GXS QuantumNexus`;
}
if (pathname.startsWith('/category/')) {
const category = pathname.split('/')[2];
return `${category} Category - GXS QuantumNexus`;
}
return routes[pathname] || 'GXS QuantumNexus';
};
const title = getPageTitle(location.pathname);
analytics.trackPageView(location.pathname, title);
}, [location]);
return (
<ErrorBoundary>
<div className="App app-shell min-h-screen bg-base-100 text-base-content">
<Navbar />
<main>
<Routes>
<Route path="/" element={<Home />} />
<Route path="/plugin/:pluginKey" element={<EnhancedPlugin />} />
<Route path="/legacy-plugin/:pluginKey" element={<Plugin />} />
<Route path="/glossary" element={<Glossary />} />
<Route path="/category/:category" element={<Category />} />
<Route path="/circuit-designer" element={<CircuitDesigner />} />
<Route path="*" element={<Error />} />
</Routes>
</main>
<Footer />
<FloatingActionButton />
</div>
</ErrorBoundary>
);
}
export default App; |