Files
tavernworks/bard/src/page.rs
Myrddin Dundragon 468b9449b2 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.
2025-09-28 15:12:03 -04:00

69 lines
1.3 KiB
Rust

use dioxus::prelude::*;
use crate::pages::{Blog, Post, Root};
use crate::settings::{BardSettings, StylesheetBehavior};
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!
{
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> {}
}
}
//#[derive(Debug, Clone, Routable, PartialEq, Eq, Hash, Debug, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, Routable, PartialEq)]
#[rustfmt::skip]
pub enum Page
{
#[layout(BlogLayout)]
#[route("/")]
Root { },
#[route("/:tag")]
Blog { tag: String },
#[route("/post/:slug")]
Post { slug: String},
}