Compare commits

...

4 commits

Author SHA1 Message Date
Adam
483d7eea1d path is an argument 2024-01-18 17:39:20 -05:00
Adam
7a98b2c3c4 give slingshot the path (change later (maybe (hopefully))) 2024-01-18 17:38:43 -05:00
Adam
30f3ee0696 format 2024-01-18 17:36:59 -05:00
Adam
95ba41e60b update deps 2024-01-18 17:34:19 -05:00
4 changed files with 28 additions and 26 deletions

16
doordesk/Cargo.lock generated
View file

@ -785,9 +785,9 @@ dependencies = [
[[package]]
name = "h2"
version = "0.3.23"
version = "0.3.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b553656127a00601c8ae5590fcfdc118e4083a7924b6cf4ffc1ea4b99dc429d7"
checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9"
dependencies = [
"bytes",
"fnv",
@ -851,9 +851,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
[[package]]
name = "hermit-abi"
version = "0.3.3"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7"
checksum = "5d3d0e0f38255e7fa3cf31335b3a56f05febd18025f4db5ef7a0cfb4f8da651f"
[[package]]
name = "html-escape"
@ -2074,9 +2074,9 @@ dependencies = [
[[package]]
name = "smallvec"
version = "1.12.0"
version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2593d31f82ead8df961d8bd23a64c2ccf2eb5dd34b0a34bfb4dd54011c72009e"
checksum = "3b187f0231d56fe41bfb12034819dd2bf336422a5866de41bc3fec4b2e3883e8"
[[package]]
name = "socket2"
@ -2414,9 +2414,9 @@ dependencies = [
[[package]]
name = "unicode-bidi"
version = "0.3.14"
version = "0.3.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f2528f27a9eb2b21e69c95319b30bd0efd85d09c379741b0f78ea1d86be2416"
checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75"
[[package]]
name = "unicode-id"

View file

@ -3,17 +3,12 @@ use leptos::*;
#[component]
pub fn Article(data: ArticleData) -> impl IntoView {
view! {
<Transition>
<article class="p-7 my-5 mx-auto w-11/12 max-w-screen-xl bg-opacity-10 rounded-md bg-zinc-700 shadow-1g">
<h1 class="text-3xl font-light text-orange-600 capitalize max-6-xs">
{&data.title}
</h1>
<hr class="opacity-50"/>
<span class="pt-0 pb-3.5 text-xs opacity-50 m-t">{&data.date}</span>
<div inner_html={&data.content}></div>
</article>
</Transition>
<article class="p-7 my-5 mx-auto w-11/12 max-w-screen-xl bg-opacity-10 rounded-md bg-zinc-700 shadow-1g">
<h1 class="text-3xl font-light text-orange-600 capitalize max-6-xs">{&data.title}</h1>
<hr class="opacity-50"/>
<span class="pt-0 pb-3.5 text-xs opacity-50 m-t">{&data.date}</span>
<div inner_html=&data.content></div>
</article>
}
}

View file

@ -10,11 +10,10 @@ pub struct ArticleData {
}
#[server]
pub async fn slingshot() -> Result<Vec<ArticleData>, ServerFnError> {
pub async fn slingshot(path: String) -> Result<Vec<ArticleData>, ServerFnError> {
let mut articles = vec![];
let data_dir = "./pubic/static";
for dir in std::fs::read_dir(data_dir)? {
for dir in std::fs::read_dir(path)? {
for file in std::fs::read_dir(dir?.path())? {
let fileinfo = file?;
let filepath = fileinfo.path();

View file

@ -1,22 +1,30 @@
use crate::components::article::*;
use crate::components::slingshot::*;
use crate::error_template::*;
use leptos::*;
#[component]
pub fn Home() -> impl IntoView {
let data_resource = create_local_resource(|| (), |_| async move { slingshot().await });
let data_resource = create_local_resource(
|| (),
|_| async move { slingshot("./public/static".to_string()).await },
);
let articles_view = move || {
data_resource.and_then(|data| {
data.iter()
.map(|article| view! { <Article data=article.to_owned()/> })
.collect_view()
.map(|article| view! { <Article data=article.to_owned()/> })
.collect_view()
})
};
view! {
<Suspense fallback=move || {
view! { <p>"Loading..."</p> }
}>{articles_view}</Suspense>
}>
<ErrorBoundary fallback=|errors| {
view! { <ErrorTemplate errors=errors/> }
}>{articles_view}</ErrorBoundary>
</Suspense>
}
}