API To Modify Code Injection?

It’d be nice if there was an API exposed that enabled us to edit the site header/footer code injection fields programmatically. The use case for this would be to stay up to date on the versions of libraries we’re using. For instance, we might be specifying version 1.20 of the PrismJS library:

<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.20.0/prism.min.js" integrity="sha256-3teItwIfMuVB74Alnxw/y5HAZ2irOsCULFff3EgbtEs=" crossorigin="anonymous"></script>

Currently, in order to update to version 1.21, we need to login to the admin page, go find the latest version, copy/paste this info over. That’s a pain and can lead to outdated versions.

While it is a good idea to keep your dependencies up to date, it’s even better to be testing those updates before deploying them. I would argue that this should be done manually incase a major version increment breaks your site.

Alternatively you could combine your dependencies into a build process done with GitHub Actions, followed by a step to automatically upload your theme to Ghost using our GitHub Action for Ghost themes:

This would provide you with some more automation, but still have control of the “in-between” steps to insert testing steps and deploying to staging environments :muscle:

1 Like