diff --git a/src/app/models/mod.rs b/src/app/models/mod.rs index 73f805a..bc89fad 100644 --- a/src/app/models/mod.rs +++ b/src/app/models/mod.rs @@ -1,6 +1,6 @@ mod post; -pub use post::Post; +pub use post::{Post, PostMetadata}; cfg_if::cfg_if! { if #[cfg(feature = "ssr")] { diff --git a/src/app/pages/posts.rs b/src/app/pages/posts.rs index c5b94e1..c5f34d8 100644 --- a/src/app/pages/posts.rs +++ b/src/app/pages/posts.rs @@ -1,7 +1,7 @@ use leptos::*; use leptos_router::*; use crate::app::{ - models::Post, + models::{Post, PostMetadata}, components::{ Loading, Nav, ReadingTime, DateTime } @@ -49,6 +49,34 @@ pub async fn get_post( .and_then(|post| post.ok_or_else(|| ServerFnError::ServerError("Post not found".to_string()))) } +#[component] +pub fn PostHeader( + metadata: PostMetadata, + full_element: bool +) -> impl IntoView { + let class = if full_element { + "metadata border-b-2 pb-5" + } else { + "metadata" + }; + + let title = if full_element { + view! { <>{metadata.title.clone()}> }.into_view() + } else { + view! { {metadata.title.clone()} } + }; + + view! { +
{metadata.description.clone()}
+{post.metadata.description.clone()}
-{post.metadata.description.clone()}
-