//! Unified PostViewer Page Component

use leptos::prelude::*;
use rustelo_core_lib::config::get_default_language;

#[component]
pub fn PostViewerPage(
    #[prop(default = get_default_language().to_string())] _language: String,
    #[prop(optional)] slug: Option<String>,
    #[prop(default = "content".to_string())] content_type: String,
    #[prop(default = true)] show_author: bool,
    #[prop(default = true)] show_date: bool,
    #[prop(default = true)] show_tags: bool,
    #[prop(default = false)] show_related_posts: bool,
    #[prop(default = false)] enable_comments: bool,
    #[prop(default = false)] enable_social_sharing: bool,
) -> impl IntoView {
    #[cfg(not(target_arch = "wasm32"))]
    {
        view! {
            <crate::post_viewer::ssr::PostViewerPageSSR
                _language=_language.clone()
                slug=slug.unwrap_or_default()
                content_type=content_type
                show_author=show_author
                show_date=show_date
                show_tags=show_tags
                show_related_posts=show_related_posts
                enable_comments=enable_comments
                enable_social_sharing=enable_social_sharing
            />
        }
    }
    #[cfg(target_arch = "wasm32")]
    {
        view! {
            <crate::post_viewer::client::PostViewerPageClient
                _language=_language.clone()
                slug=slug.unwrap_or_default()
                content_type=content_type
                show_author=show_author
                show_date=show_date
                show_tags=show_tags
                show_related_posts=show_related_posts
                enable_comments=enable_comments
                enable_social_sharing=enable_social_sharing
            />
        }
    }
}
