use dioxus::prelude::*; use std::sync::Arc; use crate::{Database, Lore, Tale}; #[server] pub async fn get_blog_list() -> Result, ServerFnError> { let db = server_context() .get::>() .ok_or_else(|| ServerFnError::ServerError("Database context not available".to_string()))?; let summaries = db.get_tales_summary(&[]).await .map_err(|e| ServerFnError::ServerError(e.to_string()))?; Ok(summaries) } #[server] pub async fn get_blog_post(slug: String) -> Result { let db = server_context() .get::>() .ok_or_else(|| ServerFnError::ServerError("Database context not available".to_string()))?; let tale = db.get_tale_by_slug(&slug).await .map_err(|e| ServerFnError::ServerError(e.to_string()))?; tale.ok_or(ServerFnError::ServerError("Post not found".into())) }