Skip to content

Commit 68e627f

Browse files
committed
docs: update next-app-router example
1 parent 56c206e commit 68e627f

File tree

10 files changed

+24
-52
lines changed

10 files changed

+24
-52
lines changed

examples/next-app-router/.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v18.17.0
1+
v20.17.0

examples/next-app-router/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Next, add these fields (you don't have to modify the settings unless specified):
8888
- `details` - **Rich text** field
8989
- `date` - **Date and time** field
9090
- `author` - **Text** field (type **short text**)
91-
- `category` - **Text** field (type **short text**)
91+
- `categoryName` - **Text** field (type **short text**)
9292
- `heroImage` - **Media** field (type **one file**)
9393

9494
Save the content type and continue.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { draftMode } from 'next/headers';
22

33
export async function GET(request: Request) {
4-
draftMode().disable();
4+
(await draftMode()).disable();
55
return new Response('Draft mode is disabled');
66
}

examples/next-app-router/app/api/enable-draft/route.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ export async function GET(request: Request) {
2727
}
2828

2929
// Enable Draft Mode by setting the cookie
30-
draftMode().enable();
30+
(await draftMode()).enable();
3131

3232
// Override cookie header for draft mode for usage in live-preview
3333
// https://github.com/vercel/next.js/issues/49927
34-
const cookieStore = cookies();
34+
const cookieStore = await cookies();
3535
const cookie = cookieStore.get('__prerender_bypass')!;
36-
cookies().set({
36+
(await cookies()).set({
3737
name: '__prerender_bypass',
3838
value: cookie?.value,
3939
httpOnly: true,

examples/next-app-router/app/blogs/[slug]/page.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ export async function generateStaticParams() {
1313
}));
1414
}
1515

16-
export default async function BlogPage({ params }: { params: { slug: string } }) {
17-
const { isEnabled } = draftMode();
16+
export default async function BlogPage(props: { params: Promise<{ slug: string }> }) {
17+
const params = await props.params;
18+
const { isEnabled } = await draftMode();
1819
const blog = await getBlog(params.slug, isEnabled);
1920

2021
if (!blog) {
Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,3 @@
11
@tailwind base;
22
@tailwind components;
33
@tailwind utilities;
4-
5-
:root {
6-
--foreground-rgb: 0, 0, 0;
7-
--background-start-rgb: 214, 219, 220;
8-
--background-end-rgb: 255, 255, 255;
9-
}
10-
11-
@media (prefers-color-scheme: dark) {
12-
:root {
13-
--foreground-rgb: 255, 255, 255;
14-
}
15-
}
16-
17-
body {
18-
color: rgb(var(--foreground-rgb));
19-
}
20-
21-
@layer utilities {
22-
.text-balance {
23-
text-wrap: balance;
24-
}
25-
}

examples/next-app-router/app/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Image from 'next/image';
44
import Link from 'next/link';
55

66
export default async function Home() {
7-
const { isEnabled } = draftMode();
7+
const { isEnabled } = await draftMode();
88
const blogs = await getAllBlogs(3, isEnabled);
99

1010
return (

examples/next-app-router/components/article.tsx

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*/
66
'use client';
77

8-
import { documentToReactComponents } from '@contentful/rich-text-react-renderer';
98
import Image from 'next/image';
109
import {
1110
useContentfulInspectorMode,
@@ -56,16 +55,6 @@ export const Blog = ({ blog }: { blog: BlogProps }) => {
5655
fieldId: 'file',
5756
})}
5857
/>
59-
<div className="space-y-4 md:space-y-6">
60-
<div className="space-y-2">
61-
<div
62-
className="max-w-[900px] text-zinc-500 md:text-xl/relaxed lg:text-base/relaxed xl:text-xl/relaxed dark:text-zinc-400"
63-
{...inspectorProps({ fieldId: 'details' })}
64-
>
65-
{documentToReactComponents(updatedBlog.details.json)}
66-
</div>
67-
</div>
68-
</div>
6958
</div>
7059
</div>
7160
</section>

examples/next-app-router/package.json

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,32 @@
22
"name": "contentful-app-router",
33
"version": "0.1.0",
44
"scripts": {
5-
"dev": "next dev",
5+
"dev": "next dev --turbopack",
66
"build": "next build",
77
"start": "next start",
88
"lint": "next lint",
99
"setup": "node ./lib/contentful/setup.js"
1010
},
1111
"dependencies": {
12-
"@contentful/live-preview": "^3.1.0",
13-
"@contentful/rich-text-react-renderer": "^15.19.4",
14-
"next": "14.2.10",
15-
"react": "^18",
16-
"react-dom": "^18"
12+
"@contentful/live-preview": "^4.5.17",
13+
"next": "15.0.4",
14+
"react": "19.0.0",
15+
"react-dom": "19.0.0"
1716
},
1817
"devDependencies": {
1918
"@types/node": "^20",
20-
"@types/react": "^18",
21-
"@types/react-dom": "^18",
19+
"@types/react": "19.0.1",
20+
"@types/react-dom": "19.0.1",
2221
"autoprefixer": "^10.0.1",
2322
"contentful-import": "^9.4.38",
2423
"eslint": "^8",
25-
"eslint-config-next": "14.1.0",
24+
"eslint-config-next": "15.0.4",
2625
"postcss": "^8",
2726
"tailwindcss": "^3.3.0",
2827
"typescript": "^5"
28+
},
29+
"overrides": {
30+
"@types/react": "19.0.1",
31+
"@types/react-dom": "19.0.1"
2932
}
3033
}

examples/next-app-router/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
],
2020
"paths": {
2121
"@/*": ["./*"]
22-
}
22+
},
23+
"target": "ES2017"
2324
},
2425
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
2526
"exclude": ["node_modules"]

0 commit comments

Comments
 (0)