Pass the nav links in the PageHeader render context.
All checks were successful
format Build format has succeeded
clippy Build clippy has succeeded
rust-test Build rust-test has succeeded

This commit is contained in:
Tom Alexander
2025-02-22 22:47:15 -05:00
parent 4403980e2e
commit ca1c456571
6 changed files with 45 additions and 3 deletions

View File

@@ -61,6 +61,12 @@ render!(
render_context.output_file,
"",
)?),
Some(get_web_path(
render_context.config,
render_context.output_root_directory,
render_context.output_file,
"about_me",
)?),
);
let link_to_blog_post = get_web_path(
render_context.config,

View File

@@ -59,6 +59,12 @@ render!(
render_context.output_file,
"",
)?),
Some(get_web_path(
render_context.config,
render_context.output_root_directory,
render_context.output_file,
"about_me",
)?),
);
let children = original

View File

@@ -40,6 +40,12 @@ render!(RenderPage, IPage, original, render_context, {
render_context.output_file,
"",
)?),
Some(get_web_path(
render_context.config,
render_context.output_root_directory,
render_context.output_file,
"about_me",
)?),
);
let link_to_blog_post = get_web_path(
render_context.config,

View File

@@ -7,13 +7,35 @@ use serde::Serialize;
pub(crate) struct PageHeader {
website_title: Option<String>,
home_link: Option<String>,
nav_links: Vec<NavLink>,
}
/// 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<String>,
url: Option<String>,
}
impl PageHeader {
pub(crate) fn new(website_title: Option<String>, home_link: Option<String>) -> PageHeader {
pub(crate) fn new(
website_title: Option<String>,
home_link: Option<String>,
about_me_link: Option<String>,
) -> 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(),
}
}
}