//! Post/content-item page renderer for blog posts, projects, activities, and
//! recipes.

use minijinja::{context, Environment};
use rustelo_core_lib::content::UnifiedContentItem;

use crate::render::render_safe;

/// Render a content post page body (goes inside `<main>`).
///
/// `body_html` is the pre-rendered markdown HTML from `load_content_by_slug`.
/// The `item` provides all metadata (title, tags, author, dates, translations).
/// Loads `pages/post.j2`; returns a safe error paragraph on template failure.
pub fn render_post_page(
    env: &Environment,
    item: &UnifiedContentItem,
    body_html: &str,
    lang: &str,
) -> String {
    render_safe(
        env,
        "pages/post.j2",
        context! {
            item => item,
            body_html => body_html,
            lang => lang,
        },
    )
}
