Agent instructions: mandatory feature set (SEO, GEO, R2, Turnstile, forms) enforced by audits
- AGENT.md §0b: one table of everything every site must have (SEO meta/maps,
JSON-LD, llms.txt + llms-full, Markdown, MCP, AI bots, R2, panel forms,
Turnstile, consent, security, ops, system pages, zero hardcodes), the
forbidden replacements (own forms, nodemailer, reCAPTCHA, hand-written
JSON-LD, static SEO files, raw S3) and an `ipal-audit-skip:` escape hatch that
needs a recorded client decision.
- ipal-audit: "missing: …" errors for every mandatory item and for plugin
replacements; ipal-seo-check: runtime GEO checks (llms, Markdown, MCP,
JSON-LD, AI bots, health). Both verified on bare and complete fixtures.
- Skills (setup, site, form, upgrade, audit, seo-check) and PROGRAMISTA.md
wire the full set from step one; GEO is no longer "optional".
- Fix: createProxy({ markdown: true }) lets /md/... through — multilingual
sites redirected /md/pl/x to /pl/md/pl/x, so the documented Markdown route
never worked — and handles Accept: text/markdown.
- createContentHelpers({ markdownAlternate: true }) adds the text/markdown
alternate link in generatePageMetadata.
- JSDoc/docs JSON-LD examples use JsonLdGraph; docs/CHANGELOG.md for 1.9.0.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -13,11 +13,13 @@ import { buildConfig, getPayload } from 'payload'
|
||||
import { afterAll, beforeAll, describe, expect, test, vi } from 'vitest'
|
||||
|
||||
import { submitForm } from '../src/modules/forms/submitForm.js'
|
||||
import { createContentHelpers } from '../src/modules/frontend/createContentHelpers.js'
|
||||
import { ipalKit } from '../src/plugin.js'
|
||||
|
||||
vi.mock('server-only', () => ({}))
|
||||
|
||||
let payload: Payload
|
||||
let configPromise: Parameters<typeof getPayload>[0]['config']
|
||||
let formId: string
|
||||
|
||||
beforeAll(async () => {
|
||||
@@ -25,7 +27,13 @@ beforeAll(async () => {
|
||||
collections: [
|
||||
// Open sign-up, the risky setup the roles field guard exists for.
|
||||
{ slug: 'users', access: { create: () => true }, auth: true, fields: [] },
|
||||
{ slug: 'pages', fields: [{ name: 'title', type: 'text' }] },
|
||||
{
|
||||
slug: 'pages',
|
||||
fields: [
|
||||
{ name: 'title', type: 'text' },
|
||||
{ name: 'slug', type: 'text', index: true, localized: true },
|
||||
],
|
||||
},
|
||||
// SiteSettings' logo/favicon upload fields point here.
|
||||
{ slug: 'media', fields: [], upload: { staticDir: path.join(os.tmpdir(), 'ipal-test-media') } },
|
||||
],
|
||||
@@ -42,6 +50,7 @@ beforeAll(async () => {
|
||||
secret: 'integration-test-secret',
|
||||
telemetry: false,
|
||||
})
|
||||
configPromise = config
|
||||
payload = await getPayload({ config })
|
||||
|
||||
const form = await payload.create({
|
||||
@@ -132,3 +141,18 @@ describe('forms against a real Payload', () => {
|
||||
expect(admin.roles).toEqual(['admin'])
|
||||
})
|
||||
})
|
||||
|
||||
describe('generatePageMetadata — markdownAlternate', () => {
|
||||
const i18n = { defaultLocale: 'pl', locales: [{ code: 'pl', label: 'Polski' }] } as const
|
||||
|
||||
test('advertises the Markdown version of an indexable page', async () => {
|
||||
await payload.create({ collection: 'pages' as never, data: { slug: 'o-nas', title: 'O nas' } as never })
|
||||
const on = createContentHelpers({ baseUrl: 'https://acme.pl', config: configPromise, i18n, markdownAlternate: true })
|
||||
const meta = await on.generatePageMetadata('pl', ['o-nas'])
|
||||
expect(meta.alternates?.canonical).toBe('https://acme.pl/o-nas')
|
||||
expect(meta.alternates?.types).toEqual({ 'text/markdown': '/md/o-nas' })
|
||||
|
||||
const off = createContentHelpers({ baseUrl: 'https://acme.pl', config: configPromise, i18n })
|
||||
expect((await off.generatePageMetadata('pl', ['o-nas'])).alternates?.types).toBeUndefined()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
import { describe, expect, test } from 'vitest'
|
||||
|
||||
import type { I18nConfig } from '../src/modules/i18n/types.js'
|
||||
|
||||
import { createProxy } from '../src/modules/i18n/createProxy.js'
|
||||
|
||||
const config: I18nConfig = {
|
||||
defaultLocale: 'pl',
|
||||
locales: [
|
||||
{ code: 'pl', label: 'Polski' },
|
||||
{ code: 'en', label: 'English' },
|
||||
],
|
||||
}
|
||||
|
||||
type Res = { cookies: { set: () => void }; kind: string; url?: string }
|
||||
const res = (kind: string, url?: string | URL): Res => ({ cookies: { set: () => {} }, kind, url: url?.toString() })
|
||||
const NextResponse = {
|
||||
next: () => res('next'),
|
||||
redirect: (url: string | URL) => res('redirect', url),
|
||||
rewrite: (url: string | URL) => res('rewrite', url),
|
||||
}
|
||||
|
||||
function request(path: string, headers: Record<string, string> = {}) {
|
||||
const url = new URL(`https://acme.pl${path}`)
|
||||
return {
|
||||
cookies: { get: () => undefined },
|
||||
headers: new Headers(headers),
|
||||
nextUrl: { clone: () => new URL(url), pathname: url.pathname, search: url.search },
|
||||
url: url.toString(),
|
||||
}
|
||||
}
|
||||
|
||||
describe('createProxy', () => {
|
||||
test('without markdown: a path with no locale is redirected', () => {
|
||||
const proxy = createProxy(config, { NextResponse })
|
||||
expect(proxy(request('/o-nas')) as unknown as Res).toMatchObject({ kind: 'redirect', url: 'https://acme.pl/pl/o-nas' })
|
||||
})
|
||||
|
||||
test('markdown: /md/… passes through instead of becoming /pl/md/…', () => {
|
||||
const proxy = createProxy(config, { markdown: true, NextResponse })
|
||||
expect((proxy(request('/md/pl/o-nas')) as unknown as Res).kind).toBe('next')
|
||||
})
|
||||
|
||||
test('markdown: Accept text/markdown rewrites to the Markdown route', () => {
|
||||
const proxy = createProxy(config, { markdown: true, NextResponse })
|
||||
const out = proxy(request('/pl/o-nas', { accept: 'text/markdown' })) as unknown as Res
|
||||
expect(out).toMatchObject({ kind: 'rewrite', url: 'https://acme.pl/md/pl/o-nas' })
|
||||
expect((proxy(request('/pl/o-nas', { accept: 'text/html' })) as unknown as Res).kind).toBe('next')
|
||||
})
|
||||
|
||||
test('markdown: a locale-less path still gets the locale redirect first', () => {
|
||||
const proxy = createProxy(config, { markdown: true, NextResponse })
|
||||
expect((proxy(request('/o-nas', { accept: 'text/markdown' })) as unknown as Res).kind).toBe('redirect')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user