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: StringUnique post ID (24-character hex string).
uuid: Option<String>UUID of the post (RFC 4122).
slug: StringURL-friendly identifier (unique, auto-generated from title).
comment_id: Option<String>ID used for Disqus/comment systems (typically same as id).
title: StringPost 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: PostStatusPublication 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.
Associated tags (array of tag objects or strings).
Post authors (array of author objects or email strings).
Primary author object.
primary_tag: Option<Value>Primary tag object.
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
impl Post
Sourcepub fn is_published(&self) -> bool
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());Sourcepub fn is_draft(&self) -> bool
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());Sourcepub fn is_scheduled(&self) -> bool
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());Sourcepub fn is_sent(&self) -> bool
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());Sourcepub fn is_featured(&self) -> bool
pub fn is_featured(&self) -> bool
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());Sourcepub fn is_email_only(&self) -> bool
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<'de> Deserialize<'de> for Post
impl<'de> Deserialize<'de> for Post
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Post
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.