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:
+131
-133
@@ -1,26 +1,26 @@
|
||||
# Hooki pluginu — automatyzacja tworzenia stron
|
||||
# Plugin hooks — automating page work
|
||||
|
||||
Plugin dostarcza hooki, które zdejmują z projektów powtarzalną robotę. Wpinasz je
|
||||
w kolekcje; działają automatycznie. Wszystkie gotowe do użycia (import z pluginu).
|
||||
The plugin ships hooks that take repetitive work off projects. You wire them
|
||||
into collections; they run automatically. All are ready to use (import from the plugin).
|
||||
|
||||
Powiązane: [pages.md](./pages.md), [seo.md](./seo.md), [PROGRAMISTA.md §5](./dev/PROGRAMISTA.md).
|
||||
Related: [pages.md](./pages.md), [seo.md](./seo.md), [the developer guide (PROGRAMISTA.md) §5](./dev/PROGRAMISTA.md).
|
||||
|
||||
---
|
||||
|
||||
## buildRevalidateHook — ISR odświeżany po zapisie (NAJWAŻNIEJSZY)
|
||||
## buildRevalidateHook — ISR refreshed on save (THE MOST IMPORTANT)
|
||||
|
||||
Bez tego ISR ma haczyk: redaktor zapisuje stronę i CZEKA na revalidate (do
|
||||
godziny). Z tym — zapisuje i OD RAZU widzi zmianę. To warunek, żeby ISR był
|
||||
używalny dla CMS.
|
||||
Without it ISR has a catch: the editor saves a page and WAITS for revalidate (up to
|
||||
an hour). With it, they save and see the change AT ONCE. This is what makes ISR
|
||||
usable for a CMS.
|
||||
|
||||
```ts
|
||||
// kolekcja Pages — z pliku projektu, który MOŻE importować next/cache
|
||||
// Pages collection — from a project file that CAN import next/cache
|
||||
import { revalidatePath } from 'next/cache'
|
||||
import { buildRevalidateHook } from '@intecion/ipal-kit'
|
||||
import { i18nConfig } from '@/i18n.config'
|
||||
|
||||
const { afterChange, afterDelete } = buildRevalidateHook({
|
||||
revalidatePath, // wstrzykiwany — plugin NIE importuje next/cache
|
||||
revalidatePath, // injected — the plugin does NOT import next/cache
|
||||
config: i18nConfig,
|
||||
})
|
||||
|
||||
@@ -31,119 +31,112 @@ export const Pages: CollectionConfig = {
|
||||
}
|
||||
```
|
||||
|
||||
**Dlaczego revalidatePath wstrzykiwany:** plugin nie importuje `next/cache` (to
|
||||
by wywaliło Payload przy generate:importmap / czystym Node). Projekt podaje.
|
||||
**Why revalidatePath is injected:** the plugin does not import `next/cache` (that
|
||||
would crash Payload during generate:importmap / in plain Node). The project passes it.
|
||||
|
||||
Opcje: `revalidatePath` (wymagane), `config` (wymagane), `homeSlug` (domyślnie `'home'`,
|
||||
string albo mapa per język — slug strony głównej, żeby rewalidować root `/pl`; przy innym
|
||||
slugu strony głównej podaj go, inaczej root nie jest odświeżany).
|
||||
Options: `revalidatePath` (required), `config` (required), `homeSlug` (default `'home'`,
|
||||
a string or a per-locale map — the home page slug, so the root `/pl` is revalidated; if your
|
||||
home page has a different slug, pass it, otherwise the root is not refreshed).
|
||||
|
||||
Co robi: dla każdego języka z `config` liczy ścieżkę `buildLocalizedPath` ze sluga
|
||||
dokumentu i woła `revalidatePath`; przy zmianie slug także stary path; `afterDelete` —
|
||||
ścieżka usuniętego dokumentu.
|
||||
What it does: for each locale in `config` it builds the path with `buildLocalizedPath` from the
|
||||
document's slug and calls `revalidatePath`; when the slug changes, the old path too; `afterDelete` —
|
||||
the path of the deleted document.
|
||||
|
||||
Ograniczenia (stan kodu, `src/modules/hooks/buildRevalidateHook.ts`):
|
||||
- **Tylko kolekcje** — to hooki `afterChange`/`afterDelete` kolekcji. Globale (SiteSettings,
|
||||
menu Header/Footer, CookieSettings, Notifications) **nie są rewalidowane** przez plugin — patrz niżej.
|
||||
- Slug w hooku to zwykle string w języku zapisu, więc ten sam slug trafia do ścieżki każdego
|
||||
języka (`/pl/o-nas`, `/en/o-nas`); prawdziwy adres innego języka (`/en/about`) nie jest
|
||||
odświeżany. Zmiana pola nielokalizowanego (np. obrazka) zostaje w innych językach do
|
||||
upływu `revalidate`.
|
||||
- Brak obsługi prefiksu archiwum: wpis `posts` daje `/pl/moj-post`, nie `/pl/artykuly/moj-post`;
|
||||
strona-archiwum (listing) nie jest odświeżana po zmianie wpisu. Dla kolekcji `content`
|
||||
dopisz własny hook (`revalidatePath('/pl/artykuly', 'layout')` albo `buildEntryPath`).
|
||||
- Sitemap, llms.txt, MCP mają własny cache/`dynamic` — hook ich nie dotyka.
|
||||
Limits (code state, `src/modules/hooks/buildRevalidateHook.ts`):
|
||||
- **Collections only** — these are collection `afterChange`/`afterDelete` hooks. Globals are
|
||||
handled by `buildGlobalRevalidateHook` / `ipalKit({ revalidatePath })` — see below.
|
||||
- The slug in the hook is usually a string in the saved locale, so the same slug goes into the path
|
||||
of every locale (`/pl/o-nas`, `/en/o-nas`); the real address in another locale (`/en/about`) is not
|
||||
refreshed. A change to a non-localized field (e.g. an image) stays stale in other locales until
|
||||
`revalidate` runs out.
|
||||
- No archive prefix support: a `posts` entry gives `/pl/moj-post`, not `/pl/artykuly/moj-post`;
|
||||
the archive page (listing) is not refreshed after an entry changes. For `content` collections
|
||||
add your own hook (`revalidatePath('/pl/artykuly', 'layout')` or `buildEntryPath`).
|
||||
- Sitemap, llms.txt and MCP have their own cache/`dynamic` — the hook does not touch them.
|
||||
|
||||
### Globale — własny hook w projekcie
|
||||
**Outside the Next server** (1.11.1) the hook does nothing: `pnpm payload run`, seeding via `tsx`,
|
||||
migrations — there is no `process.env.NEXT_RUNTIME`. Before, Next threw `Invariant: static generation store missing`
|
||||
and the seed failed. Deliberate skip (bulk import in the app): `context: { disableRevalidate: true }`
|
||||
in the Local API call.
|
||||
|
||||
### Globals — buildGlobalRevalidateHook / `ipalKit({ revalidatePath })`
|
||||
|
||||
A global (Site Settings, Cookie Settings, the project's menu) feeds the layout of **every** page — logo, menu,
|
||||
consent texts, analytics IDs. Without revalidation, ISR pages kept the old values until the end of the
|
||||
`revalidate` window. Saving a global → `revalidatePath('/', 'layout')` (the whole site).
|
||||
|
||||
```ts
|
||||
// src/globals/Header.ts (albo override SiteSettings — patrz niżej)
|
||||
import { revalidatePath, revalidateTag } from 'next/cache'
|
||||
import type { GlobalAfterChangeHook } from 'payload'
|
||||
// payload.config.ts — the plugin's globals (Site Settings, Site Integrations, Cookie Settings, Notifications)
|
||||
import { revalidatePath } from 'next/cache'
|
||||
ipalKit({ …, revalidatePath })
|
||||
|
||||
export const revalidateEverything: GlobalAfterChangeHook = ({ doc, context }) => {
|
||||
if (!process.env.NEXT_RUNTIME || context?.disableRevalidate) return doc
|
||||
revalidatePath('/', 'layout') // menu/stopka są w każdym layoucie
|
||||
// albo precyzyjnie, jeśli fetchujesz z tagami: revalidateTag('header')
|
||||
return doc
|
||||
}
|
||||
|
||||
export const Header: GlobalConfig = { slug: 'header', hooks: { afterChange: [revalidateEverything] }, fields: [/* … */] }
|
||||
// the project's own global (e.g. a menu)
|
||||
import { buildGlobalRevalidateHook } from '@intecion/ipal-kit'
|
||||
hooks: { afterChange: [buildGlobalRevalidateHook({ revalidatePath })] }
|
||||
```
|
||||
|
||||
Globale budowane przez plugin (`site-settings`, `cookie-settings`, `notifications`,
|
||||
`site-integrations`) nie mają opcji hooków w `ipalKit()` — dopnij hook w payload.config po
|
||||
pluginie, np. własnym pluginem uruchomionym po `ipalKit`:
|
||||
|
||||
```ts
|
||||
plugins: [
|
||||
ipalKit({ /* … */ }),
|
||||
(config) => ({
|
||||
...config,
|
||||
globals: config.globals?.map((g) =>
|
||||
['site-settings', 'cookie-settings', 'notifications', 'site-integrations'].includes(g.slug)
|
||||
? { ...g, hooks: { ...g.hooks, afterChange: [...(g.hooks?.afterChange ?? []), revalidateEverything] } }
|
||||
: g),
|
||||
}),
|
||||
]
|
||||
```
|
||||
|
||||
**Poza serwerem Next** (1.11.1) hook nic nie robi: `pnpm payload run`, seed przez `tsx`, migracje —
|
||||
brak `process.env.NEXT_RUNTIME`. Wcześniej Next rzucał `Invariant: static generation store missing`
|
||||
i seed padał. Celowe pominięcie (masowy import w aplikacji): `context: { disableRevalidate: true }`
|
||||
w wywołaniu Local API.
|
||||
- With `revalidatePath` passed to `ipalKit()`, the plugin appends the hook itself to `afterChange` of
|
||||
`site-settings`, `site-integrations`, `cookie-settings` and `notifications`
|
||||
(`src/plugin.ts`). Without the option, the plugin's globals are not revalidated.
|
||||
- The project's own globals (Header/Footer menu etc.) need the hook wired by hand, as above.
|
||||
- Same rules as above: without `NEXT_RUNTIME` and with `context: { disableRevalidate: true }` it does nothing.
|
||||
- Need something more precise (e.g. `revalidateTag('header')`) or want to drop the plugin's hook? Use
|
||||
`globalOverrides` (see "Turn off, override, extend" below) — an object appends your hooks after the
|
||||
plugin's, a function gets the whole global and returns the one to use.
|
||||
|
||||
---
|
||||
|
||||
## setPublishedAtHook — auto-data publikacji
|
||||
## setPublishedAtHook — automatic publish date
|
||||
|
||||
Ustawia `publishedAt` na teraz przy pierwszej publikacji (jeśli puste). Redaktor
|
||||
nie wpisuje daty ręcznie; data jest dokładna dla Article JSON-LD i sitemap.
|
||||
Sets `publishedAt` to now on the first publish (if empty). The editor
|
||||
does not type the date by hand; the date is exact for Article JSON-LD and the sitemap.
|
||||
|
||||
```ts
|
||||
import { setPublishedAtHook } from '@intecion/ipal-kit'
|
||||
// kolekcja z draftami (blog, artykuły):
|
||||
// a collection with drafts (blog, articles):
|
||||
hooks: { beforeChange: [setPublishedAtHook] }
|
||||
```
|
||||
|
||||
Ustawia tylko przy przejściu na published; nie nadpisuje istniejącej daty
|
||||
(redaktor może backdatować ręcznie).
|
||||
It sets the date only on the switch to published; it does not overwrite an existing date
|
||||
(the editor can backdate by hand).
|
||||
|
||||
---
|
||||
|
||||
## buildPreventDeleteSystemPage — ochrona stron systemowych
|
||||
## buildPreventDeleteSystemPage — protecting system pages
|
||||
|
||||
Blokuje usunięcie strony przypisanej do roli (homepage, privacyPolicy,
|
||||
cookiePolicy, termsOfService). Redaktor nie usunie przypadkiem polityki
|
||||
prywatności albo strony głównej → nie rozbije routingu i linków compliance.
|
||||
Blocks deleting a page assigned to a role (homepage, privacyPolicy,
|
||||
cookiePolicy, termsOfService). The editor cannot delete the privacy policy
|
||||
or the home page by accident → routing and compliance links do not break.
|
||||
|
||||
```ts
|
||||
import { buildPreventDeleteSystemPage } from '@intecion/ipal-kit'
|
||||
hooks: { beforeDelete: [buildPreventDeleteSystemPage({ settingsSlug: 'site-settings' })] }
|
||||
```
|
||||
|
||||
Żeby usunąć — najpierw odłącz rolę w Site Settings (świadoma decyzja).
|
||||
It reads Site Settings in the same `req` (the delete transaction).
|
||||
|
||||
Opcje: `settingsSlug` (`'site-settings'`), `roleFields` (domyślnie `['homepage',
|
||||
'privacyPolicy', 'cookiePolicy', 'termsOfService']` — **bez `notFound`**; strona 404 i
|
||||
strony-archiwa `content` są usuwalne, chyba że dopiszesz je, np. `'postsArchive'`).
|
||||
Błąd odczytu SiteSettings → usunięcie przechodzi.
|
||||
To delete — first detach the role in Site Settings (a deliberate decision).
|
||||
|
||||
Options: `settingsSlug` (`'site-settings'`), `roleFields` (default `['homepage',
|
||||
'privacyPolicy', 'cookiePolicy', 'termsOfService']` — **without `notFound`**; the 404 page and
|
||||
`content` archive pages can be deleted unless you add them, e.g. `'postsArchive'`).
|
||||
An error reading SiteSettings → the delete goes through.
|
||||
|
||||
---
|
||||
|
||||
## buildValidateUniqueRole — jedna strona = jedna rola
|
||||
## buildValidateUniqueRole — one page = one role
|
||||
|
||||
Zapobiega przypisaniu tej samej strony do dwóch ról systemowych (np. homepage I
|
||||
privacyPolicy naraz → niejednoznaczny routing).
|
||||
Prevents assigning the same page to two system roles (e.g. homepage AND
|
||||
privacyPolicy at once → ambiguous routing).
|
||||
|
||||
Pola ról w SiteSettings buduje plugin i **nie dokłada do nich tego hooka** — sam z siebie
|
||||
nie działa. Dopinasz go do własnych pól ról (albo do pól pluginu przez nadpisanie globalu
|
||||
po `ipalKit`, jak w przykładzie rewalidacji wyżej). Nie dodawaj `notFound` do `siblingFields`,
|
||||
jeśli 404 ma móc być stroną główną.
|
||||
The plugin builds the role fields in SiteSettings and **does not add this hook to them** — it does
|
||||
not work on its own. Wire it into your own role fields (or into the plugin's fields through
|
||||
`globalOverrides['site-settings']` as a function that maps the fields). Do not add `notFound` to `siblingFields`
|
||||
if the 404 page should be allowed to be the home page.
|
||||
|
||||
```ts
|
||||
import { buildValidateUniqueRole } from '@intecion/ipal-kit'
|
||||
// na polu roli:
|
||||
// on a role field:
|
||||
{
|
||||
name: 'privacyPolicy',
|
||||
type: 'relationship',
|
||||
@@ -156,12 +149,12 @@ import { buildValidateUniqueRole } from '@intecion/ipal-kit'
|
||||
|
||||
---
|
||||
|
||||
## trackSlugHistoryHook — auto-redirect 308 (stały) przy zmianie slug
|
||||
## trackSlugHistoryHook — automatic 308 (permanent) redirect on slug change
|
||||
|
||||
Gdy slug się zmienia, dopisuje STARY slug do pola `slugHistory` (bez duplikatów; nazwa pola
|
||||
jest stała — `slugHistory` z podpolem `slug`). Pole musisz dodać do kolekcji sam. Projekt czyta to
|
||||
i robi stały redirect (308, dla Google jak 301) ze starego URL na nowy → zmiana adresu nie daje 404 (realna strata SEO
|
||||
z audytu).
|
||||
When the slug changes, it appends the OLD slug to the `slugHistory` field (no duplicates; the field name
|
||||
is fixed — `slugHistory` with a `slug` subfield). You must add the field to the collection yourself. The project reads it
|
||||
and does a permanent redirect (308, for Google the same as 301) from the old URL to the new one → an address change does not give a 404 (a real SEO loss
|
||||
found in the audit).
|
||||
|
||||
```ts
|
||||
import { trackSlugHistoryHook } from '@intecion/ipal-kit'
|
||||
@@ -176,8 +169,8 @@ export const Pages: CollectionConfig = {
|
||||
}
|
||||
```
|
||||
|
||||
Odczyt tej historii robi `resolveRedirect` (moduł content) — NIE pisz własnego
|
||||
lookupu. W catch-all, gdy `resolveRoute` nie znajdzie strony:
|
||||
Reading this history is done by `resolveRedirect` (content module) — do NOT write your own
|
||||
lookup. In the catch-all, when `resolveRoute` finds no page:
|
||||
|
||||
```tsx
|
||||
import { resolveRoute, resolveRedirect } from '@intecion/ipal-kit'
|
||||
@@ -189,25 +182,25 @@ if (!route) {
|
||||
payload, locale, segments: slug, config: i18nConfig, homeSlug,
|
||||
collections: [{ slug: 'pages' }],
|
||||
})
|
||||
if (dest) permanentRedirect(dest) // HTTP 308 — pod SEO równoważne 301
|
||||
if (dest) permanentRedirect(dest) // HTTP 308 — for SEO equivalent to 301
|
||||
notFound()
|
||||
}
|
||||
```
|
||||
|
||||
Plugin liczy cel, projekt woła `permanentRedirect` (plugin nie importuje
|
||||
`next/navigation`). Kolekcja bez pola `slugHistory` jest pomijana bezpiecznie
|
||||
(try/catch — ta sama klasa błędu co `_status`). Slugi wielosegmentowe
|
||||
(`uslugi/biznesowe`) działają; wpisy archiwów (`/artykuly/<wpis>`) jeszcze nie.
|
||||
Szczegóły: [content.md](./content.md).
|
||||
The plugin computes the target, the project calls `permanentRedirect` (the plugin does not import
|
||||
`next/navigation`). A collection without a `slugHistory` field is skipped safely
|
||||
(try/catch — the same class of error as `_status`). Multi-segment slugs
|
||||
(`uslugi/biznesowe`) work; archive entries (`/artykuly/<entry>`) not yet.
|
||||
Details: [content.md](./content.md).
|
||||
|
||||
---
|
||||
|
||||
## buildCrossLocaleFieldSync — pola wspólne w lokalizowanym blocks
|
||||
## buildCrossLocaleFieldSync — shared fields in localized blocks
|
||||
|
||||
Payload lokalizuje całe pole `blocks`/`array` naraz — nie da się oznaczyć
|
||||
pojedynczego podpola (obrazka) jako nielokalizowanego. Efekt: redaktor wybiera
|
||||
obrazki po polsku i musi powtórzyć wybór w każdym języku. Ten hook kopiuje
|
||||
wskazane pola (obrazki, ikony) z edytowanego locale do pozostałych.
|
||||
Payload localizes the whole `blocks`/`array` field at once — you cannot mark a
|
||||
single subfield (an image) as non-localized. Result: the editor picks
|
||||
images in Polish and must repeat the choice in every language. This hook copies
|
||||
the given fields (images, icons) from the edited locale to the others.
|
||||
|
||||
```ts
|
||||
import { buildCrossLocaleFieldSync } from '@intecion/ipal-kit'
|
||||
@@ -220,48 +213,51 @@ hooks: {
|
||||
}
|
||||
```
|
||||
|
||||
- **Lista języków z `config`** — NIGDY nie hardkoduj `['pl','en',…]` (A0:
|
||||
dodanie języka w panelu działa bez zmiany kodu).
|
||||
- **Dopasowanie wierszy po `id`**, fallback pozycyjny tylko gdy `blockType` się
|
||||
zgadza — nie wrzuci obrazka do bloku innego typu.
|
||||
- **Wiele pól:** `fields: ['image', 'backgroundImage', 'icon']`.
|
||||
- **Tylko wypełnione pola** — wyczyszczenie obrazka w jednym języku nie zeruje
|
||||
go w innych (zachowawczo).
|
||||
- Guard `_ipalSyncingCrossLocale` zrywa pętlę `afterChange`→`update`.
|
||||
- **Locale list from `config`** — NEVER hardcode `['pl','en',…]` (A0:
|
||||
adding a language in the admin panel works without a code change).
|
||||
- **Rows matched by `id`**, positional fallback only when `blockType`
|
||||
matches — it will not put an image into a block of another type.
|
||||
- **Many fields:** `fields: ['image', 'backgroundImage', 'icon']`.
|
||||
- **Filled fields only** — clearing an image in one language does not clear
|
||||
it in the others (conservative).
|
||||
- The `_ipalSyncingCrossLocale` guard breaks the `afterChange`→`update` loop.
|
||||
- **Inside the save transaction:** reading and writing the other locales go through `req` (Postgres/Mongo — a rollback
|
||||
also covers the sync); `req.locale` / `req.fallbackLocale` are restored after the hook to the values from the
|
||||
save, so the API response stays in the editor's language.
|
||||
|
||||
Parametry: `config`, `collection`, `fields` (wymagane), `arrayField` (domyślnie `'layout'`),
|
||||
`guardFlag` (domyślnie `'_ipalSyncingCrossLocale'`). Kopiowane są tylko pola najwyższego
|
||||
poziomu wiersza (bez zagnieżdżonych tablic); język bez żadnych wierszy jest pomijany.
|
||||
Błąd synchronizacji jest logowany, zapis nie pada.
|
||||
Parameters: `config`, `collection`, `fields` (required), `arrayField` (default `'layout'`),
|
||||
`guardFlag` (default `'_ipalSyncingCrossLocale'`). Only top-level fields of a row are copied
|
||||
(no nested arrays); a locale without any rows is skipped.
|
||||
A sync error is logged; the save does not fail.
|
||||
|
||||
---
|
||||
|
||||
## buildNoindexField — checkbox → meta.noindex (pole, nie hook)
|
||||
## buildNoindexField — checkbox → meta.noindex (a field, not a hook)
|
||||
|
||||
Sidebarowy checkbox `noindex` zgrany z `meta.noindex` (to czyta sitemap i
|
||||
metadata), bez `any`. To field factory — wpinasz w `fields`, nie w `hooks`:
|
||||
A sidebar `noindex` checkbox kept in sync with `meta.noindex` (which the sitemap and
|
||||
metadata read), without `any`. It is a field factory — wire it into `fields`, not `hooks`:
|
||||
|
||||
```ts
|
||||
import { buildNoindexField } from '@intecion/ipal-kit'
|
||||
fields: [ /* … */ buildNoindexField() ]
|
||||
```
|
||||
|
||||
Opcje: `name`, `label`, `description`, `metaPath` (domyślnie `'meta.noindex'`),
|
||||
`overrides`. Szczegóły: [seo.md](./seo.md).
|
||||
Options: `name`, `label`, `description`, `metaPath` (default `'meta.noindex'`),
|
||||
`overrides`. Details: [seo.md](./seo.md).
|
||||
|
||||
---
|
||||
|
||||
## KOLEJNOŚĆ hooków (ważne)
|
||||
## Hook ORDER (important)
|
||||
|
||||
W jednej kolekcji hooki tej samej fazy uruchamiają się po kolei. Typowa Media:
|
||||
In one collection, hooks of the same phase run in order. A typical Media:
|
||||
```ts
|
||||
hooks: {
|
||||
beforeOperation: [normalizeFilenameHook], // czyste nazwy
|
||||
beforeOperation: [normalizeFilenameHook], // clean file names
|
||||
afterChange: [afterChange], // revalidate
|
||||
afterDelete: [afterDelete],
|
||||
}
|
||||
```
|
||||
Typowa Pages:
|
||||
A typical Pages:
|
||||
```ts
|
||||
hooks: {
|
||||
beforeChange: [setPublishedAtHook, trackSlugHistoryHook],
|
||||
@@ -269,18 +265,20 @@ hooks: {
|
||||
afterChange: [afterChange, buildCrossLocaleFieldSync({ config, collection: 'pages', fields: ['image'] })],
|
||||
afterDelete: [afterDelete],
|
||||
}
|
||||
// pole: buildNoindexField() w `fields`
|
||||
// field: buildNoindexField() in `fields`
|
||||
```
|
||||
|
||||
Które hooki wpiąć zależy od kolekcji — nie każda potrzebuje wszystkich (blog:
|
||||
setPublishedAt; wszystkie z URL: revalidate + slugHistory; Pages: + preventDelete).
|
||||
Which hooks to wire depends on the collection — not every one needs all of them (blog:
|
||||
setPublishedAt; everything with a URL: revalidate + slugHistory; Pages: + preventDelete).
|
||||
|
||||
---
|
||||
|
||||
## Wyłączenie, nadpisanie, rozszerzenie
|
||||
## Turn off, override, extend
|
||||
|
||||
- Plugin nie wpina tych hooków sam (wyjątek: `seo` → auto-fill meta, `indexNow` → hook IndexNow) — każdy dodajesz w kolekcji projektu, więc wyłączenie = nie dodawać.
|
||||
- Rewalidację pomijasz per wywołanie: `context: { disableRevalidate: true }`.
|
||||
- Konfigurowalne: `homeSlug` (revalidate), `settingsSlug`/`roleFields` (preventDelete), `siblingFields` (unique role), `arrayField`/`guardFlag`/`fields` (cross-locale sync).
|
||||
- Stałe: nazwa pola `slugHistory` w `trackSlugHistoryHook` i `publishedAt`/`_status` w `setPublishedAtHook` — inne nazwy wymagają własnego hooka.
|
||||
- Globale i prefiksy archiwów rewalidujesz własnym hookiem (wyżej).
|
||||
- The plugin does not wire these collection hooks itself (exceptions: `seo` → meta auto-fill, `indexNow` → the IndexNow hook) — you add each one in the project's collection, so turning one off = not adding it.
|
||||
- Global revalidation: the plugin adds `buildGlobalRevalidateHook` to its own globals only when you pass `ipalKit({ revalidatePath })`; leave the option out to turn it off.
|
||||
- `globalOverrides` (`ipalKit({ globalOverrides: { 'site-settings': …, 'site-integrations': …, 'cookie-settings': …, notifications: … } })`): an object merges over the plugin's global — `access`, `admin` and `hooks` key by key (your access rules win, your hooks run after the plugin's), any other key replaces the plugin's value; a function gets the plugin's global and returns the one to use (full control, e.g. drop the plugin's revalidate hook, add `buildValidateUniqueRole` to the role fields, or use `revalidateTag`).
|
||||
- Skip revalidation per call: `context: { disableRevalidate: true }`.
|
||||
- Configurable: `homeSlug` (revalidate), `settingsSlug`/`roleFields` (preventDelete), `siblingFields` (unique role), `arrayField`/`guardFlag`/`fields` (cross-locale sync).
|
||||
- Fixed: the field name `slugHistory` in `trackSlugHistoryHook` and `publishedAt`/`_status` in `setPublishedAtHook` — other names need your own hook.
|
||||
- The project's own globals and archive prefixes: revalidate with your own hook (`buildGlobalRevalidateHook` / `revalidatePath(…, 'layout')`, above).
|
||||
|
||||
Reference in New Issue
Block a user