fix(rank): 热门文档榜链接补 locale 前缀,修 /content/ 死链#362
Merged
Conversation
后端 top-docs 返回的 path 是无 locale 的 canonical(/docs/...)。HotDocsTab /
HotDocsPreview 之前直接 <Link href={doc.path}>,配合后端旧 bug 渲染出
/en/content/docs/... 死链。
新增 lib/top-doc-href.ts:拼当前 locale 前缀 + 防御性剥掉残留 content/ 前缀,
两个组件共用。即使后端某次回退到旧格式也不会再拼出 404。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
/en/rank?tab=hot热门文档榜(及首页"本周最热")的链接点进去 404,URL 形如/en/content/docs/learn/ai。根因
HotDocsTab/HotDocsPreview直接<Link href={doc.path}>渲染后端返回的 path。后端 top-docs 的 canonical 本应是无 locale 的/docs/...,需前端补当前 locale 前缀;而后端旧 bug 还会泄漏content/前缀,叠加成/en/content/docs/...死链。修复
lib/top-doc-href.ts:topDocHref(locale, path)拼当前 locale 前缀,并防御性剥掉可能残留的content/前缀和多余前导斜杠(后端若回退旧格式也不会再拼出 404)。HotDocsTab、HotDocsPreview改用useLocale()+topDocHref。验证
/{locale}/docs/...。🤖 Generated with Claude Code