flatten articles

This commit is contained in:
Adam 2024-01-27 03:31:55 -05:00
parent f4695b7729
commit afdfd02556
22 changed files with 62 additions and 67 deletions

View file

@ -14,7 +14,7 @@ pub struct ArticleData {
pub fn ArticleBuilder() -> impl IntoView { pub fn ArticleBuilder() -> impl IntoView {
let data_resource = create_local_resource( let data_resource = create_local_resource(
|| (), || (),
|_| async move { slingshot("./public/articles".to_string()).await }, |_| async move { slingshot("./public/blog".to_string()).await },
); );
let articles_view = move || { let articles_view = move || {

View file

@ -13,8 +13,7 @@ struct ArticleFrontmatter {
pub async fn slingshot(path: String) -> Result<Vec<ArticleData>, ServerFnError> { pub async fn slingshot(path: String) -> Result<Vec<ArticleData>, ServerFnError> {
let mut articles = vec![]; let mut articles = vec![];
for dir in std::fs::read_dir(path)? { for file in std::fs::read_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();
@ -29,9 +28,9 @@ pub async fn slingshot(path: String) -> Result<Vec<ArticleData>, ServerFnError>
if let Some(front_raw) = html_from_md.frontmatter { if let Some(front_raw) = html_from_md.frontmatter {
if let Some(front_code) = front_raw.code_block { if let Some(front_code) = front_raw.code_block {
let toml: ArticleFrontmatter = let toml: ArticleFrontmatter = toml::from_str(&front_code.source)?;
toml::from_str(&front_code.source)?;
println!("{} {}", &toml.date, &toml.title);
articles.push(ArticleData { articles.push(ArticleData {
content_type: toml.content_type, content_type: toml.content_type,
title: toml.title, title: toml.title,
@ -43,12 +42,7 @@ pub async fn slingshot(path: String) -> Result<Vec<ArticleData>, ServerFnError>
} }
} }
} }
}
// Simulate lag
// use std::thread::sleep;
// use std::time::Duration;
// sleep(Duration::from_millis(300));
println!("iran");
Ok(articles) Ok(articles)
} }

View file

@ -8,8 +8,7 @@ pub mod components;
pub mod error_template; pub mod error_template;
pub mod routes; pub mod routes;
// use crate::routes::{blog::*, home::*, projects::*}; use crate::routes::{blog::Blog, home::Home, projects::Projects};
use crate::routes::home::Home;
#[component] #[component]
pub fn App() -> impl IntoView { pub fn App() -> impl IntoView {
@ -47,8 +46,8 @@ pub fn App() -> impl IntoView {
<main> <main>
<Routes> <Routes>
<Route path="" view=Home/> <Route path="" view=Home/>
// <Route path="blog" view=Blog/> <Route path="blog" view=Blog/>
// <Route path="projects" view=Projects/> <Route path="projects" view=Projects/>
</Routes> </Routes>
</main> </main>
<p class="m-auto w-8 text-center duration-200 hover:rotate-180"> <p class="m-auto w-8 text-center duration-200 hover:rotate-180">

View file

@ -1,3 +1,3 @@
pub mod home; pub mod home;
// pub mod blog; pub mod blog;
// pub mod projects; pub mod projects;

View file

@ -1,7 +1,20 @@
use crate::components::article::*; use crate::components::article::*;
use crate::components::slingshot::*;
use crate::error_template::*;
use leptos::*; use leptos::*;
#[component] #[island]
pub fn Blog() -> impl IntoView { pub fn Blog() -> impl IntoView {
view! { <Article/> }
view! {
<Suspense fallback=move || {
view! { <p>"Loading..."</p> }
}>
<ErrorBoundary fallback=|errors| {
view! { <ErrorTemplate errors=errors/> }
}>
<ArticleBuilder/>
</ErrorBoundary>
</Suspense>
}
} }

View file

@ -3,7 +3,7 @@ use crate::components::slingshot::*;
use crate::error_template::*; use crate::error_template::*;
use leptos::*; use leptos::*;
#[island] #[component]
pub fn Home() -> impl IntoView { pub fn Home() -> impl IntoView {
view! { view! {
@ -13,7 +13,7 @@ pub fn Home() -> impl IntoView {
<ErrorBoundary fallback=|errors| { <ErrorBoundary fallback=|errors| {
view! { <ErrorTemplate errors=errors/> } view! { <ErrorTemplate errors=errors/> }
}> }>
<ArticleBuilder/> "Hello again"
</ErrorBoundary> </ErrorBoundary>
</Suspense> </Suspense>
} }

View file

@ -1,7 +1,20 @@
use crate::components::article::*; // use crate::components::article::*;
// use crate::components::slingshot::*;
use crate::error_template::*;
use leptos::*; use leptos::*;
#[component] #[component]
pub fn Projects() -> impl IntoView { pub fn Projects() -> impl IntoView {
view! { <Article/> }
view! {
<Suspense fallback=move || {
view! { <p>"Loading..."</p> }
}>
<ErrorBoundary fallback=|errors| {
view! { <ErrorTemplate errors=errors/> }
}>
"Projects"
</ErrorBoundary>
</Suspense>
}
} }

View file

@ -1 +0,0 @@
cartman

View file

@ -1,23 +0,0 @@
<h3>Some games using wasm/webgl</h3>
<p>Browser performance as of January 2023</p>
<p>Tested better:</p>
<ol>
<li>Opera</li>
<li>Firefox Developer Edition</li>
<li>Brave</li>
</ol>
<p>Tested poor or broken:</p>
<ol>
<li>Safari</li>
<li>Chrome stable release or older</li>
<li>Edge, see above^</li>
</ol>
<p>Consider anything else average or let me know otherwise</p>
<ul>
---MY GAMES---
<li><a href="https://old.doordesk.net/games/adam">adam</a> - The first. Unity Demo/Tutorial with some mods</li>
<li><a href="https://old.doordesk.net/games/fps">multiplayer fps</a> - Dive into netcode with Godot (Open two, invite
your friends!)</li>
<li><a href="https://old.doordesk.net/games/../snek">snek</a> - Canvas + JS (the actual first)</li>
<li><a href="https://old.doordesk.net/games/balls">balls</a> - Godot demo engine test</li>
</ul>

View file

@ -1,6 +1,6 @@
```toml ```toml
content_type = "blog" content_type = "blog"
title = "Hume" title = "Swim"
date = "2022 2 7" date = "2022 2 7"
``` ```

View file

@ -1,7 +1,7 @@
```toml ```toml
content_type = "project" content_type = "project"
title = "What goes into a successful Reddit post?" title = "What goes into a successful Reddit post?"
date = "2022 6 16" date = "2022 6 14"
``` ```
In an attempt to find out what about a Reddit post makes it successful I will use some In an attempt to find out what about a Reddit post makes it successful I will use some