There鈥檚 this, but it鈥檚 not per collection: https://www.netlifycms.org/docs/beta-features/#registering-to-cms-events
Can you share your use case? That would help us prioritize the request.
Sent with GitHawk
Let's say I have two collections, one named Articles, and the other Products.
When an Article is created (not deleted or edited), I want to be able to trigger a webhook that automatically tweets the title and link of the article page.
I only want that for Articles, not Products.
I believe there are many such possibilities that can be unlocked by allowing webhooks at the per collection per action type level.
(Also, thanks for letting me know about the "registering to cms events" beta feature. I didn't know that existed)
If there's any way I can use CMS.registerEventListener for my use case described earlier, please let me know.
registerEventListener is close to what you need. I believe you can get the collection from the entry, so the only other thing you would need to know is whether the entry being published is new.
Sent with GitHawk
Thanks for your support.
I'm able to use registerEventListener for my use-case like:
import CMS from 'netlify-cms-app'
CMS.registerEventListener({
name: 'postPublish',
handler: ({ entry }) => {
console.log(`entry.newRecord:`, entry.newRecord) // true
console.log(`entry.collection:`, entry.collection) // 'articles'
console.log(`entry.data:`, entry.data) // { ... }
if (entry.newRecord && entry.collection === 'articles') {
// trigger webhook here
}
}
})
Ah, newRecord is included, nice!
Sent with GitHawk