|
| 1 | +import * as React from 'react'; |
| 2 | +import { BrowserRouter, Navigate, Route, Routes } from 'react-router-dom'; |
| 3 | +import { SiteShell } from '../components/site-shell'; |
| 4 | + |
| 5 | +const HomePage = React.lazy(() => |
| 6 | + import('../pages/home-page/home-page').then(module => ({ |
| 7 | + default: module.HomePage, |
| 8 | + })) |
| 9 | +); |
| 10 | +const DocumentationPage = React.lazy(() => |
| 11 | + import('../pages/documentation-page/documentation-page').then(module => ({ |
| 12 | + default: module.DocumentationPage, |
| 13 | + })) |
| 14 | +); |
| 15 | +const ApiPage = React.lazy(() => |
| 16 | + import('../pages/api-page/api-page').then(module => ({ |
| 17 | + default: module.ApiPage, |
| 18 | + })) |
| 19 | +); |
| 20 | +const DemoPage = React.lazy(() => |
| 21 | + import('../pages/demo-page/demo-page').then(module => ({ |
| 22 | + default: module.DemoPage, |
| 23 | + })) |
| 24 | +); |
| 25 | + |
| 26 | +const basename = |
| 27 | + import.meta.env.BASE_URL === '/' |
| 28 | + ? undefined |
| 29 | + : import.meta.env.BASE_URL.replace(/\/$/, ''); |
| 30 | + |
| 31 | +export const App: React.FC = () => ( |
| 32 | + <BrowserRouter basename={basename}> |
| 33 | + <React.Suspense fallback={null}> |
| 34 | + <Routes> |
| 35 | + <Route element={<SiteShell />}> |
| 36 | + <Route path="/" element={<HomePage />} /> |
| 37 | + <Route path="/demo" element={<DemoPage />} /> |
| 38 | + <Route path="/api" element={<ApiPage />} /> |
| 39 | + <Route path="/api/builder" element={<ApiPage />} /> |
| 40 | + <Route path="/api/fields" element={<ApiPage />} /> |
| 41 | + <Route path="/api/data" element={<ApiPage />} /> |
| 42 | + <Route path="/api/builder-props" element={<Navigate to="/api/builder" replace />} /> |
| 43 | + <Route path="/api/components" element={<ApiPage />} /> |
| 44 | + <Route path="/api/theming" element={<ApiPage />} /> |
| 45 | + <Route path="/api/format-query" element={<ApiPage />} /> |
| 46 | + <Route path="/api/parse-query" element={<ApiPage />} /> |
| 47 | + <Route path="/documentation" element={<DocumentationPage />} /> |
| 48 | + <Route path="/documentation/installation" element={<DocumentationPage />} /> |
| 49 | + <Route path="/documentation/usage" element={<DocumentationPage />} /> |
| 50 | + <Route path="/documentation/components" element={<DocumentationPage />} /> |
| 51 | + <Route |
| 52 | + path="/documentation/parsing-and-formatting" |
| 53 | + element={<DocumentationPage />} |
| 54 | + /> |
| 55 | + <Route |
| 56 | + path="/documentation/parsing-and-formatting/sql" |
| 57 | + element={ |
| 58 | + <Navigate |
| 59 | + to="/documentation/parsing-and-formatting/supported-formats" |
| 60 | + replace |
| 61 | + /> |
| 62 | + } |
| 63 | + /> |
| 64 | + <Route |
| 65 | + path="/documentation/parsing-and-formatting/mongo" |
| 66 | + element={ |
| 67 | + <Navigate |
| 68 | + to="/documentation/parsing-and-formatting/supported-formats" |
| 69 | + replace |
| 70 | + /> |
| 71 | + } |
| 72 | + /> |
| 73 | + <Route |
| 74 | + path="/documentation/parsing-and-formatting/other-formats" |
| 75 | + element={ |
| 76 | + <Navigate |
| 77 | + to="/documentation/parsing-and-formatting/supported-formats" |
| 78 | + replace |
| 79 | + /> |
| 80 | + } |
| 81 | + /> |
| 82 | + <Route |
| 83 | + path="/documentation/parsing-and-formatting/supported-formats" |
| 84 | + element={<DocumentationPage />} |
| 85 | + /> |
| 86 | + <Route |
| 87 | + path="/documentation/configuration/fields" |
| 88 | + element={<Navigate to="/api/fields" replace />} |
| 89 | + /> |
| 90 | + <Route |
| 91 | + path="/documentation/configuration/data" |
| 92 | + element={<Navigate to="/api/data" replace />} |
| 93 | + /> |
| 94 | + <Route |
| 95 | + path="/documentation/configuration/builder-props" |
| 96 | + element={<Navigate to="/api/builder" replace />} |
| 97 | + /> |
| 98 | + <Route |
| 99 | + path="/documentation/configuration/components" |
| 100 | + element={<Navigate to="/documentation/components" replace />} |
| 101 | + /> |
| 102 | + <Route path="/documentation/theming" element={<DocumentationPage />} /> |
| 103 | + <Route |
| 104 | + path="/documentation/localization" |
| 105 | + element={<DocumentationPage />} |
| 106 | + /> |
| 107 | + <Route path="*" element={<Navigate to="/" replace />} /> |
| 108 | + </Route> |
| 109 | + </Routes> |
| 110 | + </React.Suspense> |
| 111 | + </BrowserRouter> |
| 112 | +); |
0 commit comments