app: Render to main to add scripts to the entire application

This commit is contained in:
traxys 2023-05-28 19:45:32 +02:00
parent db8cb0efff
commit 12fc86492d
2 changed files with 14 additions and 5 deletions

View file

@ -6,5 +6,8 @@
<link href="/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
<link data-trunk rel="copy-file" href="static/login.css" />
</head>
<body></body>
<body>
<main></main>
<script src="/bootstrap/js/bootstrap.bundle.min.js"></script>
</body>
</html>

View file

@ -21,9 +21,7 @@ enum Route {
fn App() -> Html {
html! {
<BrowserRouter>
<main>
<Switch<Route> render={switch} />
</main>
<Switch<Route> render={switch} />
</BrowserRouter>
}
}
@ -151,5 +149,13 @@ fn Login() -> Html {
fn main() {
console_log::init_with_level(Level::Debug).unwrap();
yew::Renderer::<App>::new().render();
yew::Renderer::<App>::with_root(
gloo_utils::document()
.body()
.expect("no body")
.get_elements_by_tag_name("main")
.item(0)
.expect("no main"),
)
.render();
}