Client side settings can now be specified.

Here we use a context provider on the app itself to handle passing the
settings to our library. This way even the layout can use them.
This commit is contained in:
2025-09-28 15:12:03 -04:00
parent 6efec6bd22
commit 468b9449b2
6 changed files with 150 additions and 34 deletions

View File

@ -1,6 +1,7 @@
use dioxus::prelude::*;
use crate::pages::{Blog, Post, Root};
use crate::settings::{BardSettings, StylesheetBehavior};
@ -11,9 +12,38 @@ const BLOG_CSS: Asset = asset!("/assets/css/blog.css");
#[component]
fn BlogLayout() -> Element
{
// Retrieve the provided settings from context.
let settings = use_context::<BardSettings>();
rsx!
{
document::Stylesheet { href: BLOG_CSS }
match settings.stylesheet
{
StylesheetBehavior::Override(asset) =>
{
rsx!
{
document::Stylesheet { href: asset }
}
}
StylesheetBehavior::Extend(asset) =>
{
rsx!
{
document::Stylesheet { href: BLOG_CSS }
document::Stylesheet { href: asset }
}
}
StylesheetBehavior::None =>
{
rsx!
{
document::Stylesheet { href: BLOG_CSS }
}
}
}
Outlet::<Page> {}
}