From 8d93c584a0bffb9200e70835dd12b8df5eff936d Mon Sep 17 00:00:00 2001 From: victor Date: Tue, 2 Apr 2024 09:08:45 -0600 Subject: [PATCH 1/4] moved hackernews example to stable --- examples/hackernews/Cargo.toml | 26 ++++++++++++++--------- examples/hackernews/index.html | 20 +++++++++++------ examples/hackernews/rust-toolchain.toml | 2 +- examples/hackernews/src/main.rs | 1 + examples/hackernews/src/routes/stories.rs | 2 +- examples/hackernews/src/routes/story.rs | 6 +++--- examples/hackernews/src/routes/users.rs | 2 +- 7 files changed, 36 insertions(+), 23 deletions(-) diff --git a/examples/hackernews/Cargo.toml b/examples/hackernews/Cargo.toml index e1e9a055c3..e4ca46f604 100644 --- a/examples/hackernews/Cargo.toml +++ b/examples/hackernews/Cargo.toml @@ -6,6 +6,10 @@ edition = "2021" [lib] crate-type = ["cdylib", "rlib"] +[[bin]] +name = "hackernews_bin" +path = "./src/main.rs" + [profile.release] codegen-units = 1 lto = true @@ -15,13 +19,13 @@ actix-files = { version = "0.6", optional = true } actix-web = { version = "4", optional = true, features = ["macros"] } console_log = "1" console_error_panic_hook = "0.1" -leptos = { path = "../../leptos", features = ["nightly"] } -leptos_meta = { path = "../../meta", features = ["nightly"] } +leptos = { path = "../../leptos" } leptos_actix = { path = "../../integrations/actix", optional = true } -leptos_router = { path = "../../router", features = ["nightly"] } +leptos_router = { path = "../../router" } +leptos_meta = { path = "../../meta" } log = "0.4" serde = { version = "1", features = ["derive"] } -gloo-net = { version = "0.2", features = ["http"] } +gloo-net = { version = "0.5", features = ["http"] } reqwest = { version = "0.11", features = ["json"] } tracing = "0.1" # openssl = { version = "0.10", features = ["v110"] } @@ -32,12 +36,12 @@ web-sys = { version = "0.3", features = ["AbortController", "AbortSignal"] } csr = ["leptos/csr", "leptos_meta/csr", "leptos_router/csr"] hydrate = ["leptos/hydrate", "leptos_meta/hydrate", "leptos_router/hydrate"] ssr = [ - "dep:actix-files", - "dep:actix-web", - "dep:leptos_actix", - "leptos/ssr", - "leptos_meta/ssr", - "leptos_router/ssr", + "dep:actix-files", + "dep:actix-web", + "dep:leptos_actix", + "leptos/ssr", + "leptos_meta/ssr", + "leptos_router/ssr", ] [profile.wasm-release] @@ -51,6 +55,8 @@ denylist = ["actix-files", "actix-web", "leptos_actix"] skip_feature_sets = [["csr", "ssr"], ["csr", "hydrate"], ["ssr", "hydrate"]] [package.metadata.leptos] +#Added to avoid name collition with lib package +bin-exe-name = "hackernews_bin" # The name used by wasm-bindgen/cargo-leptos for the JS/WASM bundle. Defaults to the crate name output-name = "hackernews" # The site root folder is where cargo-leptos generate all output. WARNING: all content of this folder will be erased on a rebuild. Use it in your server setup. diff --git a/examples/hackernews/index.html b/examples/hackernews/index.html index 609a9b5d08..96065ae844 100644 --- a/examples/hackernews/index.html +++ b/examples/hackernews/index.html @@ -1,8 +1,14 @@ - + - - - - - - \ No newline at end of file + + + + + + diff --git a/examples/hackernews/rust-toolchain.toml b/examples/hackernews/rust-toolchain.toml index 99fa95aaaf..292fe499e3 100644 --- a/examples/hackernews/rust-toolchain.toml +++ b/examples/hackernews/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "nightly-2024-03-31" +channel = "stable" diff --git a/examples/hackernews/src/main.rs b/examples/hackernews/src/main.rs index 5ee11f48c0..637266cc20 100644 --- a/examples/hackernews/src/main.rs +++ b/examples/hackernews/src/main.rs @@ -49,6 +49,7 @@ async fn main() -> std::io::Result<()> { #[cfg(not(feature = "ssr"))] fn main() { use hackernews::App; + use leptos::mount_to_body; _ = console_log::init_with_level(log::Level::Debug); console_error_panic_hook::set_once(); diff --git a/examples/hackernews/src/routes/stories.rs b/examples/hackernews/src/routes/stories.rs index 594667f45c..bc5d2214a4 100644 --- a/examples/hackernews/src/routes/stories.rs +++ b/examples/hackernews/src/routes/stories.rs @@ -37,7 +37,7 @@ pub fn Stories() -> impl IntoView { let hide_more_link = move || { stories.get().unwrap_or(None).unwrap_or_default().len() < 28 - || pending() + || pending.get() }; view! { diff --git a/examples/hackernews/src/routes/story.rs b/examples/hackernews/src/routes/story.rs index c63dafc043..e268febb67 100644 --- a/examples/hackernews/src/routes/story.rs +++ b/examples/hackernews/src/routes/story.rs @@ -7,7 +7,7 @@ use leptos_router::*; pub fn Story() -> impl IntoView { let params = use_params_map(); let story = create_resource( - move || params().get("id").cloned().unwrap_or_default(), + move || params.get().get("id").cloned().unwrap_or_default(), move |id| async move { if id.is_empty() { None @@ -87,7 +87,7 @@ pub fn Comment(comment: api::Comment) -> impl IntoView { { let comments_len = comment.comments.len(); - move || if open() { + move || if open.get() { "[-]".into() } else { format!("[+] {}{} collapsed", comments_len, pluralize(comments_len)) @@ -95,7 +95,7 @@ pub fn Comment(comment: api::Comment) -> impl IntoView { } - {move || open().then({ + {move || open.get().then({ let comments = comment.comments.clone(); move || view! {