From 2975984104eee5bc474aef46548fe67a60a008c8 Mon Sep 17 00:00:00 2001 From: Adrian Altner Date: Tue, 21 Apr 2026 02:37:13 +0200 Subject: [PATCH] Implement multilingual support in footer and add legal pages --- src/components/Footer.astro | 45 ++++++++++- src/components/Header.astro | 21 ++++- src/i18n/ui.ts | 12 +++ src/layouts/BaseLayout.astro | 2 +- src/layouts/Prose.astro | 50 ++++++++++++ src/pages/datenschutz.md | 119 ++++++++++++++++++++++++++++ src/pages/en/contact.astro | 138 +++++++++++++++++++++++++++++++++ src/pages/en/imprint.md | 38 +++++++++ src/pages/en/privacy-policy.md | 119 ++++++++++++++++++++++++++++ src/pages/impressum.md | 38 +++++++++ src/pages/kontakt.astro | 138 +++++++++++++++++++++++++++++++++ src/styles/global.css | 7 ++ 12 files changed, 719 insertions(+), 8 deletions(-) create mode 100644 src/layouts/Prose.astro create mode 100644 src/pages/datenschutz.md create mode 100644 src/pages/en/contact.astro create mode 100644 src/pages/en/imprint.md create mode 100644 src/pages/en/privacy-policy.md create mode 100644 src/pages/impressum.md create mode 100644 src/pages/kontakt.astro diff --git a/src/components/Footer.astro b/src/components/Footer.astro index c4c7d84..7a87348 100644 --- a/src/components/Footer.astro +++ b/src/components/Footer.astro @@ -1,15 +1,52 @@ --- +import { DEFAULT_LOCALE, type Locale } from '~/consts'; +import { getLocaleFromUrl, localizePath, t } from '~/i18n/ui'; + +interface Props { + locale?: Locale; +} + +const locale: Locale = Astro.props.locale ?? getLocaleFromUrl(Astro.url) ?? DEFAULT_LOCALE; +const contactSegment = locale === 'de' ? 'kontakt' : 'contact'; +const imprintSegment = locale === 'de' ? 'impressum' : 'imprint'; +const privacySegment = locale === 'de' ? 'datenschutz' : 'privacy-policy'; + const today = new Date(); --- diff --git a/src/components/Header.astro b/src/components/Header.astro index f26f787..5e6a2c8 100644 --- a/src/components/Header.astro +++ b/src/components/Header.astro @@ -1,6 +1,6 @@ --- import type { CollectionEntry } from 'astro:content'; -import { DEFAULT_LOCALE, type Locale, SITE } from '~/consts'; +import { type Locale, SITE } from '~/consts'; import { aboutSegment, categoryIndexSegment, @@ -131,6 +131,12 @@ const switchHref = await resolveSwitchHref(); h2 { margin: 0; font-size: 1em; + text-align: left; + } + nav > h2 a { + display: block; + padding: 1em 0; + text-align: left; } h2 a, @@ -138,11 +144,20 @@ const switchHref = await resolveSwitchHref(); text-decoration: none; } nav { - display: flex; + display: grid; + grid-template-columns: auto 1fr auto; align-items: center; - justify-content: space-between; gap: 1em; } + nav > h2 { + justify-self: start; + } + nav > .internal-links { + justify-self: center; + } + nav > .toolbar { + justify-self: end; + } nav a { padding: 1em 0.5em; color: var(--black); diff --git a/src/i18n/ui.ts b/src/i18n/ui.ts index bf3e672..94aa759 100644 --- a/src/i18n/ui.ts +++ b/src/i18n/ui.ts @@ -19,6 +19,9 @@ export const ui = { 'tags.description': 'Alle Schlagwörter im Überblick.', 'tag.postsTagged': 'Beiträge mit', 'tag.noPosts': 'Noch keine Beiträge mit diesem Stichwort.', + 'footer.contact': 'Kontakt', + 'footer.imprint': 'Impressum', + 'footer.privacy': 'Datenschutz', 'lang.de': 'Deutsch', 'lang.en': 'English', }, @@ -40,6 +43,9 @@ export const ui = { 'tags.description': 'All tags at a glance.', 'tag.postsTagged': 'Posts tagged', 'tag.noPosts': 'No posts with this tag yet.', + 'footer.contact': 'Contact', + 'footer.imprint': 'Imprint', + 'footer.privacy': 'Privacy', 'lang.de': 'Deutsch', 'lang.en': 'English', }, @@ -82,6 +88,9 @@ const LOCALIZED_SEGMENTS: Record> = { about: 'ueber-mich', tag: 'schlagwort', tags: 'schlagwoerter', + contact: 'kontakt', + imprint: 'impressum', + 'privacy-policy': 'datenschutz', }, en: { kategorie: 'category', @@ -89,6 +98,9 @@ const LOCALIZED_SEGMENTS: Record> = { 'ueber-mich': 'about', schlagwort: 'tag', schlagwoerter: 'tags', + kontakt: 'contact', + impressum: 'imprint', + datenschutz: 'privacy-policy', }, }; diff --git a/src/layouts/BaseLayout.astro b/src/layouts/BaseLayout.astro index 3248167..1d5e3c9 100644 --- a/src/layouts/BaseLayout.astro +++ b/src/layouts/BaseLayout.astro @@ -66,6 +66,6 @@ const {
-