Keep language switcher on the same page when switching#46
Merged
Conversation
The nav language links pointed unconditionally at / and /de, so switching language on the imprint page dumped you back on the homepage instead of the equivalent /de/impressum or /en/imprint. Extract a shared LangSwitcher component that reads the current location and links each language to the equivalent page in the other tree. The en/de page pairs are derived from the existing PAGES record in seo-links.ts, so it stays a single source of truth alongside the canonical/hreflang links and the sitemap — a new bilingual page added there now flows into the switcher too. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
What
The nav language links pointed unconditionally at
/and/de. Switching language on the imprint page therefore dumped you back on the homepage instead of the equivalent/de/impressumor/en/imprint.This extracts a shared
LangSwitchercomponent that reads the current location and links each language to the equivalent page in the other tree, preserving your place.Why it's tidy
The en/de page pairs are derived from the existing
PAGESrecord inseo-links.ts— already the single source of truth for canonical/hreflang<link>s and the sitemap. A new bilingual page added there now flows into the switcher too, with no duplicated path constants.Notes for reviewer
layout.tsxandlayout-de.tsxnow render<LangSwitcher />instead of duplicating the hard-coded links.NavLinkusesendso the active-highlight (lang-left/lang-right) reflects the current language exactly on each page./,/de,/en/imprint,/de/impressum): each language links to its same-page equivalent with the correct active state. Typecheck passes.🤖 Generated with Claude Code