From 74bd4cb00553f948ec576c2ae7050cd12c6708b4 Mon Sep 17 00:00:00 2001 From: Saket Reddy <144753536+SaketR3@users.noreply.github.com> Date: Sun, 24 Aug 2025 10:26:52 -0500 Subject: [PATCH 1/3] Change Contentful environment variable imports to use dynamic instead of static --- src/hooks.server.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/hooks.server.ts b/src/hooks.server.ts index c91458f..17acb2f 100644 --- a/src/hooks.server.ts +++ b/src/hooks.server.ts @@ -1,16 +1,22 @@ import { minify, type Options } from "html-minifier-terser"; import { building } from "$app/environment"; import type { Handle } from "@sveltejs/kit"; -import { - CONTENTFUL_DELIVERY_KEY, - CONTENTFUL_PREVIEW_FLAG, - CONTENTFUL_PREVIEW_KEY, - CONTENTFUL_SPACE_ID, -} from "$env/static/private"; +// import { +// CONTENTFUL_DELIVERY_KEY, +// CONTENTFUL_PREVIEW_FLAG, +// CONTENTFUL_PREVIEW_KEY, +// CONTENTFUL_SPACE_ID, +// } from "$env/static/private"; +import { env } from "$env/dynamic/private"; import { ContentWrapper } from "$lib/utils/api"; const contentfulPreviewSearchParam = "preview"; +const CONTENTFUL_DELIVERY_KEY = env.CONTENTFUL_DELIVERY_KEY; +const CONTENTFUL_PREVIEW_FLAG = env.CONTENTFUL_PREVIEW_FLAG; +const CONTENTFUL_PREVIEW_KEY = env.CONTENTFUL_PREVIEW_KEY; +const CONTENTFUL_SPACE_ID = env.CONTENTFUL_SPACE_ID; + const isPreview = (url: URL) => url.searchParams.get(contentfulPreviewSearchParam) === CONTENTFUL_PREVIEW_FLAG; From 8dec39b502d260eb8599481c100331874d8060e0 Mon Sep 17 00:00:00 2001 From: Saket Reddy <144753536+SaketR3@users.noreply.github.com> Date: Sun, 24 Aug 2025 10:35:13 -0500 Subject: [PATCH 2/3] Add type annotations for Contentful environment variables --- src/hooks.server.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hooks.server.ts b/src/hooks.server.ts index 17acb2f..b85a54b 100644 --- a/src/hooks.server.ts +++ b/src/hooks.server.ts @@ -12,10 +12,10 @@ import { ContentWrapper } from "$lib/utils/api"; const contentfulPreviewSearchParam = "preview"; -const CONTENTFUL_DELIVERY_KEY = env.CONTENTFUL_DELIVERY_KEY; -const CONTENTFUL_PREVIEW_FLAG = env.CONTENTFUL_PREVIEW_FLAG; -const CONTENTFUL_PREVIEW_KEY = env.CONTENTFUL_PREVIEW_KEY; -const CONTENTFUL_SPACE_ID = env.CONTENTFUL_SPACE_ID; +const CONTENTFUL_DELIVERY_KEY: string | undefined = env.CONTENTFUL_DELIVERY_KEY; +const CONTENTFUL_PREVIEW_FLAG: string | undefined = env.CONTENTFUL_PREVIEW_FLAG; +const CONTENTFUL_PREVIEW_KEY: string | undefined = env.CONTENTFUL_PREVIEW_KEY; +const CONTENTFUL_SPACE_ID: string | undefined = env.CONTENTFUL_SPACE_ID; const isPreview = (url: URL) => url.searchParams.get(contentfulPreviewSearchParam) === From 75825bbbda4fa396e3da4c4ce3234daf6d22fc61 Mon Sep 17 00:00:00 2001 From: Saket Reddy <144753536+SaketR3@users.noreply.github.com> Date: Sun, 24 Aug 2025 10:36:27 -0500 Subject: [PATCH 3/3] Refactor Contentful keys to remove type annotations --- src/hooks.server.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hooks.server.ts b/src/hooks.server.ts index b85a54b..2361731 100644 --- a/src/hooks.server.ts +++ b/src/hooks.server.ts @@ -12,10 +12,10 @@ import { ContentWrapper } from "$lib/utils/api"; const contentfulPreviewSearchParam = "preview"; -const CONTENTFUL_DELIVERY_KEY: string | undefined = env.CONTENTFUL_DELIVERY_KEY; -const CONTENTFUL_PREVIEW_FLAG: string | undefined = env.CONTENTFUL_PREVIEW_FLAG; -const CONTENTFUL_PREVIEW_KEY: string | undefined = env.CONTENTFUL_PREVIEW_KEY; -const CONTENTFUL_SPACE_ID: string | undefined = env.CONTENTFUL_SPACE_ID; +const CONTENTFUL_DELIVERY_KEY = env.CONTENTFUL_DELIVERY_KEY; +const CONTENTFUL_PREVIEW_FLAG = env.CONTENTFUL_PREVIEW_FLAG; +const CONTENTFUL_PREVIEW_KEY = env.CONTENTFUL_PREVIEW_KEY; +const CONTENTFUL_SPACE_ID = env.CONTENTFUL_SPACE_ID; const isPreview = (url: URL) => url.searchParams.get(contentfulPreviewSearchParam) ===