This commit is contained in:
Florian RICHER 2024-06-02 13:13:50 +02:00
parent c2ec1d9504
commit bd5c46d44d

View file

@ -184,29 +184,29 @@ pub fn PostElement() -> impl IntoView {
let post = create_resource(|| (), move |_| get_post(slug())); let post = create_resource(|| (), move |_| get_post(slug()));
let post_view = move || { let render_draft_notice = |post: &Post| -> Option<View> {
if post.metadata.draft {
return Some(view! {
<div class="bg-warning text-on_warning dark:bg-dark_warning dark:text-dart_on_warning rounded-md p-5 mb-5">
r#"
L'article est en cours d'écriture. La formulation peut ne pas être exacte et les phrases peuvent contenir des fautes.
"#
</div>
}.into_view());
}
None
};
let render_post_view = move || {
post.and_then(|post| { post.and_then(|post| {
let draft_notice = render_draft_notice(&post);
view! { view! {
<> <>
{ {draft_notice}
if post.metadata.draft { <PostHeader metadata=post.metadata.clone() full_element=true />
Some(view!{ <div inner_html={post.content.clone()}></div>
<div class="bg-warning text-on_warning dark:bg-dark_warning dark:text-dart_on_warning rounded-md p-5 mb-5"> </>
r#" }
L'article est en cours d'écriture. La formulation peut ne pas être exacte et les phrases peuvent contenir des fautes.
"#
</div>
})
} else {
None
}
}
<PostHeader metadata=post.metadata.clone() full_element=true />
<div inner_html={post.content.clone()}></div>
</>
}
}) })
}; };
@ -214,7 +214,7 @@ pub fn PostElement() -> impl IntoView {
<Suspense fallback=move || view! { <Loading title="Chargement du post...".to_string() /> }> <Suspense fallback=move || view! { <Loading title="Chargement du post...".to_string() /> }>
<Nav/> <Nav/>
<main class="post"> <main class="post">
{post_view} {render_post_view}
<script>load();</script> <script>load();</script>
</main> </main>
</Suspense> </Suspense>