Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 83 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,4 @@ chrono = "0.4"
thiserror = "2.0"
bincode = { version = "2.0.0-rc.3", features = ["serde"] }
reqwest = "0.13"
axum = "0.8"
14 changes: 8 additions & 6 deletions examples/function_router/src/content.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use serde::{Deserialize, Serialize};

use crate::generator::{Generated, Generator};

#[derive(Clone, Debug, Eq, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
pub struct Author {
pub seed: u32,
pub name: String,
Expand All @@ -22,7 +24,7 @@ impl Generated for Author {
}
}

#[derive(Clone, Debug, Eq, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
pub struct PostMeta {
pub seed: u32,
pub title: String,
Expand All @@ -48,7 +50,7 @@ impl Generated for PostMeta {
}
}

#[derive(Clone, Debug, Eq, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
pub struct Post {
pub meta: PostMeta,
pub content: Vec<PostPart>,
Expand All @@ -68,7 +70,7 @@ impl Generated for Post {
}
}

#[derive(Clone, Debug, Eq, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
pub enum PostPart {
Section(Section),
Quote(Quote),
Expand All @@ -87,7 +89,7 @@ impl Generated for PostPart {
}
}

#[derive(Clone, Debug, Eq, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
pub struct Section {
pub title: String,
pub paragraphs: Vec<String>,
Expand All @@ -112,7 +114,7 @@ impl Generated for Section {
}
}

#[derive(Clone, Debug, Eq, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
pub struct Quote {
pub author: Author,
pub content: String,
Expand Down
6 changes: 3 additions & 3 deletions examples/function_router/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
// Hence, it may not yield the same value on the client and server side.

mod app;
mod components;
mod content;
pub mod components;
pub mod content;
mod generator;
pub mod imagegen;
mod pages;
pub mod pages;

pub use app::*;
pub use content::*;
Expand Down
20 changes: 13 additions & 7 deletions examples/ssr_router/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ version = "0.1.0"
edition = "2024"
rust-version.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[[bin]]
name = "ssr_router_hydrate"
required-features = ["hydration"]
Expand All @@ -16,7 +14,13 @@ required-features = ["ssr"]

[dependencies]
yew = { path = "../../packages/yew" }
yew-link = { path = "../../packages/yew-link" }
yew-router = { path = "../../packages/yew-router" }
function_router = { path = "../function_router" }
rand = { workspace = true }
getrandom = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
futures = { workspace = true, features = ["std"] }
hyper-util = "0.1.20"

Expand All @@ -26,9 +30,8 @@ tracing-web.workspace = true
tracing-subscriber.workspace = true

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
yew-router = { path = "../../packages/yew-router" }
tokio = { workspace = true, features = ["macros", "rt-multi-thread", "net", "fs"] }
axum = "0.8"
axum = { workspace = true }
tower = { version = "0.5", features = ["make"] }
tower-http = { version = "0.6", features = ["fs", "cors"] }
env_logger = "0.11"
Expand All @@ -40,12 +43,15 @@ jemallocator = "0.5"

[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
wasm-bindgen-test.workspace = true
wasm-bindgen.workspace = true
web-sys = { workspace = true }
gloo = { workspace = true }
ssr-e2e-harness = { path = "../../tools/ssr-e2e-harness" }

[dev-dependencies]
yew = { path = "../../packages/yew", features = ["hydration"] }
yew = { path = "../../packages/yew", features = ["hydration", "test"] }
yew-link = { path = "../../packages/yew-link", features = ["hydration"] }

[features]
ssr = ["yew/ssr"]
hydration = ["yew/hydration"]
ssr = ["yew/ssr", "yew-link/ssr", "yew-link/axum"]
hydration = ["yew/hydration", "yew-link/hydration"]
7 changes: 5 additions & 2 deletions examples/ssr_router/src/bin/ssr_router_hydrate.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use function_router::App;
use ssr_router::{App, AppProps, LINK_ENDPOINT};

fn main() {
#[cfg(target_arch = "wasm32")]
Expand All @@ -11,5 +11,8 @@ fn main() {
use tracing_subscriber::prelude::*;
tracing_subscriber::registry().with(fmt_layer).init();
}
yew::Renderer::<App>::new().hydrate();
yew::Renderer::<App>::with_props(AppProps {
endpoint: LINK_ENDPOINT.into(),
})
.hydrate();
}
Loading
Loading