Merge main (security-perf + SEO) into docs; finish English docs and agent guide

- Resolve conflicts in analytics, consent, content, i18n, mcp and stats,
  keeping the docs fixes and the new code behaviour, verified against src
- Translate the remaining 14 module pages, ipal-seo-check skill and script
- Integrate the security-perf and SEO agent-guide text: getRobots,
  isPathVisible, Search & AI (DNS verification first, meta fields optional),
  sitemap index/cache/503, consentMode basic/advanced, policyVersion,
  globalOverrides, revalidatePath / buildGlobalRevalidateHook, authAccess,
  firstUserAdmin, allowCollectionMismatch, unknown-IP rate limit; stale
  claims fixed across AGENT.md, skills, frontend, developer guide, vibe
- docsConsistency: pending list removed (all docs English); relative links
  now also check #anchors

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-10-22 17:59:52 +02:00
co-authored by Claude Opus 5.5
107 changed files with 5476 additions and 2541 deletions
+45 -35
View File
@@ -89,34 +89,19 @@ export const i18nConfig = {
import type { ContentOption } from '@intecion/ipal-kit'
export const contentConfig: ContentOption = { collections: [] }
// src/hooks/revalidateGlobals.ts — the plugin does NOT revalidate globals (hooks.md)
import { revalidatePath } from 'next/cache'
import type { GlobalAfterChangeHook } from 'payload'
export const revalidateEverything: GlobalAfterChangeHook = ({ doc, context }) => {
if (!process.env.NEXT_RUNTIME || context?.disableRevalidate) return doc
revalidatePath('/', 'layout')
return doc
}
```
```ts
// src/payload.config.ts — keep from create-payload-app: db, editor, secret, sharp, typescript, admin.importMap
import { buildConfig, type Plugin } from 'payload'
import { buildConfig } from 'payload'
import { revalidatePath } from 'next/cache'
import { buildR2Storage, ipalKit, mailAdapter } from '@intecion/ipal-kit'
import { payloadTotp } from '@clocklimited/payload-2fa'
import { s3Storage } from '@payloadcms/storage-s3'
import { i18nConfig } from '@/i18n.config'
import { contentConfig } from '@/content.config'
import { revalidateEverything } from '@/hooks/revalidateGlobals'
import { Pages } from '@/collections/Pages'
import { Media } from '@/collections/Media'
const PLUGIN_GLOBALS = ['site-settings', 'site-integrations', 'cookie-settings', 'notifications']
const revalidatePluginGlobals: Plugin = (config) => ({
...config,
globals: config.globals?.map((g) => PLUGIN_GLOBALS.includes(g.slug)
? { ...g, hooks: { ...g.hooks, afterChange: [...(g.hooks?.afterChange ?? []), revalidateEverything] } } : g),
})
export default buildConfig({
// …db, editor, secret, sharp, typescript from create-payload-app…
collections: [Pages, Media], // ipalKit injects users
@@ -133,8 +118,8 @@ export default buildConfig({
whiteLabel: true,
indexNow: true,
consentLog: true, // without this there is no POST /api/ipal/consent
revalidatePath, // saving a plugin global refreshes the whole site (ISR)
}),
revalidatePluginGlobals, // AFTER ipalKit — the plugin globals already exist
buildR2Storage(['media'], { s3Storage }), // ALWAYS: R2 with the full R2_* set, local disk without it
],
})
@@ -153,17 +138,24 @@ the panel shows Site Settings, Site Integrations, Cookie Settings, Notifications
-d '{"id":"0123456789abcdef","version":1,"state":{"necessary":true,"functional":false,"analytics":false,"marketing":false}}'` → `201`.
**Turn off / override.**
- `enabled: false` — `ipalKit` returns the config unchanged: the plugin's collections and globals **disappear from the config**
(Postgres: do not approve a migration/push that drops tables).
- `enabled: false` — collections, globals and fields stay (schema unchanged, `migrate:create` drops nothing);
no `/api/ipal/*` endpoints, no `onInit` work, no admin components.
- Omitted option = module off: `seo`, `forms`, `pages` (without it `content` does not work), `content`,
`consentLog`, `indexNow`, `whiteLabel`, `access`, `stats`.
- `twoFactor`: **omitting it throws** (`issuer` is required) — turn it off only explicitly with `twoFactor: false`
(discouraged); without an injected `plugin: payloadTotp` it also throws. `forceSetup` currently always `true`.
- `users`: your own collection with that slug wins (the plugin only adds `roles`). `localization` currently always
- `users`: the injected collection lets admins manage everyone and others only themselves — loosen with
`access: { authCollection: 'users', authAccess: { read: authenticated } }` (your keys win); your own collection with
that slug wins whole (the plugin only adds `roles` — give it `adminOrSelf` / `adminOnly`). The first account
(Create first user) gets `admin` — `access.firstUserAdmin: false` turns that off. `localization` currently always
overridden from `i18n`.
- The `site-settings`, `site-integrations`, `cookie-settings`, `notifications` globals, the
`/api/ipal/test-email` endpoint and dashboard alerts — currently always; extend `siteSettingsFields` /
`integrationsFields`, remove/replace them with your own plugin after `ipalKit` (like `revalidatePluginGlobals`).
- 2FA wraps the panel's login collection (`admin.user`); a different `twoFactor.collectionSlug` stops startup with
`[ipal] twoFactor…` unless `allowCollectionMismatch: true`.
- The `site-settings`, `site-integrations`, `cookie-settings`, `notifications` globals (write: editor+; Site
Integrations: admin), the `/api/ipal/test-email` endpoint and dashboard alerts — currently always present; extend
`siteSettingsFields` / `integrationsFields`; change access, admin or hooks with
`globalOverrides: { notifications: { access: { update: authenticated } } }` (object = merged key by key, your keys
win; a function `(global) => global` takes over). Without `revalidatePath` global saves wait for the ISR window.
- `whiteLabel: { credit: false, titleSuffix, settingsSlug, logoField, … }`; with `whiteLabel` the plugin overrides
`graphics.Logo/Icon` — your own graphics only without it.
- Mail: any Payload adapter instead of `mailAdapter()`; `mailAdapter({ fallbackFromAddress, smtp, graph })`.
@@ -307,7 +299,9 @@ and `rel="alternate" type="text/markdown"`; `/pl/nie-ma-takiej` → 404 with con
- `createProxy`: `markdown: '/ai'` (another prefix), `exposeHeaders: false`, `cookieName`, `consentCategory`;
a fully custom proxy on `createLocaleMiddleware`. The matcher belongs to the project.
- `createContentHelpers`: skip any key or replace it with your own function of that name in `lib/content.ts`;
`siteJsonLd: false` (no WebSite/Organization), `pageJsonLd`, `robots`, `sitemapStyle`, `markdownAlternate: false`.
`siteJsonLd: false` (no WebSite/Organization), `pageJsonLd`, `robots`, `sitemapStyle`, `markdownAlternate: false`,
`settingsDepth`, `sitemapOptions`, `sitemapEntries`, `underConstructionSeo: false`; construction filter off in Markdown/MCP:
`markdown: { isPathVisible: () => true }`, `mcp: { isPathVisible: () => true }`.
- `createPageRoute`: `render` (your own view, e.g. an archive), `onMissing: 'redirectHome'`, `jsonLd: false`,
`homeAlias: false`, `layoutField`; a fully custom page on `resolveRoute` (pages.md).
`generateStaticParams` covers **only the pages collection, up to 1000 per language** — the scope is currently fixed (entries → ISR).
@@ -324,7 +318,7 @@ and `rel="alternate" type="text/markdown"`; `/pl/nie-ma-takiej` → 404 with con
| File | Content |
|---|---|
| `src/app/sitemap.xml/route.ts` | `export { sitemapRoute as GET } from '@/lib/content'` + `export const dynamic = 'force-dynamic'` |
| `src/app/robots.ts` | `export { robots as default } from '@/lib/content'` |
| `src/app/robots.ts` | `export { getRobots as default } from '@/lib/content'` + `force-dynamic` (AI crawler policy from Site Settings → Search & AI; `robots` = code only) |
| `src/app/manifest.ts` | `export { manifest as default } from '@/lib/content'` + `force-dynamic` |
| `src/app/api/health/route.ts` | `export { healthRoute as GET } from '@/lib/content'` + `force-dynamic` |
@@ -361,7 +355,8 @@ export function register() {
**Check.** `curl -s localhost:3000/sitemap.xml | head` → `<urlset` with `xhtml:link hreflang`; in the browser
the "XML Sitemap" style; `curl -s localhost:3000/robots.txt` → `Sitemap:`, `Disallow: /admin`, AI bots (GPTBot,
ClaudeBot…) with `Allow`; `/manifest.webmanifest` → JSON with the name from Site Settings; `/api/health` → `200`
ClaudeBot…) with `Allow` (a policy picked in Site Settings → Search & AI → AI crawlers shows up after a reload);
`curl -sI localhost:3000/sitemap.xml | grep -i cache-control` → `s-maxage=3600`; `/manifest.webmanifest` → JSON with the name from Site Settings; `/api/health` → `200`
(`503` without a database); `curl -sI localhost:3000/pl | grep -i 'x-frame-options\|content-security-policy-report-only'`;
an empty `PAYLOAD_SECRET` in `.env` → `pnpm dev` exits with a list of missing variables (restore it).
@@ -370,7 +365,18 @@ an empty `PAYLOAD_SECRET` in `.env` → `pnpm dev` exits with a list of missing
or your own text; `buildSecurityHeaders({ frameOptions, coop, hsts, additional })` — an `additional` entry with the same key
overrides the default; CSP: `buildCsp` flags (`youtube`, `googleMaps`, `extra`), after a clean console `mode: 'enforce'`;
`buildImagesConfig({ extraHosts })`; env validation is fully opt-in — filter/add rules
(`ipalEnvRules(…).filter(…)`). Staging: `IPAL_NOINDEX=1`.
(`ipalEnvRules(…).filter(…)`). Staging: `IPAL_NOINDEX=1` (also stops IndexNow). Search & AI: `robots` instead of
`getRobots` ignores the panel; `seo: { …, searchSettings: false }` removes the tab; per-bot exceptions in code:
`createContentHelpers({ robots: { aiBotRules: [{ userAgent, access }] } })`. Sitemap: `sitemapOptions: { maxUrls,
cacheControl, memoSeconds }`, `sitemapEntries: (entries) => entries` (add/remove URLs), `underConstructionSeo: false`.
**Search & AI panel step.** Nothing in code — the tab exists by default. **Postgres:** after installing or upgrading
the plugin run `pnpm payload migrate:create` (new columns `search_verification_*`, `ai_crawlers_policy`, the
`ai_crawlers_rules` table, localized `llms_intro`) → `pnpm payload migrate`; SQLite/Mongo: nothing. Search Console:
verify the **domain via DNS** (stage 11) and leave the verification fields empty; only for URL-prefix verification
paste the code into Site Settings → Search & AI (never into code). `llmsIntro` (per language): 2–4 sentences of facts
from the brief (who, what, where, since when, for whom) — it goes at the top of `/llms.txt`. Check:
`curl -s localhost:3000/llms.txt | head` (the note under the description).
## 8. GEO (mandatory)
@@ -416,15 +422,19 @@ after a choice in the banner a new record in Consent records.
`turnstileOnConfigError: 'reject'`; the Turnstile/SMTP fields in Site Integrations currently always. Form look:
`formClasses`, unusual ones → `useBuilderForm` (no copy of the engine). Banner: `settings`, `controls`, `order`,
`equalChoice`, `classNames`, tokens; no `consentLog` = no register and no endpoint (then remove `logEndpoint`).
**GA4/GTM load before consent in Consent Mode v2 with `denied`** (pixels and Clarity only after consent) — currently
always, basic mode cannot be turned on by an option; a client requiring zero requests to Google → note it in the report /
**plugin gap** (`ipal-plugin-gap`). Analytics: empty IDs in the panel or `analytics={false}`.
**Consent Mode choice** (record it in "Project decisions"): `'advanced'` (default) — the Google tag loads at once with
every signal `denied` (pixels and Clarity only after consent); `'basic'` — `<SiteProviders analytics={{ consentMode: 'basic' }}>`,
no request to `googletagmanager.com` before analytics or marketing consent (a client requiring zero requests to Google).
Check in `basic`: DevTools → Network shows no `gtm.js` / `gtag/js` before consent. Analytics: empty IDs in the panel or
`analytics={false}`. Forms: `createSubmitAction({ turnstileHostnames: ['client.pl'] })` rejects a token solved on
another domain (leave it empty in dev — Cloudflare test keys report `example.com`). The locale cookie respects consent;
after an editor bumps Cookie Settings → Policy version nothing to change (`createProxy(config, { policyVersion })` pins one).
## 10. Navigation
**Steps.** Skill **ipal-nav**: Header/Footer/Company globals (`buildLinkField`/`buildLinksField`, `resolveNav`,
legal links via `getSystemLinks(locale)`), `afterChange` with `revalidatePath('/', 'layout')` on **your own**
globals (`revalidateEverything` from stage 3), Header/Footer in the layout, optionally
legal links via `getSystemLinks(locale)`), `afterChange: [buildGlobalRevalidateHook({ revalidatePath })]` on **your own**
globals (the plugin's globals already refresh with `ipalKit({ revalidatePath })` from stage 3), Header/Footer in the layout, optionally
`<SiteProviders jsonLd={[buildNavigationJsonLd(…)]}>`.
**Check.** A menu item change in the panel is visible on `/pl` right after saving; a link to a page in EN leads to
@@ -446,7 +456,7 @@ relationTo, appearances: false, disableLabel })`, `LanguageSwitcher` (`className
**Commands (all must pass):**
```bash
pnpm generate:types && pnpm payload generate:importmap
pnpm payload migrate:create # Postgres with migrations only
pnpm payload migrate:create # Postgres with migrations only — also after every ipal-kit upgrade (new plugin fields)
bash .agents/skills/ipal-audit/scripts/audit.sh # full: §0b "missing: …" = 0, tsc, build
pnpm build && pnpm start
node .agents/skills/ipal-seo-check/scripts/seo-check.mjs http://localhost:3000 # 0 errors
@@ -505,7 +515,7 @@ prepare the list with values, a human adds them, you verify with `dig`). Full ta
From domain: SMTP from the panel → the domain of the *From address* (records from the mailbox provider); Graph → From is
always `GRAPH_SENDER` (agency domain, set once — nothing in the project). After DNS: *Send test* and in the received
email `Authentication-Results: spf=pass dkim=pass dmarc=pass`. We verify Search Console **via DNS** —
meta-tag verification fields in Site Settings (if any) stay **empty**; submit the sitemap `https://client.pl/sitemap.xml`
the verification fields in Site Settings → Search & AI stay **empty** (only URL-prefix verification uses them; the plugin then adds the `<meta>` itself); submit the sitemap `https://client.pl/sitemap.xml`
once by hand in GSC and Bing (no API). Turnstile, IndexNow, llms, MCP — no DNS.
Final report: what is wired, what is missing (data, keys, decisions), the DNS record list with values (`dig` status), every `ipal-audit-skip`, any