Pass the nav links in the PageHeader render context.
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user