seo: open site to search engines + expand sitemap to full catalog

- layout.tsx: flip robots.index from false→true (and the matching
  googleBot block). Drop the manual <meta name="robots"
  content="index, follow"> in the JSX head — it was duplicating
  (and conflicting with) the metadata-driven tag, so Google was
  seeing both "index, follow" AND "noindex, nofollow" and taking
  the more restrictive one. Now the metadata block is the single
  source of truth.
- sitemap.ts: expand from 5,000 articles to up to 45,000 (catalog
  is ~26k; cap leaves room for static + authors + events under
  Google's 50k-per-file ceiling). Add /authors/[slug] entries
  pulled from bb.author_profiles, and /events/[slug] entries
  pulled from bb.events. Drop the duplicate /articles/[slug]
  emissions — /news/[slug] is the canonical news URL.
- legacy-source.ts: page through the supabase query in 1,000-row
  chunks via Range headers so the 25k cap actually returns the
  full catalog (the previous `.limit(25000)` was getting silently
  truncated at PostgREST's default 1,000 max_rows).

Phase B (Ollama rewriter) is live; the press-release scrubber +
AI featured-image jobs are running in background to clean the
catalog. User explicitly chose to open SEO now rather than wait
for those jobs to finish.
This commit is contained in:
Ryan Salazar
2026-05-20 07:17:59 +00:00
parent a9823b1d8a
commit 4e11438963
3 changed files with 133 additions and 57 deletions

View File

@@ -392,38 +392,66 @@ export async function getLegacyRecentSlugs(limit = 200): Promise<string[]> {
}
export async function getLegacyRecentSitemapEntries(
limit = 5000,
limit = 25000,
): Promise<{ slug: string; date: string }[]> {
const out: { slug: string; date: string }[] = [];
try {
const { data } = await client()
.from("wp_imported_posts")
.select("wp_slug,wp_published_at")
.eq("status", "published")
.order("wp_published_at", { ascending: false })
.limit(limit);
for (const r of data || []) {
out.push({
slug: (r as any).wp_slug,
date: (r as any).wp_published_at || new Date().toISOString(),
});
// PostgREST caps each response at max_rows (1000 by default), so we
// page with explicit Range headers via .range() until either limit is
// hit OR we get a short page back (end of data).
const PAGE = 1000;
async function pageThrough(
table: string,
selectCols: string,
orderCol: string,
slugCol: string,
dateCols: string[],
cap: number,
) {
let from = 0;
while (from < cap) {
const to = Math.min(from + PAGE - 1, cap - 1);
let q = client().from(table).select(selectCols).eq("status", "published");
q = q.order(orderCol, { ascending: false, nullsFirst: false });
const { data, error } = await q.range(from, to);
if (error) break;
const rows = (data || []) as any[];
if (rows.length === 0) break;
for (const r of rows) {
const slug = r[slugCol];
if (!slug) continue;
let date: string | null = null;
for (const c of dateCols) {
if (r[c]) { date = r[c]; break; }
}
out.push({ slug, date: date || new Date().toISOString() });
}
if (rows.length < PAGE) break;
from += rows.length;
}
}
try {
await pageThrough(
"wp_imported_posts",
"wp_slug,wp_published_at",
"wp_published_at",
"wp_slug",
["wp_published_at"],
limit,
);
} catch {
// ignore
}
try {
const { data } = await client()
.from("ai_rewritten_articles")
.select("slug,published_at,created_at")
.eq("status", "published")
.order("published_at", { ascending: false, nullsFirst: false })
.limit(limit);
for (const r of data || []) {
out.push({
slug: (r as any).slug,
date: (r as any).published_at || (r as any).created_at || new Date().toISOString(),
});
}
await pageThrough(
"ai_rewritten_articles",
"slug,published_at,created_at",
"published_at",
"slug",
["published_at", "created_at"],
limit,
);
} catch {
// ignore
}