fix(i18n): localePath 三处双 en 一刀治+canonical 全量(blog-5f T2/T3 车道收编)
- T2:localePath 先归一 zh 再拼前缀(Header/CommandPalette/
BaseLayout 三处 /en/en/ 同源病根一刀),返回值统一尾斜杠;
BaseLayout 自指 canonical 全量 35 页;E2E 新增 en canonical
自指断言(33→34)
- T3:content-lint.mjs 零依赖三检(断链 FAIL/缺图 FAIL/zh-en
配对 WARN;CONTENT_LINT 逃生门;photos-originals 叠加层与
/admin 单语两误报已修);prod-smoke.sh 三断言(robots 未落明
确 FAIL 不静默);build.sh 守卫行挂载(smoke 对 staging 首版
容忍,T1 robots 上线后转硬门,触发条件注释在案)
- tasks.md verify 字面量 33→34 联动同步(6 处)
车道:op-gitea(verify 六条实录);收编验收:E2E 34/34+产物零
/en/en/+lint 0/0/0 实跑复现
验证: node tests/e2e.mjs 34/34 PASS;! grep -r /en/en/ dist/;
content-lint 三检 0 违例;bash -n+test -x 过
Spec: 2026-10-26_blog-5f
Co-authored-by: GLM-5.3
This commit is contained in:
1 parent
8ec1712135
commit
c307285a25
7 files changed
+131
-9
No files matched your search
@@ -30,6 +30,8 @@ const rawPath = Astro.url.pathname.replace(/\/index\.html$/, '');
|
||||
const zhPath = localeOf(rawPath) === 'en' ? localePath(rawPath, 'zh') : rawPath;
|
||||
const enPath = localePath(rawPath, 'en');
|
||||
const withSlash = (p: string) => (p.endsWith('/') ? p : `${p}/`);
|
||||
// 自指 canonical(T2):SEO 权重收敛到当前页自身,与 hreflang 组合覆盖双轨
|
||||
const canonicalUrl = new URL(withSlash(rawPath), Astro.site).href;
|
||||
---
|
||||
|
||||
<!doctype html>
|
||||
@@ -87,6 +89,7 @@ const withSlash = (p: string) => (p.endsWith('/') ? p : `${p}/`);
|
||||
addEventListener('load', () => navigator.serviceWorker.register('/sw.js'));
|
||||
}
|
||||
</script>
|
||||
<link rel="canonical" href={canonicalUrl} />
|
||||
<link rel="alternate" hreflang="zh" href={new URL(withSlash(zhPath), Astro.site)} />
|
||||
<link rel="alternate" hreflang="en" href={new URL(withSlash(enPath), Astro.site)} />
|
||||
<link rel="alternate" hreflang="x-default" href={new URL(withSlash(zhPath), Astro.site)} />
|
||||
|
||||
Reference in new issue
Block a user