I’m currently posting programmatic updates to a page that already contains existing content I do not want to lose. Specifically, I am prepending HTML content to a page that already has content using the Ghost Admin API.
My current approach involves fetching the existing content, storing it, and then reposting the old content along with the new content. However, I’m curious if someone might know of a more efficient method to achieve this where I can simply add the new content.
I currently have a function calledupdateGhostBlog
This is where the HTML prepending takes place. The function first fetches the existing HTML content of a specified page (identified by TARGET_PAGE_ID
) using the Ghost Admin API. It stores this content in a variable (existingHtml
). Depending on the action (created
, updated
, etc.), it either prepends the new HTML content to this existing content or handles it differently. In this case, for the ‘created’ action, it prepends the new HTML (htmlContent
) to the existing content. The combined HTML is then used to update the page on the Ghost site through the Admin API.
Is there a more efficient way to prepend new data to a page without first retrieving the existing content? Since I’m doing this in a cloud function I don’t want to run up against time/data limits if the page gets too large.
Thanks!