templates: Add a template for web applications

This commit is contained in:
traxys 2023-05-17 18:58:52 +02:00
parent 47094c899f
commit e380eff9b5
12 changed files with 328 additions and 0 deletions

View file

@ -0,0 +1,40 @@
use log::Level;
use yew::prelude::*;
use yew_router::prelude::*;
#[derive(Routable, Debug, Clone, Copy, PartialEq, Eq)]
enum Route {
#[at("/")]
Index,
#[at("/404")]
#[not_found]
NotFound,
}
#[function_component]
fn App() -> Html {
html! {
<BrowserRouter>
<main>
<Switch<Route> render={switch} />
</main>
</BrowserRouter>
}
}
fn switch(route: Route) -> Html {
match route {
Route::Index => html! {
"Index"
},
Route::NotFound => html! {
"Page not found"
},
}
}
fn main() {
console_log::init_with_level(Level::Debug).unwrap();
yew::Renderer::<App>::new().render();
}