Add preview handling

This commit is contained in:
nicwands
2026-06-01 11:08:03 -04:00
parent ef70a0c756
commit 6776a14757
18 changed files with 1186 additions and 14 deletions

View File

@@ -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
}
}