Compare commits

..

No commits in common. "483d7eea1d6c6875d0cda1fc7635610cce345e91" and "f0f9d1bf1a237df1151bd8844a03937eebc526ae" have entirely different histories.

4 changed files with 26 additions and 28 deletions

16
doordesk/Cargo.lock generated
View file

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

View file

@ -3,12 +3,17 @@ use leptos::*;
#[component] #[component]
pub fn Article(data: ArticleData) -> impl IntoView { pub fn Article(data: ArticleData) -> impl IntoView {
view! { view! {
<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"> <Transition>
<h1 class="text-3xl font-light text-orange-600 capitalize max-6-xs">{&data.title}</h1> <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">
<hr class="opacity-50"/> <h1 class="text-3xl font-light text-orange-600 capitalize max-6-xs">
<span class="pt-0 pb-3.5 text-xs opacity-50 m-t">{&data.date}</span> {&data.title}
<div inner_html=&data.content></div> </h1>
</article> <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>
} }
} }

View file

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

View file

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