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,25 +307,18 @@ pub fn TagSelector(toggled_tags: Signal<HashSet<String>>) -> Element
pub fn PostHeaderAuthor(adventurer: Signal<Option<Adventurer>>) -> Element
{
rsx! {
match adventurer()
if let Some(author) = &*adventurer.read()
{
Some(author) =>
h4
{
rsx!
{
h4
{
"Author: ",
a { href: "{author.legend.profile}", "{author.name} @{author.handle}" }
}
}
}
None =>
{
rsx! { h4 { "Author: Unknown" } }
"Author: ",
a { href: "{author.legend.profile}", "{author.name} @{author.handle}" }
}
}
else
{
h4 { "Author: Unknown" }
}
}
}
@ -345,45 +338,36 @@ pub fn PostHeader(tale: Signal<Option<Tale>>,
.unwrap_or_default()
});
rsx! {
match tale()
rsx!
{
if let Some(tale) = tale()
{
Some(tale) =>
h1 { {tale.lore.title} }
TagList
{
rsx!
for (tag, style) in converted_tags().iter()
{
h1 { {tale.lore.title} }
TagList
{
for (tag, style) in converted_tags().iter()
{
TagItem
{
tag: tag.clone(),
style: style.clone()
}
}
TagItem
{
tag: tag.clone(),
style: style.clone()
}
}
}
None =>
{
rsx! { p { "Loading post header..." } }
}
}
else
{
p { "Loading post header..." }
}
match adventurer()
if let Some(_) = adventurer()
{
Some(_) =>
{
rsx! { PostHeaderAuthor { adventurer: adventurer } }
}
None =>
{
rsx! { p { "Loading author..." } }
}
PostHeaderAuthor { adventurer: adventurer }
}
else
{
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,42 +421,28 @@ pub fn BlogPost(slug: Signal<String>, children: Element) -> Element
{
class: "blog_post_style",
match &*post.read()
if let Some(Ok(post)) = &*post.read()
{
Some(Ok(post)) =>
PostHeader
{
rsx!
{
PostHeader
{
tale: tale,
adventurer: adventurer
}
//Story {}
div { dangerous_inner_html: "{post.story}" }
//Author {}
}
tale: tale,
adventurer: adventurer
}
Some(Err(e)) =>
{
rsx!
{
p { "Unable to load desired post: {slug.read()}" }
p { "{e}" }
}
}
//Story {}
None =>
{
rsx!
{
p { "Loading..." }
}
}
div { dangerous_inner_html: "{post.story}" }
//Author {}
}
else if let Some(Err(e)) = &*post.read()
{
p { "Unable to load desired post: {slug.read()}" }
p { "{e}" }
}
else
{
p { "Loading..." }
}
{children}
@ -499,40 +469,26 @@ pub fn TagNav() -> Element
ul
{
class: "tag_list",
match &*tags.read()
if let Some(Ok(categories)) = &*tags.read()
{
Some(Ok(categories)) =>
for tag in categories
{
rsx!
li
{
for tag in categories
{
li
{
class: "tag_item",
a { href: "/blog/{strip_tag(tag)}", "{strip_tag(tag)}" }
}
}
}
}
Some(Err(e)) =>
{
rsx!
{
p { "Unable to show desired post." }
p { "{e}" }
}
}
None =>
{
rsx!
{
p { "Loading..." }
class: "tag_item",
a { href: "/blog/{strip_tag(tag)}", "{strip_tag(tag)}" }
}
}
}
else if let Some(Err(e)) = &*tags.read()
{
p { "Unable to show desired post." }
p { "{e}" }
}
else
{
p { "Loading..." }
}
}
}
}