Add preview handling
This commit is contained in:
@@ -1,7 +1,28 @@
|
||||
import { getGlobal } from '@/libs/strapi'
|
||||
|
||||
export const data = async () => {
|
||||
const global = await getGlobal()
|
||||
export const data = async (pageContext) => {
|
||||
const { urlParsed } = pageContext
|
||||
const searchParams = urlParsed.search || {}
|
||||
|
||||
// Extract preview parameters from URL
|
||||
const isPreview = searchParams.preview === 'true'
|
||||
const status = searchParams.status || 'published'
|
||||
const documentId = searchParams.documentId
|
||||
const uid = searchParams.uid
|
||||
|
||||
// Fetch global content with preview support
|
||||
const global = await getGlobal({
|
||||
isPreview,
|
||||
status,
|
||||
...(documentId && { params: { documentId } })
|
||||
})
|
||||
|
||||
return { global: global.data }
|
||||
return {
|
||||
global: global.data,
|
||||
// Pass preview state to the component
|
||||
isPreview,
|
||||
status,
|
||||
documentId,
|
||||
uid
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user