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
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
6 changed files with 45 additions and 3 deletions

View File

@ -118,7 +118,7 @@ body {
background: var(--header-nav-regular-background-color); background: var(--header-nav-regular-background-color);
padding: 0 0.5rem; padding: 0 0.5rem;
transition-property: background, color; transition-property: background, color;
transition-duration: 0.2s; transition-duration: 0.1s;
transition-timing-function: ease-out; transition-timing-function: ease-out;
&:hover { &:hover {

View File

@ -2,6 +2,8 @@
<a class="home_link" href="{.home_link}">{.website_title}</a> <a class="home_link" href="{.home_link}">{.website_title}</a>
{! TODO: Additional links? Probably using the nav semantic element. !} {! TODO: Additional links? Probably using the nav semantic element. !}
<nav class="header_nav_bar"> <nav class="header_nav_bar">
<a class="nav_link" href="{.me_link}"><div>About Me</div></a> {#.nav_links}
<a class="nav_link" href="{.url}"><div>{.text}</div></a>
{/.nav_links}
</nav> </nav>
</header> </header>

View File

@ -61,6 +61,12 @@ render!(
render_context.output_file, 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( let link_to_blog_post = get_web_path(
render_context.config, render_context.config,

View File

@ -59,6 +59,12 @@ render!(
render_context.output_file, 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 let children = original

View File

@ -40,6 +40,12 @@ render!(RenderPage, IPage, original, render_context, {
render_context.output_file, 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( let link_to_blog_post = get_web_path(
render_context.config, render_context.config,

View File

@ -7,13 +7,35 @@ use serde::Serialize;
pub(crate) struct PageHeader { pub(crate) struct PageHeader {
website_title: Option<String>, website_title: Option<String>,
home_link: 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 { 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 { PageHeader {
website_title, website_title,
home_link, home_link,
nav_links: about_me_link
.map(|url| {
vec![NavLink {
text: Some("About Me".to_owned()),
url: Some(url),
}]
})
.unwrap_or_default(),
} }
} }
} }