SEO/GEO/GSC: sitemap index + caching, Search & AI settings, getRobots

- Sitemap: batched reads (500), published-only where, field select; sitemap
  index over maxUrls (default 10k) with ?part=N; Cache-Control; in-process
  memo; runtime errors → 503 Retry-After (empty urlset only during next build)
- Site Settings → Search & AI tab (seo.searchSettings: false removes it):
  Google/Bing/Yandex verification (paste code or whole meta tag) added to
  page metadata; AI crawler policy + per-bot exceptions; llms.txt note
- buildRobots aiBotRules; getRobots helper reads the panel; more AI agents
- Under construction: sitemap and llms.txt list only open pages
- collectSiteIndex: no silent 1000 cap; llms routes send Cache-Control
- IndexNow: nothing sent with IPAL_NOINDEX
- Unknown route metadata is noindex
- Tests (unit + SQLite integration) and docs/seo.md

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-10-22 17:09:01 +02:00
co-authored by Claude Opus 5.5
parent 12fbd424a5
commit 94e563055f
23 changed files with 1144 additions and 67 deletions
+37 -5
View File
@@ -38,7 +38,12 @@ export type CollectSiteIndexArgs = {
content?: ContentOption
/** Population depth of `doc`. Default 0 (1 when you render blocks with images). */
depth?: number
/** Max documents per collection and locale. Default 1000. */
/**
* Only paths this returns true for — e.g. the pages still open while the site
* is under construction. Default: every path.
*/
include?: (path: string) => boolean
/** Max documents per collection and locale. Default: no limit (read in batches of 500). */
limit?: number
/** Only these locales. Default: every configured locale. */
locales?: string[]
@@ -80,6 +85,33 @@ function slugMap(rel: unknown, locales: string[]): Record<string, string> | unde
return Object.keys(map).length ? map : undefined
}
const BATCH = 500
/** Published documents of one collection in one locale, BATCH at a time, up to `limit`. */
async function readDocs(
payload: BasePayload,
collection: string,
{ depth, limit, locale }: { depth: number; limit?: number; locale: string },
): Promise<Row[]> {
const cfg = (payload.collections as Record<string, { config?: { versions?: { drafts?: unknown } | false } }> | undefined)?.[collection]?.config
const drafts = Boolean(cfg?.versions && cfg.versions.drafts)
const docs: Row[] = []
const size = limit === undefined ? BATCH : Math.max(1, Math.min(BATCH, limit))
for (let page = 1; limit === undefined || docs.length < limit; page++) {
const res = await payload.find({
collection: collection as never,
depth,
limit: size,
locale: locale as never,
page,
...(drafts ? { where: { _status: { equals: 'published' } } } : {}),
})
docs.push(...((res?.docs ?? []) as Row[]))
if (!res?.hasNextPage) {break}
}
return limit === undefined ? docs : docs.slice(0, limit)
}
/**
* Every public page and archive entry, per language, with its URL, title,
* description and dates — ONE source for everything that lists the site to
@@ -95,7 +127,8 @@ export async function collectSiteIndex({
config,
content,
depth = 0,
limit = 1000,
include,
limit,
locales,
pagesSlug = 'pages',
payload,
@@ -127,8 +160,7 @@ export async function collectSiteIndex({
if (collection !== pagesSlug && !prefix?.[locale]) {continue}
let docs: Row[] = []
try {
const res = await payload.find({ collection: collection as never, depth, limit, locale: locale as never })
docs = (res?.docs ?? []) as Row[]
docs = await readDocs(payload, collection, { depth, limit, locale })
} catch {
continue
}
@@ -142,7 +174,7 @@ export async function collectSiteIndex({
const slug = typeof doc.slug === 'string' ? doc.slug : ''
if (!title || !slug || EXCLUDED_SLUGS.has(slug)) {continue}
const path = buildLocalizedPath({ config, homeSlug, locale, prefix, slugs: { [locale]: slug } })
if (!path) {continue}
if (!path || (include && !include(path))) {continue}
const summary = summaryField && typeof doc[summaryField] === 'string' ? (doc[summaryField]).trim() : ''
const metaDescription = typeof doc.meta?.description === 'string' ? doc.meta.description.trim() : ''
const description = summary || metaDescription