-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add pre-save, pre-publish hooks to CMS #1348
Comments
I recently needed a widget to automatically generate a modified time for entries, but had to make do with generating it when the editor was opened. Seems like a good example of a widget that would benefit from these hooks. Could components declare |
I love the idea of events in general, big thumbs up for this. I'm not sure about the component methods approach - it introduces problems that are just unnecessary. |
Ha! Any ideas for alternatives? |
I think this feature could be very usefull for some cases. I have my content in a git submodules. So each netlify-cms update commit to my submodule repo. But My main repo does not change anymore so netlify does not trigger a new deploy. |
Oh yes this feature would be really nice! I could then create dynamically pages with a script within in my nextjs app. So let's say: As an author I create a new page and publish it over netlify cms, "on save" -> the hook kicks in, executes the script which creates tsx files in pages/ based on the .md files in content/. Are there any news about the progress here? |
See #2344 for a quick mockup of how this might be implemented. Unsure if this is the right direction but it's a suggestion. |
Commented, thanks for using a PR to promote a path forward! |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Has there been some movement on this or other ways of achieving this behaviour? I see that #2344 is still open. |
Well #2344 was also just closed for inactivity by the bot. :( It seems this whole project is pretty hit-or-miss when it comes to activity. The stale bot was just added yesterday and seems to have wiped a bunch of stuff out. |
I also desperately need this. Is this a WIP or just stale? |
This issue is not going to be closed. Introducing stale bot was a step towards maintaining a meaningful backlog - it’s actually a good thing. You’ll see us following up on virtually every issue on this repo over the next two weeks. Thank you all so much for your patience! Sent with GitHawk |
#1171 is somehow related in the way both mechanisms hook into specific CMS operations |
Just chiming in that this would be SUPER helpful for my project! Would love to see a path forward. |
You can now add events handlers for Doesn't allow modifying the entry data before publish (at the moment and open to discussion) - can anyone share a use case for changing the data before publish that can't be achieved using a custom widget? The reason for not allowing it yet is that it requires some thought on how to do it in a safe way. Meaning making sure any change conforms to the data validation enforced by the widgets. |
@erezrokah My use case was for a last modified date field. This can be achieved with a custom widget, but my effort a while back (see my comment above) only allowed me to update that time when a post was opened for editing, not when it was saved, which I guess could be more idiomatically handled with |
Thanks @delucis, that does make sense. Will keep the issue open for further discussion and feedback. |
@delucis have you been able to find a solution that allows for updating the time on publish rather than on opening the entry? i am also trying to create a "date modified" widget, but none of the solutions have been ideal. |
@vai0 It’s a while since I worked on this, but no, I just made do with using the time the entry was opened, I think. |
Per discussion in the Gitter channel, just making an issue for thoughts & discussion around adding some "hooks" to the CMS for pre-save and pre-publish events. These hooks could allow the CMS user to modify file content before persisting to the backend (and/or other content changes anyone might want to do in the given hook).
The text was updated successfully, but these errors were encountered: