web: most post favicon more cachable

This commit is contained in:
Bill Thiede 2024-12-10 09:13:11 -08:00
parent 4c88ee18d3
commit a0eb291371

View File

@ -1095,13 +1095,20 @@ fn news_post(
}
fn render_news_post_header(post: &ShowThreadQueryThreadOnNewsPost) -> Node<Msg> {
let from = &post.site;
// TODO: move avatar/favicon stuff to the server side and and come up with a solution for emails
let avatar: Option<String> = None;
//let avatar: Option<String> = Some(String::from("https://bulma.io/images/placeholders/64x64.png"));
let id = post.thread_id.clone();
let is_unread = !post.is_read;
// TODO: use https://www.google.com/s2/favicons?domain={domain}
let avatar = render_avatar(avatar, &from, true);
let domain = &post.url;
let url = &post.url;
let idx = url
.match_indices('/')
.nth(2)
.map(|(idx, _)| idx)
.unwrap_or(url.len());
let domain = &url[..idx];
let favicon = div![
C![
"w-16",
@ -1114,7 +1121,7 @@ fn render_news_post_header(post: &ShowThreadQueryThreadOnNewsPost) -> Node<Msg>
"uppercase"
],
img![
C!["object-cover", "w-16", "h-16",],
C!["object-cover", "w-16", "h-16"],
attrs! {At::Src=>format!("https://www.google.com/s2/favicons?sz=64&domain={domain}")}
],
];