How can I check on my post page whether the post is published or a draft? I would like to display a “not published yet” warning on the page when I share the preview url.
You can’t share preview url
Hey @woubuc
If you’re trying to share the unlisted preview URL, it will follow the format {url}/p/{id}
- e.g. https://example.com/p/42984787-ef27-4826-9f68-14ae10e725bb
I was looking for a field in the post object on the page. How can I check the URL format in the hbs template?
Aah, if you’re using handlebars, you can use the {{is}}
helper. The preview context is missing from there, but it works:
{{#is "preview"}}
<p style="color: red; font-size:100px">This is a draft, please do not share this link with other people</p>
{{/is}}
How stable is this to use in production? I’m a little anxious about relying on undocumented behaviour…
This has been part of Ghost since at least 1.x, and if I recall correctly, it was documented before the docs got a major overhaul; I think it’s more that this specific thing didn’t get copied over rather than not being documented