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
+66 -60
View File
@@ -1,17 +1,17 @@
# Rich text (Lexical) — RenderRichText
Renderowanie pól `richText` (edytor Lexical) na froncie. Plugin dostarcza
`RenderRichText` — cienki wrapper nad OFICJALNYM konwerterem Payload
(`@payloadcms/richtext-lexical/react`). To RenderBlocks rich textu: plugin
dostarcza silnik, projekt dostarcza wygląd.
Rendering `richText` fields (the Lexical editor) on the frontend. The plugin ships
`RenderRichText` — a thin wrapper over Payload's OFFICIAL converter
(`@payloadcms/richtext-lexical/react`). It is the RenderBlocks of rich text: the plugin
provides the engine, the project provides the look.
> **NIGDY nie pisz własnego renderera Lexical** (switch po `node.type`, flagi
> bitowe `node.format & 1`). To powiela to, co Payload już robi, pomija typy
> węzłów, rozjeżdża się przy aktualizacjach Lexical i kusi do
> `dangerouslySetInnerHTML` (XSS) oraz hardkodu locale (`.pl`). Użyj
> **NEVER write your own Lexical renderer** (a switch on `node.type`, bit flags
> `node.format & 1`). It duplicates what Payload already does, misses node
> types, drifts with Lexical updates and tempts you into
> `dangerouslySetInnerHTML` (XSS) and a hardcoded locale (`.pl`). Use
> RenderRichText.
## Podstawowe użycie (RSC)
## Basic use (RSC)
```tsx
import { RenderRichText } from '@intecion/ipal-kit/rsc'
@@ -19,14 +19,14 @@ import { RenderRichText } from '@intecion/ipal-kit/rsc'
<RenderRichText data={page.content} className="prose prose-slate max-w-none" />
```
Propsy: `data` (puste → `null`), `className`, `converters`, `headingIds`.
`data` to pole richText z dokumentu — JUŻ zlokalizowane (Payload zwraca wartość
bieżącego locale). Zero obsługi kluczy per język, zero hardkodu `.pl`.
Props: `data` (empty → `null`), `className`, `converters`, `headingIds`, `safeLinks` (default `true`).
`data` is the richText field from the document — ALREADY localized (Payload returns the value
for the current locale). No per-language keys, no hardcoded `.pl`.
## Własne style per węzeł (converters)
## Your own styles per node (converters)
Styl zostaje w projekcie (Tailwind), parsowanie w pluginie. Nadpisujesz JSX
konkretnych węzłów przez `converters`:
The style stays in the project (Tailwind), the parsing in the plugin. Override the JSX
of specific nodes through `converters`:
```tsx
import { RenderRichText } from '@intecion/ipal-kit/rsc'
@@ -51,20 +51,25 @@ const converters: JSXConvertersFunction = ({ defaultConverters }) => ({
<RenderRichText data={page.content} converters={converters} />
```
Spread `defaultConverters` — nadpisujesz tylko te węzły, które chcesz. Reszta
(listy, tabele, obrazy, linki) działa z oficjalnej obsługi Payload.
Spread `defaultConverters` — you override only the nodes you want. The rest
(lists, tables, images, links) works through Payload's official handling.
## Spis treści i kotwice nagłówków (1.11.1)
**Links are filtered as in `<CMSLink>` (`safeHref`).** A custom link with an address outside `http(s)`,
`mailto`, `tel`, `sms`, `#`, `/` (e.g. `javascript:`, `data:`) gets `href="#"` — also when it reached
the database through an import, a seed or the API, bypassing the panel field. Internal links (`linkType: 'internal'`)
are not touched. Turn off (fully trusted content only): `<RenderRichText data={…} safeLinks={false} />`.
Długie dokumenty (polityka prywatności, regulamin) — spis treści z linkami do sekcji.
Id nagłówków w spisie i w treści liczy ta sama funkcja, więc się nie rozjadą.
## Table of contents and heading anchors (1.11.1)
Long documents (privacy policy, terms) — a table of contents with links to sections.
Heading ids in the table and in the content are computed by the same function, so they never drift apart.
```tsx
// config bloku
// block config
import { buildTableOfContentsField } from '@intecion/ipal-kit'
fields: [buildTableOfContentsField(), { name: 'content', type: 'richText' }] // grupa tableOfContents: show, label
fields: [buildTableOfContentsField(), { name: 'content', type: 'richText' }] // group tableOfContents: show, label
// komponent bloku (RSC)
// block component (RSC)
import { extractHeadings, RenderRichText } from '@intecion/ipal-kit/rsc'
import { TableOfContents } from '@intecion/ipal-kit/client'
@@ -73,54 +78,55 @@ const items = block.tableOfContents?.show ? extractHeadings(block.content) : []
<RenderRichText data={block.content} converters={converters} headingIds={{ className: 'scroll-mt-24' }} />
```
- `extractHeadings(content, { levels: ['h2'] })` — nagłówki w kolejności z tekstu; id = `toSlug(tekst)`,
powtórzenia `-2`, `-3`, puste nagłówki pomijane. Także z roota: `import { extractHeadings, headingText } from '@intecion/ipal-kit'`.
- `RenderRichText headingIds` — `true` (h2) albo `{ levels, className }`. Twój konwerter `heading` dalej
renderuje nagłówek; plugin dokłada `id` (i `className`, np. `scroll-mt-*` pod przyklejonym nagłówkiem).
- `<TableOfContents>` — bez stylów: `<nav aria-label={label}>` + `<ol>` linków. Serwer renderuje całą listę
(działa bez JS); w przeglądarce link czytanej sekcji dostaje `aria-current="location"` i `classNames.linkActive`.
`classNames`: `nav`, `label`, `list`, `item`, `link`, `linkActive`; `offset` (domyślnie 0.3 wysokości ekranu);
`data-ipal="toc"`, `data-level` na pozycjach.
- `buildTableOfContentsField({ name = 'tableOfContents' })` — przełącznik „Show table of contents” + lokalizowana etykieta (typ `TableOfContentsSettings`).
Nowe pole w bloku = migracja (`pnpm payload migrate:create`).
- `extractHeadings(content, { levels: ['h2'] })` — headings in text order; id = `toSlug(text)`,
repeats `-2`, `-3`, empty headings skipped. Also from the root: `import { extractHeadings, headingText } from '@intecion/ipal-kit'`.
- `RenderRichText headingIds` — `true` (h2) or `{ levels, className }`. Your `heading` converter still
renders the heading; the plugin adds the `id` (and `className`, e.g. `scroll-mt-*` under a sticky header).
- `<TableOfContents>` — no styles: `<nav aria-label={label}>` + an `<ol>` of links. The server renders the whole list
(works without JS); in the browser the link of the section being read gets `aria-current="location"` and `classNames.linkActive`.
`classNames`: `nav`, `label`, `list`, `item`, `link`, `linkActive`; `offset` (default 0.3 of the screen height);
`data-ipal="toc"`, `data-level` on items.
- `buildTableOfContentsField({ name = 'tableOfContents' })` — a "Show table of contents" switch + a localized label (type `TableOfContentsSettings`).
A new field in a block = a migration (`pnpm payload migrate:create`).
## lexicalToMarkdown — richText → Markdown (dla AI)
## lexicalToMarkdown — richText → Markdown (for AI)
Do czytelności dla agentów AI (Markdown per strona, llms-full) potrzebny jest
tekst, nie JSX. `lexicalToMarkdown` konwertuje pole richText na czysty Markdown:
For readability by AI agents (Markdown per page, llms-full) you need
text, not JSX. `lexicalToMarkdown` converts a richText field to plain Markdown:
```ts
import { lexicalToMarkdown } from '@intecion/ipal-kit'
const md = lexicalToMarkdown(page.content) // '## Nagłówek\n\nAkapit **bold**…'
const md = lexicalToMarkdown(page.content) // '## Heading\n\nParagraph **bold**…'
```
Obsługuje nagłówki, akapity, bold/kursywa/kod/strikethrough, linki, listy
(zagnieżdżone), cytaty, `---`, obrazy (upload). To tekstowy brat `RenderRichText`
— ten sam wejściowy kształt, inne wyjście. **Samodzielny walker**, NIE zależy od
konkretnego eksportu MD z `@payloadcms/richtext-lexical` (te zmieniają się między
wersjami), więc bump Payloada go nie zepsuje. Nieznany węzeł degraduje się do
swojej treści, nie rzuca.
It handles headings, paragraphs, bold/italic/code/strikethrough, links, lists
(nested), quotes, `---`, images (upload). It is the text sibling of `RenderRichText`
— the same input shape, a different output. **A standalone walker**, it does NOT depend on
a specific MD export from `@payloadcms/richtext-lexical` (those change between
versions), so a Payload bump will not break it. An unknown node degrades to
its content and does not throw.
Dla całej strony (bloki, nie pojedyncze pole) użyj `blocksToMarkdown` /
`createMarkdownRenderer` — patrz [content.md](./content.md).
For a whole page (blocks, not a single field) use `blocksToMarkdown` /
`createMarkdownRenderer` — see [content.md](./content.md).
## Zależność
## Dependency
Oficjalny konwerter jest częścią `@payloadcms/richtext-lexical`, które projekt
Payload już ma (to edytor). Zero dodatkowych zależności.
The official converter is part of `@payloadcms/richtext-lexical`, which a Payload
project already has (it is the editor). No extra dependencies.
## Czego to unika (vs ręczny renderer)
## What this avoids (vs a hand-written renderer)
- **XSS** — brak `dangerouslySetInnerHTML`
- **Hardkod locale** — brak `val.alt.pl` (dane już zlokalizowane)
- **Brakujące węzły** — oficjalny konwerter obsługuje wszystkie (zagnieżdżone
listy, upload, relacje, horizontal rule…)
- **Rozjazd przy aktualizacji** — Payload utrzymuje konwerter, nie Ty
- **`any`** — typowane (SerializedEditorState)
- **XSS** — no `dangerouslySetInnerHTML`, and unsafe link URLs are neutralised
- **Hardcoded locale** — no `val.alt.pl` (the data is already localized)
- **Missing nodes** — the official converter handles all of them (nested
lists, upload, relationships, horizontal rule…)
- **Drift on updates** — Payload maintains the converter, not you
- **`any`** — typed (SerializedEditorState)
## Wyłączenie, nadpisanie, rozszerzenie
## Turn off, override, extend
- Moduł nie ma opcji w `ipalKit()` — nic nie dodaje do schematu; komponenty i funkcje używasz albo nie.
- Wygląd węzłów nadpisujesz przez `converters` (spread `defaultConverters`); id nagłówków przez `headingIds` (`levels`, `className`).
- `extractHeadings(data, { levels })` i `headingText(node)` — klocki do własnego spisu treści; `<TableOfContents>` stylujesz `classNames`, próg aktywnej sekcji — `offset`.
- `lexicalToMarkdown` nie ma opcji (obsługiwane węzły są stałe; nieznane degradują się do tekstu) — inny format wymaga własnego konwertera.
- The module has no option in `ipalKit()` — it adds nothing to the schema; you use the components and functions or you don't.
- Override the look of nodes through `converters` (spread `defaultConverters`); heading ids through `headingIds` (`levels`, `className`).
- Link filtering: on by default; `safeLinks={false}` turns it off for fully trusted content.
- `extractHeadings(data, { levels })` and `headingText(node)` — building blocks for your own table of contents; style `<TableOfContents>` with `classNames`, the active-section threshold with `offset`.
- `lexicalToMarkdown` has no options (the handled nodes are fixed; unknown ones degrade to text) — another format needs your own converter.