gitea_pages/frontend/src/main.rs

47 lines
1.1 KiB
Rust

use bounce::{helmet::HelmetBridge, BounceRoot};
use implicit_clone::unsync::IString;
use yew::prelude::*;
use yew_router::prelude::*;
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
use frontend::{layouts, routes};
pub const DEFAULT_TITLE: &str = "Gitea Pages";
fn format_title(title: IString) -> IString {
IString::from(format!("{} | {}", title, DEFAULT_TITLE))
}
struct App;
impl Component for App {
type Message = ();
type Properties = ();
fn create(_ctx: &Context<Self>) -> Self {
Self
}
fn view(&self, _ctx: &Context<Self>) -> Html {
html! {
<BrowserRouter>
<BounceRoot>
<HelmetBridge default_title={DEFAULT_TITLE} {format_title} />
<layouts::Main>
<Switch<routes::Route> render={routes::switch} />
</layouts::Main>
</BounceRoot>
</BrowserRouter>
}
}
}
fn main() {
wasm_logger::init(wasm_logger::Config::default());
yew::Renderer::<App>::new().render();
}