The emails module handles synchronization of Buttondown newsletter emails between remote API and local markdown files.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/buttondown/cli/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Emails are stored locally as markdown files with YAML frontmatter containing metadata. The module provides serialization, deserialization, and image reference resolution capabilities.Types
Email schema from OpenAPI specification.
FrontMatterFields
Metadata fields extracted to YAML frontmatter:RelativeImageReference
Represents a relative image path found in markdown content:Serialization Functions
deserialize()
Parses markdown content with YAML frontmatter into an email object.Markdown content with YAML frontmatter delimited by
---Parsed email object with frontmatter fields and body content
Whether the content was successfully parsed with valid frontmatter
Error message if parsing failed
Example
serialize()
Converts an email object into markdown content with YAML frontmatter.Email object containing body and frontmatter fields
Formatted markdown with YAML frontmatter
Behavior
- Removes fields with null, undefined, empty string, or empty object/array values
- Excludes fields matching default values defined in
FRONT_MATTER_FIELD_TO_DEFAULT_VALUE - Strips editor mode sigils from body content
- Formats YAML with 2-space indentation
Example
Image Reference Functions
findRelativeImageReferences()
Finds all relative image references in markdown content.Markdown content to search for image references
Array of relative image references found (excludes absolute URLs)
Example
replaceImageReference()
Replaces an image reference with a new URL.Markdown content containing the image reference
Original markdown image syntax to replace
New URL to use in the image reference
Alt text for the image
Updated markdown content with replaced reference
resolveRelativeImageReferences()
Replaces relative image paths with absolute URLs from synced images.Markdown content with relative image references
Directory containing the email file (for resolving relative paths)
Map of synced images with local paths and remote URLs
Content with relative paths replaced by absolute URLs
convertAbsoluteToRelativeImages()
Converts absolute image URLs to relative paths for local storage.Markdown content with absolute image URLs
Directory containing the email file
Map of synced images with local paths and remote URLs
Content with absolute URLs replaced by relative paths
Resource Objects
REMOTE_EMAILS_RESOURCE
Handles email operations with the Buttondown API.Methods
get(configuration) - Fetches all emails from the API with pagination set(value, configuration) - Creates or updates emails via API- Adds markdown mode sigil to email body
- Updates emails with
id, creates new emails withoutid - Returns operation counts (created, updated, deleted, failed)
LOCAL_EMAILS_RESOURCE
Handles email operations with local markdown files.Methods
get(configuration) - Reads all.md files from emails/ directory
set(value, configuration) - Writes emails as markdown files
- Creates files at
emails/{slug-or-id}.md - Uses slug for filename if available, otherwise uses ID