feat(i18n): implement astro i18n integration and refactor locale handling

- Add i18n configuration to astro.config.mjs with default locale and routing
- Refactor language handling to use Astro.currentLocale instead of URL parsing
- Update tsconfig to include only necessary files for better type checking
- Improve LanguageSwitcher to handle routing based on astro i18n config
- Add new translation keys and update components to use dynamic titles
- Simplify MotionWrapper component by removing unused default animations
This commit is contained in:
joyzhao
2025-06-15 17:20:29 +08:00
parent 22799c9d8a
commit 1476f4eeec
9 changed files with 110 additions and 53 deletions

View File

@@ -1,5 +1,4 @@
---
import { getLangFromUrl } from "@/i18n/utils";
import Layout from "@/layouts/Layout.astro";
import GlassHeader from "@/components/GlassHeader";
import HeroSection from "@/components/HeroSection";
@@ -7,11 +6,15 @@ import ExperienceSection from "@/components/ExperienceSection";
import SkillsSection from "@/components/SkillsSection";
import ProjectsSection from "@/components/ProjectsSection";
import Footer from "@/components/Footer";
import { useTranslations, type Lang } from "@/i18n/utils";
import { defaultLang } from "@/i18n/ui";
const lang = getLangFromUrl(Astro.url);
const lang: Lang = defaultLang;
const t = useTranslations(lang);
const pageTitle = t('page.home.title');
---
<Layout title="Home" lang={lang}>
<Layout title={pageTitle}>
<GlassHeader lang={lang} client:only="react" />
<main class="min-h-screen">
<HeroSection lang={lang} client:only="react" />