//! jpl-website - Application Library
//!
//! Generated by cargo rustelo v0.1.0 from content-website template
//! This library contains your application components and business logic.
//! This file won't be overwritten by framework updates.

use leptos::*;
use leptos_router::*;

pub mod app;
pub mod components;
pub mod pages;

// Re-export commonly used items
pub use app::App;
pub use components::*;

/// Application configuration and settings
#[derive(Debug, Clone)]
pub struct AppConfig {
    pub site_name: String,
    pub description: String,
    pub version: String,
    pub template_variant: String,
    pub generated_at: String,
}

impl Default for AppConfig {
    fn default() -> Self {
        Self {
            site_name: "jpl-website".to_string(),
            description: "{{project_description}}".to_string(),
            version: env!("CARGO_PKG_VERSION").to_string(),
            template_variant: "content-website".to_string(),
            generated_at: "2025-10-28T18:46:17.145459+00:00".to_string(),
        }
    }
}

/// Application context for sharing state across components
#[derive(Debug, Clone)]
pub struct AppContext {
    pub config: AppConfig,
    // Add your application context here
}

impl AppContext {
    pub fn new() -> Self {
        Self {
            config: AppConfig::default(),
        }
    }

    pub fn with_config(config: AppConfig) -> Self {
        Self {
            config,
        }
    }
}

/// Provide application context to child components
#[component]
pub fn AppContextProvider(
    children: Children,
    #[prop(optional)] config: Option<AppConfig>,
) -> impl IntoView {
    let context = match config {
        Some(config) => AppContext::with_config(config),
        None => AppContext::new(),
    };

    provide_context(context);

    children()
}
