update islands example
This commit is contained in:
parent
1182aff410
commit
7c5b7fcbb1
|
@ -1,5 +1,24 @@
|
|||
use leptos::prelude::*;
|
||||
|
||||
pub fn shell(options: &LeptosOptions) -> impl IntoView {
|
||||
view! {
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<AutoReload options=options.clone() />
|
||||
<HydrationScripts options=options.clone() islands=true/>
|
||||
<link rel="stylesheet" id="leptos" href="/pkg/todo_app_sqlite_axum.css"/>
|
||||
<link rel="shortcut icon" type="image/ico" href="/favicon.ico"/>
|
||||
</head>
|
||||
<body>
|
||||
<App/>
|
||||
</body>
|
||||
</html>
|
||||
}
|
||||
}
|
||||
|
||||
#[component]
|
||||
pub fn App() -> impl IntoView {
|
||||
view! {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{error_template::ErrorTemplate, errors::TodoAppError};
|
||||
use crate::{app::shell, error_template::ErrorTemplate, errors::TodoAppError};
|
||||
use axum::{
|
||||
body::Body,
|
||||
extract::State,
|
||||
|
@ -22,10 +22,8 @@ pub async fn file_and_error_handler(
|
|||
} else {
|
||||
let mut errors = Errors::default();
|
||||
errors.insert_with_default_key(TodoAppError::NotFound);
|
||||
let handler = leptos_axum::render_app_to_stream(
|
||||
options.to_owned(),
|
||||
move || view! { <ErrorTemplate outside_errors=errors.clone()/> },
|
||||
);
|
||||
let handler =
|
||||
leptos_axum::render_app_to_stream(move || shell(&options));
|
||||
handler(req).await.into_response()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,26 +26,8 @@ async fn main() {
|
|||
let app = Router::new()
|
||||
.leptos_routes(&leptos_options, routes, {
|
||||
let leptos_options = leptos_options.clone();
|
||||
move || {
|
||||
use leptos::prelude::*;
|
||||
|
||||
view! {
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<AutoReload options=leptos_options.clone() />
|
||||
<HydrationScripts options=leptos_options.clone() islands=true/>
|
||||
<link rel="stylesheet" id="leptos" href="/pkg/todo_app_sqlite_axum.css"/>
|
||||
<link rel="shortcut icon" type="image/ico" href="/favicon.ico"/>
|
||||
</head>
|
||||
<body>
|
||||
<App/>
|
||||
</body>
|
||||
</html>
|
||||
}
|
||||
}})
|
||||
move || shell(&leptos_options)
|
||||
})
|
||||
.fallback(file_and_error_handler)
|
||||
.with_state(leptos_options);
|
||||
|
||||
|
|
Loading…
Reference in New Issue