From 72a1013829275c5ae2124cc6f7824ae37a6c97fc Mon Sep 17 00:00:00 2001 From: Maneren Date: Sun, 4 Aug 2024 17:25:03 +0200 Subject: [PATCH] add home icon to breadcrumbs --- src/app/components/breadcrumbs.rs | 38 +++++++++++++++++-------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/app/components/breadcrumbs.rs b/src/app/components/breadcrumbs.rs index 10da661..f744b15 100644 --- a/src/app/components/breadcrumbs.rs +++ b/src/app/components/breadcrumbs.rs @@ -1,4 +1,4 @@ -use std::{iter, path::PathBuf}; +use std::path::PathBuf; use leptos::*; @@ -8,32 +8,36 @@ use crate::app::utils::os_to_string; pub fn Breadcrumbs(path: Signal) -> impl IntoView { let breadcrumbs = move || { path.with(|path| { - let leading_breadcrumb = ("/".into(), "/index".into()); + path + .iter() + .scan(PathBuf::new(), |path, part| { + path.push(part); + let path = format!("/index/{}", path.display()); - let path_breadcrumbs = path.iter().scan(PathBuf::new(), |path, part| { - let part_str = os_to_string(part); - path.push(part); - let path = format!("/index/{}", path.display()); - - Some((part_str, path)) - }); - - iter::once(leading_breadcrumb) - .chain(path_breadcrumbs) - .map(|(name, path)| { - view! { + Some(view! {
  • - {name} + {os_to_string(part)}
  • - } + }) }) .collect_view() }) }; + let home_icon = view! { + + + + + + }; + view! { } }