Switch over to WebAssembly, Rust and Yew #35

Merged
BlakeRain merged 87 commits from yew-static into main 2023-08-30 18:01:40 +00:00
8 changed files with 1800 additions and 0 deletions
Showing only changes of commit a61c5027e6 - Show all commits

1
.gitignore vendored
View File

@ -44,3 +44,4 @@ yarn-error.log*
# Optimized images # Optimized images
/public/content/**/optimized /public/content/**/optimized
/public/content/images.sha256.json /public/content/images.sha256.json
/target

1716
Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

48
Cargo.toml Normal file
View File

@ -0,0 +1,48 @@
[package]
name = "site"
version = "2.0.0"
edition = "2021"
publish = false
[features]
ssr = ["yew/ssr"]
hydration = ["yew/hydration"]
[[bin]]
name = "site-hydrate"
required-features = [
"hydrate"
]
[[bin]]
name = "site-build"
required-features = [
"ssr"
]
[dependencies]
yew = { version = "0.20" }
yew-router = { version = "0.17" }
log = { version = "0.4" }
futures = { version = "0.3", features = ["std"], default-features = false }
[dependencies.yew_icons]
version = "0.7"
features = [
"LucideRss"
]
[target.'cfg(target_arch = "wasm32")'.dependencies]
wasm-bindgen-futures = { version = "0.4" }
wasm-logger = { version = "0.2" }
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
tokio = { version = "1.32", features = ["full"] }
axum = { version = "0.6" }
tower = { version = "0.4", features = ["make"] }
tower-http = { version = "0.4", features = ["fs"] }
env_logger = { version = "0.10" }
clap = { version = "4.3", features = ["derive"] }
hyper = { version = "0.14", features = ["server", "http1"] }
jemallocator = { version = "0.5" }

13
index.html Normal file
View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link
data-trunk
rel="rust"
data-bin="site-hydrate"
data-cargo-features="hydration"
/>
</head>
</html>

8
src/app.rs Normal file
View File

@ -0,0 +1,8 @@
use yew::{function_component, html, Html};
#[function_component(App)]
pub fn app() -> Html {
html! {
<h1>{"Hello, World!"}</h1>
}
}

8
src/bin/site-build.rs Normal file
View File

@ -0,0 +1,8 @@
use site::app::App;
use yew::ServerRenderer;
#[tokio::main]
async fn main() {
let renderer = ServerRenderer::<App>::new();
println!("{}", renderer.render().await);
}

5
src/bin/site-hydrate.rs Normal file
View File

@ -0,0 +1,5 @@
fn main() {
#[cfg(target_arch = "wasm32")]
wasm_logger::init(wasm_logger::Config::new(log::Level::Trace));
yew::Renderer::<App>::new().hydrate();
}

1
src/lib.rs Normal file
View File

@ -0,0 +1 @@
pub mod app;