From 0e3d97ae97d955ce0d61fc050333c59cb7d1a04f Mon Sep 17 00:00:00 2001 From: alemi Date: Thu, 4 Jul 2024 02:36:31 +0200 Subject: [PATCH] feat(web): show hastag badges on posts --- web/src/objects/item.rs | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/web/src/objects/item.rs b/web/src/objects/item.rs index ed27fa6b..0186aa91 100644 --- a/web/src/objects/item.rs +++ b/web/src/objects/item.rs @@ -58,23 +58,37 @@ pub fn Object( content = content.replace(&from, &to); } - - let audience_badge = object.audience().id().str() .map(|x| view! { - - + + & - + {Uri::pretty(&x, 30)} }); + let hashtag_badges = object.tag().filter_map(|x| { + if let Ok(apb::LinkType::Hashtag) = apb::Link::link_type(&x) { + let name = apb::Link::name(&x).unwrap_or_default().replace('#', ""); + let href = Uri::web(U::Hashtag, &name); + Some(view! { + + + # + + {name} + + + + }) + } else { + None + } + }).collect_view(); + let post_image = object.image().get().and_then(|x| x.url().id().str()).map(|x| { let (expand, set_expand) = create_signal(false); view! { @@ -140,6 +154,7 @@ pub fn Object( {post}
+ {if !reply { Some(hashtag_badges) } else { None }} {if !reply { audience_badge } else { None }}