From 0105f1576dff9c266b4127d7111ef1d8ff040ab1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Asger=20Geel=20Weirs=C3=B8e?= Date: Thu, 29 Oct 2026 18:24:00 +0100 Subject: [PATCH] Put the language switch in the header on every translated page Claude-Session: https://claude.ai/code/session_012LCTmU2ewo8tnM1dByYAoG --- src/components/Header.astro | 8 +++++++- src/components/ProjektSide.astro | 14 +++++--------- src/layouts/Base.astro | 2 +- src/pages/chat.astro | 5 +---- src/pages/cv.astro | 5 +---- src/pages/en/chat.astro | 5 +---- src/pages/en/cv.astro | 5 +---- src/pages/en/index.astro | 7 ++----- src/pages/en/projects/index.astro | 5 +---- src/pages/index.astro | 1 - 10 files changed, 20 insertions(+), 37 deletions(-) diff --git a/src/components/Header.astro b/src/components/Header.astro index 78e4734..524c5ea 100644 --- a/src/components/Header.astro +++ b/src/components/Header.astro @@ -1,6 +1,8 @@ --- import { NAV, NAV_EN, SITE } from '../consts'; -const { lang } = Astro.props as { lang?: 'da' | 'en' }; +const { lang, alternates = [] } = Astro.props as { lang?: 'da' | 'en'; alternates?: { lang: 'da' | 'en'; path: string }[] }; +// Sprogskiftet bor KUN her: findes siden på det andet sprog (sidens alternates), linkes der til den. +const andet = alternates.find((a) => a.lang !== (lang ?? 'da')); const nav = lang === 'en' ? NAV_EN : NAV; const home = lang === 'en' ? '/en' : '/'; const path = Astro.url.pathname.replace(/\/$/, '') || '/'; @@ -23,6 +25,10 @@ const isActive = (href: string) => (href === '/' || href === '/en' ? path === hr ))} + {andet && ( + {andet.lang === 'en' ? 'English' : 'Dansk'} + )}