From 45448cc443e77c6ce78d2f406a70fcd643f2626a Mon Sep 17 00:00:00 2001 From: Timothy DeHerrera Date: Sat, 14 Feb 2026 07:09:05 -0700 Subject: [PATCH] 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/.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. --- docs/plans/api-stabilization.md | 14 +++++------ docs/templates/base.html | 4 ++-- docs/templates/homepage.html | 9 ------- docs/templates/section/features.html | 18 -------------- src/config.rs | 34 ++++++++++++++++++++++++++ src/template_engine.rs | 36 ++++++++++++++++++++++------ 6 files changed, 72 insertions(+), 43 deletions(-) delete mode 100644 docs/templates/homepage.html delete mode 100644 docs/templates/section/features.html diff --git a/docs/plans/api-stabilization.md b/docs/plans/api-stabilization.md index c0ff0d3..15eb013 100644 --- a/docs/plans/api-stabilization.md +++ b/docs/plans/api-stabilization.md @@ -102,15 +102,15 @@ Items validated by codebase investigation: - [x] Change `tags` from `taxonomies.tags` nesting to flat `tags = ["..."]` (direct TOML array) - [x] Migrate all 17 content files from YAML (`---`) to TOML (`+++`) frontmatter - [x] Update embedded frontmatter examples in documentation pages (7 files) - - [ ] Add `FeedConfig` and `SitemapConfig` structs to `config.rs` with `enabled: bool` (default `true`) - - [ ] Wire feed/sitemap config into `SiteConfig` deserialization + - [x] Add `FeedConfig` and `SitemapConfig` structs to `config.rs` with `enabled: bool` (default `true`) + - [x] Wire feed/sitemap config into `SiteConfig` deserialization - [ ] Gate feed generation in `main.rs` on `config.feed.enabled` - [ ] Gate sitemap generation in `main.rs` on `config.sitemap.enabled` - - [ ] Refactor `ConfigContext`: flat `nested_nav: bool` → nested `nav: NavContext { nested, toc }` - - [ ] Remove duplicate `base_url` top-level template variable injection - - [ ] Update `docs/templates/base.html`: `config.nested_nav` → `config.nav.nested`, `base_url` → `config.base_url` - - [ ] Delete `docs/templates/section/features.html` and `docs/templates/homepage.html` - - [ ] Add template section fallback in `render_section`: try `section/.html`, fall back to `section/default.html` + - [x] Refactor `ConfigContext`: flat `nested_nav: bool` → nested `nav: NavContext { nested, toc }` + - [x] Remove duplicate `base_url` top-level template variable injection + - [x] Update `docs/templates/base.html`: `config.nested_nav` → `config.nav.nested`, `base_url` → `config.base_url` + - [x] Delete `docs/templates/section/features.html` and `docs/templates/homepage.html` + - [x] Add template section fallback in `render_section`: try `section/.html`, fall back to `section/default.html` - [x] Update/fix all existing tests to use TOML frontmatter - [ ] Add new tests: TOML parsing, date validation (valid + invalid), feed/sitemap config gating - [ ] Verify all 69 existing tests pass (updated for TOML) diff --git a/docs/templates/base.html b/docs/templates/base.html index a7e77d2..3b12a14 100644 --- a/docs/templates/base.html +++ b/docs/templates/base.html @@ -7,7 +7,7 @@ {% if page.description %} {% endif %} {{ title }} | {{ config.title }} - + @@ -39,7 +39,7 @@ {% endfor %} {% endif %} - {% if config.nested_nav and item.children %} + {% if config.nav.nested and item.children %}