From 0fa676f45735a92ffc143cf3f36bc56950d581fb Mon Sep 17 00:00:00 2001 From: Jamie Folsom Date: Mon, 13 Jul 2026 16:08:13 -0400 Subject: [PATCH 1/2] Render Header and Footer statically instead of as server islands (#745) Their content only changes on CMS publish, so per-request island rendering buys nothing and costs two SSR round-trips per page view. Active-nav state now comes from the page's own pathname (passed down from Layout) instead of the Referer header, which also removes the island-without-Referer failure mode (#743) for these components and lets static builds render them at build time. HeaderContainer's client:load transparency wrapper is unchanged; content islands (posts, detail pages, home) are untouched. --- src/layouts/Footer.astro | 9 +++------ src/layouts/Header.astro | 13 +++++-------- src/layouts/Layout.astro | 4 ++-- src/utils/url.ts | 12 ------------ 4 files changed, 10 insertions(+), 28 deletions(-) diff --git a/src/layouts/Footer.astro b/src/layouts/Footer.astro index 7072c997..cfe1c445 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 310f70e9..f42525cf 100644 --- a/src/layouts/Header.astro +++ b/src/layouts/Header.astro @@ -5,18 +5,17 @@ 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'; const locales = getRelativeLocaleUrlList(); const currentLocale = Astro.currentLocale; -const currentUrl = getCurrentURL(Astro.request.headers); const { fullscreen, image, imageAlt, + pathname, title, transparent } = Astro.props; @@ -30,13 +29,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); - ---
@@ -87,6 +84,6 @@ setCacheControl(Astro.response.headers); diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index 67c2db01..54174658 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -115,9 +115,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 962e0602..eb9a1cfc 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. * From 6242fbd8504f80c356b9a1a15d8267ba0e9b85df Mon Sep 17 00:00:00 2001 From: Jamie Folsom Date: Mon, 13 Jul 2026 16:35:28 -0400 Subject: [PATCH 2/2] Rebuild deploy preview (staging cache env vars added)