web: add tag when viewing news posts
This commit is contained in:
parent
7828fa0ac8
commit
3138379e7d
@ -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![
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user