import type { MetadataRoute } from "next";

import { absoluteUrl, IS_PRODUCTION } from "@/lib/site";

/**
 * Blueprint 12: robots.txt allows all in production. Previews send
 * X-Robots-Tag via page metadata and are disallowed here as well, so a preview
 * alias cannot be indexed by accident (Blueprint 14).
 */
export default function robots(): MetadataRoute.Robots {
  if (!IS_PRODUCTION) {
    return { rules: [{ userAgent: "*", disallow: "/" }] };
  }

  return {
    rules: [{ userAgent: "*", allow: "/" }],
    sitemap: absoluteUrl("/sitemap.xml"),
    host: absoluteUrl("/"),
  };
}
