import { getContentValues } from "@/lib/content"; import { isValidUploadPath } from "@/lib/uploads"; export interface BrandAssets { /** Logo fuer helle Flaechen (Kopfzeile); null = gezeichnetes Waben-Zeichen. */ logo: string | null; /** Logo fuer dunkle Flaechen (Mobilmenue, Fusszeile, Admin-Leiste); faellt auf `logo` zurueck. */ logoInverted: string | null; /** Quadratisches Favicon-Bild; null = Standard-Icon (siehe lib/brand-icon.ts). */ favicon: string | null; } export const BRAND_CONTENT_KEYS = ["brand.logo", "brand.logoInverted", "brand.favicon"] as const; /** * Hochgeladene Marken-Bilder aus den Inhalten (Admin > Inhalte > Logo und * Favicon). Jeder Wert wird hier noch einmal gegen das Upload-Pfadmuster * geprueft, obwohl updateSiteContentAction das beim Speichern schon tut: * der Pfad landet ungefiltert in einem src-Attribut auf jeder Seite, ein * irgendwie in die Datenbank geratener fremder Wert (z.B. eine externe URL) * soll dort nie ankommen. */ export async function getBrandAssets(): Promise { // Nicht lokalisierte Felder — die Locale spielt fuer den Wert keine Rolle. const values = await getContentValues([...BRAND_CONTENT_KEYS], "de"); const pick = (value: string | undefined): string | null => value && isValidUploadPath(value) ? value : null; const logo = pick(values["brand.logo"]); return { logo, logoInverted: pick(values["brand.logoInverted"]) ?? logo, favicon: pick(values["brand.favicon"]), }; }