keystatic icon indicating copy to clipboard operation
keystatic copied to clipboard

Feature request: accommodations for event hooks

Open spiffytech opened this issue 3 months ago • 0 comments

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:

  1. Commit to the /update route being a stable API so I can build a middleware that intercepts it
  2. Include the collection name and slug as fields in the POST body to /update
  3. Allow the server to signal that the client needs to reload the post content. Maybe a header?
  4. 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.

spiffytech avatar Sep 12 '25 13:09 spiffytech