From 8da3c9229104b9da381ecb26ca1398b6a38db1f6 Mon Sep 17 00:00:00 2001 From: Korbs Date: Fri, 21 Jun 2024 21:34:31 -0400 Subject: [PATCH] Fix Astro Cookies for fallback --- src/components/global/Head.astro | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/components/global/Head.astro b/src/components/global/Head.astro index 0127d8f..e1da580 100644 --- a/src/components/global/Head.astro +++ b/src/components/global/Head.astro @@ -3,7 +3,14 @@ import i18next, { t } from "i18next"; import { Trans, HeadHrefLangs } from "astro-i18next/components"; -if (Astro.cookies.get("Language").value === undefined) {Astro.cookies.set("Language", "EN", {path: "/",sameSite: 'strict'})} +// Cookies +/// Language +//// If the user is new to the site, set English as default +if (Astro.cookies.get("Language") === undefined) { + Astro.cookies.set("Language", "EN", {path: "/",sameSite: 'strict'}) +} + +//// Check what language the user has set it to and switch to it var UserLanguage = Astro.cookies.get("Language").value if (UserLanguage === "JP") {i18next.changeLanguage("jp")} else if (UserLanguage === "EN") {i18next.changeLanguage("en")} @@ -13,11 +20,16 @@ const { Title, Description } = Astro.props + +// Components +import { ViewTransitions } from 'astro:transitions'; +import { fade } from "astro/virtual-modules/transitions.js"; --- + {Title}