import { site } from "../data/site";
import { getPublishedArticles } from "../lib/articles";

export async function GET() {
  const articles = await getPublishedArticles();
  const lines = [
    `# ${site.brand.name}`,
    "",
    `> ${site.brand.tagline}`,
    "",
    `银妆是拥有 14 年行业积淀的银饰连锁品牌，提供足银首饰零售、来料加工、专属雕刻与银饰 DIY 编织服务。`,
    "",
    "## 核心页面",
    "- [首页](/)", "- [产品与定制](/services/)", "- [关于银妆](/about/)", "- [门店与服务](/join/)", "- [银饰资讯](/articles/)", "- [常见问题](/faq/)", "- [联系我们](/contact/)",
    "", "## 银饰资讯",
    ...articles.map((article) => `- [${article.data.title}](/articles/${article.id}/): ${article.data.excerpt}`),
    "", `客服电话：${site.contact.phone}`, `公司地址：${site.contact.address}`,
  ];
  return new Response(lines.join("\n"), { headers: { "Content-Type": "text/plain; charset=utf-8", "Cache-Control": "public, max-age=3600" } });
}
