add a bit more content to the router example
This commit is contained in:
1 file changed
+31
-14
@@ -15,31 +15,40 @@ fn App(cx: Scope) -> Element {
|
|||||||
// history: Box::new(MemoryHistory::with_initial_path("/apple").unwrap()),
|
// history: Box::new(MemoryHistory::with_initial_path("/apple").unwrap()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
&|| Segment::content(comp(RootIndex)).fixed("apple", comp(Apple)),
|
&|| {
|
||||||
|
Segment::content(comp(Home))
|
||||||
|
.fixed("apple", comp(Apple))
|
||||||
|
.fixed("potato", Route::content(comp(Potato)).name::<PotatoName>())
|
||||||
|
.fixed("earth_apple", named::<PotatoName>())
|
||||||
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
render! {
|
render! {
|
||||||
h1 { "Simple Example App" }
|
h1 { "Simple Example App" }
|
||||||
nav {
|
Outlet { }
|
||||||
Link {
|
Link {
|
||||||
target: named::<RootIndex>(),
|
target: named::<RootIndex>(),
|
||||||
"Go to root"
|
"Go to root"
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Outlet { }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn RootIndex(cx: Scope) -> Element {
|
fn Home(cx: Scope) -> Element {
|
||||||
render! {
|
render! {
|
||||||
h2 { "Root Index" }
|
h2 { "Root Index" }
|
||||||
ul {
|
ul {
|
||||||
li {
|
li { Link {
|
||||||
Link {
|
target: "/apple",
|
||||||
target: "/apple",
|
"Read about apples…"
|
||||||
"Read about apples…"
|
} }
|
||||||
}
|
li { Link {
|
||||||
}
|
target: named::<PotatoName>(),
|
||||||
|
"Read about potatoes…"
|
||||||
|
} }
|
||||||
|
li { Link {
|
||||||
|
target: "/earth_apple",
|
||||||
|
"Read about earth apples (literal translation of a german word for potato)…"
|
||||||
|
} }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -53,3 +62,11 @@ fn Apple(cx: Scope) -> Element {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct PotatoName;
|
||||||
|
fn Potato(cx: Scope) -> Element {
|
||||||
|
render! {
|
||||||
|
h2 { "Potato" }
|
||||||
|
p { "The potato grows underground. There are many recipes involving potatoes." }
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user