1
0
Fork 0
mirror of https://github.com/Nutomic/ibis.git synced 2025-02-04 15:44:40 +00:00
ibis/src/frontend/components/article_nav.rs

25 lines
860 B
Rust
Raw Normal View History

2024-01-24 16:12:17 +00:00
use crate::common::ArticleView;
use crate::frontend::app::GlobalState;
use leptos::*;
use leptos_router::*;
#[component]
pub fn ArticleNav(article: Resource<String, ArticleView>) -> impl IntoView {
let global_state = use_context::<RwSignal<GlobalState>>().unwrap();
view! {
<Suspense fallback=|| view! { "Loading..." }>
{move || article.get().map(|article| {
let title = article.article.title;
view!{
<nav class="inner">
<A href={format!("/article/{title}")}>"Read"</A>
<A href={format!("/article/{title}/history")}>"History"</A>
<Show when=move || global_state.with(|state| state.my_profile.is_some())>
<A href={format!("/article/{title}/edit")}>"Edit"</A>
</Show>
</nav>
}})}
</Suspense>
}
}