"use client"; import { useEffect, useState } from "react"; /** * Lädt eine Inhaltsseite (Impressum, Datenschutz) aus dem CMS nach. * Bis dahin und ohne JavaScript bleibt der eingebaute Text stehen. */ export function useCmsPage(key: string, locale: string): string | null { const [html, setHtml] = useState(null); useEffect(() => { let cancelled = false; (async () => { try { const res = await fetch(`/api/content/page?key=${encodeURIComponent(key)}&locale=${encodeURIComponent(locale)}`); const data = await res.json(); if (!cancelled && data?.content?.html && data?.content?.locale === locale) { setHtml(data.content.html as string); } } catch {} })(); return () => { cancelled = true; }; }, [key, locale]); return html; }