feat(demo): remove regex

This commit is contained in:
luoxiao 2023-10-11 21:12:45 +08:00
parent 63007dc7c4
commit 17f909d861
2 changed files with 8 additions and 15 deletions

View file

@ -13,7 +13,6 @@ icondata = { version = "0.0.7", features = [
"AiCheckOutlined",
] }
leptos_router = { version = "0.5.1", features = ["csr"] }
regex = "1.8.2"
leptos_devtools = "0.0.1"
prisms = { git = "https://github.com/luoxiaozero/prisms" }

View file

@ -2,25 +2,19 @@ use crate::components::SiteHeader;
use leptos::*;
use leptos_router::{use_location, use_navigate, Outlet};
use melt_ui::*;
use regex::Regex;
#[component]
pub fn ComponentsPage() -> impl IntoView {
let loaction = use_location();
let navigate = use_navigate();
let selected = create_rw_signal(String::from(""));
create_effect(move |_| {
let pathname = loaction.pathname.get();
let selected = create_rw_signal({
let loaction = use_location();
let mut pathname = loaction.pathname.get_untracked();
let re = Regex::new(r"^/melt-ui/components/(.+)$").unwrap();
let Some(caps) = re.captures(&pathname) else {
return;
};
let Some(path) = caps.get(1) else {
return;
};
let path = path.as_str().to_string();
selected.set(path);
if pathname.starts_with("/melt-ui/components/") {
pathname.drain(20..).collect()
} else {
String::new()
}
});
create_effect(move |value| {