fix(feed): derive URLs from content paths

Replace hardcoded "/blog/{slug}.html" URL pattern with dynamic
path derivation using Content.output_path(). This ensures feed
URLs work correctly for any content location, not just blog posts.
This commit is contained in:
Timothy DeHerrera
2026-01-31 13:59:05 -07:00
parent a5c56c2b2f
commit 1bf265f14b
2 changed files with 13 additions and 5 deletions

View File

@@ -2,9 +2,10 @@
use crate::config::SiteConfig;
use crate::content::Content;
use std::path::Path;
/// Generate an Atom 1.0 feed from blog posts.
pub fn generate_atom_feed(posts: &[Content], config: &SiteConfig) -> String {
pub fn generate_atom_feed(posts: &[Content], config: &SiteConfig, content_root: &Path) -> String {
let base_url = config.base_url.trim_end_matches('/');
// Use the most recent post date as feed updated time, or fallback
@@ -16,7 +17,9 @@ pub fn generate_atom_feed(posts: &[Content], config: &SiteConfig) -> String {
let mut entries = String::new();
for post in posts {
let post_url = format!("{}/blog/{}.html", base_url, post.slug);
// Derive URL from output path (e.g., blog/foo.html → /blog/foo.html)
let relative_path = post.output_path(content_root);
let post_url = format!("{}/{}", base_url, relative_path.display());
let post_date = post
.frontmatter
.date