Files
supabase/apps/cms/src/hooks/populatePublishedAt.ts
Francesco SansalvadoreandIvan Vasilov f7d90bbc30 feat: new cms app (#35999)
* add cms turbo app

* add cms scripts to package.json

* update README

* update README

* update files

* fix formatting

* fix populateAuthors

* sync dependencies

* update launch week field

* update lint config

* Coordinate the deps to be the same as the other apps.

* Remove extra files.

* Run prettier on the CMS files.

* Add commands for cleaning and typechecking.

* Fix weird version of @types/react in docs.

* run pnpm install

* fix pnpm-lock

* fix cms lint

---------

Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
2025-06-03 14:26:43 +03:00

16 lines
379 B
TypeScript

import type { CollectionBeforeChangeHook } from 'payload'
export const populatePublishedAt: CollectionBeforeChangeHook = ({ data, operation, req }) => {
if (operation === 'create' || operation === 'update') {
if (req.data && !req.data.publishedAt) {
const now = new Date()
return {
...data,
publishedAt: now,
}
}
}
return data
}