feat: manage blog detail chrome via payload

This commit is contained in:
syntaxbullet
2026-06-22 11:54:18 +02:00
parent 43f85dfea2
commit aa839fcebc
7 changed files with 260 additions and 19 deletions

View File

@@ -0,0 +1,42 @@
import 'dotenv/config'
import config from '@payload-config'
import { getPayload } from 'payload'
import { blogDetailContent } from '@/spa/blogDetailContent'
async function main() {
const payload = await getPayload({ config })
const posts = await payload.find({
collection: 'posts',
draft: true,
overrideAccess: true,
pagination: false,
limit: 1000,
})
await Promise.all(
posts.docs.map((post) =>
payload.update({
collection: 'posts',
id: post.id,
overrideAccess: true,
context: { disableRevalidate: true },
data: {
detailPage: {
...blogDetailContent,
metaCopy: blogDetailContent.meta,
},
} as never,
}),
),
)
payload.logger.info(`Preloaded Blog detail CMS fields for ${posts.docs.length} records`)
}
main().catch((error) => {
console.error(error)
process.exit(1)
})