Update a blog post with new data.
Args:
post_id: The ID of the post to update
update_data: Dictionary containing the updated data and updated_at timestamp.
Note: 'updated_at' is required. If 'lexical' is provided, it must be a valid JSON string.
The lexical content must be a properly escaped JSON string in this format:
{
"root": {
"children": [
{
"children": [
{
"detail": 0,
"format": 0,
"mode": "normal",
"style": "",
"text": "Your content here",
"type": "text",
"version": 1
}
],
"direction": "ltr",
"format": "",
"indent": 0,
"type": "paragraph",
"version": 1
}
],
"direction": "ltr",
"format": "",
"indent": 0,
"type": "root",
"version": 1
}
}
Example usage:
update_data = {
"post_id": "67abcffb7f82ac000179d76f",
"update_data": {
"updated_at": "2025-02-11T22:54:40.000Z",
"lexical": "{"root":{"children":[{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"Hello World","type":"text","version":1}],"direction":"ltr","format":"","indent":0,"type":"paragraph","version":1}],"direction":"ltr","format":"","indent":0,"type":"root","version":1}}"
}
}
Updatable fields for a blog post:
- slug: Unique URL slug for the post.
- id: Identifier of the post.
- uuid: Universally unique identifier for the post.
- title: The title of the post.
- lexical: JSON string representing the post content in lexical format.
- html: HTML version of the post content.
- comment_id: Identifier for the comment thread.
- feature_image: URL to the post's feature image.
- feature_image_alt: Alternate text for the feature image.
- feature_image_caption: Caption for the feature image.
- featured: Boolean flag indicating if the post is featured.
- status: The publication status (e.g., published, draft).
- visibility: Visibility setting (e.g., public, private).
- created_at: Timestamp when the post was created.
- updated_at: Timestamp when the post was last updated.
- published_at: Timestamp when the post was published.
- custom_excerpt: Custom excerpt text for the post.
- codeinjection_head: Code to be injected into the head section.
- codeinjection_foot: Code to be injected into the footer section.
- custom_template: Custom template assigned to the post.
- canonical_url: The canonical URL for SEO purposes.
- tags: List of tag objects associated with the post.
- authors: List of author objects for the post.
- primary_author: The primary author object.
- primary_tag: The primary tag object.
- url: Direct URL link to the post.
- excerpt: Short excerpt or summary of the post.
- og_image: Open Graph image URL for social sharing.
- og_title: Open Graph title for social sharing.
- og_description: Open Graph description for social sharing.
- twitter_image: Twitter-specific image URL.
- twitter_title: Twitter-specific title.
- twitter_description: Twitter-specific description.
- meta_title: Meta title for SEO.
- meta_description: Meta description for SEO.
- email_only: Boolean flag indicating if the post is for email distribution only.
- newsletter: Dictionary containing newsletter configuration details.
- email: Dictionary containing email details related to the post.
ctx: Optional context for logging
Returns:
Formatted string containing the updated post details
Raises:
GhostError: If there is an error accessing the Ghost API or missing required fields