Wire testimonials CMS collection and Payload Live Preview

Testimonials on /todo-cards, /newsletter, /challenge now come from the new
Payload testimonials collection via a shared TestimonialsGrid component,
instead of 3 separately hardcoded arrays.

Adds Next.js Draft Mode (/api/preview) plus Live-Preview-aware client
wrappers (LiveRichText, LiveTestimonialsGrid, LivePostContent) for posts,
legal pages, and testimonials — mounted only while Draft Mode is enabled,
so ordinary visitors keep getting the plain static components.
This commit is contained in:
Marco
2026-07-21 19:02:20 +00:00
parent 2d6cff9f40
commit 26ae4a15f4
18 changed files with 420 additions and 305 deletions
+4 -1
View File
@@ -1,10 +1,12 @@
import type { Metadata } from "next";
import Link from "next/link";
import Image from "next/image";
import { draftMode } from "next/headers";
import { Reveal } from "../components/Reveal";
import { Footer } from "../components/Footer";
import { TrustRow } from "../components/TrustRow";
import { RichText, extractHeadings } from "../components/RichText";
import { LiveRichText } from "../components/LiveRichText";
import { SectionTOC } from "../components/SectionTOC";
import { getLegalPage } from "../lib/payload";
@@ -17,6 +19,7 @@ export const metadata: Metadata = {
export default async function WiderrufPage() {
const page = await getLegalPage("widerruf");
const headings = page ? extractHeadings(page.content) : [];
const { isEnabled: isPreview } = await draftMode();
return (
<>
@@ -60,7 +63,7 @@ export default async function WiderrufPage() {
<div className="w-full lg:flex-1 min-w-0 flex flex-col gap-8">
{page ? (
<RichText content={page.content} />
isPreview ? <LiveRichText initialContent={page.content} /> : <RichText content={page.content} />
) : (
<p className="text-body text-text-muted">Inhalte werden gerade aktualisiert.</p>
)}