2025-09-24 19:52:25 -04:00
|
|
|
use dioxus::prelude::*;
|
|
|
|
|
|
|
|
|
|
use bard::*;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const FAVICON: Asset = asset!("/assets/favicon.ico");
|
2025-09-28 20:25:19 -04:00
|
|
|
const BLOG: Asset = asset!("/assets/blog.css");
|
2025-10-09 17:00:56 -04:00
|
|
|
const BLOG_IMAGE: Asset = asset!("/assets/runes_and_ramblings_text.png",
|
|
|
|
|
AssetOptions::builder().with_hash_suffix(false));
|
|
|
|
|
const POST_IMAGE: Asset = asset!("/assets/runes_and_ramblings_logo.png",
|
|
|
|
|
AssetOptions::builder().with_hash_suffix(false));
|
|
|
|
|
|
2025-09-24 19:52:25 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
fn main()
|
|
|
|
|
{
|
|
|
|
|
#[cfg(feature = "server")]
|
|
|
|
|
{
|
2025-10-08 15:17:48 -04:00
|
|
|
let rt = tokio::runtime::Runtime::new().unwrap();
|
|
|
|
|
rt.block_on(async
|
|
|
|
|
{
|
|
|
|
|
let db_path = "/home/myrddin/cybermages/website/tavern.db";
|
|
|
|
|
|
|
|
|
|
let _ = bard::init_database(db_path).await;
|
|
|
|
|
});
|
2025-09-24 19:52:25 -04:00
|
|
|
}
|
|
|
|
|
|
2025-10-08 15:17:48 -04:00
|
|
|
LaunchBuilder::new().launch(App);
|
2025-09-24 19:52:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[component]
|
|
|
|
|
fn App() -> Element
|
|
|
|
|
{
|
2025-09-28 20:25:19 -04:00
|
|
|
let custom_settings = BardSettings
|
|
|
|
|
{
|
|
|
|
|
blog_name: Some(String::from("Blog Test")),
|
2025-10-09 17:00:56 -04:00
|
|
|
blog_image: Some(BLOG_IMAGE),
|
|
|
|
|
default_post_image: Some(POST_IMAGE),
|
2025-09-28 20:25:19 -04:00
|
|
|
stylesheet: StylesheetBehavior::Extend(BLOG),
|
|
|
|
|
};
|
|
|
|
|
provide_context(custom_settings);
|
|
|
|
|
|
2025-09-24 19:52:25 -04:00
|
|
|
rsx!
|
|
|
|
|
{
|
|
|
|
|
document::Link { rel: "icon", href: FAVICON }
|
|
|
|
|
Router::<Page> {}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Home page
|
|
|
|
|
#[component]
|
|
|
|
|
fn Home() -> Element
|
|
|
|
|
{
|
2025-09-28 20:25:19 -04:00
|
|
|
rsx! {
|
2025-09-24 19:52:25 -04:00
|
|
|
h1 { "Blog Test" }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// This is the content for the About page.
|
|
|
|
|
#[component]
|
|
|
|
|
pub fn PageNotFound(route: Vec<String>) -> Element
|
|
|
|
|
{
|
2025-09-28 20:25:19 -04:00
|
|
|
rsx! {
|
2025-09-24 19:52:25 -04:00
|
|
|
h1 { "Page not found" }
|
|
|
|
|
p { "We are terribly sorry, but the page you requested doesn't exist." }
|
|
|
|
|
pre { color: "red", "log:\nattemped to navigate to: {route:?}" }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Shared navbar component.
|
|
|
|
|
#[component]
|
|
|
|
|
fn Navbar() -> Element
|
|
|
|
|
{
|
|
|
|
|
rsx! {
|
|
|
|
|
div {
|
|
|
|
|
id: "navbar",
|
|
|
|
|
Link {
|
|
|
|
|
to: Page::Home {},
|
|
|
|
|
"Home"
|
|
|
|
|
}
|
|
|
|
|
Link {
|
|
|
|
|
to: Page::Bard{ child: bard::Page::Blog { tag: String::from("all") }},
|
|
|
|
|
"Blog"
|
|
|
|
|
}
|
|
|
|
|
//a { href: "/blog/all", "Blog" }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Outlet::<Page> {}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, Routable, PartialEq)]
|
|
|
|
|
#[rustfmt::skip]
|
|
|
|
|
pub enum Page
|
|
|
|
|
{
|
|
|
|
|
#[layout(Navbar)]
|
|
|
|
|
#[route("/")]
|
|
|
|
|
Home {},
|
|
|
|
|
|
2025-09-25 11:37:36 -04:00
|
|
|
#[child("/blog")]
|
|
|
|
|
Bard
|
|
|
|
|
{
|
|
|
|
|
child: bard::Page
|
|
|
|
|
},
|
2025-09-24 19:52:25 -04:00
|
|
|
|
|
|
|
|
#[route("/:..route")]
|
|
|
|
|
PageNotFound { route: Vec<String> }
|
|
|
|
|
}
|