Skip to content

Commit

Permalink
feat(site): impl prime domain debugging resouce on homepage
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbchron committed Nov 25, 2024
1 parent 5be3c94 commit 81fb98a
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion crates/site-app/src/pages/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
use leptos::prelude::*;
use leptos::{either::Either, prelude::*};

use crate::components::Section;

#[component]
pub fn HomePage() -> impl IntoView {
let fallback = move || {
view! {
<p>"Loading photos..."</p>
}
};
let photos = Resource::new(|| (), |_| enumerate_photos());
let photos_suspense_viewer = move || {
Suspend::new(async move {
match photos.await {
Ok(photos) => Either::Left(view! {
<pre>{ format!("{photos:#?}") }</pre>
}),
Err(e) => Either::Right(view! {
<pre>{ format!("{e}") }</pre>
}),
}
})
};

view! {
<Section>
<p class="text-5xl font-serif font-semibold tracking-tight mb-4">
Expand All @@ -12,6 +31,16 @@ pub fn HomePage() -> impl IntoView {
<p class="max-w-prose">
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nonne merninisti licere mihi ista probare, quae sunt a te dicta? Duo Reges: constructio interrete. Quae cum dixisset, finem ille."
</p>
<Suspense fallback>
{ photos_suspense_viewer }
</Suspense>
</Section>
}
}

#[server]
pub async fn enumerate_photos() -> Result<Vec<models::Photo>, ServerFnError> {
let service: prime_domain::DynPrimeDomainService = expect_context();

service.enumerate_photos().await.map_err(ServerFnError::new)
}

0 comments on commit 81fb98a

Please sign in to comment.