use serde::Serialize; /// The header that goes above the content of the page. /// /// This header will be mostly the same on every page. #[derive(Debug, Serialize)] pub(crate) struct PageHeader { website_title: Option, home_link: Option, nav_links: Vec, } /// A link in the top-right of the page. #[derive(Debug, Serialize)] #[serde(tag = "type")] #[serde(rename = "nav_link")] pub(crate) struct NavLink { text: Option, url: Option, } impl PageHeader { pub(crate) fn new( website_title: Option, home_link: Option, about_me_link: Option, ) -> PageHeader { PageHeader { website_title, home_link, nav_links: about_me_link .map(|url| { vec![NavLink { text: Some("About Me".to_owned()), url: Some(url), }] }) .unwrap_or_default(), } } }