noindex tooling, content/noindex/component/testing guidelines for agents

- IPAL_NOINDEX=1: whole-site noindex for staging (robots Disallow /, robots
  meta noindex,nofollow, X-Robots-Tag via buildSecurityHeaders).
- Markdown mirrors and llms files: X-Robots-Tag noindex; Markdown adds a
  Link rel=canonical to the HTML page.
- buildNoindexField refuses noindex on the homepage and archive pages.
- AGENT.md §0c: writing pages for Google and AI (structure, answer-first,
  facts, E-E-A-T, entity consistency, sameAs, aiSummary, meta) and a
  when-to-noindex table (legal pages stay indexed by default; drafts instead
  of noindexed pages; staging via env).
- AGENT.md §6.0: ten component rules (small, Button styled once, buttons as
  '+ Add Button' array, variants, panel clarity); audit warns on buttons
  styled inside sections.
- AGENT.md §8a + smoke.spec.template.ts: what to test in a client project;
  PROGRAMISTA §8.1a: how the plugin itself is tested.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-16 03:13:44 +02:00
co-authored by Claude Opus 5.5
parent 8e2dd28b83
commit f7466cf77f
13 changed files with 314 additions and 10 deletions
+16 -6
View File
@@ -105,10 +105,8 @@ export function createMarkdownRenderer(args: CreateMarkdownRendererArgs = {}) {
const fm = ['---', `locale: ${locale}`]
if (title) {fm.push(`title: ${yamlEscape(title)}`)}
if (description) {fm.push(`description: ${yamlEscape(description)}`)}
if (baseUrl) {
const segments = config?.locales.length === 1 ? (slug ?? []) : [locale, ...(slug ?? [])]
fm.push(`url: ${baseUrl.replace(/\/$/, '')}/${segments.join('/')}`.replace(/\/$/, ''))
}
const url = canonicalOf(baseUrl, config, locale, slug)
if (url) {fm.push(`url: ${url}`)}
if (typeof doc.updatedAt === 'string') {fm.push(`updated: ${doc.updatedAt.slice(0, 10)}`)}
fm.push('---')
parts.push(fm.join('\n'))
@@ -127,7 +125,7 @@ export function createMarkdownRenderer(args: CreateMarkdownRendererArgs = {}) {
* Wraps a Markdown string in a `text/markdown` Response, or a 404 when null.
* Uses the global Response — no next/server import.
*/
export function markdownResponse(md: null | string): Response {
export function markdownResponse(md: null | string, options: { canonical?: string } = {}): Response {
if (md == null) {
return new Response('Not found', { headers: { 'content-type': 'text/plain' }, status: 404 })
}
@@ -135,11 +133,22 @@ export function markdownResponse(md: null | string): Response {
headers: {
'cache-control': 'public, max-age=0, s-maxage=3600, stale-while-revalidate=86400',
'content-type': 'text/markdown; charset=utf-8',
// A mirror of an HTML page: AI agents read it, search engines must not
// index it as a duplicate — and should credit the HTML page instead.
'x-robots-tag': 'noindex',
...(options.canonical ? { link: `<${options.canonical}>; rel="canonical"` } : {}),
},
status: 200,
})
}
/** Canonical HTML URL of a Markdown page — same rule as the frontmatter `url:`. */
function canonicalOf(baseUrl: string | undefined, config: { locales: readonly unknown[] } | undefined, locale: string, slug?: string[]) {
if (!baseUrl) {return undefined}
const segments = config?.locales.length === 1 ? (slug ?? []) : [locale, ...(slug ?? [])]
return `${baseUrl.replace(/\/$/, '')}/${segments.join('/')}`.replace(/\/$/, '')
}
type MarkdownRouteContext = { params: Promise<{ locale: string; slug?: string[] }> }
/**
@@ -167,7 +176,8 @@ export function createMarkdownRoute(
GET: async (_req, { params }) => {
try {
const { slug, locale } = await params
return markdownResponse(await render({ slug, locale, payload: await getCachedPayload() }))
const md = await render({ slug, locale, payload: await getCachedPayload() })
return markdownResponse(md, { canonical: canonicalOf(rendererArgs.baseUrl, rendererArgs.config, locale, slug) })
} catch (err) {
console.warn('[ipal] createMarkdownRoute: render failed:', err)
return new Response('Service unavailable', { headers: { 'content-type': 'text/plain' }, status: 503 })