Conversation
- Nav templates (side-nav, header-nav, mobile-drawer), note/tag back links now emit /en_US/... instead of the stale /en/... prefix, which caused 404s when navigating after switching language. - site.go: hreflang alternates and tag link prefix; render.go: tagURL template func. - theme.ts: detect English pages via /en_US prefix. - settings-overlay.ts: match hyphenated html lang (en-US) so the settings overlay syncs to English after SPA navigation.
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.
问题
942e18d(refactor: completely replace zh-CN and en with zh_CN and en_US)把语言代码从en迁移到en_US后,部分 URL 前缀没有被同步更新,英文站存在指向已不存在的/en/...路径的链接,导致 404。复现步骤
/en_US//en/notes/→ 404 Not Found根因
模板中的判断条件更新成了新语言代码
en_US,但 href 里的 URL 前缀仍是硬编码的旧前缀/en:href="{{if eq .Lang "en_US"}}/en{{end}}/notes/"而 Go 侧生成内容的实际前缀是
en_US(site.go中langPrefix = "en_US"),两边不一致。修复内容
side-nav.html/header-nav.html/mobile-drawer.html各 5 个导航链接/en→/en_USnote.html/tag.html的返回链接site.gohreflang alternates(altPrefix)/en→en_USsite.gocollectTagLinksForLang(langPrefix)/en→en_USrender.gotagURL模板函数/en→/en_UStheme.ts英文页判断startsWith('/en')→startsWith('/en_US')(原写法碰巧能匹配/en_US,改为精确匹配)settings-overlay.tssyncLanguagetoLowerCase().startsWith('en_US')永远无法匹配<html lang>的连字号值en-US,导致 SPA 跳转后设置面板文案不随语言切换;改为startsWith('en')internal/embedded/static/js/下两个受影响的产物(theme.js、settings-overlay.js)已通过npm run build:js重新生成。验证
npm ci && npm run typecheck && npm run build:js通过/en_US/...;全站grep 'href="/en/'结果为 0go build ./...、go test ./...通过