web: add tag when viewing news posts

This commit is contained in:
Bill Thiede 2024-10-27 12:27:16 -07:00
parent 7828fa0ac8
commit 3138379e7d

View File

@ -981,9 +981,43 @@ fn news_post(
set_title(subject);
let read_thread_id = post.thread_id.clone();
let unread_thread_id = post.thread_id.clone();
fn tag(tag: String, is_mobile: bool) -> Node<Msg> {
let hex = compute_color(&tag);
let style = style! {St::BackgroundColor=>hex};
let classes = C!["tag", IF!(is_mobile => "is-small")];
let attrs = attrs! {
At::Href => urls::search(&format!("tag:{tag}"), 0)
};
let tag = tag.clone();
div![
C!["control"],
div![
C!["tags", "has-addons"],
a![
classes,
attrs,
style,
match tag.as_str() {
"attachment" => span!["📎"],
"replied" => span![i![C!["fa-solid", "fa-reply"]]],
_ => span![&tag],
},
ev(Ev::Click, move |_| Msg::FrontPageRequest {
query: format!("tag:{tag}"),
after: None,
before: None,
first: None,
last: None,
})
]
]
]
}
div![
C!["thread"],
h3![C!["is-size-5"], subject],
tag(format!("News/{}", post.slug), false),
div![
C!["level", "is-mobile"],
div![