Adding a custom function that runs when a post is added

I want to create a post type called news articles which has the fields: URL, title and date published.

Is there a way to add a hook so the editor only provides a URL, and my ‘hook’ would automatically fetch the URL and extract the date, title and automatically fill out the fields in the CMS when the post is created?

Hey @rahul-sundaresan , it does look like you can execute a function when a certain CMS event takes place. This is a beta feature, but you can find more details about it on the CMS docs site

Let us know if you have any additional questions!

1 Like

Oh I forgot to update this post after finding it :sweat_smile:

Where would you write these functions? I didn’t use the npm package for the CMS. I directly imported it into a blank HTML document.

Hi @rahul-sundaresan :wave:t6: , welcome back to the forums.

Netlify Functions are files you write in JavaScript, TypeScript, or Go and then place inside your project under the path netlify/functions .

Here is a helpful doc to get you sorted:

Thanks Sam! Now just to clarify, I was referring to the functions for the CMS, not Netlify functions.

Anyways, I found out it goes into the cms.js file in my repo