import { site } from "@/content/site";
import { industries } from "@/content/industries";
import { BLOG_POSTS } from "@/content/blog";
import { AUTHORS_DATA } from "@/lib/authors-data";

// Programmatic llms.txt via the App Router Route Handler convention
// (app/llms.txt/route.ts → /llms.txt). Generated from live site data so it
// never references deleted routes.
export const dynamic = "force-static";

export function GET() {
  const lines: string[] = [
    `# ${site.name}`,
    "",
    `> ${site.description}`,
    "",
    "Quto AI is a done-for-you AI agents agency. We design, build and deploy conversational AI agents across voice, WhatsApp, chat and web — plus the Quto Chatbot Agent, an intelligent chatbot that understands and answers from a customer's own website and works specifically for their business.",
    "",
    "## Core pages",
    `- [Home](${site.url}/): AI agents that do the work — voice, WhatsApp, chat and web.`,
    `- [Voice AI Agents](${site.url}/voice-ai): Done-for-you AI voice agents for inbound and outbound calls — answer, qualify and book 24/7.`,
    `- [WhatsApp AI Automation](${site.url}/whatsapp-ai): AI automation on the official WhatsApp Business API — support, sales, bookings and reminders.`,
    `- [About](${site.url}/about): Who we are and how we work.`,
    `- [Industries](${site.url}/industries): AI agents tuned to each industry's conversations.`,
    `- [Blog](${site.url}/blog): Practical guides on AI agents, voice AI and automation.`,
    `- [Contact](${site.url}/contact): Talk to us and start a project.`,
    "",
    "## Industries",
    ...industries.map(
      (i) => `- [${i.name}](${site.url}/industries/${i.slug}): ${i.tagline}`,
    ),
    "",
    "## Authors",
    `- [Authors](${site.url}/author): The team writing about AI agents and automation.`,
    ...[...AUTHORS_DATA]
      .sort((a, b) => a.displayOrder - b.displayOrder)
      .map((a) => `- [${a.name}](${site.url}/author/${a.slug}): ${a.role}.`),
    "",
    "## Recent articles",
    ...BLOG_POSTS.slice(0, 12).map(
      (p) => `- [${p.title}](${site.url}/blog/${p.slug})`,
    ),
    "",
    "## Legal",
    `- [Privacy Policy](${site.url}/privacy)`,
    `- [Terms of Service](${site.url}/terms)`,
    `- [Disclaimer](${site.url}/disclaimer)`,
    "",
  ];

  return new Response(lines.join("\n"), {
    headers: { "Content-Type": "text/plain; charset=utf-8" },
  });
}
