diff --git a/src/pages/component.rs b/src/pages/component.rs index d5e2f95..ceed7cb 100644 --- a/src/pages/component.rs +++ b/src/pages/component.rs @@ -95,3 +95,9 @@ pub async fn render_page(content: PreEscaped, ctx: RequestContext) -> St ) .await } + +pub fn favicon(site: &str) -> PreEscaped { + html! { + img class="h-8 w-8 m-2" src=(format!("/favicon/{site}")) {}; + } +} diff --git a/src/pages/mod.rs b/src/pages/mod.rs index 562281f..99d11c5 100644 --- a/src/pages/mod.rs +++ b/src/pages/mod.rs @@ -57,7 +57,7 @@ pub async fn index(ctx: RequestContext, arc: &State) -> StringRe @for site in websites { a href=(format!("/d/{site}")) class="bg-neutral-900 shadow-md rounded-lg hover:bg-neutral-800 bg-gray-1 hover:cursor-pointer transition-all duration-300 flex flex-col items-center justify-center aspect-square max-w-60" { div class="bg-blue-500 text-white rounded-full p-4" { - img class="h-8 w-8" src=(format!("/favicon/{site}")) {}; + (favicon(&site)) }; p class="mt-4 text-base font-medium" { (site) }; }; @@ -182,7 +182,7 @@ pub fn gen_search_element(x: &DocEmbedding) -> PreEscaped { hx-get=(format!("/d/{}/{}", x.domain, x.path)) hx-target="#main_content" hx-push-url="true" hx-swap="innerHTML" { - img class="p-2" src=(format!("/favicon/{}", &x.domain)); + (favicon(&x.domain)) a { (x.domain) }; (slash_seperator()); (gen_path_header(x.path.split('/').collect(), &x.domain, false));