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

View file

@ -184,26 +184,26 @@ 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> {
post.and_then(|post| {
view! {
<>
{
if post.metadata.draft { if post.metadata.draft {
Some(view!{ 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"> <div class="bg-warning text-on_warning dark:bg-dark_warning dark:text-dart_on_warning rounded-md p-5 mb-5">
r#" r#"
L'article est en cours d'écriture. La formulation peut ne pas être exacte et les phrases peuvent contenir des fautes. L'article est en cours d'écriture. La formulation peut ne pas être exacte et les phrases peuvent contenir des fautes.
"# "#
</div> </div>
}) }.into_view());
} else { }
None None
} };
}
let render_post_view = move || {
post.and_then(|post| {
let draft_notice = render_draft_notice(&post);
view! {
<>
{draft_notice}
<PostHeader metadata=post.metadata.clone() full_element=true /> <PostHeader metadata=post.metadata.clone() full_element=true />
<div inner_html={post.content.clone()}></div> <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>