Skip to main content

minimaxh3_site_kit/
lib.rs

1//! Public URL helpers for MiniMax H3.
2
3pub const BASE: &str = "https://minimaxh3.art";
4pub const BRAND: &str = "MiniMax H3";
5pub const DESCRIPTION: &str = "2K AI video generator with synced audio — text-to-video and image-to-video.";
6
7pub fn page_url(path: &str) -> String {
8    if path.is_empty() || path == "/" { return format!("{}/", BASE); }
9    let with_slash = if path.starts_with('/') { path.to_string() } else { format!("/{}", path) };
10    let trimmed = with_slash.trim_end_matches('/');
11    format!("{}{}{}", BASE, trimmed, "/")
12}
13
14pub fn localized_url(locale: &str, path: &str) -> Result<String, String> {
15    match locale {
16        "en" => Ok(page_url(path)),
17        "zh" | "zh-CN" => {
18            let value = if path.is_empty() || path == "/" { "/".to_string() } else if path.starts_with('/') { path.to_string() } else { format!("/{}", path) };
19            Ok(page_url(&format!("/zh{}", if value == "/" { "" } else { &value })))
20        }
21        _ => Err(format!("unsupported locale: {}", locale)),
22    }
23}
24
25pub fn home_url() -> String { page_url("/") }
26pub fn studio_url() -> String { format!("{}/#studio", BASE) }
27pub fn pricing_url() -> String { format!("{}/#pricing", BASE) }
28pub fn blog_url() -> String { page_url("/blog") }
29pub fn about_url() -> String { page_url("/about") }
30pub fn contact_url() -> String { page_url("/contact") }
31pub fn privacy_url() -> String { page_url("/privacy-policy") }
32pub fn terms_url() -> String { page_url("/terms-of-service") }
33pub fn refund_policy_url() -> String { page_url("/refund-policy") }
34pub fn zh_home_url() -> String { localized_url("zh", "/").unwrap() }
35
36#[cfg(test)]
37mod tests {
38    use super::*;
39    #[test]
40    fn builds_public_urls() {
41        assert_eq!(BRAND, "MiniMax H3");
42        assert_eq!(home_url(), "https://minimaxh3.art/");
43        assert_eq!(studio_url(), "https://minimaxh3.art/#studio");
44        assert_eq!(pricing_url(), "https://minimaxh3.art/#pricing");
45        assert_eq!(blog_url(), "https://minimaxh3.art/blog/");
46        assert_eq!(contact_url(), "https://minimaxh3.art/contact/");
47        assert_eq!(zh_home_url(), "https://minimaxh3.art/zh/");
48    }
49    #[test]
50    fn follows_locale_rules() {
51        assert_eq!(localized_url("en", "/blog").unwrap(), "https://minimaxh3.art/blog/");
52        assert_eq!(localized_url("zh-CN", "blog").unwrap(), "https://minimaxh3.art/zh/blog/");
53        assert!(localized_url("fr", "/blog").is_err());
54    }
55}