feat: v1.7.0 — AI-readability suite, form engine & boilerplate helpers
AI / GEO: - feat(content): lexicalToMarkdown, blocksToMarkdown, createMarkdownRenderer (+markdownResponse) — per-page Markdown for AI agents - feat(content): markdown content negotiation + discovery (prefersMarkdown, markdownHref) - feat(seo): buildRobots aiBots policy (allow/block-training/disallow) - feat(seo): llms-full.txt mode in buildLlmsTxt/createLlmsTxtRoute - feat(mcp): createMcpRoute — read-only MCP server (search_content, get_page) - feat(content): searchContent + createSearchRoute — shared JSON search - feat(seo): buildSpeakableJsonLd + buildSummaryField (aiSummary, auto-fill) Forms: - feat(forms): useForm/useContactForm + validators (logic-only, no markup) - feat(forms): honeypot anti-spam (honeypotInputProps, isHoneypotTripped) Helpers / hardening: - feat(i18n): resolveLocalized — replaces ad-hoc getSafeString - feat(hooks): buildCrossLocaleFieldSync — locales from config, no hardcoded list - feat(seo): buildNoindexField — checkbox → meta.noindex, no - feat(content): resolveRedirect — 301/308 from slugHistory - feat(env): assertEnv + ipalEnvRules — fail-fast env validation - feat(consent): ConsentScript — load third-party only after consent - feat(health): createHealthRoute — Coolify/Docker DB liveness Fixes: - fix(seo): wrap getCachedPayload in try/catch in createManifestHandler (Docker/CI build no longer crashes when DB unreachable) docs: migration.md (20 sections), new env.md/mcp.md, updated agents.md, AGENTS-TEMPLATE.md, forms/hooks/content/seo/consent/deployment/richtext
This commit is contained in:
@@ -1,4 +1,52 @@
|
||||
type RobotRule = { allow?: string; disallow?: string[]; userAgent: string | string[] }
|
||||
|
||||
/**
|
||||
* Known AI user agents, split by purpose:
|
||||
* - assistant/search bots fetch a page to answer a user's question live or to
|
||||
* power an AI search index — the ones that make "the chat reads your site"
|
||||
* work, and that most businesses WANT.
|
||||
* - training crawlers collect pages to train models — some clients prefer to
|
||||
* opt out of these while keeping assistant/search visibility.
|
||||
*/
|
||||
export const AI_ASSISTANT_BOTS = [
|
||||
'ClaudeBot',
|
||||
'Claude-Web',
|
||||
'Claude-SearchBot',
|
||||
'ChatGPT-User',
|
||||
'OAI-SearchBot',
|
||||
'PerplexityBot',
|
||||
'Perplexity-User',
|
||||
] as const
|
||||
|
||||
export const AI_TRAINING_BOTS = [
|
||||
'GPTBot',
|
||||
'Google-Extended',
|
||||
'CCBot',
|
||||
'anthropic-ai',
|
||||
'Applebot-Extended',
|
||||
'Bytespider',
|
||||
'Meta-ExternalAgent',
|
||||
] as const
|
||||
|
||||
type AiBotsPolicy = 'allow' | 'block-training' | 'disallow' | false
|
||||
|
||||
type BuildRobotsArgs = {
|
||||
/** Override the assistant/search bot list. */
|
||||
aiAssistantAgents?: readonly string[]
|
||||
/**
|
||||
* How to treat AI crawlers (assistant/search + training). Default 'allow' —
|
||||
* explicitly welcome them so the site stays visible to Claude, ChatGPT,
|
||||
* Perplexity etc. and an accidental future '*' tightening doesn't lock them
|
||||
* out. Options:
|
||||
* - 'allow' (default): explicit allow for assistant AND training bots.
|
||||
* - 'block-training': allow assistant/search bots, disallow training crawlers
|
||||
* — keep AI answers/visibility, opt out of model training.
|
||||
* - 'disallow': block all known AI bots.
|
||||
* - false: emit no AI-specific rules (only the '*' rule).
|
||||
*/
|
||||
aiBots?: AiBotsPolicy
|
||||
/** Override the training crawler list. */
|
||||
aiTrainingAgents?: readonly string[]
|
||||
/** Absolute origin, e.g. 'https://example.com'. */
|
||||
baseUrl: string
|
||||
/** Paths to disallow. Defaults to Payload's admin and API. */
|
||||
@@ -8,17 +56,19 @@ type BuildRobotsArgs = {
|
||||
}
|
||||
|
||||
/**
|
||||
* Shape for Next's `app/robots.ts`.
|
||||
* Shape for Next's `app/robots.ts`. `rules` may be a single rule or an array
|
||||
* (Next accepts both) — it becomes an array when AI-bot rules are added.
|
||||
*/
|
||||
export type RobotsRules = {
|
||||
host?: string
|
||||
rules: { allow?: string; disallow?: string[]; userAgent: string }
|
||||
rules: RobotRule | RobotRule[]
|
||||
sitemap?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds robots rules that allow crawling everything except the admin panel and
|
||||
* API, and point crawlers at the sitemap.
|
||||
* API, point crawlers at the sitemap, and (by default) explicitly welcome AI
|
||||
* assistant/search/training bots.
|
||||
*
|
||||
* ```ts
|
||||
* // app/robots.ts
|
||||
@@ -29,20 +79,42 @@ export type RobotsRules = {
|
||||
*
|
||||
* The admin and API are disallowed by default — no reason for them in the index,
|
||||
* and it keeps crawl budget on real content.
|
||||
*
|
||||
* AI visibility: the #1 reason "the chat won't read the site" is an AI user
|
||||
* agent being blocked (or not explicitly allowed under a tightened '*' rule).
|
||||
* `aiBots: 'allow'` (default) emits explicit allow rules for ClaudeBot, GPTBot,
|
||||
* PerplexityBot, Google-Extended and friends. To keep AI answers but opt out of
|
||||
* model training, use `aiBots: 'block-training'`. To block them all, 'disallow'.
|
||||
*
|
||||
* Pass custom disallow to block parametrized/thin URLs that waste crawl budget:
|
||||
* ```ts
|
||||
* buildRobots({ baseUrl, disallow: ['/admin', '/api', '/*?meter=*', '/*?s=*'] })
|
||||
* ```
|
||||
*/
|
||||
export function buildRobots({
|
||||
aiAssistantAgents = AI_ASSISTANT_BOTS,
|
||||
aiBots = 'allow',
|
||||
aiTrainingAgents = AI_TRAINING_BOTS,
|
||||
baseUrl,
|
||||
disallow = ['/admin', '/api'],
|
||||
sitemap = true,
|
||||
}: BuildRobotsArgs): RobotsRules {
|
||||
const origin = baseUrl.replace(/\/$/, '')
|
||||
|
||||
const baseRule: RobotRule = { allow: '/', disallow, userAgent: '*' }
|
||||
|
||||
const aiRules: RobotRule[] = []
|
||||
if (aiBots === 'allow') {
|
||||
aiRules.push({ allow: '/', disallow, userAgent: [...aiAssistantAgents, ...aiTrainingAgents] })
|
||||
} else if (aiBots === 'block-training') {
|
||||
aiRules.push({ allow: '/', disallow, userAgent: [...aiAssistantAgents] })
|
||||
aiRules.push({ disallow: ['/'], userAgent: [...aiTrainingAgents] })
|
||||
} else if (aiBots === 'disallow') {
|
||||
aiRules.push({ disallow: ['/'], userAgent: [...aiAssistantAgents, ...aiTrainingAgents] })
|
||||
}
|
||||
|
||||
return {
|
||||
rules: {
|
||||
allow: '/',
|
||||
disallow,
|
||||
userAgent: '*',
|
||||
},
|
||||
rules: aiRules.length > 0 ? [baseRule, ...aiRules] : baseRule,
|
||||
...(sitemap ? { sitemap: `${origin}/sitemap.xml` } : {}),
|
||||
host: origin,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user