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] [package]
name = "bard" name = "bard"
version = "0.0.22" version = "0.0.23"
edition = "2024" edition = "2024"
description = "Dioxus components that will display a Tavern blogging system Blog." description = "Dioxus components that will display a Tavern blogging system Blog."
repository = "/CyberMages/tavern" 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 pub fn PostHeaderAuthor(adventurer: Signal<Option<Adventurer>>) -> Element
{ {
rsx! { rsx! {
match adventurer() if let Some(author) = &*adventurer.read()
{ {
Some(author) => h4
{ {
rsx! "Author: ",
{ a { href: "{author.legend.profile}", "{author.name} @{author.handle}" }
h4
{
"Author: ",
a { href: "{author.legend.profile}", "{author.name} @{author.handle}" }
}
}
}
None =>
{
rsx! { h4 { "Author: Unknown" } }
} }
} }
else
{
h4 { "Author: Unknown" }
}
} }
} }
@ -345,45 +338,36 @@ pub fn PostHeader(tale: Signal<Option<Tale>>,
.unwrap_or_default() .unwrap_or_default()
}); });
rsx! { rsx!
match tale() {
if let Some(tale) = tale()
{ {
Some(tale) => h1 { {tale.lore.title} }
TagList
{ {
rsx! for (tag, style) in converted_tags().iter()
{ {
h1 { {tale.lore.title} } TagItem
TagList {
{ tag: tag.clone(),
for (tag, style) in converted_tags().iter() style: style.clone()
{
TagItem
{
tag: tag.clone(),
style: style.clone()
}
}
} }
} }
} }
}
None => else
{ {
rsx! { p { "Loading post header..." } } p { "Loading post header..." }
}
} }
match adventurer() if let Some(_) = adventurer()
{ {
Some(_) => PostHeaderAuthor { adventurer: adventurer }
{ }
rsx! { PostHeaderAuthor { adventurer: adventurer } } else
} {
p { "Loading author..." }
None =>
{
rsx! { p { "Loading author..." } }
}
} }
} }
} }
@ -405,9 +389,9 @@ pub fn BlogPost(slug: Signal<String>, children: Element) -> Element
})?; })?;
let author = use_server_future(move || { 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() None => "unknown_author_handle".to_string()
}; };
@ -437,42 +421,28 @@ pub fn BlogPost(slug: Signal<String>, children: Element) -> Element
{ {
class: "blog_post_style", class: "blog_post_style",
match &*post.read() if let Some(Ok(post)) = &*post.read()
{ {
Some(Ok(post)) => PostHeader
{ {
rsx! tale: tale,
{ adventurer: adventurer
PostHeader
{
tale: tale,
adventurer: adventurer
}
//Story {}
div { dangerous_inner_html: "{post.story}" }
//Author {}
}
} }
Some(Err(e)) => //Story {}
{
rsx!
{
p { "Unable to load desired post: {slug.read()}" }
p { "{e}" }
}
}
None => div { dangerous_inner_html: "{post.story}" }
{
rsx! //Author {}
{ }
p { "Loading..." } else if let Some(Err(e)) = &*post.read()
} {
} p { "Unable to load desired post: {slug.read()}" }
p { "{e}" }
}
else
{
p { "Loading..." }
} }
{children} {children}
@ -499,40 +469,26 @@ pub fn TagNav() -> Element
ul ul
{ {
class: "tag_list", 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 class: "tag_item",
{ a { href: "/blog/{strip_tag(tag)}", "{strip_tag(tag)}" }
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..." }
} }
} }
} }
else if let Some(Err(e)) = &*tags.read()
{
p { "Unable to show desired post." }
p { "{e}" }
}
else
{
p { "Loading..." }
}
} }
} }
} }