2026-10-04 09:34:55 +07:00
|
|
|
import './App.css'
|
2026-10-18 23:45:47 +07:00
|
|
|
import { lazy, Suspense } from 'react'
|
2026-10-22 09:55:24 +07:00
|
|
|
import type { ReactNode } from 'react'
|
|
|
|
|
import { BrowserRouter, Routes, Route, useLocation } from 'react-router'
|
2026-10-06 11:42:11 +07:00
|
|
|
import { ThemeProvider } from '@/hooks/useTheme'
|
|
|
|
|
import { Layout } from '@/components/layout/Layout'
|
2026-10-14 11:15:48 +07:00
|
|
|
import { LanguageProvider } from '@/hooks/useLanguage'
|
2026-10-22 07:29:06 +07:00
|
|
|
import { I18nProvider } from '@/i18n/provider'
|
2026-10-18 23:45:47 +07:00
|
|
|
import { HomePage } from '@/pages/HomePage'
|
|
|
|
|
|
|
|
|
|
// HomePage stays eager: it is the landing route and owns the LCP, so its code must
|
|
|
|
|
// already be in the entry chunk. The other six split out and load on navigation.
|
|
|
|
|
const AboutPage = lazy(() => import('@/pages/AboutPage').then((m) => ({ default: m.AboutPage })))
|
|
|
|
|
const ExperiencePage = lazy(() => import('@/pages/ExperiencePage').then((m) => ({ default: m.ExperiencePage })))
|
|
|
|
|
const ProjectsListPage = lazy(() => import('@/pages/ProjectsListPage').then((m) => ({ default: m.ProjectsListPage })))
|
|
|
|
|
const ProjectDetailPage = lazy(() => import('@/pages/ProjectDetailPage').then((m) => ({ default: m.ProjectDetailPage })))
|
|
|
|
|
const PhilosophyPage = lazy(() => import('@/pages/PhilosophyPage').then((m) => ({ default: m.PhilosophyPage })))
|
2026-10-22 09:55:24 +07:00
|
|
|
|
2026-10-18 23:45:47 +07:00
|
|
|
const ContactPage = lazy(() => import('@/pages/ContactPage').then((m) => ({ default: m.ContactPage })))
|
2026-10-04 09:34:55 +07:00
|
|
|
|
2026-10-22 09:55:24 +07:00
|
|
|
// Edit mode is lazy too: visitors never download the draft store, the panel
|
|
|
|
|
// or the save pipeline (spec-v4 §7 P3.4). The gate only mounts the shell when
|
|
|
|
|
// `?edit` is present; the shell then authenticates or strips the query again.
|
|
|
|
|
const EditModeShell = lazy(() => import('@/components/layout/EditModeShell'))
|
|
|
|
|
|
|
|
|
|
function MaybeEditMode({ children }: { children: ReactNode }) {
|
|
|
|
|
const location = useLocation()
|
|
|
|
|
const editing = new URLSearchParams(location.search).has('edit')
|
|
|
|
|
if (!editing) return <>{children}</>
|
|
|
|
|
return (
|
|
|
|
|
<Suspense fallback={null}>
|
|
|
|
|
<EditModeShell>{children}</EditModeShell>
|
|
|
|
|
</Suspense>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-04 09:34:55 +07:00
|
|
|
function App() {
|
|
|
|
|
return (
|
2026-10-14 11:15:48 +07:00
|
|
|
<BrowserRouter>
|
|
|
|
|
<ThemeProvider>
|
|
|
|
|
<LanguageProvider>
|
2026-10-22 07:29:06 +07:00
|
|
|
{/* I18nProvider sits below LanguageProvider: it resolves the language
|
|
|
|
|
through useLanguage and hands every consumer the UI/CONTENT of it. */}
|
|
|
|
|
<I18nProvider>
|
2026-10-22 09:55:24 +07:00
|
|
|
<MaybeEditMode>
|
|
|
|
|
<Layout>
|
|
|
|
|
{/* A null fallback keeps the shell (nav, footer) painted without reserving a
|
|
|
|
|
box that would shift the page when the route chunk lands. */}
|
|
|
|
|
<Suspense fallback={null}>
|
|
|
|
|
<Routes>
|
|
|
|
|
<Route path="/" element={<HomePage />} />
|
|
|
|
|
<Route path="/about" element={<AboutPage />} />
|
|
|
|
|
<Route path="/experience" element={<ExperiencePage />} />
|
|
|
|
|
<Route path="/projects" element={<ProjectsListPage />} />
|
|
|
|
|
<Route path="/projects/:id" element={<ProjectDetailPage />} />
|
|
|
|
|
<Route path="/philosophy" element={<PhilosophyPage />} />
|
|
|
|
|
<Route path="/contact" element={<ContactPage />} />
|
|
|
|
|
</Routes>
|
|
|
|
|
</Suspense>
|
|
|
|
|
</Layout>
|
|
|
|
|
</MaybeEditMode>
|
2026-10-22 07:29:06 +07:00
|
|
|
</I18nProvider>
|
2026-10-18 23:45:47 +07:00
|
|
|
</LanguageProvider>
|
|
|
|
|
</ThemeProvider>
|
2026-10-14 11:15:48 +07:00
|
|
|
</BrowserRouter>
|
2026-10-04 09:34:55 +07:00
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default App
|