diff --git a/src/layouts/Footer.astro b/src/layouts/Footer.astro index 7072c99..cfe1c44 100644 --- a/src/layouts/Footer.astro +++ b/src/layouts/Footer.astro @@ -8,7 +8,6 @@ import config from '@config'; import NavBar from '@layouts/NavBar.astro'; import { getCustomNavbar, getDefaultNavbar, getPages } from '@utils/nav'; import { toBackgroundClass } from '@utils/pageBuilder'; -import { getCurrentURL, setCacheControl } from '@utils/url'; import clsx from 'clsx'; import _ from 'underscore'; @@ -18,6 +17,7 @@ const { customContent, login, logos, + pathname, privacyUrl, termsUrl, title @@ -26,7 +26,6 @@ const { const year = new Date().getFullYear(); const currentLocale = Astro.currentLocale; -const currentUrl = getCurrentURL(Astro.request.headers); const [{ t }, navbar, pages] = await Promise.all([ getTranslations(currentLocale), @@ -37,13 +36,11 @@ const [{ t }, navbar, pages] = await Promise.all([ let items; if (navbar && navbar.items) { - items = getCustomNavbar(navbar, currentLocale, currentUrl.pathname); + items = getCustomNavbar(navbar, currentLocale, pathname); } else { - items = getDefaultNavbar(pages, currentLocale, currentUrl.pathname, t); + items = getDefaultNavbar(pages, currentLocale, pathname, t); } -setCacheControl(Astro.response.headers); - --- { !custom && ( diff --git a/src/layouts/Header.astro b/src/layouts/Header.astro index f54b73c..d3692fa 100644 --- a/src/layouts/Header.astro +++ b/src/layouts/Header.astro @@ -1,78 +1,56 @@ --- -import { getTranslations } from '@backend/i18n'; -import { fetchNavbar } from '@backend/tina'; -import LanguagePicker from '@components/LanguagePicker'; -import MobileHeader from '@components/MobileHeader'; -import NavBar from '@layouts/NavBar.astro'; -import { getCustomNavbar, getDefaultNavbar, getPages } from '@utils/nav'; -import { getCurrentURL, setCacheControl } from '@utils/url'; -import { getRelativeLocaleUrl, getRelativeLocaleUrlList } from 'astro:i18n'; -import clsx from 'clsx'; +import { getTranslations } from "@backend/i18n"; +import { fetchNavbar } from "@backend/tina"; +import LanguagePicker from "@components/LanguagePicker"; +import MobileHeader from "@components/MobileHeader"; +import NavBar from "@layouts/NavBar.astro"; +import { getCustomNavbar, getDefaultNavbar, getPages } from "@utils/nav"; +import { getRelativeLocaleUrl, getRelativeLocaleUrlList } from "astro:i18n"; +import clsx from "clsx"; const locales = getRelativeLocaleUrlList(); const currentLocale = Astro.currentLocale; -const currentUrl = getCurrentURL(Astro.request.headers); -const { - fullscreen, - image, - imageAlt, - title, - transparent -} = Astro.props; +const { fullscreen, image, imageAlt, pathname, title, transparent } = + Astro.props; const [{ t }, navbar, pages] = await Promise.all([ getTranslations(currentLocale), fetchNavbar(currentLocale), - getPages(currentLocale) + getPages(currentLocale), ]); let items; if (navbar && navbar.items) { - items = getCustomNavbar(navbar, currentLocale, currentUrl.pathname); + items = getCustomNavbar(navbar, currentLocale, pathname); } else { - items = getDefaultNavbar(pages, currentLocale, currentUrl.pathname, t); + items = getDefaultNavbar(pages, currentLocale, pathname, t); } - -setCacheControl(Astro.response.headers); - ---
- { image && ( - {imageAlt} - )} - { title && ( -

- { title } -

- )} + {image && {imageAlt}} + {title &&

{title}

}
@@ -87,7 +65,7 @@ setCacheControl(Astro.response.headers); diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index 0f70c9b..b35c2f1 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -113,9 +113,9 @@ const { fullscreen={fullscreen} image={header?.logo} imageAlt={branding.title} + pathname={Astro.url.pathname} title={header?.hide_title ? undefined : branding.title} transparent={transparent} - server:defer /> )} diff --git a/src/utils/url.ts b/src/utils/url.ts index e7805c2..4369044 100644 --- a/src/utils/url.ts +++ b/src/utils/url.ts @@ -5,8 +5,6 @@ interface SearchParams { [key: string]: string; } -const HEADER_REFERER = 'Referer'; - /** * Returns the fully formed URL and search parameters for the passed arguments. * @@ -33,16 +31,6 @@ export const convertToNumber = (str) => { return str; }; -/** - * Returns the referer URL on the passed headers. - * - * @param headers - */ -export const getCurrentURL = (headers: Headers): URL => { - const referer = headers.get(HEADER_REFERER); - return new URL(referer); -}; - /** * Parses the search parameters from the passed URL string and returns it as an object. *