I am creating a custom integration and will be including a js script on each page of the site (via the footer) which would insert an extra element on the page. This is all good, except for the element is dependent on information within the page such as the title of the page and the body - so I need to extract these and I thought the best way would be using the content API.
However, my issue is that I can easily get content for ‘all posts’ from the site, using an API endpoint
eg. https://demo.ghost.io/ghost/api/v2/content/posts/?key=22444f78447824223cefc48062 …but I need to get the content of the current page (where the script is loading) and I can’t find an identifier (such as ID) within the markup to use…I could write some js to scrape the title and body on the page, but this seems messy and I would rather use the API, so I guess I am looking for a way to get the ID of my post from within the markup? (preferably without editing themes, as I want to make this custom integration available to anyone!)
Thanks for taking the time to read my question and hopefully you understand my issue!