namespace DeepDrftPublic.Seo;
///
/// Pure composition of the robots.txt body (Phase 23 wave 23.1). The environment gate is the
/// caller's: the endpoint reads
/// server-side and passes the boolean here, so the production-vs-beta branch lives in one testable place.
/// Fail-safe is closed — anything that is not Production yields Disallow: / (Invariant E1).
///
public static class RobotsTxt
{
///
/// Builds the directive body. In Production: allow everything except the embed shell and the proxy API
/// paths, plus a Sitemap: pointer (OQ-R2). In any non-production environment: a closed door
/// (Disallow: /) with no sitemap pointer, so a crawl of beta sees nothing and the sitemap is
/// never advertised.
///
/// The server-side IsProduction() result — the single gate.
/// Canonical origin (no trailing slash) for the Sitemap: line; Production only.
public static string Build(bool isProduction, string baseUrl)
{
if (!isProduction)
{
return "User-agent: *\n" +
"Disallow: /\n";
}
var origin = baseUrl.TrimEnd('/');
return "User-agent: *\n" +
"Allow: /\n" +
"Disallow: /FramePlayer\n" +
"Disallow: /api/\n" +
$"Sitemap: {origin}/sitemap.xml\n";
}
}