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! { +
+

{title}

+

{metadata.description.clone()}

+ + + +
+ } +} + #[component] pub fn PostTags( tags: Vec @@ -82,13 +110,7 @@ pub fn PostListCard( } } -
- -

{post.metadata.title.clone()}

-

{post.metadata.description.clone()}

- - -
+ } } @@ -142,14 +164,7 @@ pub fn PostElement() -> impl IntoView { } } -
- format!("Image -

{post.metadata.title.clone()}

-

{post.metadata.description.clone()}

- - - -
+
diff --git a/style/post.css b/style/post.css index c653568..0d82e3f 100644 --- a/style/post.css +++ b/style/post.css @@ -62,6 +62,12 @@ & pre code { @apply p-0; } + + .metadata { + & > .icon_container, & > .tags_list { + @apply my-1; + } + } } .posts { @@ -83,7 +89,7 @@ } & > div { - @apply p-5 flex flex-col gap-3; + @apply p-5; } } }