feat(templates): complete Tera migration, remove maud

Fully migrate from compile-time maud templates to runtime Tera:
- Rewrote main.rs to use TemplateEngine and discover_sections()
- Replaced hardcoded blog/projects with generic section loop
- Added Clone derive to Frontmatter and Content
- Fixed section_type dispatch via Section struct
- Deleted src/templates.rs, removed maud dependency

Users can now add sections without code changes.
This commit is contained in:
Timothy DeHerrera
2026-01-31 15:10:39 -07:00
parent 244b0ce85b
commit e200e94583
7 changed files with 103 additions and 435 deletions

View File

@@ -44,6 +44,7 @@ impl TemplateEngine {
nav: &[NavItem],
) -> Result<String> {
let mut ctx = self.base_context(page_path, config, nav);
ctx.insert("title", &content.frontmatter.title);
ctx.insert("page", &FrontmatterContext::from(&content.frontmatter));
ctx.insert("content", html_body);
self.render("page.html", &ctx)
@@ -64,6 +65,7 @@ impl TemplateEngine {
.as_deref()
.unwrap_or("content/default.html");
let mut ctx = self.base_context(page_path, config, nav);
ctx.insert("title", &content.frontmatter.title);
ctx.insert("page", &FrontmatterContext::from(&content.frontmatter));
ctx.insert("content", html_body);
self.render(template, &ctx)
@@ -73,19 +75,16 @@ impl TemplateEngine {
pub fn render_section(
&self,
section: &Content,
section_type: &str,
items: &[ContentContext],
page_path: &str,
config: &SiteConfig,
nav: &[NavItem],
) -> Result<String> {
let section_type = section
.frontmatter
.section_type
.as_deref()
.unwrap_or("default");
let template = format!("section/{}.html", section_type);
let mut ctx = self.base_context(page_path, config, nav);
ctx.insert("title", &section.frontmatter.title);
ctx.insert("section", &FrontmatterContext::from(&section.frontmatter));
ctx.insert("items", items);
self.render(&template, &ctx)
@@ -98,6 +97,8 @@ impl TemplateEngine {
ctx.insert("nav", nav);
ctx.insert("page_path", page_path);
ctx.insert("prefix", &relative_prefix(page_path));
// Trimmed base_url for canonical links
ctx.insert("base_url", config.base_url.trim_end_matches('/'));
ctx
}
}