add ssr
Build and Deploy / build-and-deploy (push) Failing after 36s

This commit is contained in:
2026-05-18 10:34:38 +02:00
parent 57af0b8386
commit fb5aa07373
7 changed files with 7282 additions and 188 deletions
+2
View File
@@ -9,6 +9,8 @@ import { urlFor } from '../sanity/imageUrl';
import { theaterHomepageQuery } from '../sanity/queries';
import { MapPin } from '@lucide/astro';
export const prerender = false
const content = await sanityClient.fetch(theaterHomepageQuery) ?? {};
---
+26
View File
@@ -0,0 +1,26 @@
interface CacheEntry {
data: unknown;
expiresAt: number;
}
const store = new Map<string, CacheEntry>();
const DEFAULT_TTL = 60 * 1000; // 1 minute
function cacheKey(query: string, params: Record<string, unknown>): string {
const p = Object.keys(params).sort().map(k => `${k}=${JSON.stringify(params[k])}`).join('&');
return `${query}${p ? `?${p}` : ''}`;
}
export function get(key: string): unknown | null {
const entry = store.get(key);
if (!entry) return null;
if (Date.now() > entry.expiresAt) {
store.delete(key);
return null;
}
return entry.data;
}
export function set(key: string, data: unknown, ms?: number): void {
store.set(key, { data, expiresAt: Date.now() + (ms ?? DEFAULT_TTL) });
}
+14 -1
View File
@@ -1 +1,14 @@
export { sanityClient } from 'sanity:client'
import { sanityClient } from 'sanity:client';
import { get, set } from './cache';
export async function fetchWithCache<T>(query: string, params?: Record<string, unknown>): Promise<T | null> {
const key = `sanity:${query}:${JSON.stringify(params ?? {})}`;
const cached = get(key) as T | null;
if (cached) return cached;
const data = await sanityClient.fetch(query, params);
if (data != null) set(key, data);
return data;
}
export { sanityClient };