feat(nav): complete Tier 1 hierarchical navigation
Add config option [nav] nested (defaults false), update base.html template with nested nav rendering, and add .nav-children CSS styling for indented section children. - Add NavConfig struct with nested: bool - Template renders item.children in .nav-children div - CSS: left border + indent for nested items
This commit is contained in:
@@ -7,3 +7,6 @@ content = "content"
|
|||||||
output = "public"
|
output = "public"
|
||||||
static = "static"
|
static = "static"
|
||||||
templates = "templates"
|
templates = "templates"
|
||||||
|
|
||||||
|
[nav]
|
||||||
|
nested = true
|
||||||
|
|||||||
13
docs/static/style.css
vendored
13
docs/static/style.css
vendored
@@ -94,6 +94,19 @@ body {
|
|||||||
color: var(--bg);
|
color: var(--bg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sidebar .nav-children {
|
||||||
|
margin-left: 1rem;
|
||||||
|
padding-left: 0.5rem;
|
||||||
|
border-left: 1px solid var(--border);
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar .nav-children a {
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
.sidebar-footer {
|
.sidebar-footer {
|
||||||
margin-top: auto;
|
margin-top: auto;
|
||||||
padding-top: 1rem;
|
padding-top: 1rem;
|
||||||
|
|||||||
13
docs/templates/base.html
vendored
13
docs/templates/base.html
vendored
@@ -34,8 +34,17 @@
|
|||||||
</label>
|
</label>
|
||||||
</header>
|
</header>
|
||||||
<nav>
|
<nav>
|
||||||
{% for item in nav %}<a href="{{ prefix }}{{ item.path }}" {% if page_path==item.path %} class="active" {% endif
|
{% for item in nav %}
|
||||||
%}>{{ item.label }}</a>{% endfor %}
|
<a href="{{ prefix }}{{ item.path }}" {% if page_path==item.path %}class="active" {% endif %}>{{ item.label }}</a>
|
||||||
|
{% if config.nested_nav and item.children %}
|
||||||
|
<div class="nav-children">
|
||||||
|
{% for child in item.children %}
|
||||||
|
<a href="{{ prefix }}{{ child.path }}" {% if page_path==child.path %}class="active" {% endif %}>{{ child.label
|
||||||
|
}}</a>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
</nav>
|
</nav>
|
||||||
<footer class="sidebar-footer">
|
<footer class="sidebar-footer">
|
||||||
<a href="https://github.com/nrdxp/sukr">GitHub</a>
|
<a href="https://github.com/nrdxp/sukr">GitHub</a>
|
||||||
|
|||||||
@@ -17,6 +17,17 @@ pub struct SiteConfig {
|
|||||||
/// Path configuration (all optional with defaults).
|
/// Path configuration (all optional with defaults).
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub paths: PathsConfig,
|
pub paths: PathsConfig,
|
||||||
|
/// Navigation configuration.
|
||||||
|
#[serde(default)]
|
||||||
|
pub nav: NavConfig,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Navigation configuration.
|
||||||
|
#[derive(Debug, Deserialize, Default)]
|
||||||
|
#[serde(default)]
|
||||||
|
pub struct NavConfig {
|
||||||
|
/// Whether to display nested navigation (default: false).
|
||||||
|
pub nested: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Path configuration with sensible defaults.
|
/// Path configuration with sensible defaults.
|
||||||
|
|||||||
@@ -121,6 +121,8 @@ pub struct ConfigContext {
|
|||||||
pub title: String,
|
pub title: String,
|
||||||
pub author: String,
|
pub author: String,
|
||||||
pub base_url: String,
|
pub base_url: String,
|
||||||
|
/// Whether to display nested navigation
|
||||||
|
pub nested_nav: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<&SiteConfig> for ConfigContext {
|
impl From<&SiteConfig> for ConfigContext {
|
||||||
@@ -129,6 +131,7 @@ impl From<&SiteConfig> for ConfigContext {
|
|||||||
title: config.title.clone(),
|
title: config.title.clone(),
|
||||||
author: config.author.clone(),
|
author: config.author.clone(),
|
||||||
base_url: config.base_url.clone(),
|
base_url: config.base_url.clone(),
|
||||||
|
nested_nav: config.nav.nested,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user