minimaxh3-site-kit 0.1.0

URL helpers and metadata utilities for MiniMax H3 - 2K AI video generator with synced audio for text-to-video and image-to-video
Documentation
//! Public URL helpers for MiniMax H3.

pub const BASE: &str = "https://minimaxh3.art";
pub const BRAND: &str = "MiniMax H3";
pub const DESCRIPTION: &str = "2K AI video generator with synced audio — text-to-video and image-to-video.";

pub fn page_url(path: &str) -> String {
    if path.is_empty() || path == "/" { return format!("{}/", BASE); }
    let with_slash = if path.starts_with('/') { path.to_string() } else { format!("/{}", path) };
    let trimmed = with_slash.trim_end_matches('/');
    format!("{}{}{}", BASE, trimmed, "/")
}

pub fn localized_url(locale: &str, path: &str) -> Result<String, String> {
    match locale {
        "en" => Ok(page_url(path)),
        "zh" | "zh-CN" => {
            let value = if path.is_empty() || path == "/" { "/".to_string() } else if path.starts_with('/') { path.to_string() } else { format!("/{}", path) };
            Ok(page_url(&format!("/zh{}", if value == "/" { "" } else { &value })))
        }
        _ => Err(format!("unsupported locale: {}", locale)),
    }
}

pub fn home_url() -> String { page_url("/") }
pub fn studio_url() -> String { format!("{}/#studio", BASE) }
pub fn pricing_url() -> String { format!("{}/#pricing", BASE) }
pub fn blog_url() -> String { page_url("/blog") }
pub fn about_url() -> String { page_url("/about") }
pub fn contact_url() -> String { page_url("/contact") }
pub fn privacy_url() -> String { page_url("/privacy-policy") }
pub fn terms_url() -> String { page_url("/terms-of-service") }
pub fn refund_policy_url() -> String { page_url("/refund-policy") }
pub fn zh_home_url() -> String { localized_url("zh", "/").unwrap() }

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn builds_public_urls() {
        assert_eq!(BRAND, "MiniMax H3");
        assert_eq!(home_url(), "https://minimaxh3.art/");
        assert_eq!(studio_url(), "https://minimaxh3.art/#studio");
        assert_eq!(pricing_url(), "https://minimaxh3.art/#pricing");
        assert_eq!(blog_url(), "https://minimaxh3.art/blog/");
        assert_eq!(contact_url(), "https://minimaxh3.art/contact/");
        assert_eq!(zh_home_url(), "https://minimaxh3.art/zh/");
    }
    #[test]
    fn follows_locale_rules() {
        assert_eq!(localized_url("en", "/blog").unwrap(), "https://minimaxh3.art/blog/");
        assert_eq!(localized_url("zh-CN", "blog").unwrap(), "https://minimaxh3.art/zh/blog/");
        assert!(localized_url("fr", "/blog").is_err());
    }
}