mod installation; mod usage; use crate::components::SiteHeader; pub use installation::*; use leptos::*; use leptos_router::{use_location, use_navigate, Outlet}; use thaw::*; pub use usage::*; #[component] pub fn GuidePage() -> impl IntoView { let navigate = use_navigate(); let selected = create_rw_signal({ let loaction = use_location(); let mut pathname = loaction.pathname.get_untracked(); if pathname.starts_with("/thaw/guide/") { pathname.drain(12..).collect() } else { String::new() } }); create_effect(move |value| { let selected = selected.get(); if value.is_some() { navigate(&format!("/guide/{selected}"), Default::default()); } selected }); view! { { gen_guide_menu_data().into_view() } } } pub(crate) struct MenuGroupOption { pub label: String, pub children: Vec, } impl IntoView for MenuGroupOption { fn into_view(self) -> View { let Self { label, children } = self; view! { { children.into_iter().map(|v| v.into_view()).collect_view() } } } } pub(crate) struct MenuItemOption { pub label: String, pub value: String, } impl IntoView for MenuItemOption { fn into_view(self) -> View { let Self { label, value } = self; view! { } } } pub(crate) fn gen_guide_menu_data() -> Vec { vec![MenuGroupOption { label: "Getting Started".into(), children: vec![ MenuItemOption { value: "installation".into(), label: "Installation".into(), }, MenuItemOption { value: "usage".into(), label: "Usage".into(), }, ], }] }