From 6251f512ffd1f7051610f347a0d7821d8d44baf7 Mon Sep 17 00:00:00 2001 From: Cloud Eric Date: Thu, 16 Apr 2026 22:38:32 +0000 Subject: [PATCH] Per-page meta descriptions in page_shell --- crates/modelrelay-web/src/templates.rs | 73 ++++++++++++++++++++++++-- 1 file changed, 70 insertions(+), 3 deletions(-) diff --git a/crates/modelrelay-web/src/templates.rs b/crates/modelrelay-web/src/templates.rs index d556a6e..0315e37 100644 --- a/crates/modelrelay-web/src/templates.rs +++ b/crates/modelrelay-web/src/templates.rs @@ -2673,6 +2673,25 @@ fn cloud_config_script(config: Option<&CloudWizardConfig>) -> String { /// `path` is the canonical URL path for this page (e.g. `/login`, `/pricing`, `/`). /// It is rendered into `og:url` and `` so that each page has a /// distinct canonical URL rather than every page claiming to be the site root. +fn meta_description_for(title: &str) -> &'static str { + let t = title.to_lowercase(); + if t.contains("sign up") { + "Create your ModelRelay account. Run local GPU workers, get an API key in minutes, and route OpenAI / Anthropic / Responses API traffic through your own hardware." + } else if t.contains("log in") { + "Log in to ModelRelay to manage your workers, API keys, and subscription." + } else if t.contains("integrat") { + "Drop-in OpenAI, Anthropic, and Responses API endpoints. Copy ready-to-run code samples for Python, Node, and curl to integrate ModelRelay in minutes." + } else if t.contains("setup") { + "Install and run a ModelRelay worker on your GPU box in minutes. Step-by-step setup for macOS, Linux, and Windows." + } else if t.contains("dashboard") { + "Your ModelRelay dashboard — manage workers, API keys, usage, and subscription billing." + } else if t.contains("checkout") || t.contains("billing") { + "Manage your ModelRelay subscription, billing, and payment method." + } else { + "ModelRelay — Run your local GPU workers behind a managed cloud relay. OpenAI, Anthropic, and Responses API compatible." + } +} + #[must_use] #[allow(clippy::too_many_lines)] pub fn page_shell_custom( @@ -2723,6 +2742,8 @@ pub fn page_shell_custom( ) }; + let description = meta_description_for(title); + format!( r##" @@ -2730,9 +2751,9 @@ pub fn page_shell_custom( {title} — ModelRelay - + - + @@ -2742,7 +2763,7 @@ pub fn page_shell_custom( - + @@ -3069,4 +3090,50 @@ mod tests { "Organization schema should include the canonical site URL" ); } + + #[test] + fn page_shell_uses_signup_specific_description() { + let html = page_shell("Sign Up", "/signup", "

body

", false); + assert!( + html.contains("Create your ModelRelay account"), + "Sign Up page should use the signup-specific meta description" + ); + } + + #[test] + fn page_shell_uses_login_specific_description() { + let html = page_shell("Log In", "/login", "

body

", false); + assert!( + html.contains("Log in to ModelRelay"), + "Log In page should use the login-specific meta description" + ); + } + + #[test] + fn page_shell_uses_integrate_specific_description() { + let html = page_shell("Integrate", "/integrate", "

body

", true); + assert!( + html.contains("Drop-in OpenAI"), + "Integrate page should use the integrate-specific meta description" + ); + } + + #[test] + fn page_shell_uses_default_description_for_unknown_title() { + let html = page_shell("Random Page", "/random", "

body

", false); + assert!( + html.contains("Run your local GPU workers"), + "Unknown page titles should fall back to the generic default description" + ); + } + + #[test] + fn page_shell_description_appears_in_both_meta_and_og() { + let html = page_shell("Sign Up", "/signup", "

body

", false); + let signup_snippet = "Create your ModelRelay account"; + assert!( + html.matches(signup_snippet).count() >= 2, + "Tuned description should appear in both and og:description (and twitter:description)" + ); + } }