mirror of
https://github.com/vercel/commerce.git
synced 2025-07-22 20:26:49 +00:00
Implemented preview functionality with next js 13 app dir
This commit is contained in:
26
app/[locale]/[[...slug]]/product-page-preview.tsx
Normal file
26
app/[locale]/[[...slug]]/product-page-preview.tsx
Normal 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})`} />
|
||||
</>
|
||||
)
|
||||
}
|
Reference in New Issue
Block a user