You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2.3 KiB
2.3 KiB
bashi-website — Migrated to Pure React (Vite + React Router)
The site was migrated from Astro 5 to a pure React SPA (Vite + React Router + Tailwind v4), so every page route is now a real .tsx file as requested.
What changed
- Removed: all
.astrofiles (src/pages/*.astro,src/pages/en/*.astro,src/layouts/BaseLayout.astro),astro.config.mjs, andscripts/. Zero Astro dependencies remain inpackage.json. - Added: Vite + React Router toolchain,
src/main.tsx,src/App.tsx(routes),src/layout/RootLayout.tsx,src/hooks/useClientEffects.ts,src/seo/Seo.tsx, and 8src/pages/*.tsxroute wrappers. - Reused unchanged:
src/styles/global.css(full BaskBuddy design system), all existing React components (Home/About/Business/Contact/Innovation/Join/Privacy/NotFound/Header/Footer/SiteShell), and the i18n catalogs (zh.ts/en.ts).
Architecture
zhat/&/{page},enat/en/{page}, unknown paths → 404.RootLayoutkeepsHeader/Footermounted across navigations and replays thepage-enteranimation on routed content.useClientEffects(pathname)ports the interaction logic that previously lived in Astro's<script>: flip-cards (About ICIDP), scroll-reveal (staggered), stat counters (.stat-value[data-target]), and copy-to-clipboard (Contact). The dead#star-fieldgeneration was dropped.Seorecreates the per-page<head>(title, description, canonical, hreflang alternates, OG/Twitter cards, Organization JSON-LD) via direct DOM updates — faithful to the original Astro output.Headermobile menu now uses ReactuseStateinstead of the old id-based global script toggle.
Verification
npm run build→ 60 modules transformed, cleandist/.npx tsc --noEmit→ 0 type errors.- Dev server live at http://localhost:4321 —
/,/about,/en/innovation,/en,/privacyand all assets return HTTP 200 (SPA fallback works).
Notes / tradeoffs
- SPA SEO: meta is set client-side (JS-executing crawlers are fine). For production, configure the host with an SPA fallback (Vite dev/preview already do this).
- A sandbox safe-delete guard blocks Vite from bulk-clearing
node_modules/.vite/deps; resolved by redirecting Vite'scacheDirto the OS temp dir invite.config.ts. - Run:
npm run dev(4321) ·npm run build·npm run preview.