feat: normalize config context and template API
Add FeedConfig and SitemapConfig structs to config.rs
with enabled: bool (default true) for opt-out control.
Refactor ConfigContext: flat nested_nav bool replaced
with nested nav: NavContext { nested, toc } to mirror
site.toml [nav] table structure.
Remove standalone base_url template variable; use
config.base_url as single source of truth with
trailing-slash trimming in ConfigContext::from().
Add section template fallback: try section/<type>.html,
fall back to section/default.html for unknown types.
Delete section/features.html (duplicate of default.html)
and homepage.html (dead code, never referenced).
Update base.html for new variable names.
This commit is contained in:
@@ -20,6 +20,40 @@ pub struct SiteConfig {
|
||||
/// Navigation configuration.
|
||||
#[serde(default)]
|
||||
pub nav: NavConfig,
|
||||
/// Feed (Atom) configuration.
|
||||
#[serde(default)]
|
||||
pub feed: FeedConfig,
|
||||
/// Sitemap configuration.
|
||||
#[serde(default)]
|
||||
pub sitemap: SitemapConfig,
|
||||
}
|
||||
|
||||
/// Feed (Atom) generation configuration.
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(default)]
|
||||
pub struct FeedConfig {
|
||||
/// Whether to generate an Atom feed (default: true).
|
||||
pub enabled: bool,
|
||||
}
|
||||
|
||||
impl Default for FeedConfig {
|
||||
fn default() -> Self {
|
||||
Self { enabled: true }
|
||||
}
|
||||
}
|
||||
|
||||
/// Sitemap generation configuration.
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(default)]
|
||||
pub struct SitemapConfig {
|
||||
/// Whether to generate a sitemap.xml (default: true).
|
||||
pub enabled: bool,
|
||||
}
|
||||
|
||||
impl Default for SitemapConfig {
|
||||
fn default() -> Self {
|
||||
Self { enabled: true }
|
||||
}
|
||||
}
|
||||
|
||||
/// Navigation configuration.
|
||||
|
||||
Reference in New Issue
Block a user