Implemented preview functionality with next js 13 app dir

This commit is contained in:
Henrik Larsson
2023-05-16 12:52:44 +02:00
parent 47b0df33d4
commit 0a2e289d85
10 changed files with 306 additions and 29 deletions

View File

@@ -0,0 +1,26 @@
'use client'
import PreviewBanner from 'components/ui/preview-banner'
import { usePreview } from 'lib/sanity/sanity.preview'
import ProductPage from './product-page'
export default function ProductPagePreview({
query,
queryParams,
}: {
query: string
queryParams: {
[key: string]: any
}
}) {
const data = usePreview(null, query, queryParams)
const { title, _type } = data
return (
<>
<ProductPage data={data} />
<PreviewBanner title={`${title} (${_type})`} />
</>
)
}