Implement live preview

This commit is contained in:
tobias
2024-06-24 11:53:43 +02:00
parent 4dfe80213e
commit 5d652dc606
6 changed files with 82 additions and 4 deletions

View File

@ -28,6 +28,7 @@ import Authors from '@payload/collections/Authors'
import Posts from '@payload/collections/Posts'
import Users from '@payload/collections/Users'
import Pages from '@payload/collections/Pages'
import { COLLECTION_SLUG_PAGE, COLLECTION_SLUG_POST } from '@/app/(payload)/collections/config'
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
@ -40,6 +41,12 @@ export default buildConfig({
password: 'test',
prefillOnly: true,
},
livePreview: {
url: ({ data, locale }) =>
//TODO: Rewrite to collection_slug/preview/
`${process.env.BASE_URL}/preview${data.path}${locale ? `?locale=${locale.code}` : ''}`,
collections: [COLLECTION_SLUG_PAGE],
},
},
editor: lexicalEditor(),
secret: process.env.PAYLOAD_SECRET || '',