From d7d34e4f7b89cc769a614ceacd9f7115ad798f42 Mon Sep 17 00:00:00 2001 From: deterge <45431127+Deterge@users.noreply.github.com> Date: Fri, 14 Nov 2025 23:01:35 -0500 Subject: [PATCH] Update 11/14 --- app/routes/[about]._index.tsx | 20 ++++++++++++++++++++ app/routes/[contact]._index.tsx | 20 ++++++++++++++++++++ app/routes/[directory]._index.tsx | 20 ++++++++++++++++++++ app/routes/[events]._index.tsx | 20 ++++++++++++++++++++ app/routes/[posts].$slug._index.tsx | 20 ++++++++++++++++++++ app/routes/[posts]._index.tsx | 20 ++++++++++++++++++++ app/routes/_index.tsx | 20 ++++++++++++++++++++ package.json | 14 +++++++------- 8 files changed, 147 insertions(+), 7 deletions(-) diff --git a/app/routes/[about]._index.tsx b/app/routes/[about]._index.tsx index 0ad12dd..ae00ff5 100644 --- a/app/routes/[about]._index.tsx +++ b/app/routes/[about]._index.tsx @@ -53,6 +53,24 @@ const customFetch: typeof fetch = (input, init) => { return Promise.resolve(response); } + if (isLocalResource(input, "current-date")) { + const now = new Date(); + // Normalize to midnight UTC to prevent hydration mismatches + const startOfDay = new Date( + Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate()) + ); + const data = { + iso: startOfDay.toISOString(), + year: startOfDay.getUTCFullYear(), + month: startOfDay.getUTCMonth() + 1, // 1-12 instead of 0-11 + day: startOfDay.getUTCDate(), + timestamp: startOfDay.getTime(), + }; + const response = new Response(JSON.stringify(data)); + response.headers.set("content-type", "application/json; charset=utf-8"); + return Promise.resolve(response); + } + return cachedFetch(projectId, input, init); }; @@ -70,6 +88,7 @@ export const loader = async (arg: LoaderFunctionArgs) => { params, search: Object.fromEntries(url.searchParams), origin: url.origin, + pathname: url.pathname, }; const resources = await loadResources( @@ -203,6 +222,7 @@ export const action = async ({ params: {}, search: {}, origin: url.origin, + pathname: url.pathname, }; const resourceName = formData.get(formIdFieldName); diff --git a/app/routes/[contact]._index.tsx b/app/routes/[contact]._index.tsx index 5f55063..3a46e61 100644 --- a/app/routes/[contact]._index.tsx +++ b/app/routes/[contact]._index.tsx @@ -53,6 +53,24 @@ const customFetch: typeof fetch = (input, init) => { return Promise.resolve(response); } + if (isLocalResource(input, "current-date")) { + const now = new Date(); + // Normalize to midnight UTC to prevent hydration mismatches + const startOfDay = new Date( + Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate()) + ); + const data = { + iso: startOfDay.toISOString(), + year: startOfDay.getUTCFullYear(), + month: startOfDay.getUTCMonth() + 1, // 1-12 instead of 0-11 + day: startOfDay.getUTCDate(), + timestamp: startOfDay.getTime(), + }; + const response = new Response(JSON.stringify(data)); + response.headers.set("content-type", "application/json; charset=utf-8"); + return Promise.resolve(response); + } + return cachedFetch(projectId, input, init); }; @@ -70,6 +88,7 @@ export const loader = async (arg: LoaderFunctionArgs) => { params, search: Object.fromEntries(url.searchParams), origin: url.origin, + pathname: url.pathname, }; const resources = await loadResources( @@ -203,6 +222,7 @@ export const action = async ({ params: {}, search: {}, origin: url.origin, + pathname: url.pathname, }; const resourceName = formData.get(formIdFieldName); diff --git a/app/routes/[directory]._index.tsx b/app/routes/[directory]._index.tsx index d35e8e7..096beca 100644 --- a/app/routes/[directory]._index.tsx +++ b/app/routes/[directory]._index.tsx @@ -53,6 +53,24 @@ const customFetch: typeof fetch = (input, init) => { return Promise.resolve(response); } + if (isLocalResource(input, "current-date")) { + const now = new Date(); + // Normalize to midnight UTC to prevent hydration mismatches + const startOfDay = new Date( + Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate()) + ); + const data = { + iso: startOfDay.toISOString(), + year: startOfDay.getUTCFullYear(), + month: startOfDay.getUTCMonth() + 1, // 1-12 instead of 0-11 + day: startOfDay.getUTCDate(), + timestamp: startOfDay.getTime(), + }; + const response = new Response(JSON.stringify(data)); + response.headers.set("content-type", "application/json; charset=utf-8"); + return Promise.resolve(response); + } + return cachedFetch(projectId, input, init); }; @@ -70,6 +88,7 @@ export const loader = async (arg: LoaderFunctionArgs) => { params, search: Object.fromEntries(url.searchParams), origin: url.origin, + pathname: url.pathname, }; const resources = await loadResources( @@ -203,6 +222,7 @@ export const action = async ({ params: {}, search: {}, origin: url.origin, + pathname: url.pathname, }; const resourceName = formData.get(formIdFieldName); diff --git a/app/routes/[events]._index.tsx b/app/routes/[events]._index.tsx index d05b4fe..dea02d3 100644 --- a/app/routes/[events]._index.tsx +++ b/app/routes/[events]._index.tsx @@ -53,6 +53,24 @@ const customFetch: typeof fetch = (input, init) => { return Promise.resolve(response); } + if (isLocalResource(input, "current-date")) { + const now = new Date(); + // Normalize to midnight UTC to prevent hydration mismatches + const startOfDay = new Date( + Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate()) + ); + const data = { + iso: startOfDay.toISOString(), + year: startOfDay.getUTCFullYear(), + month: startOfDay.getUTCMonth() + 1, // 1-12 instead of 0-11 + day: startOfDay.getUTCDate(), + timestamp: startOfDay.getTime(), + }; + const response = new Response(JSON.stringify(data)); + response.headers.set("content-type", "application/json; charset=utf-8"); + return Promise.resolve(response); + } + return cachedFetch(projectId, input, init); }; @@ -70,6 +88,7 @@ export const loader = async (arg: LoaderFunctionArgs) => { params, search: Object.fromEntries(url.searchParams), origin: url.origin, + pathname: url.pathname, }; const resources = await loadResources( @@ -203,6 +222,7 @@ export const action = async ({ params: {}, search: {}, origin: url.origin, + pathname: url.pathname, }; const resourceName = formData.get(formIdFieldName); diff --git a/app/routes/[posts].$slug._index.tsx b/app/routes/[posts].$slug._index.tsx index f17d814..e443205 100644 --- a/app/routes/[posts].$slug._index.tsx +++ b/app/routes/[posts].$slug._index.tsx @@ -53,6 +53,24 @@ const customFetch: typeof fetch = (input, init) => { return Promise.resolve(response); } + if (isLocalResource(input, "current-date")) { + const now = new Date(); + // Normalize to midnight UTC to prevent hydration mismatches + const startOfDay = new Date( + Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate()) + ); + const data = { + iso: startOfDay.toISOString(), + year: startOfDay.getUTCFullYear(), + month: startOfDay.getUTCMonth() + 1, // 1-12 instead of 0-11 + day: startOfDay.getUTCDate(), + timestamp: startOfDay.getTime(), + }; + const response = new Response(JSON.stringify(data)); + response.headers.set("content-type", "application/json; charset=utf-8"); + return Promise.resolve(response); + } + return cachedFetch(projectId, input, init); }; @@ -70,6 +88,7 @@ export const loader = async (arg: LoaderFunctionArgs) => { params, search: Object.fromEntries(url.searchParams), origin: url.origin, + pathname: url.pathname, }; const resources = await loadResources( @@ -203,6 +222,7 @@ export const action = async ({ params: {}, search: {}, origin: url.origin, + pathname: url.pathname, }; const resourceName = formData.get(formIdFieldName); diff --git a/app/routes/[posts]._index.tsx b/app/routes/[posts]._index.tsx index 5f4a5dc..c53befa 100644 --- a/app/routes/[posts]._index.tsx +++ b/app/routes/[posts]._index.tsx @@ -53,6 +53,24 @@ const customFetch: typeof fetch = (input, init) => { return Promise.resolve(response); } + if (isLocalResource(input, "current-date")) { + const now = new Date(); + // Normalize to midnight UTC to prevent hydration mismatches + const startOfDay = new Date( + Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate()) + ); + const data = { + iso: startOfDay.toISOString(), + year: startOfDay.getUTCFullYear(), + month: startOfDay.getUTCMonth() + 1, // 1-12 instead of 0-11 + day: startOfDay.getUTCDate(), + timestamp: startOfDay.getTime(), + }; + const response = new Response(JSON.stringify(data)); + response.headers.set("content-type", "application/json; charset=utf-8"); + return Promise.resolve(response); + } + return cachedFetch(projectId, input, init); }; @@ -70,6 +88,7 @@ export const loader = async (arg: LoaderFunctionArgs) => { params, search: Object.fromEntries(url.searchParams), origin: url.origin, + pathname: url.pathname, }; const resources = await loadResources( @@ -203,6 +222,7 @@ export const action = async ({ params: {}, search: {}, origin: url.origin, + pathname: url.pathname, }; const resourceName = formData.get(formIdFieldName); diff --git a/app/routes/_index.tsx b/app/routes/_index.tsx index 23ce052..386b9b5 100644 --- a/app/routes/_index.tsx +++ b/app/routes/_index.tsx @@ -53,6 +53,24 @@ const customFetch: typeof fetch = (input, init) => { return Promise.resolve(response); } + if (isLocalResource(input, "current-date")) { + const now = new Date(); + // Normalize to midnight UTC to prevent hydration mismatches + const startOfDay = new Date( + Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate()) + ); + const data = { + iso: startOfDay.toISOString(), + year: startOfDay.getUTCFullYear(), + month: startOfDay.getUTCMonth() + 1, // 1-12 instead of 0-11 + day: startOfDay.getUTCDate(), + timestamp: startOfDay.getTime(), + }; + const response = new Response(JSON.stringify(data)); + response.headers.set("content-type", "application/json; charset=utf-8"); + return Promise.resolve(response); + } + return cachedFetch(projectId, input, init); }; @@ -70,6 +88,7 @@ export const loader = async (arg: LoaderFunctionArgs) => { params, search: Object.fromEntries(url.searchParams), origin: url.origin, + pathname: url.pathname, }; const resources = await loadResources( @@ -203,6 +222,7 @@ export const action = async ({ params: {}, search: {}, origin: url.origin, + pathname: url.pathname, }; const resourceName = formData.get(formIdFieldName); diff --git a/package.json b/package.json index 5cde935..d1b8df6 100644 --- a/package.json +++ b/package.json @@ -11,13 +11,13 @@ "dependencies": { "@react-router/dev": "^7.5.3", "@react-router/fs-routes": "^7.5.3", - "@webstudio-is/image": "0.231.0", - "@webstudio-is/react-sdk": "0.231.0", - "@webstudio-is/sdk": "0.231.0", - "@webstudio-is/sdk-components-animation": "0.231.0", - "@webstudio-is/sdk-components-react-radix": "0.231.0", - "@webstudio-is/sdk-components-react-router": "0.231.0", - "@webstudio-is/sdk-components-react": "0.231.0", + "@webstudio-is/image": "0.234.0", + "@webstudio-is/react-sdk": "0.234.0", + "@webstudio-is/sdk": "0.234.0", + "@webstudio-is/sdk-components-animation": "0.234.0", + "@webstudio-is/sdk-components-react-radix": "0.234.0", + "@webstudio-is/sdk-components-react-router": "0.234.0", + "@webstudio-is/sdk-components-react": "0.234.0", "isbot": "^5.1.25", "react": "18.3.0-canary-14898b6a9-20240318", "react-dom": "18.3.0-canary-14898b6a9-20240318",