From e7f4520f71278b3ec26371055593ea2c914e1246 Mon Sep 17 00:00:00 2001 From: Rob Pinciuc Date: Thu, 7 Nov 2024 16:52:24 -0800 Subject: [PATCH] chore: update draftMode() calls for async use --- app/[locale]/[[...slug]]/page.tsx | 4 ++-- app/[locale]/layout.tsx | 2 +- components/site-header/site-header.tsx | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/[locale]/[[...slug]]/page.tsx b/app/[locale]/[[...slug]]/page.tsx index a94bf71..3ab6ea4 100644 --- a/app/[locale]/[[...slug]]/page.tsx +++ b/app/[locale]/[[...slug]]/page.tsx @@ -129,7 +129,7 @@ export default async function LandingPage(props: PageProps) { setStaticParamsLocale(locale); const slug = params.slug?.join('/') ?? 'home'; - const { isEnabled: isDraftMode } = await draftMode(); + const isDraftMode = (await draftMode()).isEnabled; const pageData = await getPage(slug, getLocaleFromPath(locale), isDraftMode); @@ -159,7 +159,7 @@ export async function generateMetadata(props: PageProps): Promise { const params = await props.params; const { locale } = params; const slug = params.slug?.join('/') ?? 'home'; - const { isEnabled: isDraftMode } = await draftMode(); + const isDraftMode = (await draftMode()).isEnabled; return getPageMetadata(slug, getLocaleFromPath(locale), isDraftMode); } diff --git a/app/[locale]/layout.tsx b/app/[locale]/layout.tsx index ad73275..fb2502a 100644 --- a/app/[locale]/layout.tsx +++ b/app/[locale]/layout.tsx @@ -26,7 +26,7 @@ export default async function RootLayout(props: { children: React.ReactNode; par const shouldInjectToolbar = process.env.NODE_ENV === 'development'; const { locale } = params; - const { isEnabled: isDraftMode } = await draftMode(); + const isDraftMode = (await draftMode()).isEnabled; const layoutQuery = graphql( ` diff --git a/components/site-header/site-header.tsx b/components/site-header/site-header.tsx index c9016cc..fef944a 100644 --- a/components/site-header/site-header.tsx +++ b/components/site-header/site-header.tsx @@ -1,11 +1,11 @@ -import { draftMode, type UnsafeUnwrappedDraftMode } from 'next/headers'; +import { draftMode } from 'next/headers'; import Link from 'next/link'; import { Navigation } from '#/components/navigation'; // TODO: Fix fragment unmasking to type navigationData, if possible. -export function SiteHeader(props: { navigationData: any }) { - const { isEnabled: isDraftMode } = draftMode() as unknown as UnsafeUnwrappedDraftMode; +export async function SiteHeader(props: { navigationData: any }) { + const isDraftMode = (await draftMode()).isEnabled; return ( <> {isDraftMode && (