From 5b226125c9720889229f1a54ab5b94570928385b Mon Sep 17 00:00:00 2001 From: Yves Rijckaert Date: Mon, 9 Dec 2024 15:34:11 +0100 Subject: [PATCH] docs: update content-source-maps-graphql example --- .../app/api/disable-draft/route.ts | 2 +- .../app/api/enable-draft/route.ts | 6 +++--- .../content-source-maps-graphql/app/layout.tsx | 4 ++-- .../content-source-maps-graphql/app/page.tsx | 2 +- .../content-source-maps-graphql/package.json | 18 +++++++++++------- 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/examples/content-source-maps-graphql/app/api/disable-draft/route.ts b/examples/content-source-maps-graphql/app/api/disable-draft/route.ts index 128e6852..6224d6d1 100644 --- a/examples/content-source-maps-graphql/app/api/disable-draft/route.ts +++ b/examples/content-source-maps-graphql/app/api/disable-draft/route.ts @@ -1,6 +1,6 @@ import { draftMode } from 'next/headers'; export async function GET(request: Request) { - draftMode().disable(); + (await draftMode()).disable(); return new Response('Draft mode is disabled'); } diff --git a/examples/content-source-maps-graphql/app/api/enable-draft/route.ts b/examples/content-source-maps-graphql/app/api/enable-draft/route.ts index a8057746..85cd2077 100644 --- a/examples/content-source-maps-graphql/app/api/enable-draft/route.ts +++ b/examples/content-source-maps-graphql/app/api/enable-draft/route.ts @@ -17,13 +17,13 @@ export async function GET(request: Request) { } // Enable Draft Mode by setting the cookie - draftMode().enable(); + (await draftMode()).enable(); // Override cookie header for draft mode for usage in live-preview // https://github.com/vercel/next.js/issues/49927 - const cookieStore = cookies(); + const cookieStore = await cookies(); const cookie = cookieStore.get('__prerender_bypass')!; - cookies().set({ + cookieStore.set({ name: '__prerender_bypass', value: cookie?.value, httpOnly: true, diff --git a/examples/content-source-maps-graphql/app/layout.tsx b/examples/content-source-maps-graphql/app/layout.tsx index dd7ef0da..5ff4894d 100644 --- a/examples/content-source-maps-graphql/app/layout.tsx +++ b/examples/content-source-maps-graphql/app/layout.tsx @@ -7,12 +7,12 @@ export const metadata: Metadata = { description: 'Generated by create next app', }; -export default function RootLayout({ +export default async function RootLayout({ children, }: Readonly<{ children: React.ReactNode; }>) { - const { isEnabled } = draftMode(); + const { isEnabled } = await draftMode(); return (