Skip to content

Commit

Permalink
examples: fix hackernews examples oops
Browse files Browse the repository at this point in the history
  • Loading branch information
gbj committed Sep 29, 2023
1 parent fb914e1 commit f7adf6f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
5 changes: 1 addition & 4 deletions examples/hackernews/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ actix-web = { version = "4", optional = true, features = ["macros"] }
console_log = "1"
console_error_panic_hook = "0.1"
cfg-if = "1"
leptos = { path = "../../leptos", features = [
"nightly",
"experimental-islands",
] }
leptos = { path = "../../leptos", features = ["nightly"] }
leptos_meta = { path = "../../meta", features = ["nightly"] }
leptos_actix = { path = "../../integrations/actix", optional = true }
leptos_router = { path = "../../router", features = ["nightly"] }
Expand Down
13 changes: 5 additions & 8 deletions examples/hackernews/src/routes/stories.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,11 @@ pub fn Stories() -> impl IntoView {
};

view! {

<div class="news-view">
<div class="news-list-nav">
<span>
{move || if page() > 1 {
view! {

<a class="page-link"
href=move || format!("/{}?page={}", story_type(), page() - 1)
attr:aria_label="Previous Page"
Expand All @@ -57,7 +55,6 @@ pub fn Stories() -> impl IntoView {
}.into_any()
} else {
view! {

<span class="page-link disabled" aria-hidden="true">
"< prev"
</span>
Expand All @@ -79,12 +76,12 @@ pub fn Stories() -> impl IntoView {
<main class="news-list">
<div>
<Transition
fallback=move || view! { <p>"Loading..."</p> }
fallback=move || view! { <p>"Loading..."</p> }
set_pending
>
{move || match stories.get() {
None => None,
Some(None) => Some(view! { <p>"Error loading stories."</p> }.into_any()),
Some(None) => Some(view! { <p>"Error loading stories."</p> }.into_any()),
Some(Some(stories)) => {
Some(view! {
<ul>
Expand Down Expand Up @@ -123,7 +120,7 @@ fn Story(story: api::Story) -> impl IntoView {
}.into_view()
} else {
let title = story.title.clone();
view! { <A href=format!("/stories/{}", story.id)>{title.clone()}</A> }.into_view()
view! { <A href=format!("/stories/{}", story.id)>{title.clone()}</A> }.into_view()
}}
</span>
<br />
Expand All @@ -132,7 +129,7 @@ fn Story(story: api::Story) -> impl IntoView {
view! {
<span>
{"by "}
{story.user.map(|user| view ! { <A href=format!("/users/{user}")>{user.clone()}</A>})}
{story.user.map(|user| view ! { <A href=format!("/users/{user}")>{user.clone()}</A>})}
{format!(" {} | ", story.time_ago)}
<A href=format!("/stories/{}", story.id)>
{if story.comments_count.unwrap_or_default() > 0 {
Expand All @@ -145,7 +142,7 @@ fn Story(story: api::Story) -> impl IntoView {
}.into_view()
} else {
let title = story.title.clone();
view! { <A href=format!("/item/{}", story.id)>{title.clone()}</A> }.into_view()
view! { <A href=format!("/item/{}", story.id)>{title.clone()}</A> }.into_view()
}}
</span>
{(story.story_type != "link").then(|| view! {
Expand Down
2 changes: 1 addition & 1 deletion examples/hackernews_axum/src/routes/stories.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub fn Stories() -> impl IntoView {
>
<a href=move || format!("/{}?page={}", story_type(), page() + 1)
aria-label="Next Page"
>=
>
"more >"
</a>
</span>
Expand Down

0 comments on commit f7adf6f

Please sign in to comment.