diff --git a/app/src/components/article.rs b/app/src/components/article.rs index 0382f9f..31e3a5e 100644 --- a/app/src/components/article.rs +++ b/app/src/components/article.rs @@ -1,3 +1,4 @@ +use crate::components::slingshot::*; use leptos::*; use serde::{Deserialize, Serialize}; @@ -9,6 +10,24 @@ pub struct ArticleData { pub content: String, } +#[component] +pub fn ArticleBuilder() -> impl IntoView { + let data_resource = create_local_resource( + || (), + |_| async move { slingshot("./public/articles".to_string()).await }, + ); + + let articles_view = move || { + data_resource.and_then(|data| { + data.iter() + .map(|article| view! {
}) + .collect_view() + }) + }; + + articles_view +} + #[component] pub fn Article(data: ArticleData) -> impl IntoView { view! { diff --git a/app/src/routes/home.rs b/app/src/routes/home.rs index 35ed087..95cf032 100644 --- a/app/src/routes/home.rs +++ b/app/src/routes/home.rs @@ -5,18 +5,6 @@ use leptos::*; #[island] pub fn Home() -> impl IntoView { - let data_resource = create_local_resource( - || (), - |_| async move { slingshot("./public/articles".to_string()).await }, - ); - - let articles_view = move || { - data_resource.and_then(|data| { - data.iter() - .map(|article| view! {
}) - .collect_view() - }) - }; view! { impl IntoView { }> } - }>{articles_view} + }> + + } }