Files
tavernworks/src/tale.rs

57 lines
1.3 KiB
Rust

use chrono::NaiveDateTime;
use serde::{Deserialize, Serialize};
/// A type alias representing the path to a Markdown file.
/// This type is used to point to the location of the content of a `Tale`.
#[cfg(feature = "publisher")]
pub type Markdown = std::path::PathBuf;
/// A type alias representing the HTML content of the tale.
#[cfg(not(feature = "publisher"))]
pub type Markdown = String;
/// Metadata describing a tale.
///
/// This includes details such as the title, author, summary, and
/// associated tags.
#[derive(Deserialize, Serialize)]
pub struct Lore
{
/// The title of the tale.
pub title: String,
/// A URL-friendly version of the title, used for routing and linking.
pub slug: String,
/// The name of the author who wrote the tale.
pub author: String,
/// A short summary or description of the tale.
pub summary: String,
/// A list of tags associated with the tale for categorization and
/// searching.
pub tags: Vec<String>,
/// The Date and Time that must elapse before this tale can be told.
pub publish_date: NaiveDateTime
}
/// Represents a post or story in the application.
#[derive(Deserialize, Serialize)]
pub struct Tale
{
/// Metadata of the post.
#[serde(flatten)]
pub lore: Lore,
/// The file path to the Markdown content of the tale.
pub story: Markdown
}