keystatic
keystatic copied to clipboard
Feature request: accommodations for event hooks
I'm trying to add some automation & verification to my workflow. Some examples:
- When a post is set to 'published', automatically set the 'published_at' field to the current time
- A post may only be published if required fields are filled in
- When a post is created, store a random nonce so I can pass around unpublished drafts with secret URLs
- Disallow saving a post if it's already published and the slug would change
- Alternatively, create a redirect if I change a post slug
I don't know what Keystatic plans for the long term, but I think right now I could do all of this with just a few small changes:
- Commit to the
/updateroute being a stable API so I can build a middleware that intercepts it - Include the collection name and slug as fields in the
POSTbody to/update - Allow the server to signal that the client needs to reload the post content. Maybe a header?
- Have the UI gracefully handle if the server returns an HTTP error status & error message when saving.
With these changes, my server can intercept post updates and change the content however it needs. Looking at the existing network traffic, this feels fairly non-intrusive, but offers big benefits.