Expand description
§riley-cms-core
Core library for riley_cms - a minimal, self-hosted headless CMS.
This crate provides the domain logic for riley_cms without any HTTP or CLI concerns. It can be embedded in other Rust applications or used standalone.
§Features
- Content Management: Parse and query posts and series from a Git-based content directory
- S3/R2 Storage: Upload and list assets from S3-compatible storage
- In-Memory Caching: Fast content access with cache refresh on demand
- Visibility Control: Support for drafts, scheduled posts, and live content
§Quick Start
ⓘ
use riley_cms_core::{RileyCms, resolve_config, ListOptions};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Load config from standard locations
let config = resolve_config(None)?;
// Create the RileyCms instance
let riley_cms = RileyCms::from_config(config).await?;
// List all live posts
let posts = riley_cms.list_posts(&ListOptions::default()).await?;
for post in posts.items {
println!("{}: {}", post.slug, post.title);
}
// Get a specific post
if let Some(post) = riley_cms.get_post("my-post").await? {
println!("Content: {}", post.content);
}
Ok(())
}§Content Structure
riley_cms expects content in this structure:
content/
├── my-post/
│ ├── config.toml
│ └── content.mdx
└── my-series/
├── series.toml
├── part-one/
│ ├── config.toml
│ └── content.mdx
└── part-two/
├── config.toml
└── content.mdx§Visibility Model
Content visibility is controlled by the goes_live_at field:
None→ Draft (only visible withinclude_drafts)Some(past_date)→ Live (always visible)Some(future_date)→ Scheduled (only visible withinclude_scheduled)
Re-exports§
pub use git::BodyStream;pub use git::GitBackend;pub use git::GitCgiCompletion;pub use git::GitCgiHeaders;pub use git::GitCgiStreamResponse;
Modules§
- git
- Git Smart HTTP protocol support via git-http-backend CGI
Structs§
- Asset
- An asset in the storage bucket
- Asset
List Options - Options for listing assets with pagination
- Asset
List Result - Paginated asset list result
- Config
- Wrapper for loading config from file
- Content
Cache - In-memory cache of parsed content
- GitConfig
- Git configuration
- List
Options - Options for listing content
- List
Result - Paginated list result
- Post
- A blog post with full content
- Post
Config - Post configuration from config.toml
- Post
Summary - Post summary without content (for list endpoints)
- Riley
Cms - Main entry point for riley_cms functionality.
- Riley
CmsConfig - Full configuration for riley_cms
- Series
- A series with its posts
- Series
Config - Series configuration from series.toml
- Series
Post Summary - Post summary within a series (includes order)
- Series
Summary - Series summary without posts (for list endpoints)
- Storage
- Storage backend for assets
- Validation
Error - Content validation error
Enums§
- Error
- Error types for riley-cms-core
Functions§
- resolve_
config - Resolve config file path using the resolution order:
Type Aliases§
- Result
- Result type for riley-cms-core operations