Skip to content

Commit

Permalink
docs: update content-source-maps-graphql example
Browse files Browse the repository at this point in the history
  • Loading branch information
YvesRijckaert committed Dec 10, 2024
1 parent 4387a88 commit 30ac46a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -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');
}
Original file line number Diff line number Diff line change
Expand Up @@ -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({
(await cookies()).set({
name: '__prerender_bypass',
value: cookie?.value,
httpOnly: true,
Expand Down
4 changes: 2 additions & 2 deletions examples/content-source-maps-graphql/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<ContentfulPreviewProvider
Expand Down
2 changes: 1 addition & 1 deletion examples/content-source-maps-graphql/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { draftMode } from 'next/headers';
import { getAllPostsForHome } from '../lib/api-graphql';

export default async function Home() {
const { isEnabled } = draftMode();
const { isEnabled } = await draftMode();
const posts = await getAllPostsForHome(isEnabled);

return (
Expand Down
18 changes: 11 additions & 7 deletions examples/content-source-maps-graphql/package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
{
"private": true,
"scripts": {
"dev": "next dev",
"dev": "next dev --turbopack",
"build": "next build",
"start": "next start"
},
"dependencies": {
"@contentful/live-preview": "^4.2.2",
"@contentful/live-preview": "^4.6.0",
"@types/node": "20.2.3",
"@types/react": "18.2.7",
"@types/react-dom": "18.2.4",
"@types/react": "19.0.1",
"@types/react-dom": "19.0.1",
"graphql-request": "^6.1.0",
"next": "14.2.10",
"react": "18.2.0",
"react-dom": "18.2.0",
"next": "15.0.4",
"react": "19.0.0",
"react-dom": "19.0.0",
"typescript": "5.0.4"
},
"overrides": {
"@types/react": "19.0.1",
"@types/react-dom": "19.0.1"
}
}

0 comments on commit 30ac46a

Please sign in to comment.