I’m looking for a way to serve XML through Ghost that’s been created elsewhere - i.e. isn’t rendered by Handlebars as in the documentation.
Aside - this is part of a workaround for the lack of necessary attributes in Ghost to properly manage a podcast feed (like epsode number, the explicit flag, etc…). If those existed, I wouldn’t need to get XML working this way. But they don’t, so I do.
What I’d like to do is get Ghost to render a page in a similar way to that in the docs above, but with completely arbritrary text content that I can set through the API.
The approaches I’ve explored so far are:
- Create a placeholder Handlebars template which simply renders the XML information stored elsewhere - This is my preferred approach, but it fails because there isn’t a way to render plain-text page content. The excerpt attributes, whilst plaintext, aren’t large enough to store the contents of the file.
- Uploading a file to Ghost - The only file uploads I can find in the API documentation are for images. This means that the object will have the wrong MIME type, plus the URL that files get uploaded to can’t be made consistent, it changes with the date.
Limitations for this use-case:
- Because this is XML there’s no client-side rendering options. All has to be done server-side.
- HTTP redirects can’t be used.
- The path needs to stay the same when the data is changed, so it can be referenced elsewhere.
- I’m using Ghost Pro, so I can’t modify Ghost’s own code.
- The contents change relatively regularly, so this isn’t a set-and-forget kind of thing.
At the moment, my least-bad option is going to be to upload the file to internet-facing storage elsewhere. Which isn’t ideal when my goal has been to move everything over to Ghost!