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 {
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 || {

View file

@ -13,42 +13,36 @@ struct ArticleFrontmatter {
pub async fn slingshot(path: String) -> Result<Vec<ArticleData>, ServerFnError> {
let mut articles = vec![];
for dir in std::fs::read_dir(path)? {
for file in std::fs::read_dir(dir?.path())? {
let fileinfo = file?;
let filepath = fileinfo.path();
for file in std::fs::read_dir(path)? {
let fileinfo = file?;
let filepath = fileinfo.path();
if let Some(filetype) = filepath.extension() {
if filetype == "md" {
let file = std::fs::read_to_string(filepath)?;
let html_from_md =
femark::process_markdown_to_html_with_frontmatter(&file.to_string(), true)
.expect("Problem processing markdown");
let content = html_from_md.content;
let _toc = html_from_md.toc;
if let Some(filetype) = filepath.extension() {
if filetype == "md" {
let file = std::fs::read_to_string(filepath)?;
let html_from_md =
femark::process_markdown_to_html_with_frontmatter(&file.to_string(), true)
.expect("Problem processing markdown");
let content = html_from_md.content;
let _toc = html_from_md.toc;
if let Some(front_raw) = html_from_md.frontmatter {
if let Some(front_code) = front_raw.code_block {
let toml: ArticleFrontmatter =
toml::from_str(&front_code.source)?;
if let Some(front_raw) = html_from_md.frontmatter {
if let Some(front_code) = front_raw.code_block {
let toml: ArticleFrontmatter = toml::from_str(&front_code.source)?;
articles.push(ArticleData {
content_type: toml.content_type,
title: toml.title,
date: toml.date,
content,
})
}
println!("{} {}", &toml.date, &toml.title);
articles.push(ArticleData {
content_type: toml.content_type,
title: toml.title,
date: toml.date,
content,
})
}
}
}
}
}
// Simulate lag
// use std::thread::sleep;
// use std::time::Duration;
// sleep(Duration::from_millis(300));
println!("iran");
Ok(articles)
}

View file

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

View file

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

View file

@ -1,7 +1,20 @@
use crate::components::article::*;
use crate::components::slingshot::*;
use crate::error_template::*;
use leptos::*;
#[component]
#[island]
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 leptos::*;
#[island]
#[component]
pub fn Home() -> impl IntoView {
view! {
@ -13,7 +13,7 @@ pub fn Home() -> impl IntoView {
<ErrorBoundary fallback=|errors| {
view! { <ErrorTemplate errors=errors/> }
}>
<ArticleBuilder/>
"Hello again"
</ErrorBoundary>
</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::*;
#[component]
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
content_type = "blog"
title = "Hume"
title = "Swim"
date = "2022 2 7"
```

View file

@ -1,7 +1,7 @@
```toml
content_type = "project"
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