Trying to simplify components render sections.
This commit is contained in:
@ -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"
|
||||||
|
|||||||
@ -307,11 +307,7 @@ 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) =>
|
|
||||||
{
|
|
||||||
rsx!
|
|
||||||
{
|
{
|
||||||
h4
|
h4
|
||||||
{
|
{
|
||||||
@ -319,12 +315,9 @@ pub fn PostHeaderAuthor(adventurer: Signal<Option<Adventurer>>) -> Element
|
|||||||
a { href: "{author.legend.profile}", "{author.name} @{author.handle}" }
|
a { href: "{author.legend.profile}", "{author.name} @{author.handle}" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
|
||||||
None =>
|
|
||||||
{
|
{
|
||||||
rsx! { h4 { "Author: Unknown" } }
|
h4 { "Author: Unknown" }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -345,14 +338,12 @@ pub fn PostHeader(tale: Signal<Option<Tale>>,
|
|||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
});
|
});
|
||||||
|
|
||||||
rsx! {
|
|
||||||
match tale()
|
|
||||||
{
|
|
||||||
Some(tale) =>
|
|
||||||
{
|
|
||||||
rsx!
|
rsx!
|
||||||
|
{
|
||||||
|
if let Some(tale) = tale()
|
||||||
{
|
{
|
||||||
h1 { {tale.lore.title} }
|
h1 { {tale.lore.title} }
|
||||||
|
|
||||||
TagList
|
TagList
|
||||||
{
|
{
|
||||||
for (tag, style) in converted_tags().iter()
|
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 }
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
|
||||||
match adventurer()
|
|
||||||
{
|
{
|
||||||
Some(_) =>
|
p { "Loading author..." }
|
||||||
{
|
|
||||||
rsx! { PostHeaderAuthor { adventurer: adventurer } }
|
|
||||||
}
|
|
||||||
|
|
||||||
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,11 +421,7 @@ 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)) =>
|
|
||||||
{
|
|
||||||
rsx!
|
|
||||||
{
|
{
|
||||||
PostHeader
|
PostHeader
|
||||||
{
|
{
|
||||||
@ -455,25 +435,15 @@ pub fn BlogPost(slug: Signal<String>, children: Element) -> Element
|
|||||||
|
|
||||||
//Author {}
|
//Author {}
|
||||||
}
|
}
|
||||||
}
|
else if let Some(Err(e)) = &*post.read()
|
||||||
|
|
||||||
Some(Err(e)) =>
|
|
||||||
{
|
|
||||||
rsx!
|
|
||||||
{
|
{
|
||||||
p { "Unable to load desired post: {slug.read()}" }
|
p { "Unable to load desired post: {slug.read()}" }
|
||||||
p { "{e}" }
|
p { "{e}" }
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
|
||||||
None =>
|
|
||||||
{
|
|
||||||
rsx!
|
|
||||||
{
|
{
|
||||||
p { "Loading..." }
|
p { "Loading..." }
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
{children}
|
{children}
|
||||||
}
|
}
|
||||||
@ -499,11 +469,7 @@ 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)) =>
|
|
||||||
{
|
|
||||||
rsx!
|
|
||||||
{
|
{
|
||||||
for tag in categories
|
for tag in categories
|
||||||
{
|
{
|
||||||
@ -514,20 +480,12 @@ pub fn TagNav() -> Element
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
else if let Some(Err(e)) = &*tags.read()
|
||||||
|
|
||||||
Some(Err(e)) =>
|
|
||||||
{
|
|
||||||
rsx!
|
|
||||||
{
|
{
|
||||||
p { "Unable to show desired post." }
|
p { "Unable to show desired post." }
|
||||||
p { "{e}" }
|
p { "{e}" }
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
|
||||||
None =>
|
|
||||||
{
|
|
||||||
rsx!
|
|
||||||
{
|
{
|
||||||
p { "Loading..." }
|
p { "Loading..." }
|
||||||
}
|
}
|
||||||
@ -535,6 +493,4 @@ pub fn TagNav() -> Element
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user