diff --git a/src/components/Footer.astro b/src/components/Footer.astro index ee27196..8e80bcf 100644 --- a/src/components/Footer.astro +++ b/src/components/Footer.astro @@ -3,11 +3,14 @@ import { t } from '../i18n/ui'; import type { Locale } from '../lib/locale'; -// /en/ 侧由 T4 薄页传 locale='en';zh 路由无人传参,默认 zh 零回归 +// locale 感知:显式 prop 优先;无 prop 时构建期按页面 URL 推断轨道 +// (BaseLayout 引用本组件不透传 locale,靠 Astro.url 静态解析补全 en 轨) +import { localeOf } from '../lib/locale'; interface Props { locale?: Locale; } -const { locale = 'zh' } = Astro.props; +const { locale: propLocale } = Astro.props; +const locale = propLocale ?? localeOf(Astro.url.pathname); ---