Live preview when editting website! Very cool!

This commit is contained in:
2026-03-26 16:30:28 -05:00
parent b678e405c5
commit 475f1cad85
8 changed files with 78 additions and 6 deletions

View File

@@ -8,13 +8,16 @@ import {
import { getPayloadClient } from './get-payload';
export const getLandingPageContent = cache(
async (): Promise<LandingPageContent> => {
async (isPreview = false): Promise<LandingPageContent> => {
const payload = await getPayloadClient();
const landingPage = await (
payload as {
findGlobal: (args: { slug: string }) => Promise<unknown>;
findGlobal: (args: {
slug: string;
draft?: boolean;
}) => Promise<unknown>;
}
).findGlobal({ slug: 'landing-page' });
).findGlobal({ slug: 'landing-page', draft: isPreview });
return mergeLandingPageContent(
(landingPage as Partial<LandingPageContent> | null | undefined) ??