Switch over to WebAssembly, Rust and Yew #35
1
.gitignore
vendored
1
.gitignore
vendored
@ -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
1716
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
48
Cargo.toml
Normal file
48
Cargo.toml
Normal 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
13
index.html
Normal 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
8
src/app.rs
Normal 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
8
src/bin/site-build.rs
Normal 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
5
src/bin/site-hydrate.rs
Normal 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
1
src/lib.rs
Normal file
@ -0,0 +1 @@
|
|||||||
|
pub mod app;
|
Loading…
Reference in New Issue
Block a user