diff --git a/.env b/.env deleted file mode 100755 index 1baa640a..00000000 --- a/.env +++ /dev/null @@ -1,10 +0,0 @@ -DATABASE_URL=postgresql://lowenware:lowenware@localhost:5434/lowenware -ORIGIN=http://localhost:3000 -FEEDBACK_NOTIFY_EMAIL=you@example.com -SMTP_HOST=localhost -SMTP_PORT=1025 -SMTP_USER= -SMTP_PASS= -SMTP_FROM=noreply@lowenware.com -# PUBLIC_INQUIRY_API_URL=https://my.lowenware.com/api/public/inquiries -PUBLIC_INQUIRY_API_URL=http://localhost:8081/api/public/inquiries diff --git a/.env.example b/.env.example index 1b68125a..781a8f3b 100644 --- a/.env.example +++ b/.env.example @@ -1,2 +1,2 @@ -ORIGIN=http://localhost:3000 +ORIGIN=https://lowenware.com PUBLIC_INQUIRY_API_URL=https://my.lowenware.com/api/inquiry diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ffbd5081..6264b5e4 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -28,6 +28,7 @@ jobs: node-version: ${{ matrix.node-version }} cache: npm - run: npm ci + - run: cp .env.example .env - run: npm run build - name: Upload run: rsync -avz ./build/ ${{ secrets.LOWENWARE_SSH_USER }}@${{ secrets.LOWENWARE_SSH_HOST }}:${{ vars.LOWENWARE_ROOT }}/${{ github.ref_name }}/ diff --git a/src/hooks.server.ts b/src/hooks.server.ts index 06c251c3..3b349f30 100644 --- a/src/hooks.server.ts +++ b/src/hooks.server.ts @@ -11,13 +11,6 @@ const redirectLegacy: Handle = async ({ event, resolve }) => { return resolve(event); }; -const rootRedirect: Handle = async ({ event, resolve }) => { - if (event.url.pathname === '/') { - throw redirect(302, `/${defaultLanguage}/`); - } - return resolve(event); -}; - const setHtmlLang: Handle = async ({ event, resolve }) => { const lang = (event.params.lang as Locale | undefined) ?? defaultLanguage; return resolve(event, { @@ -28,4 +21,4 @@ const setHtmlLang: Handle = async ({ event, resolve }) => { }); }; -export const handle = sequence(rootRedirect, redirectLegacy, setHtmlLang); +export const handle = sequence(redirectLegacy, setHtmlLang); diff --git a/src/lib/shared/locale-preference.ts b/src/lib/shared/locale-preference.ts new file mode 100644 index 00000000..d7beac7f --- /dev/null +++ b/src/lib/shared/locale-preference.ts @@ -0,0 +1,23 @@ +import { browser } from '$app/environment'; +import { defaultLanguage, isValidLocale, type Locale } from '$lib/shared/defaults'; + +export const STORAGE_KEY = 'preferred-locale'; + +export function savePreferredLocale(lang: Locale): void { + if (!browser) return; + localStorage.setItem(STORAGE_KEY, lang); +} + +export function resolvePreferredLocale(): Locale { + if (browser) { + const stored = localStorage.getItem(STORAGE_KEY); + if (stored && isValidLocale(stored)) return stored; + } + + if (browser) { + const nav = navigator.language.toLowerCase(); + if (nav.startsWith('cs') || nav.startsWith('sk')) return 'cs'; + } + + return defaultLanguage; +} diff --git a/src/lib/ui/layout/site-header.svelte b/src/lib/ui/layout/site-header.svelte index 14bc5b5d..e2722cc1 100644 --- a/src/lib/ui/layout/site-header.svelte +++ b/src/lib/ui/layout/site-header.svelte @@ -34,10 +34,11 @@ $effect(() => { if (!open) return; - const previousOverflow = document.body.style.overflow; - document.body.style.overflow = 'hidden'; + const root = document.documentElement; + const previousOverflow = root.style.overflow; + root.style.overflow = 'hidden'; return () => { - document.body.style.overflow = previousOverflow; + root.style.overflow = previousOverflow; }; }); @@ -75,17 +76,17 @@ - - {#if open} - - - {/if} +{#if open} + + +{/if} +