diff --git a/Cargo.toml b/Cargo.toml index 2367174dc..06ac19814 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,6 +33,8 @@ members = [ # libraries "meta", "router", + "routing", + "is_server", ] exclude = ["benchmarks", "examples"] diff --git a/examples/router/Cargo.toml b/examples/router/Cargo.toml index 11a7511e9..faad2fd5f 100644 --- a/examples/router/Cargo.toml +++ b/examples/router/Cargo.toml @@ -10,12 +10,16 @@ lto = true [dependencies] console_log = "1" log = "0.4" -leptos = { path = "../../leptos", features = ["csr"] } -leptos_router = { path = "../../router", features = ["csr"] } +leptos = { path = "../../leptos", features = ["csr", "tracing"] } +routing = { path = "../../routing", features = ["tracing"] } +#leptos_router = { path = "../../router", features = ["csr"] } serde = { version = "1", features = ["derive"] } futures = "0.3" console_error_panic_hook = "0.1.7" -leptos_meta = { path = "../../meta", features = ["csr"] } +tracing-subscriber = "0.3.18" +tracing-subscriber-wasm = "0.1.0" +tracing = "0.1.40" +#leptos_meta = { path = "../../meta", features = ["csr"] } [dev-dependencies] wasm-bindgen-test = "0.3.0" diff --git a/examples/router/src/api.rs b/examples/router/src/api.rs index cac7d6069..6ed4cfd9f 100644 --- a/examples/router/src/api.rs +++ b/examples/router/src/api.rs @@ -2,7 +2,7 @@ use futures::{ channel::oneshot::{self, Canceled}, Future, }; -use leptos::set_timeout; +use leptos::leptos_dom::helpers::set_timeout; use serde::{Deserialize, Serialize}; use std::time::Duration; diff --git a/examples/router/src/lib.rs b/examples/router/src/lib.rs index aeb0474fb..e0fb2d2b3 100644 --- a/examples/router/src/lib.rs +++ b/examples/router/src/lib.rs @@ -1,20 +1,69 @@ mod api; use crate::api::*; -use leptos::{logging::log, *}; -use leptos_router::*; +use leptos::{ + component, + prelude::*, + reactive_graph::{ + owner::{provide_context, use_context, Owner}, + signal::ArcRwSignal, + }, + view, IntoView, +}; +use log::{debug, info}; +use routing::{ + location::{BrowserUrl, Location}, + NestedRoute, Router, Routes, StaticSegment, +}; #[derive(Copy, Clone, Debug, PartialEq, Eq)] struct ExampleContext(i32); #[component] pub fn RouterExample() -> impl IntoView { - log::debug!("rendering "); + info!("rendering "); // contexts are passed down through the route tree provide_context(ExampleContext(0)); + let router = Router::new( + BrowserUrl::new().unwrap(), + Routes::new(( + NestedRoute { + segments: StaticSegment("settings"), + children: (), + data: (), + view: Settings, + }, + NestedRoute { + segments: StaticSegment("about"), + children: (), + data: (), + view: About, + }, + )), + || "This page could not be found.", + ); + view! { - + + {router} + /*