Update 11/14

This commit is contained in:
deterge
2025-11-14 23:01:35 -05:00
parent 60eacaace4
commit d7d34e4f7b
8 changed files with 147 additions and 7 deletions

View File

@@ -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);