Trying to simplify components render sections.

This commit is contained in:
2025-09-12 21:54:06 -04:00
parent 1bb4386010
commit 2ffe20254c
2 changed files with 63 additions and 107 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "bard"
version = "0.0.22"
version = "0.0.23"
edition = "2024"
description = "Dioxus components that will display a Tavern blogging system Blog."
repository = "/CyberMages/tavern"

View File

@ -307,11 +307,7 @@ pub fn TagSelector(toggled_tags: Signal<HashSet<String>>) -> Element
pub fn PostHeaderAuthor(adventurer: Signal<Option<Adventurer>>) -> Element
{
rsx! {
match adventurer()
{
Some(author) =>
{
rsx!
if let Some(author) = &*adventurer.read()
{
h4
{
@ -319,12 +315,9 @@ pub fn PostHeaderAuthor(adventurer: Signal<Option<Adventurer>>) -> Element
a { href: "{author.legend.profile}", "{author.name} @{author.handle}" }
}
}
}
None =>
else
{
rsx! { h4 { "Author: Unknown" } }
}
h4 { "Author: Unknown" }
}
}
}
@ -345,14 +338,12 @@ pub fn PostHeader(tale: Signal<Option<Tale>>,
.unwrap_or_default()
});
rsx! {
match tale()
{
Some(tale) =>
{
rsx!
{
if let Some(tale) = tale()
{
h1 { {tale.lore.title} }
TagList
{
for (tag, style) in converted_tags().iter()
@ -365,25 +356,18 @@ pub fn PostHeader(tale: Signal<Option<Tale>>,
}
}
}
else
{
p { "Loading post header..." }
}
None =>
if let Some(_) = adventurer()
{
rsx! { p { "Loading post header..." } }
PostHeaderAuthor { adventurer: adventurer }
}
}
match adventurer()
else
{
Some(_) =>
{
rsx! { PostHeaderAuthor { adventurer: adventurer } }
}
None =>
{
rsx! { p { "Loading author..." } }
}
p { "Loading author..." }
}
}
}
@ -405,9 +389,9 @@ pub fn BlogPost(slug: Signal<String>, children: Element) -> Element
})?;
let author = use_server_future(move || {
let handle = match tale()
let handle = match &*tale.read()
{
Some(data) => data.lore.author,
Some(data) => data.lore.author.to_owned(),
None => "unknown_author_handle".to_string()
};
@ -437,11 +421,7 @@ pub fn BlogPost(slug: Signal<String>, children: Element) -> Element
{
class: "blog_post_style",
match &*post.read()
{
Some(Ok(post)) =>
{
rsx!
if let Some(Ok(post)) = &*post.read()
{
PostHeader
{
@ -455,25 +435,15 @@ pub fn BlogPost(slug: Signal<String>, children: Element) -> Element
//Author {}
}
}
Some(Err(e)) =>
{
rsx!
else if let Some(Err(e)) = &*post.read()
{
p { "Unable to load desired post: {slug.read()}" }
p { "{e}" }
}
}
None =>
{
rsx!
else
{
p { "Loading..." }
}
}
}
{children}
}
@ -499,11 +469,7 @@ pub fn TagNav() -> Element
ul
{
class: "tag_list",
match &*tags.read()
{
Some(Ok(categories)) =>
{
rsx!
if let Some(Ok(categories)) = &*tags.read()
{
for tag in categories
{
@ -514,20 +480,12 @@ pub fn TagNav() -> Element
}
}
}
}
Some(Err(e)) =>
{
rsx!
else if let Some(Err(e)) = &*tags.read()
{
p { "Unable to show desired post." }
p { "{e}" }
}
}
None =>
{
rsx!
else
{
p { "Loading..." }
}
@ -536,5 +494,3 @@ pub fn TagNav() -> Element
}
}
}
}
}