@@ -1,32 +1,52 @@
|
||||
use crate::error_template::{AppError, ErrorTemplate};
|
||||
|
||||
use leptos::*;
|
||||
use leptos::prelude::*;
|
||||
use leptos_meta::*;
|
||||
use leptos_router::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use leptos_router::{components::*, StaticSegment};
|
||||
|
||||
pub mod error_template;
|
||||
|
||||
#[cfg(feature = "ssr")]
|
||||
pub mod state;
|
||||
|
||||
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 />
|
||||
<MetaTags />
|
||||
</head>
|
||||
<body>
|
||||
<App />
|
||||
</body>
|
||||
</html>
|
||||
}
|
||||
}
|
||||
|
||||
#[component]
|
||||
pub fn App() -> impl IntoView {
|
||||
// Provides context that manages stylesheets, titles, meta tags, etc.
|
||||
provide_meta_context();
|
||||
|
||||
view! {
|
||||
<Stylesheet id="leptos" href="/pkg/%%name%%.css"/>
|
||||
<Stylesheet id="leptos" href="/pkg/%%name%%.css" />
|
||||
|
||||
// sets the document title
|
||||
<Title text="%%name%%"/>
|
||||
<Title text="%%name%%" />
|
||||
|
||||
// content for this welcome page
|
||||
<Router fallback=|| {
|
||||
let mut outside_errors = Errors::default();
|
||||
outside_errors.insert_with_default_key(AppError::NotFound);
|
||||
view! { <ErrorTemplate outside_errors/> }.into_view()
|
||||
}>
|
||||
<main>
|
||||
<Routes>
|
||||
<Route ssr=SsrMode::Async path="" view=HomePage/>
|
||||
<Router>
|
||||
<main class="">
|
||||
<Routes fallback=|| {
|
||||
let mut outside_errors = Errors::default();
|
||||
outside_errors.insert_with_default_key(AppError::NotFound);
|
||||
view! { <ErrorTemplate outside_errors /> }.into_view()
|
||||
}>
|
||||
<Route path=StaticSegment("") view=pages::home::HomePage />
|
||||
</Routes>
|
||||
</main>
|
||||
</Router>
|
||||
@@ -34,6 +54,8 @@ pub fn App() -> impl IntoView {
|
||||
}
|
||||
|
||||
#[component]
|
||||
fn HomePage() -> impl IntoView {
|
||||
view! {<h1> Hello %%name%% </h1>}
|
||||
pub fn HomePage() -> impl IntoView {
|
||||
view! {
|
||||
<h1> "%%name%%" </h1>
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user