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:
@@ -0,0 +1,25 @@
|
||||
"use client";
|
||||
|
||||
import { useLivePreview } from "@payloadcms/live-preview-react";
|
||||
import { RichText } from "./RichText";
|
||||
|
||||
const PAYLOAD_URL = process.env.NEXT_PUBLIC_PAYLOAD_URL || "https://payload.mk360.de";
|
||||
|
||||
// Wraps just the RichText body of a legal page (/agb, /datenschutz,
|
||||
// /impressum, /widerruf) for Payload Live Preview — those 4 pages' own
|
||||
// headings/sidebars/TOC are hardcoded per page, not sourced from
|
||||
// `page.title` at all, so `content` is the only field that actually
|
||||
// benefits from real-time editing preview. Falls back to the
|
||||
// server-fetched `initialContent` until a postMessage arrives, which only
|
||||
// happens at all while this page is open inside the Payload admin's Live
|
||||
// Preview iframe — ordinary visitors never mount this differently from a
|
||||
// plain <RichText>.
|
||||
export function LiveRichText({ initialContent, quoteLabel }: { initialContent: unknown; quoteLabel?: string }) {
|
||||
const { data } = useLivePreview<{ content: unknown }>({
|
||||
initialData: { content: initialContent },
|
||||
serverURL: PAYLOAD_URL,
|
||||
depth: 2,
|
||||
});
|
||||
|
||||
return <RichText content={data.content} quoteLabel={quoteLabel} />;
|
||||
}
|
||||
Reference in New Issue
Block a user