Files
blackheart-website/src/lib/content.ts
T
diana.dolgolyova e56a6a1608 fix: remove fallback content, fix video upload and positioning
- Remove hardcoded fallback data — DB is sole content source
- Sections render conditionally when data exists
- Hero video slots save after each upload (not only when all 3 filled)
- Video positions preserved (left/center/right) with empty string slots
- Client-side 10MB hard limit on video uploads with clear error
- Server-side upload error handling for body size limits
- Guard Team section against empty members array
- Clean up old uploaded images and videos
2026-03-29 22:17:11 +03:00

29 lines
691 B
TypeScript

import { getSiteContent } from "@/lib/db";
import type { SiteContent } from "@/types/content";
let cached: { data: SiteContent; expiresAt: number } | null = null;
const CACHE_TTL = 5 * 60 * 1000; // 5 minutes
export function getContent(): SiteContent | null {
const now = Date.now();
if (cached && now < cached.expiresAt) {
return cached.data;
}
try {
const content = getSiteContent();
if (content) {
cached = { data: content, expiresAt: now + CACHE_TTL };
return content;
}
return null;
} catch {
return null;
}
}
/** Invalidate the content cache (call after admin edits). */
export function invalidateContentCache() {
cached = null;
}