((props, ref) => {
- const { left = true, right = true, className, children } = props
+ const { children, className, left = true, right = true } = props
return (
= forwardRef((props,
]
.filter(Boolean)
.join(' ')}
+ ref={ref}
>
{children}
diff --git a/examples/draft-preview/next-app/app/_components/Header/index.tsx b/examples/draft-preview/next-app/app/_components/Header/index.tsx
index b71a8db489..7002fe3ca8 100644
--- a/examples/draft-preview/next-app/app/_components/Header/index.tsx
+++ b/examples/draft-preview/next-app/app/_components/Header/index.tsx
@@ -1,11 +1,11 @@
+import React from 'react'
import Image from 'next/image'
import Link from 'next/link'
-import React from 'react'
import type { MainMenu } from '../../../payload-types'
-
import { CMSLink } from '../CMSLink'
import { Gutter } from '../Gutter'
+
import classes from './index.module.scss'
export async function Header() {
diff --git a/examples/draft-preview/next-app/app/_components/RichText/serialize.tsx b/examples/draft-preview/next-app/app/_components/RichText/serialize.tsx
index 1067a9815a..1d7d2652e9 100644
--- a/examples/draft-preview/next-app/app/_components/RichText/serialize.tsx
+++ b/examples/draft-preview/next-app/app/_components/RichText/serialize.tsx
@@ -6,14 +6,14 @@ import { Text } from 'slate'
type Children = Leaf[]
type Leaf = {
- type: string
- value?: {
- url: string
- alt: string
- }
- children: Children
- url?: string
[key: string]: unknown
+ children: Children
+ type: string
+ url?: string
+ value?: {
+ alt: string
+ url: string
+ }
}
const serialize = (children: Children): React.ReactNode[] =>
@@ -35,7 +35,7 @@ const serialize = (children: Children): React.ReactNode[] =>
if (node.underline) {
text = (
-
+
{text}
)
@@ -43,7 +43,7 @@ const serialize = (children: Children): React.ReactNode[] =>
if (node.strikethrough) {
text = (
-
+
{text}
)
@@ -57,6 +57,8 @@ const serialize = (children: Children): React.ReactNode[] =>
}
switch (node.type) {
+ case 'blockquote':
+ return {serialize(node.children)}
case 'h1':
return {serialize(node.children)}
case 'h2':
@@ -69,12 +71,6 @@ const serialize = (children: Children): React.ReactNode[] =>
return {serialize(node.children)}
case 'h6':
return {serialize(node.children)}
- case 'blockquote':
- return {serialize(node.children)}
- case 'ul':
- return {serialize(node.children)}
- case 'ol':
- return {serialize(node.children)}
case 'li':
return {serialize(node.children)}
case 'link':
@@ -83,6 +79,10 @@ const serialize = (children: Children): React.ReactNode[] =>
{serialize(node.children)}
)
+ case 'ol':
+ return {serialize(node.children)}
+ case 'ul':
+ return {serialize(node.children)}
default:
return {serialize(node.children)}
diff --git a/examples/draft-preview/next-app/app/api/exit-preview/route.ts b/examples/draft-preview/next-app/app/api/exit-preview/route.ts
index 0c15caea1e..a8e3e69b57 100644
--- a/examples/draft-preview/next-app/app/api/exit-preview/route.ts
+++ b/examples/draft-preview/next-app/app/api/exit-preview/route.ts
@@ -1,6 +1,7 @@
import { draftMode } from 'next/headers'
export async function GET(): Promise {
- draftMode().disable()
+ const draft = await draftMode()
+ draft.disable()
return new Response('Draft mode is disabled')
}
diff --git a/examples/draft-preview/next-app/app/api/preview/route.ts b/examples/draft-preview/next-app/app/api/preview/route.ts
index a7f09a8ff0..b5f023d6f1 100644
--- a/examples/draft-preview/next-app/app/api/preview/route.ts
+++ b/examples/draft-preview/next-app/app/api/preview/route.ts
@@ -2,13 +2,13 @@ import { draftMode } from 'next/headers'
import { redirect } from 'next/navigation'
export async function GET(
- req: Request & {
+ req: {
cookies: {
get: (name: string) => {
value: string
}
}
- },
+ } & Request,
): Promise {
const payloadToken = req.cookies.get('payload-token')?.value
const { searchParams } = new URL(req.url)
@@ -32,8 +32,10 @@ export async function GET(
const userRes = await userReq.json()
+ const draft = await draftMode()
+
if (!userReq.ok || !userRes?.user) {
- draftMode().disable()
+ draft.disable()
return new Response('You are not allowed to preview this page', { status: 403 })
}
@@ -41,7 +43,7 @@ export async function GET(
return new Response('Invalid token', { status: 401 })
}
- draftMode().enable()
+ draft.enable()
redirect(url)
}
diff --git a/examples/draft-preview/next-app/app/api/revalidate/route.ts b/examples/draft-preview/next-app/app/api/revalidate/route.ts
index 3306cda4d0..4335f6e759 100644
--- a/examples/draft-preview/next-app/app/api/revalidate/route.ts
+++ b/examples/draft-preview/next-app/app/api/revalidate/route.ts
@@ -5,19 +5,20 @@ import { NextResponse } from 'next/server'
// this endpoint will revalidate a page by tag or path
// this is to achieve on-demand revalidation of pages that use this data
// send either `collection` and `slug` or `revalidatePath` as query params
-export async function GET(request: NextRequest): Promise {
+/* eslint-disable @typescript-eslint/require-await */
+export async function GET(request: NextRequest): Promise {
const collection = request.nextUrl.searchParams.get('collection')
const slug = request.nextUrl.searchParams.get('slug')
const path = request.nextUrl.searchParams.get('path')
const secret = request.nextUrl.searchParams.get('secret')
if (secret !== process.env.NEXT_PRIVATE_REVALIDATION_KEY) {
- return NextResponse.json({ revalidated: false, now: Date.now() })
+ return NextResponse.json({ now: Date.now(), revalidated: false })
}
if (typeof collection === 'string' && typeof slug === 'string') {
revalidateTag(`${collection}_${slug}`)
- return NextResponse.json({ revalidated: true, now: Date.now() })
+ return NextResponse.json({ now: Date.now(), revalidated: true })
}
// there is a known limitation with `revalidatePath` where it will not revalidate exact paths of dynamic routes
@@ -27,8 +28,8 @@ export async function GET(request: NextRequest): Promise {
// - https://github.com/vercel/next.js/issues/49778#issuecomment-1547028830
if (typeof path === 'string') {
revalidatePath(path)
- return NextResponse.json({ revalidated: true, now: Date.now() })
+ return NextResponse.json({ now: Date.now(), revalidated: true })
}
- return NextResponse.json({ revalidated: false, now: Date.now() })
+ return NextResponse.json({ now: Date.now(), revalidated: false })
}
diff --git a/examples/draft-preview/next-app/app/layout.tsx b/examples/draft-preview/next-app/app/layout.tsx
index 36288879aa..7737315f71 100644
--- a/examples/draft-preview/next-app/app/layout.tsx
+++ b/examples/draft-preview/next-app/app/layout.tsx
@@ -4,10 +4,11 @@ import { Header } from './_components/Header'
import './app.scss'
export const metadata = {
- title: 'Create Next App',
description: 'Generated by create next app',
+ title: 'Create Next App',
}
+// eslint-disable-next-line @typescript-eslint/require-await
export default async function RootLayout(props: { children: React.ReactNode }) {
const { children } = props
@@ -23,7 +24,6 @@ export default async function RootLayout(props: { children: React.ReactNode }) {
Update: this is fixed in `@types/react` v18.2.14 but still requires `@ts-expect-error` to build :shrug:
See my comment here: https://github.com/vercel/next.js/issues/42292#issuecomment-1622979777
*/}
- {/* @ts-expect-error */}
{children}