fix: language switch matches translated page, translate TOC, fix 404#34
Merged
Conversation
- LangToggle now reads <link rel="alternate" hreflang> from the DOM
instead of doing a naive path substitution, so switching language on
a blog post navigates to the correct translated slug
(e.g. /en/posts/docker-installation/ → /es/posts/docker-installation-es/)
- [...slug].astro computes the translated post at build time and passes
the correct alternate URLs through BlogPost → Base → BaseHead, which
emits accurate hreflang tags (also a SEO improvement)
- TOC component now uses the i18n translation system ("toc.title")
instead of the hardcoded English string "Table of Contents"
- Root 404 redirects client-side to the locale-specific 404 page
(detected from URL prefix, lang cookie, or browser language) instead
of displaying both languages at once
https://claude.ai/code/session_01Ue6yERWgLpZpLmVfqqSY3E
|
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.
$(cat <<'EOF'
Summary
LangTogglereads<link rel="alternate" hreflang>from the document head instead of doing a naive path substitution. For blog posts, the[...slug].astropage computes the translated post slug at build time and passes the correct alternate URLs down throughBlogPost → Base → BaseHead, which emits accuratehreflangtags (e.g./en/posts/docker-installation/↔/es/posts/docker-installation-es/). This also improves SEO.TOCcomponent was hardcoded to"Table of Contents". It now accepts alocaleprop and uses the i18nt("toc.title")translation key ("Tabla de contenidos"in Spanish).langcookie, or browser language) and redirects to the locale-specific 404 page (/en/404or/es/404).Test plan
/en/posts/docker-installation/, click the language switcher → should navigate to/es/posts/docker-installation-es/(not 404)/es/posts/docker-installation-es/, click the language switcher → should navigate to/en/posts/docker-installation//es/...shows the Spanish 404 (not both languages)https://claude.ai/code/session_01Ue6yERWgLpZpLmVfqqSY3E
EOF
)
Generated by Claude Code