120 lines
3.0 KiB
Rust
120 lines
3.0 KiB
Rust
#![allow(non_snake_case)]
|
|
|
|
use components::H1;
|
|
use dioxus::prelude::*;
|
|
|
|
use dioxus_i18n::prelude::use_init_i18n;
|
|
use dioxus_i18n::prelude::I18nConfig;
|
|
use dioxus_i18n::prelude::Locale;
|
|
use dioxus_i18n::unic_langid::langid;
|
|
use layout::footer::Footer;
|
|
use layout::header::Header;
|
|
use tracing::Level;
|
|
|
|
pub mod components;
|
|
mod cv;
|
|
mod home;
|
|
mod impressum;
|
|
mod layout;
|
|
mod publications;
|
|
|
|
use crate::cv::CV;
|
|
use crate::home::Home;
|
|
use crate::impressum::Impressum;
|
|
use crate::layout::Layout;
|
|
use crate::publications::PublicationsProjects;
|
|
|
|
#[derive(Clone, Routable, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
|
|
pub enum Route {
|
|
#[layout(Layout)]
|
|
#[route("/")]
|
|
Home {},
|
|
#[route("/impressum")]
|
|
Impressum {},
|
|
#[route("/publications")]
|
|
PublicationsProjects {},
|
|
#[route("/resume")]
|
|
CV {},
|
|
#[end_layout]
|
|
#[route("/:..route")]
|
|
PageNotFound { route: Vec<String> },
|
|
}
|
|
|
|
fn main() {
|
|
dioxus_logger::init(Level::DEBUG).expect("failed to init logger");
|
|
LaunchBuilder::new().launch(App)
|
|
}
|
|
|
|
fn App() -> Element {
|
|
use_init_i18n(|| {
|
|
I18nConfig::new(langid!("en-GB"))
|
|
.with_locale(Locale::new_static(
|
|
langid!("en-GB"),
|
|
include_str!("../languages/en-GB.ftl"),
|
|
))
|
|
.with_locale(Locale::new_static(
|
|
langid!("de-DE"),
|
|
include_str!("../languages/de-DE.ftl"),
|
|
))
|
|
});
|
|
|
|
rsx! {
|
|
document::Link { rel: "stylesheet", href: asset!("./assets/tailwind.css") }
|
|
document::Link { rel: "icon", href: asset!("./assets/favicon.ico") }
|
|
meta {
|
|
name: "description",
|
|
content: "Visit Tuan-Dat Tran's website for his CV, publications, projects, and consulting services. Connect for collaboration.",
|
|
},
|
|
script {
|
|
r#type: "application/ld+json",
|
|
"
|
|
{{
|
|
\"@context\": \"https://schema.org\",
|
|
\"@type\": \"ProfilePage\",
|
|
\"mainEntity\": {{
|
|
\"@type\": \"Person\",
|
|
\"name\": \"Tuan-Dat Tran\",
|
|
\"alternateName\": \"TuDatTr\",
|
|
\"image\": \"https://www.tudattr.dev/pictures/headshot.webp\",
|
|
}}
|
|
}}
|
|
"
|
|
}
|
|
div {
|
|
class: "bg-gray-900 min-h-screen",
|
|
Router::<Route> {},
|
|
}
|
|
}
|
|
}
|
|
|
|
#[component]
|
|
fn PageNotFound(route: Vec<String>) -> Element {
|
|
rsx! {
|
|
div {
|
|
class: "flex flex-col min-h-screen items",
|
|
Header {},
|
|
div {
|
|
class: "container mx-auto p-4 flex items-center justify-center max-w-md w-full",
|
|
H1 {
|
|
"Site not found (404)"
|
|
},
|
|
}
|
|
Footer {}
|
|
},
|
|
}
|
|
}
|
|
|
|
#[derive(PartialEq, Props, Clone)]
|
|
pub struct BodyProp {
|
|
children: Element,
|
|
}
|
|
|
|
pub fn Body(prop: BodyProp) -> Element {
|
|
rsx! {
|
|
div {
|
|
class: "flex-grow container mx-auto p-4",
|
|
{prop.children}
|
|
}
|
|
}
|
|
}
|