Commit 916a6e8
committed
fix(seo): 修复排行榜链接全 404 + 补段化前旧 URL 的 301
排行榜每条链接都 404:generate-leaderboard 从文件路径手拼 URL,没跟上
2026-05 的 i18n 段化——少 /zh|/en 前缀、保留 .en/.zh 后缀和 /index、leetcode
没拼音化。重写 buildCanonicalDocUrl 产出真实 canonical:按后缀选 locale 前缀、
去 /index、leetcode 按题号指向英文版 /en(中文翻译文件名经 fumadocs 解析后
slug 不可预测,英文 ASCII slug 一定 200),并过滤内容树里已不存在的孤儿 docId
死链。dev server 实测 153/153 链接全部 200(原 0/153)。
GSC 上百条 .en/.zh 后缀旧 URL(最大一类 404):在 next.config redirects 补 301
(必须放这而非 proxy.ts——proxy matcher 排除带点路径,.en/.zh 后缀全带点碰不到
中间件)。含 .en/.zh 后缀剥离、/index 剥离、裸 /computer-science 映射、no-locale
/docs 兜底。六类重定向 curl 实测均单跳 301 到正确 canonical。
脚本因导入 lib/leetcode-slug.ts 改用 node 跑 .mts(tsx 在 Node 24 下解析 .ts
具名导出报错),prebuild 同步改。1 parent d21f336 commit 916a6e8
5 files changed
Lines changed: 1742 additions & 935 deletions
File tree
- dev_docs
- generated
- scripts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
280 | 280 | | |
281 | 281 | | |
282 | 282 | | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
283 | 313 | | |
284 | 314 | | |
285 | 315 | | |
| |||
0 commit comments