feat: reset to selection page when switching language on category/tag pages
Some checks failed
CI / update (push) Has been cancelled

When switching languages on specific category or tag pages, redirect to
the selection page instead of trying to maintain the same category/tag,
since category and tag names differ between languages. Icon pages continue
to swap directly since icons are consistent across languages.
This commit is contained in:
2026-01-02 18:52:06 +01:00
parent 7877e0bc64
commit f22b8d86be

View File

@@ -63,7 +63,13 @@
// Convert current path to target language (for non-recipe pages)
let newPath = path;
if (lang === 'en' && path.startsWith('/rezepte')) {
// Special handling for category and tag pages - reset to selection page
// Icons are consistent across languages, so they can be swapped directly
if (path.match(/\/(rezepte|recipes)\/(category|tag)\//)) {
const pathType = path.match(/\/(category|tag)\//)?.[1];
newPath = lang === 'en' ? `/recipes/${pathType}` : `/rezepte/${pathType}`;
} else if (lang === 'en' && path.startsWith('/rezepte')) {
newPath = path.replace('/rezepte', '/recipes');
} else if (lang === 'de' && path.startsWith('/recipes')) {
newPath = path.replace('/recipes', '/rezepte');