TLDR;
How can I store raw json in a ghost page and access that in my custom theme?
I am creating a theme for a high volume site. Most if not all of the page/posts will be built on 3rd party data. I have written nodejs scripts to gather the data and then use the ghost api and handlebars to post html merged with the data into a new post each time.
In operation, each page will be subject to updates (which will decrease in frequency over time. So I will need to rewrite these pages from time to time.
Also, I may change the theme and hence the layout at some point in the future.
This works as far as it goes but now that I have moved onto the actual theme, I have questions around themnatter of if it is a good practice or necessary to blend the end-user html (which gives the layout that the theme is responsible for with the data on the page.
Currently I create the page via api with an html block.
What I wonder is if there is a way to save just the data via api, and then let the theme do all the formatting based on the context of the page (or other db query if that’s a thing that’s possible).
I understand that the current {{content}} handlebar tag can’t be modified directly. Is that correct?
One possile way to approach this seems to be:
1 - store data via api as stingified json
2 - in the theme, capture that stringified data and convert it so regular json data (but how?)
3 - pass that json data to a new partial that would replace {{content}} in my theme
I understand that I am really pushing “the ghost way” here. In my use case, I don’t care that much about the UI of editing posts and pages, that will all be done by script.
But I am interested in not rewriting all the mail bits like I would have to if I built this from scratch from nextjs.
Right now, I am building an MVP to get things launched, and thinking about how I will move forward beyond that and into actual operations and scaling. Maybe eventually this will need to be redone, but for nowit does seem like if I can separate the UI from the data this way, I should do that from the very beginning.
So, has anyone tried something like this that you can share your experience? Or ideas with how I might do it?