From 75fa22e208ad2f571005764b6661e65c05a70550 Mon Sep 17 00:00:00 2001 From: arsam Date: Fri, 18 Sep 2026 23:27:11 +0330 Subject: [PATCH] Import source: global/src/global-app Import the existing local project snapshot. This commit organizes existing files; it does not represent newly developed functionality. --- global/src/global-app.jsx | 70 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 global/src/global-app.jsx diff --git a/global/src/global-app.jsx b/global/src/global-app.jsx new file mode 100644 index 0000000..b8f7001 --- /dev/null +++ b/global/src/global-app.jsx @@ -0,0 +1,70 @@ +import { useState, useEffect } from 'react'; +import { ToastProvider, NavProvider, AuthProvider, useNav, Header, Footer, PushPrompt } from './global-ui.jsx'; +import HomePage from './global-home.jsx'; +import ArticlePage, { ArticlesListPage } from './global-articles.jsx'; +import { AboutPage, PrivacyPage, TermsPage, EditorialPage, NotFoundPage, PersianOnlyPage, CategoryPage } from './global-pages.jsx'; + +function getRoute() { + const path = window.location.pathname; + const search = window.location.search; + if (path === '/' || path === '') return { page: 'home' }; + if (path === '/articles') return { page: 'articles', q: new URLSearchParams(search).get('q') || '' }; + if (path.startsWith('/article/')) return { page: 'article', slug: path.replace('/article/', '').replace(/\/$/, '') }; + if (path.startsWith('/category/')) return { page: 'category', cat: path.replace('/category/', '').replace(/\/$/, '') }; + if (path === '/about') return { page: 'about' }; + if (path === '/privacy') return { page: 'privacy' }; + if (path === '/terms') return { page: 'terms' }; + if (path === '/editorial-policy') return { page: 'editorial' }; + if (path === '/persian-only') return { page: 'persian-only' }; + return { page: '404' }; +} + +function AppInner() { + const { page: navPage, navigate } = useNav(); + const [route, setRoute] = useState(getRoute()); + + useEffect(() => { + function onPop() { setRoute(getRoute()); } + window.addEventListener('popstate', onPop); + return () => window.removeEventListener('popstate', onPop); + }, []); + + // Keep route in sync when NavProvider navigate() is called + useEffect(() => { setRoute(getRoute()); }, [navPage]); + + function renderPage() { + switch (route.page) { + case 'home': return ; + case 'articles': return ; + case 'article': return ; + case 'category': return ; + case 'about': return ; + case 'privacy': return ; + case 'terms': return ; + case 'editorial': return ; + case 'persian-only': return ; + default: return ; + } + } + + return ( +
+
+
{renderPage()}
+
+ +
+ ); +} + +export default function App() { + return ( + + + + + + + + ); +}