Added the ability to specify images.

The blog title can now be set to be an image. If not it will default to
the text. If no text it will just be "Blog".

A Post has now been given a default post image that will be used for all
posts for their openGraph sharing. This can later be expanded to allow
a blog post to have a desired image.
This commit is contained in:
2025-10-09 17:00:56 -04:00
parent 725824003b
commit 3fe3d874ca
10 changed files with 89 additions and 19 deletions

View File

@ -15,12 +15,12 @@ pub fn BlogItem(title: String, slug: String, author: String, summary: String,
tags: Vec<String>)
-> Element
{
let author_future = use_server_future(move ||
let author_future = use_resource(move ||
{
let handle: String = author.clone();
async move { get_author(handle).await }
})?;
});
rsx!
{
@ -80,13 +80,13 @@ pub fn BlogList(tags: Signal<HashSet<String>>, children: Element) -> Element
// Retrieve the provided settings from context.
let settings = use_context::<BardSettings>();
let list = use_server_future(move ||
let list = use_resource(move ||
{
let t = tags();
let categories = t.iter().cloned().collect();
let tags = tags();
let categories: Vec<String> = tags.iter().cloned().collect();
async move { get_blog_list(categories).await }
})?;
});
rsx!
{
@ -94,20 +94,51 @@ pub fn BlogList(tags: Signal<HashSet<String>>, children: Element) -> Element
{
class: "blog_list",
match settings.blog_name
match settings.blog_image
{
Some(title) =>
Some(image) =>
{
rsx!
match settings.blog_name
{
h1 { class: "blog_title", "{title}" }
Some(title) =>
{
rsx!
{
h1 { class: "blog_title visually_hidden", "{title}" }
img { class: "blog_title_image", alt: "{title} blog logo", src: image }
}
}
None =>
{
rsx!
{
h1 { class: "blog_title visually_hidden", "Blog" }
img { class: "blog_title_image", alt: "Blog logo", src: image }
}
}
}
}
None =>
{
rsx!
match settings.blog_name
{
h1 { class: "blog_title visually_hidden", "Blog" }
Some(title) =>
{
rsx!
{
h1 { class: "blog_title", "{title}" }
}
}
None =>
{
rsx!
{
h1 { class: "blog_title visually_hidden", "Blog" }
}
}
}
}
}
@ -118,6 +149,7 @@ pub fn BlogList(tags: Signal<HashSet<String>>, children: Element) -> Element
{
BlogItem
{
key: "{lore.slug}",
title: lore.title.clone(),
slug: lore.slug.clone(),
author: lore.author.clone(),
@ -144,6 +176,7 @@ pub fn BlogList(tags: Signal<HashSet<String>>, children: Element) -> Element
#[component]
pub fn ToggleTag(tag: String, toggled_tags: Signal<HashSet<String>>) -> Element
{
let is_checked = toggled_tags.read().is_toggled(&tag);
rsx!
{
label
@ -153,7 +186,7 @@ pub fn ToggleTag(tag: String, toggled_tags: Signal<HashSet<String>>) -> Element
input
{
r#type: "checkbox",
checked: toggled_tags.read().is_toggled(&tag),
checked: is_checked,
onchange: move |_|
{
toggled_tags.write().toggle(&tag.clone());