Skip to main content

Post

Struct Post 

Source
pub struct Post {
Show 38 fields pub id: String, pub uuid: Option<String>, pub slug: String, pub comment_id: Option<String>, pub title: String, pub lexical: Option<String>, pub html: Option<String>, pub excerpt: Option<String>, pub custom_excerpt: Option<String>, pub status: PostStatus, pub visibility: Option<String>, pub email_only: Option<bool>, pub created_at: Option<String>, pub updated_at: Option<String>, pub published_at: Option<String>, pub feature_image: Option<String>, pub feature_image_alt: Option<String>, pub feature_image_caption: Option<String>, pub featured: Option<bool>, pub tags: Option<Value>, pub authors: Option<Value>, pub primary_author: Option<Value>, pub primary_tag: Option<Value>, pub newsletter: Option<Value>, pub email: Option<Value>, pub url: Option<String>, pub canonical_url: Option<String>, pub meta_title: Option<String>, pub meta_description: Option<String>, pub og_image: Option<String>, pub og_title: Option<String>, pub og_description: Option<String>, pub twitter_image: Option<String>, pub twitter_title: Option<String>, pub twitter_description: Option<String>, pub codeinjection_head: Option<String>, pub codeinjection_foot: Option<String>, pub custom_template: Option<String>,
}
Expand description

A Ghost post/article.

Represents a post with all its metadata, content, and relationships. Posts can contain Lexical JSON content or HTML, along with extensive metadata for SEO, social sharing, and organization.

§Required Fields

Only title is required when creating a new post. The Ghost API will generate IDs, slugs, and timestamps automatically.

§Field Details

  • Identifiers: id, uuid, slug, comment_id
  • Content: title, lexical, html, excerpt, custom_excerpt
  • Status: status, visibility, email_only
  • Timestamps: created_at, updated_at, published_at
  • Media: feature_image, feature_image_alt, feature_image_caption
  • Flags: featured
  • Relationships: tags, authors, primary_author, primary_tag, newsletter
  • SEO: meta_title, meta_description, canonical_url, url
  • Social: og_* (Open Graph), twitter_* (Twitter Cards)
  • Code Injection: codeinjection_head, codeinjection_foot, custom_template

§Example

use ghost_io_api::models::post::{Post, PostStatus};
use serde_json::json;

let json = json!({
    "id": "5ddc9141c35e7700383b2937",
    "title": "Welcome",
    "slug": "welcome-short",
    "status": "published",
    "visibility": "public",
    "created_at": "2019-11-26T02:43:13.000Z",
    "published_at": "2019-11-26T02:44:17.000Z"
});

let post: Post = serde_json::from_value(json).unwrap();
assert_eq!(post.title, "Welcome");
assert_eq!(post.status, PostStatus::Published);
assert!(post.is_published());

Fields§

§id: String

Unique post ID (24-character hex string).

§uuid: Option<String>

UUID of the post (RFC 4122).

§slug: String

URL-friendly identifier (unique, auto-generated from title).

§comment_id: Option<String>

ID used for Disqus/comment systems (typically same as id).

§title: String

Post title (required on create).

§lexical: Option<String>

Rich text content in Lexical JSON format.

§html: Option<String>

Rendered HTML content (read-only, use ?formats=html).

§excerpt: Option<String>

Auto-generated excerpt from content.

§custom_excerpt: Option<String>

Custom excerpt/summary (overrides auto-generated).

§status: PostStatus

Publication status: draft, published, scheduled, or sent.

§visibility: Option<String>

Who can see the post: “public”, “members”, “paid”, “tiers”.

§email_only: Option<bool>

If true, post is sent as email only (no web post).

§created_at: Option<String>

When the post was created (ISO 8601).

§updated_at: Option<String>

When the post was last updated (ISO 8601).

§published_at: Option<String>

When the post was/will be published (ISO 8601).

§feature_image: Option<String>

URL to the feature image.

§feature_image_alt: Option<String>

Alt text for the feature image (accessibility).

§feature_image_caption: Option<String>

Caption for the feature image.

§featured: Option<bool>

Whether this post is featured/highlighted.

§tags: Option<Value>

Associated tags (array of tag objects or strings).

§authors: Option<Value>

Post authors (array of author objects or email strings).

§primary_author: Option<Value>

Primary author object.

§primary_tag: Option<Value>

Primary tag object.

§newsletter: Option<Value>

Newsletter this post belongs to.

§email: Option<Value>

Email send metadata (for posts sent as emails).

§url: Option<String>

Public URL of the post (read-only).

§canonical_url: Option<String>

Override canonical URL for SEO.

§meta_title: Option<String>

Custom meta title for <title> tag.

§meta_description: Option<String>

Custom meta description for <meta name="description">.

§og_image: Option<String>

Custom Open Graph image URL.

§og_title: Option<String>

Custom Open Graph title.

§og_description: Option<String>

Custom Open Graph description.

§twitter_image: Option<String>

Custom Twitter Card image URL.

§twitter_title: Option<String>

Custom Twitter Card title.

§twitter_description: Option<String>

Custom Twitter Card description.

§codeinjection_head: Option<String>

Custom HTML injected into <head> (Ghost Admin only).

§codeinjection_foot: Option<String>

Custom HTML injected before </body> (Ghost Admin only).

§custom_template: Option<String>

Custom theme template name to use for rendering.

Implementations§

Source§

impl Post

Source

pub fn is_published(&self) -> bool

Returns true if the post is published.

§Example
use ghost_io_api::models::post::{Post, PostStatus};

let mut post = Post::default();
post.status = PostStatus::Published;
assert!(post.is_published());
Source

pub fn is_draft(&self) -> bool

Returns true if the post is a draft.

§Example
use ghost_io_api::models::post::{Post, PostStatus};

let mut post = Post::default();
post.status = PostStatus::Draft;
assert!(post.is_draft());
Source

pub fn is_scheduled(&self) -> bool

Returns true if the post is scheduled for future publication.

§Example
use ghost_io_api::models::post::{Post, PostStatus};

let mut post = Post::default();
post.status = PostStatus::Scheduled;
assert!(post.is_scheduled());
Source

pub fn is_sent(&self) -> bool

Returns true if the post was sent as an email newsletter.

§Example
use ghost_io_api::models::post::{Post, PostStatus};

let mut post = Post::default();
post.status = PostStatus::Sent;
assert!(post.is_sent());

Returns true if the post is featured.

§Example
use ghost_io_api::models::post::Post;

let mut post = Post::default();
post.featured = Some(true);
assert!(post.is_featured());
Source

pub fn is_email_only(&self) -> bool

Returns true if the post is email-only (no web post).

§Example
use ghost_io_api::models::post::Post;

let mut post = Post::default();
post.email_only = Some(true);
assert!(post.is_email_only());

Trait Implementations§

Source§

impl Clone for Post

Source§

fn clone(&self) -> Post

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Post

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Post

Source§

fn default() -> Post

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Post

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for Post

Source§

impl PartialEq for Post

Source§

fn eq(&self, other: &Post) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Post

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Post

Auto Trait Implementations§

§

impl Freeze for Post

§

impl RefUnwindSafe for Post

§

impl Send for Post

§

impl Sync for Post

§

impl Unpin for Post

§

impl UnsafeUnpin for Post

§

impl UnwindSafe for Post

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more