- {post.title} -
-{post.excerpt}
-- Björn • {formatDate(post.publishedAt)} -
-+ {post.title} +
+{post.excerpt}
++ Björn • {formatDate(post.publishedAt)} +
+{t.quote}
-{t.name}
-{t.role}
-{t.quote}
+{t.name}
+{t.role}
+Inhalte werden gerade aktualisiert.
)} diff --git a/app/impressum/page.tsx b/app/impressum/page.tsx index 1063e3e..cb26c47 100644 --- a/app/impressum/page.tsx +++ b/app/impressum/page.tsx @@ -1,9 +1,11 @@ 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 { RichText, extractHeadings } from "../components/RichText"; +import { LiveRichText } from "../components/LiveRichText"; import { SectionTOC } from "../components/SectionTOC"; import { getLegalPage } from "../lib/payload"; @@ -16,6 +18,7 @@ export const metadata: Metadata = { export default async function ImpressumPage() { const page = await getLegalPage("impressum"); const headings = page ? extractHeadings(page.content) : []; + const { isEnabled: isPreview } = await draftMode(); return ( <> @@ -65,7 +68,7 @@ export default async function ImpressumPage() {Inhalte werden gerade aktualisiert.
)} diff --git a/app/lib/payload.ts b/app/lib/payload.ts index eaacc44..4af7e99 100644 --- a/app/lib/payload.ts +++ b/app/lib/payload.ts @@ -1,8 +1,18 @@ +import { draftMode } from "next/headers"; import { formatPrice } from "./format"; const PAYLOAD_URL = process.env.PAYLOAD_URL || "https://payload.mk360.de"; const TENANT_SLUG = "einfach-produktiv"; +// Used only by the fetchers backing Live Preview (posts, legal pages, +// testimonials) — Draft Mode is enabled exclusively while a document is +// open in the Payload admin's Live Preview iframe, so bypassing the normal +// 60s ISR cache there doesn't affect ordinary site visitors at all. +async function livePreviewCacheOption(): Promise<{ cache: "no-store" } | { next: { revalidate: 60 } }> { + const { isEnabled } = await draftMode(); + return isEnabled ? { cache: "no-store" } : { next: { revalidate: 60 } }; +} + export type BlogPost = { id: number; title: string; @@ -81,31 +91,16 @@ export type PostDetail = BlogPost & { relatedProduct: Product | null; }; -type PayloadPostDetail = PayloadPost & { +export type PayloadPostDetail = PayloadPost & { content: unknown; quoteLabel: string | null; relatedProduct: PayloadProduct | null; }; -export async function getPostBySlug(slug: string): Promise{t.quote}
-{t.name}
-{t.role}
-{t.quote}
-{t.name}
-{t.role}
-Inhalte werden gerade aktualisiert.
)} diff --git a/package-lock.json b/package-lock.json index 04fb4cd..7410e42 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,7 @@ "name": "einfach-produktiv", "version": "0.1.0", "dependencies": { + "@payloadcms/live-preview-react": "^3.85.2", "motion": "^12.42.2", "next": "16.2.9", "react": "19.2.4", @@ -1307,6 +1308,25 @@ "node": ">=12.4.0" } }, + "node_modules/@payloadcms/live-preview": { + "version": "3.85.2", + "resolved": "https://registry.npmjs.org/@payloadcms/live-preview/-/live-preview-3.85.2.tgz", + "integrity": "sha512-nWOQhBv4ei3uEjJGGCo1m541fx4D8wONLv74/yjzsawDHRq6tOcOMUTQuQPIZt5xNlomYFPH9XlZfgIs3BSWdA==", + "license": "MIT" + }, + "node_modules/@payloadcms/live-preview-react": { + "version": "3.85.2", + "resolved": "https://registry.npmjs.org/@payloadcms/live-preview-react/-/live-preview-react-3.85.2.tgz", + "integrity": "sha512-HMulvQRXAQp2OaqmXgZa5Sg1htN+5FC36g0vFnoYooG5XtIuRriFNPOPbokygg67AOQPo+0G0r6jPM9JTjYkXA==", + "license": "MIT", + "dependencies": { + "@payloadcms/live-preview": "3.85.2" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.1 || ^19.1.2 || ^19.2.1", + "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.1 || ^19.1.2 || ^19.2.1" + } + }, "node_modules/@rtsao/scc": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@rtsao/scc/-/scc-1.1.0.tgz", diff --git a/package.json b/package.json index 91f728c..198e02e 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "lint": "eslint" }, "dependencies": { + "@payloadcms/live-preview-react": "^3.85.2", "motion": "^12.42.2", "next": "16.2.9", "react": "19.2.4",