Merge commit '77b826e' into claude/admin-ux-wording-9e043e
This commit is contained in:
@@ -24,6 +24,7 @@ API details — one file per module:
|
||||
| GA4, GTM, Meta Pixel, Clarity, LinkedIn, TikTok, `defer` | [analytics.md](./analytics.md) |
|
||||
| Blocks, RenderBlocks, enhanceProps | [blocks.md](./blocks.md) |
|
||||
| Cookie consent, banner, settings window (in the bar / modal / large with cookie details) | [consent.md](./consent.md) |
|
||||
| Cookie scanner: review list of drafts, "Scan cookies", Open Cookie Database lookup (optional) | [cookie-scanner.md](./cookie-scanner.md) |
|
||||
| Under construction — locks subpages behind a popup (developer tool) | [construction.md](./construction.md) |
|
||||
| Routing, archives, redirects, Markdown, search | [content.md](./content.md) |
|
||||
| Site frontend: `createContentHelpers` (`@/lib/content`), `createPageRoute`, `SiteProviders` | [frontend.md](./frontend.md) |
|
||||
@@ -38,6 +39,7 @@ API details — one file per module:
|
||||
| Integrations (`site-integrations` global, statuses, test email) | [integrations.md](./integrations.md) |
|
||||
| Links / CTA: buildLinkField, buildLinksField, resolveLinkHref, rowLabel | [links.md](./links.md) |
|
||||
| Media: collection, file names, optimization, placeholders, `mediaImageProps` | [media.md](./media.md) |
|
||||
| Image lightbox: enlarge a thumbnail, galleries, rich text images | [lightbox.md](./lightbox.md) |
|
||||
| Site MCP server | [mcp.md](./mcp.md) |
|
||||
| Form messages | [notifications.md](./notifications.md) |
|
||||
| System pages, 404, generateStaticParams | [pages.md](./pages.md) |
|
||||
|
||||
+14
-1
@@ -107,7 +107,7 @@ site), **P** = a test in the panel. Full code: PROGRAMISTA.md §2.
|
||||
| 9 | **Media / R2 / speed** | `Media` with `focalPoint`, `normalizeFilenameHook`, `buildOptimizeUploadHook`, `buildMediaPlaceholderHook` + field; **always** `buildR2Storage(['media'], { s3Storage })` + `@payloadcms/storage-s3`; `R2_*` in `.env.example`; `<MediaPreconnect/>`; `images: buildImagesConfig()` and `buildUploadSecurityHeaders()` in `next.config.ts`; the project's `<Media>` via `mediaImageProps`/`videoProps` (§6.11b) | `buildR2Storage`, `mediaImageProps`, `videoProps`, `buildImagesConfig` | A, S |
|
||||
| 10 | **Forms** | every form from a **seed** (`scripts/seed-form-*.ts`: fields, confirmation, mail to the company **and** confirmation to the customer, every language); a block with `<RenderForm>` + `formClasses.ts` (look, once); `actions.ts` = `createSubmitAction({ getCachedPayload, headers })`; `forms: {…}` in `ipalKit`; `email: mailAdapter()` | `RenderForm` (`/rsc`), `createSubmitAction`, `mailAdapter` | A, P |
|
||||
| 11 | **Turnstile** | `<SiteProviders>` in `[locale]/layout.tsx` (wires `TurnstileProvider` with the key from the panel); `RenderForm` renders the widget; keys in Site Integrations | `SiteProviders`, `getTurnstileConfig`, `TurnstileProvider` | A, P |
|
||||
| 12 | Consent + analytics | Consent Mode: `'advanced'` (default — the Google tag loads at once with every signal `denied`) or `'basic'` (`<SiteProviders analytics={{ consentMode: 'basic' }}>` — no request to Google before consent; a client who wants zero requests), the choice goes to "Project decisions"; `ipalKit({ consentLog: true })` (without it the `/api/ipal/consent` endpoint does not exist) + `<SiteProviders logEndpoint="/api/ipal/consent" banner={<CookieBanner equalChoice settings="detailed" />}>` (ConsentProvider, banner, CookieButton, Analytics in the right order); settings window mode (`settings`: `inline` / `modal` / `detailed`) per the design, brief is silent → `detailed`, the decision goes to "Project decisions"; tool IDs in the panel; the cookie list from a scan (cookie-scan → import) — feeds `<CookieTable>` on the policy page **and** the lists in the `detailed` window; Cookie Settings → Detail labels in every language | consent.md, analytics.md | A, `ipal-consent-check` |
|
||||
| 12 | Consent + analytics | Consent Mode: `'advanced'` (default — the Google tag loads at once with every signal `denied`) or `'basic'` (`<SiteProviders analytics={{ consentMode: 'basic' }}>` — no request to Google before consent; a client who wants zero requests), the choice goes to "Project decisions"; `ipalKit({ consentLog: true })` (without it the `/api/ipal/consent` endpoint does not exist) + `<SiteProviders logEndpoint="/api/ipal/consent" banner={<CookieBanner equalChoice settings="detailed" />}>` (ConsentProvider, banner, CookieButton, Analytics in the right order); settings window mode (`settings`: `inline` / `modal` / `detailed`) per the design, brief is silent → `detailed`, the decision goes to "Project decisions"; tool IDs in the panel; the cookie list from a scan (`cookieScanner: true` → *Cookie review* → **Scan cookies** → the editor accepts; or cookie-scan → import) — feeds `<CookieTable>` on the policy page **and** the lists in the `detailed` window; Cookie Settings → Detail labels in every language | consent.md, analytics.md | A, `ipal-consent-check` |
|
||||
| 13 | Security | `buildSecurityHeaders` in `next.config.ts`; `twoFactor: { issuer, plugin: payloadTotp }`; CSP `report-only` → `enforce`; `IPAL_IP_HEADER` in production | security.md, forms.md | A |
|
||||
| 14 | Operations | `src/app/api/health/route.ts` (`healthRoute`); `src/instrumentation.ts` with `assertEnv(ipalEnvRules({ storage: true, ipHeader: true }))`; staging with `IPAL_NOINDEX=1`; smoke tests (§8a) | `healthRoute`, `assertEnv`, `ipalEnvRules` | A |
|
||||
| 15 | System pages | Site Settings → System Pages: homepage, 404, privacy policy, cookies; legal links in the footer by role (`getSystemLinks(locale)`) | `getSystemLinks`, `getSystemPagePath`, `getNotFoundPage` | P |
|
||||
@@ -739,6 +739,11 @@ Skill: **ipal-nav**.
|
||||
`server-only`, secrets. Types are allowed (`import type`).
|
||||
6. Plugin hooks from `@intecion/ipal-kit/client` (`useForm`, `useConsentContext`…).
|
||||
7. a11y labels (`aria-label`, "Close", "Next slide") — from the panel, via props.
|
||||
8. **An enlarged image is never a hand-made modal** (no `useState(index)` + `div role="dialog"`,
|
||||
`glightbox`, `photoswipe`, a link to the raw file in a new tab) — `<LightboxTrigger>` around the
|
||||
thumbnail (a client component you render from a server block with plain `lightboxImage(…)` data),
|
||||
one `<SiteProviders lightbox>`, labels from Notifications → Lightbox (lightbox.md). `ipal-audit`
|
||||
warns about lightbox libraries and hand-made image dialogs.
|
||||
|
||||
### 6.10 Icons
|
||||
|
||||
@@ -893,6 +898,7 @@ project → **plugin gap**, not a copy.
|
||||
|---|---|---|
|
||||
| R2, file names, optimization, preview | `buildR2Storage`, `normalizeFilenameHook`, `buildOptimizeUploadHook`, `buildMediaPlaceholderHook` | storage.md |
|
||||
| Image / video in `<Media>` | `mediaImageProps`, `videoProps`, `MEDIA_SIZES` | storage.md |
|
||||
| Enlarge an image (card, gallery, product, rich text) | `<SiteProviders lightbox>` + `<LightboxTrigger group image={lightboxImage(media, { size })}>` (`/client`), `RenderRichText lightbox`, `useLightbox`; labels: `ipalKit({ lightbox: true })` → Notifications → Lightbox | lightbox.md |
|
||||
| YouTube without cookies before a click | `<YouTubeEmbed>` (`/client`) | storage.md |
|
||||
| `next.config` | `buildImagesConfig`, `buildSecurityHeaders`, `buildCsp`, `buildUploadSecurityHeaders` | storage.md, security.md |
|
||||
| Fluid typography and spacing | `fluid.css` / `fluid-wide.css` (`--ipal-*` variables) | PROGRAMISTA §2.5 |
|
||||
@@ -904,6 +910,8 @@ project → **plugin gap**, not a copy.
|
||||
| Settings window: in the bar / small / large with cookie details | `<CookieBanner settings="inline" \| "modal" \| "detailed">` — do not build your own window or cookie list | consent.md → "Large window with details" |
|
||||
| A consent-dependent script | `ConsentScript` | consent.md |
|
||||
| Cookie table on the policy page | `<CookieTable>` (`/rsc`), `getCookieTable` | consent.md |
|
||||
| Cookie list filled from the panel (drafts the editor accepts) | `ipalKit({ cookieScanner: true })` + `pnpm generate:importmap` + migration; project cookies: `cookieScanner.declarations` / `integrations` — do not type the list by hand or build your own scanner | cookie-scanner.md |
|
||||
| Pre-consent check in a browser (button in the panel, violations, dashboard + e-mail warning) | `cookieScanner: { crawl: true }` + env `IPAL_COOKIE_SCAN_URL` / `IPAL_COOKIE_SCAN_TOKEN` (`ipalEnvRules({ cookieCrawl: true })`) + the site's `host=token` in the shared service's `IPAL_CRAWLER_SITES`; never Playwright/Chromium in the site | cookie-scanner.md → Browser crawl |
|
||||
| GA4, GTM, Pixel, Clarity, LinkedIn, TikTok | IDs in the panel — `SiteProviders` loads `Analytics` (`analytics={{ defer: true }}`; `consentMode: 'basic'` = no Google request before consent) | analytics.md |
|
||||
| Mail | `email: mailAdapter()`, `sendEmail` | email.md |
|
||||
| Env validation, health | `assertEnv(ipalEnvRules({…}))` (`/env`), `healthRoute` | env.md |
|
||||
@@ -927,6 +935,8 @@ payloadTotp } })`, never `twoFactor: false` without a client decision). CSP: fir
|
||||
| Plugin globals: write editor+ (Site Integrations: admin) | — | `ipalKit({ globalOverrides: { <slug>: { access, admin, hooks } } })`; a function `(global) => global` takes over (`applyGlobalOverrides`) |
|
||||
| Global saves revalidate the layout (with `ipalKit({ revalidatePath })`) | omit `revalidatePath`; once: `context: { disableRevalidate: true }` | `buildGlobalRevalidateHook` on your own globals |
|
||||
| Staff features without `access` (no roles field): every logged-in account passes (`userMeetsRole`) | add `access` (roles decide) | `globalOverrides`, `forms.formSubmissionOverrides`, `consentLog.collectionOverrides`, `stats.collectionOverrides` |
|
||||
| Cookie crawl (`crawl`): start editor+ or the token, results token-only for the running job, latest result only, dashboard warning on, e-mail off until recipients are set | omit `crawl`; `crawl.dashboard: false` | `crawl.serviceUrl` / `token` / `siteUrl` / `maxPages` / `acceptSelector` / `consentMode` / `trackerHosts` / `globalOverride`; *Cookie crawl → E-mail warnings to*; building blocks `ingestCrawlResult`, `findCrawlViolations`, `parseCrawlResult` |
|
||||
| Cookie review: scan + review editor+, delete admin; Open Cookie Database "Functional" → `functional` | omit `cookieScanner` | `cookieScanner.access`, `collectionOverrides`, `databaseCategories`, `integrations`, `declarations`, `labels`, `syncAccepted: false`; building blocks `runCookieScan`, `collectCookieFindings`, `applyCookieFindings` |
|
||||
| Consent records / stats visits: read and delete admin (stats view and chart follow `stats-visits` read access) | omit `consentLog` / `stats` | `consentLog.collectionOverrides`, `stats.collectionOverrides` (object merges `access`/`admin`/`hooks`, function takes over; `applyCollectionOverride`) |
|
||||
| Injected `users`: admin manages everyone, others only themselves | — | `access.authAccess` (your keys win); your own `users` collection wins whole |
|
||||
| First registered account = admin | `access.firstUserAdmin: false` | `buildRolesField(defaultRole, { firstUserAdmin })` |
|
||||
@@ -939,6 +949,7 @@ payloadTotp } })`, never `twoFactor: false` without a client decision). CSP: fir
|
||||
| Construction mode hides pages in Markdown, MCP | `markdown: { isPathVisible: () => true }`, `mcp: { isPathVisible: () => true }` | `isPathVisible`, `isPathVisibleIn(mode, path)`, `pathOf(url)`, type `PathVisibility` |
|
||||
| Construction mode filters the sitemap and llms.txt | `underConstructionSeo: false` | `include` / `getIncludedPaths` in the low-level builders |
|
||||
| `getSettings` at `depth: 1` | — | `createContentHelpers({ settingsDepth: 2 })` (every request pays) |
|
||||
| Image lightbox (off) | — (opt-in: `<SiteProviders lightbox>`, `LightboxTrigger`, `RenderRichText lightbox`, `ipalKit({ lightbox: true })` for panel labels) | `texts`, `classNames`, `unstyled`, `--ipal-lightbox-*` variables, `renderImage`, `renderDialog`, `loop`, `useLightbox`, `withLightboxUploads`, `lightboxImage` |
|
||||
| `RenderRichText` renders unsafe link URLs as `#` | `safeLinks={false}` (fully trusted content only) | your own `converters` |
|
||||
| Search & AI tab in Site Settings | `searchSettings: false` (top level, works without `seo`; `seo.searchSettings` still works) | `searchSettings: (fields) => fields`; `verificationFrom`, `robotsOptionsFrom` |
|
||||
| Verification `<meta>` from the panel | empty fields = no tag | `const { verification, ...meta } = await generatePageMetadata(…)` |
|
||||
@@ -1102,6 +1113,7 @@ Anything that needs a developer → move it to the panel.
|
||||
| GA4, GTM, Meta Pixel, Clarity, LinkedIn, TikTok | [analytics.md](../analytics.md) |
|
||||
| Blocks, RenderBlocks, enhanceProps | [blocks.md](../blocks.md) |
|
||||
| Cookie consent, banner | [consent.md](../consent.md) |
|
||||
| Cookie scanner (review list, Open Cookie Database) | [cookie-scanner.md](../cookie-scanner.md) |
|
||||
| Routing, archives, redirects, Markdown, search | [content.md](../content.md) |
|
||||
| Email SMTP / Graph | [email.md](../email.md) |
|
||||
| Env validation | [env.md](../env.md) |
|
||||
@@ -1121,6 +1133,7 @@ Anything that needs a developer → move it to the panel.
|
||||
| SEO, metadata, sitemap, JSON-LD, llms.txt | [seo.md](../seo.md) |
|
||||
| Auto-slug | [slug.md](../slug.md) |
|
||||
| Media: collection, file names, optimization, placeholders | [media.md](../media.md) |
|
||||
| Image lightbox (enlarge, galleries, rich text images) | [lightbox.md](../lightbox.md) |
|
||||
| R2, `buildImagesConfig`, YouTube | [storage.md](../storage.md) |
|
||||
| Front end: `createContentHelpers` (`@/lib/content`), `createPageRoute`, `SiteProviders` | [frontend.md](../frontend.md) |
|
||||
| Integrations (the `site-integrations` global, statuses, email test) | [integrations.md](../integrations.md) |
|
||||
|
||||
@@ -312,6 +312,8 @@ report WARNING "<form> outside the form renderer" "§0b — panel forms render v
|
||||
# Project copies of what the plugin now ships (import instead of code)
|
||||
report WARNING "own form engine" "ipal-form §3 — <RenderForm> / useBuilderForm (steps, choices, Turnstile, honeypot; Emails tab never reaches the browser)" \
|
||||
"$(g 'buildValidator|useForm\(' src --include=*.tsx | grep -v 'useBuilderForm')"
|
||||
report WARNING "own image lightbox" "lightbox.md — <LightboxTrigger> + lightboxImage, one <SiteProviders lightbox>; labels from Notifications → Lightbox" \
|
||||
"$(g "['\"](glightbox|photoswipe|yet-another-react-lightbox|react-medium-image-zoom|fslightbox-react)['\"]" src --include=*.ts --include=*.tsx)"
|
||||
report WARNING "project copy of section fields / navigation" "blocks.md, links.md — buildSectionHeaderField, buildSectionSettingsField, resolveNav (lib/content)" \
|
||||
"$(ls src/fields/sectionHeader.ts src/fields/sectionSettings.ts src/lib/navigation.ts 2>/dev/null)"
|
||||
if [ -n "$UI" ]; then
|
||||
|
||||
@@ -39,6 +39,10 @@ File patterns (Hero, FeatureGrid + FeatureCard): `resources/section-code.md`.
|
||||
`<Section settings>` → `<SectionHeader header>` → content with `<Media>`, `<CMSLink>`,
|
||||
`items.map(<Card/>)`. No text, `href`, `<img>`, hex colors or inline SVG.
|
||||
3. Subcomponents go in the same folder; shared by 2+ sections → `src/components/ui/`.
|
||||
An image the visitor can enlarge (gallery, card, product, certificate) → wrap the `<Media>` in
|
||||
`<LightboxTrigger group={`<name>-${id}`} image={lightboxImage(item.image, { size: 'hero' })}>`
|
||||
(`@intecion/ipal-kit/client`; skip the trigger when `lightboxImage` returns `null`). No
|
||||
`useState` dialog, no `glightbox` — lightbox.md.
|
||||
4. Add `config.ts` to `layout` in `src/collections/Pages.ts`,
|
||||
and the component to `src/blocks/registry.ts` (key = slug).
|
||||
5. `pnpm generate:types`.
|
||||
|
||||
@@ -41,9 +41,52 @@ before analytics or marketing consent — check the project's choice in "Project
|
||||
The script needs buttons with `data-ipal="accept"` / `"reject"` — the plugin's
|
||||
`CookieBanner` has them in every `settings` mode (`inline`, `modal`, `detailed`). A custom banner in the project violates AGENT.md §7.
|
||||
|
||||
## Cookie list from the panel (`cookieScanner`)
|
||||
|
||||
When the project has `ipalKit({ cookieScanner: true })` (cookie-scanner.md), the editor fills the
|
||||
list in the panel and you check it:
|
||||
|
||||
1. Not on yet → turn it on, `pnpm generate:importmap`, `pnpm payload migrate:create cookie-scanner`
|
||||
(Postgres), commit the migration. Embeds and widgets the plugin does not inject (YouTube, maps,
|
||||
chat): add them as `cookieScanner.declarations` (or an `integrations` entry with `isEnabled`) —
|
||||
never a hand-typed list in code.
|
||||
2. *Settings → Cookie review* → **Scan cookies**. "Integrations in use" must match the IDs in Site
|
||||
Integrations; a filled ID that is missing → **ipal-debug**.
|
||||
3. Run the browser scan below and paste every cookie it reports as unknown into **More cookie
|
||||
names**, scan again. Entries with *Found by* = "Unknown — fill in" need provider, category and
|
||||
purpose: ask the client, do not guess.
|
||||
4. The editor accepts or rejects every draft (bulk edit works). Accepted → Cookie Settings →
|
||||
Cookies, every language; existing text there is never overwritten. Open the banner's
|
||||
"Settings" and check each category lists its cookies.
|
||||
5. Database lookups come with category `functional` when the Open Cookie Database says
|
||||
"Functional" (it files some trackers there) — lower to `necessary` only when the cookie really
|
||||
is needed for the site to work.
|
||||
|
||||
## Pre-consent check from the panel (`cookieScanner.crawl`)
|
||||
|
||||
When the project has `cookieScanner: { crawl: true }` (cookie-scanner.md → Browser crawl):
|
||||
|
||||
1. Not on yet and the client wants it → turn it on; env `IPAL_COOKIE_SCAN_URL` +
|
||||
`IPAL_COOKIE_SCAN_TOKEN` (`openssl rand -hex 32`) in Coolify; ask the team to add
|
||||
`<host>=<token>` to the scanner service's `IPAL_CRAWLER_SITES`; `generate:importmap`,
|
||||
`migrate:create cookie-crawl`. Never add Playwright or Chromium to the site.
|
||||
2. *Cookie review* → **Crawl site**. "Crawl site" disabled → the box names the missing variable.
|
||||
Failed → *Settings → Cookie crawl → Error* ("Could not reach the scanner service" = URL / DNS /
|
||||
firewall; a Cloudflare challenge page = allow the Coolify server's IP).
|
||||
3. Filter the list by **Violation**: every entry is a non-necessary cookie or key stored before
|
||||
consent — fix it as in the table above (or, if it really is necessary, set its category and accept
|
||||
it). *Cookie crawl → Violations* also lists tracker **requests** before consent.
|
||||
4. Classify the new drafts (*Found by* = "Unknown — fill in"), then crawl again: 0 violations is
|
||||
the goal before handover.
|
||||
5. Optional: recipients in *Cookie crawl → E-mail warnings to*, and a weekly Coolify scheduled task
|
||||
`curl -X POST -H "Authorization: Bearer $IPAL_COOKIE_SCAN_TOKEN" $NEXT_PUBLIC_SERVER_URL/api/ipal/cookie-crawl`.
|
||||
Record both in `AGENTS.md` → "Project decisions".
|
||||
|
||||
## Cookie list for the cookie policy (cookie-scan)
|
||||
|
||||
After every change of tools (new pixel, chat, map, video) and before handing the site over:
|
||||
After every change of tools (new pixel, chat, map, video) and before handing the site over
|
||||
(with `cookieScanner` on, use step 1 below to find what really appears in the browser, then feed the
|
||||
unknown names to the panel scan above instead of step 2):
|
||||
|
||||
1. Scan the running site (without consent and after "Accept all", homepage + up to 10 pages from the sitemap):
|
||||
```bash
|
||||
|
||||
@@ -64,10 +64,18 @@ description: Complete map of everything @intecion/ipal-kit provides — every ip
|
||||
| `forms.consentFieldName` | `'consent'` | name of the GDPR consent field `submitForm` requires (read from `config.custom.ipal`) | `createSubmitAction({ consentFieldName })` / `submitForm` argument wins |
|
||||
| `consentLog` | off | `consent-records` collection + `POST /api/ipal/consent` (rate limit 20/min) | `true` / `{ retentionDays }` (default 1095) |
|
||||
| `consentLog.collectionOverrides` | none | changes `consent-records`: an object merges `access` / `admin` / `hooks` key by key (your keys win), a function `(collection) => collection` takes over (keep the slug) | e.g. `{ access: { read: ({ req }) => req.user?.email === '[email protected]' } }` — narrows who reads records in a project without roles |
|
||||
| `cookieScanner` | off | `cookie-review` collection (drafts an editor accepts → Cookie Settings → Cookies), "Scan cookies" box above its list (`CookieScanButton`), `GET`/`POST /api/ipal/cookie-scan`; a scan lists the cookies of the integrations switched on + names looked up in the bundled Open Cookie Database; never deletes, never overwrites edited text, never publishes by itself | `true` / object; after switching on: `pnpm generate:importmap` + `migrate:create`. Check: *Settings → Cookie review* → **Scan cookies** → drafts appear; set one to Accepted → it is in Cookie Settings → Cookies (cookie-scanner.md) |
|
||||
| `cookieScanner.declarations` / `.integrations` | built-ins only | the project's own cookies (`CookieDeclaration[]`), or `(defaults) => CookieIntegration[]` to add / change / drop integrations (`key`, `label`, `declarations`, `isEnabled(ctx)`) | e.g. a chat widget on when `ctx.integrations.chatId` is filled |
|
||||
| `cookieScanner.access` / `.collectionOverrides` / `.labels` | editor+ / none / `en` + `pl` | who may scan; changes `cookie-review` like `consentLog.collectionOverrides`; admin labels per language (`CookieScanLabels`) | object or function |
|
||||
| `cookieScanner.crawl` | off | browser pre-consent check through the shared scanner service (`services/cookie-crawler`, Coolify): **Crawl site** in the review box, `cookie-crawl` global (latest result only), `GET`/`POST /api/ipal/cookie-crawl`, `POST /api/ipal/cookie-crawl/results` (token), `violation` / `violationDetail` / `seenBeforeConsent` on `cookie-review`, `CookieCrawlAlert` on the dashboard, e-mail to *Cookie crawl → E-mail warnings to* | `true` / `CookieCrawlOptions`; env `IPAL_COOKIE_SCAN_URL` + `IPAL_COOKIE_SCAN_TOKEN`; `generate:importmap` + `migrate:create`. Check: the review box's **Crawl site** is enabled → click → "Last crawl …" with counts; `curl -X POST -H "Authorization: Bearer $IPAL_COOKIE_SCAN_TOKEN" $U/api/ipal/cookie-crawl` → 202 |
|
||||
| `cookieScanner.crawl.serviceUrl` / `.token` / `.siteUrl` / `.maxPages` / `.acceptSelector` | env URL / env token / `serverURL` → `NEXT_PUBLIC_SERVER_URL` / `20` / `[data-ipal="accept"]` | where the service is, the shared secret, the public origin crawled and called back, pages from the sitemap (max 100), the banner's accept button | options win over env |
|
||||
| `cookieScanner.crawl.consentMode` / `.trackerHosts` / `.dashboard` / `.globalOverride` | `'advanced'` / `DEFAULT_TRACKER_HOSTS` / `true` / none | `'basic'` also flags Google tag requests before consent; hosts counted as trackers; dashboard warning; changes the `cookie-crawl` global like `globalOverrides` | `(defaults) => [...defaults, 'chat.example']`; `dashboard: false` |
|
||||
| `cookieScanner.database` / `.databaseCategories` / `.syncAccepted` | `true` / Functional+Personalization → functional, Security+Necessary → necessary / `true` | Open Cookie Database lookup on or off; category map; accepting writes to Cookie Settings | `database: false`; `{ Functional: 'necessary' }`; `syncAccepted: false` |
|
||||
| `stats` | off | `stats-visits` collection, `POST /api/ipal/hit`, `/<admin>/stats` view, nav link, dashboard chart | `true` / object |
|
||||
| `stats.collectionOverrides` | none | changes `stats-visits` like `consentLog.collectionOverrides`; its `access.read` also decides who sees the stats view and dashboard chart | object or function |
|
||||
| `stats.retentionDays` / `timeZone` / `dashboard` | 90 / `'Europe/Warsaw'` / `true` | retention, day boundary, `StatsWidget` | `dashboard: false` hides the chart |
|
||||
| `indexNow` | `false` | `afterChange` hook (publish → IndexNow, production + https only) in the `pages.slug ?? 'pages'` collection and each one from `content` | `true` + `indexnow-key.txt` route |
|
||||
| `lightbox` | `false` | **Lightbox** group in the Notifications global (image viewer labels: open, dialog, previous, next, close, counter — localized); read by `getNotificationTexts(...).lightbox` / `getSiteShell().lightboxTexts`. Postgres: `migrate:create` | omit = English fallbacks + the `texts` prop; `lightboxNotificationFields` for your own global; `globalOverrides.notifications` |
|
||||
| `siteSettingsFields` | none | **Custom** tab in Site Settings | `Field[]` |
|
||||
| `integrationsFields` | none | **Custom** tab in Site Integrations | `Field[]` |
|
||||
| `globalOverrides` | none | changes the plugin's globals (`site-settings`, `site-integrations`, `cookie-settings`, `notifications`): an object merges `access` / `admin` / `hooks` key by key (your keys win, your hooks run after the plugin's), other keys replace; a function `(global) => global` takes over | e.g. `{ notifications: { access: { update: authenticated } } }`; the way to change the plugin globals' access or hooks |
|
||||
@@ -81,6 +89,8 @@ description: Complete map of everything @intecion/ipal-kit provides — every ip
|
||||
| auth collection (`users`) | `{ slug, auth: true, useAsTitle: 'email' }`, when the project has none (slug: `access.authCollection` → `twoFactor.collectionSlug` → `admin.user` → `'users'`); with `access`: create/delete/unlock admin only, read/update admin or self | `access.authAccess`; your own collection with that slug | yours wins |
|
||||
| `forms`, `form-submissions` | form-builder + ipal blocks `step`, `checkboxGroup`, `time` | `forms` | omit `forms` |
|
||||
| `consent-records` | proof of consent (id, choices, policy version; `consentLog.collectionOverrides`) | `consentLog` | off by default |
|
||||
| global `cookie-crawl` | latest browser crawl (status, counts, violations, third-party hosts) + e-mail recipients; read editor+, update admin | `cookieScanner.crawl` (`globalOverride`) | off by default |
|
||||
| `cookie-review` | cookie scanner drafts (`status` draft / accepted / rejected; create/read/update editor+, delete admin) | `cookieScanner` | off by default |
|
||||
| `stats-visits` | visits without IP (admin reads/deletes; `stats.collectionOverrides`) | `stats` | off by default |
|
||||
| global `site-settings` | General, Theme, [System Pages], [Emails], [Under construction], Search & AI, [Custom]; public read, write editor+ | `pages`, `content`, `forms.emailLayout`, `searchSettings` / `seo.searchSettings`, `siteSettingsFields` | always present; access/hooks/fields: `globalOverrides` |
|
||||
| global `site-integrations` | Analytics, Turnstile, SMTP, IndexNow, [Custom]; admin only | `integrationsFields` | always present; `globalOverrides` |
|
||||
@@ -90,6 +100,8 @@ description: Complete map of everything @intecion/ipal-kit provides — every ip
|
||||
| `POST /api/ipal/test-email` | SMTP/Graph test (admin only) | — | **currently always** |
|
||||
| `POST /api/ipal/consent` | saves consent | `consentLog` | off by default |
|
||||
| `POST /api/ipal/hit` | page view for stats | `stats` | off by default |
|
||||
| `GET`/`POST /api/ipal/cookie-crawl`, `POST /api/ipal/cookie-crawl/results` | crawl status / start (editor+ or bearer token) / the scanner service's callback (token, running job only) | `cookieScanner.crawl` | off by default |
|
||||
| `GET`/`POST /api/ipal/cookie-scan` | integrations a scan covers / run a scan (`{ names? }`), editor+ | `cookieScanner` (`access`) | off by default |
|
||||
| `localization` | from `i18n` | `i18n` | **currently always** |
|
||||
| `routes.admin` | from `adminRoute` | `adminRoute` | — |
|
||||
| `beforeChange` meta auto-fill hook | in `seo.collections` | `seo.autoFill` | `autoFill: false` |
|
||||
@@ -104,6 +116,8 @@ description: Complete map of everything @intecion/ipal-kit provides — every ip
|
||||
| `AdminLogo`, `AdminIcon` | `graphics.Logo/Icon` | `whiteLabel` |
|
||||
| `IntecionCredit` | `afterLogin`, `afterNavLinks` | `whiteLabel` and `credit !== false` |
|
||||
| `StatsNavLink`, `StatsView` (`views.ipalStats`, `/stats`), `StatsWidget` (`beforeDashboard`) | nav, view, dashboard | `stats` (`dashboard: false` without the widget) |
|
||||
| `CookieScanButton` | `beforeListTable` of `cookie-review` (with **Crawl site** when `crawl` is on) | `cookieScanner` |
|
||||
| `CookieCrawlAlert` | `beforeDashboard` | `cookieScanner.crawl` and `dashboard !== false` |
|
||||
| `IntegrationAlerts` | `beforeDashboard` | **currently always** (renders nothing when everything works) |
|
||||
| `IntegrationStatusBanner` | UI field in the Site Integrations tabs | always (with the global) |
|
||||
| `MaskedField` | SMTP / Turnstile secrets | always |
|
||||
@@ -142,6 +156,7 @@ Mandatory set: AGENT.md §0b, skill **ipal-setup**; checks: **ipal-audit**, **ip
|
||||
| Pages | `src/collections/Pages.ts` | `buildSlugField({ from: 'title' })`, `buildNoindexField()`, `buildSummaryField()`, `slugHistory` field + `trackSlugHistoryHook`, `buildRevalidateHook({ revalidatePath, config })` → `afterChange`/`afterDelete` | edit in the panel → the page refreshes without a deploy | slug.md, hooks.md, seo.md |
|
||||
| Pages — protection | as above | `beforeDelete: [buildPreventDeleteSystemPage({ settingsSlug: 'site-settings' })]`; `setPublishedAtHook`, `buildCrossLocaleFieldSync(...)` as needed | delete the homepage → error | hooks.md |
|
||||
| Media | `src/collections/Media.ts` | `upload: { focalPoint: true }`, `hooks.beforeOperation: [normalizeFilenameHook, buildOptimizeUploadHook(), buildMediaPlaceholderHook()]`, fields `buildOptimizeUploadField()`, `buildMediaPlaceholderField()`, `alt` | upload `Zdjęcie Ś.JPG` → `zdjecie-s.jpg`, placeholder in the document | media.md |
|
||||
| image lightbox (optional) | layout + blocks | `lightbox: true` in `ipalKit`; `<SiteProviders shell lightbox>`; `<LightboxTrigger group image={lightboxImage(media, { size: 'hero' })}>` around the thumbnail (`/client`); `<RenderRichText lightbox>` | keyboard: Tab to a thumbnail, Enter → dialog with focus on Close, ←/→, Esc → focus back; Network: a resized file on a phone | lightbox.md |
|
||||
| image on the frontend | `Media` primitive | `<Image {...mediaImageProps(media, { sizes })} />`, video `videoProps` | blur before load | media.md |
|
||||
| storage | `payload.config.ts` | `buildR2Storage(['media'], { s3Storage })` — always (without `R2_*` = local disk) | upload → URL from `R2_PUBLIC_URL` | storage.md |
|
||||
| e-mail | `payload.config.ts` | `email: mailAdapter()` (SMTP from the panel / Graph from env; also `panelSmtpAdapter`, `graphAdapter`, `sendEmail` from `/server`) | Site Integrations → SMTP → **Send test** | email.md |
|
||||
@@ -149,6 +164,8 @@ Mandatory set: AGENT.md §0b, skill **ipal-setup**; checks: **ipal-audit**, **ip
|
||||
| forms — render | form block | `<RenderForm form={form} action={sendForm} locale={locale} texts={formTexts} classNames={formClasses} />` (`/rsc`) | form from the panel, Turnstile, message from Notifications | forms.md |
|
||||
| Turnstile | panel / env | `SiteProviders` wires `TurnstileProvider`; keys in Site Integrations → Turnstile or env; server: `verifyTurnstile` (`/server`) | widget in the form; dashboard alert on a bad key | turnstile.md |
|
||||
| consent | layout + policy page | banner via `SiteProviders`; table `<CookieTable rows={…} labels={…} />` (`/rsc`) from `getCookieTable` | `ipal-consent-check`; delete the consent cookie → the banner comes back | consent.md |
|
||||
| cookie crawl | config + env + service | `cookieScanner: { crawl: true }`, `IPAL_COOKIE_SCAN_URL` / `IPAL_COOKIE_SCAN_TOKEN`, site in the service's `IPAL_CRAWLER_SITES`; optional Coolify scheduled task `curl -X POST -H "Authorization: Bearer $IPAL_COOKIE_SCAN_TOKEN" $U/api/ipal/cookie-crawl` | **Crawl site** → "Last crawl …: N pages, N violations"; *Settings → Cookie crawl* | cookie-scanner.md → Browser crawl |
|
||||
| cookie list | config | `cookieScanner: true` (+ `declarations` for embeds/chat), `generate:importmap`, `migrate:create` | *Cookie review* → **Scan cookies** → accept → Cookie Settings → Cookies; `<CookieBanner settings="detailed">` lists it | cookie-scanner.md |
|
||||
| proof of consent | config + layout | `consentLog: true` + `logEndpoint="/api/ipal/consent"` | after a click, a document in Consent Records | consent.md |
|
||||
| stats | config + layout | `stats: true` + `<SiteProviders stats={{ locale }}>` (or `<PageStats locale />` inside `ConsentProvider`) | `/<admin>/stats`; `POST /api/ipal/hit` request in Network | stats.md |
|
||||
| analytics | layout | `SiteProviders` wires `Analytics` (ID from Site Integrations → Analytics); Consent Mode: `analytics={{ consentMode: 'basic' }}` = no request to Google before consent, default `'advanced'` = the Google tag loads at once with every signal `denied` | Meta/other pixels only after consent; in `basic` no `gtm.js` / `gtag/js` in Network before consent | analytics.md, gtm-meta-pixel.md |
|
||||
@@ -198,6 +215,7 @@ and what throws without `i18n`: frontend.md. `SiteProviders` props: `shell`, `ba
|
||||
| `NEXT_PUBLIC_TURNSTILE_SITE_KEY`, `TURNSTILE_SECRET_KEY` | `turnstile: true` (names: `siteKeyVar`/`secretVar`) | fallback for keys from Site Integrations → Turnstile; neither set → Turnstile off | panel (takes precedence) or env |
|
||||
| `INDEXNOW_KEY` | no | key from Site Integrations → IndexNow (generated) | env or panel |
|
||||
| `IPAL_IP_HEADER` | `ipHeader: true` + production | rate limit trusts any IP header (spoofing) + warning in prod | env: `cf-connecting-ip` (Cloudflare) / `x-forwarded-for` (Traefik/nginx) |
|
||||
| `IPAL_COOKIE_SCAN_URL`, `IPAL_COOKIE_SCAN_TOKEN` | `cookieScanner.crawl` (`ipalEnvRules({ cookieCrawl: true })` requires both in production; token ≥ 16 chars) | **Crawl site** disabled, the box names the missing variable | env; the token also goes into the scanner service's `IPAL_CRAWLER_SITES` as `host=token` |
|
||||
| `IPAL_NOINDEX` | no; `1`/`true`/`yes` **staging/preview only** | — (when set: robots Disallow, meta noindex, `X-Robots-Tag`, IndexNow sends nothing) | staging env |
|
||||
| `NEXT_PHASE` | set by Next | only tells `next build` from runtime: during the build an unreachable database gives an empty sitemap; at runtime the sitemap throws (route → 503) | do not set by hand |
|
||||
| `NEXT_RUNTIME` | set by Next | `instrumentation.ts` checks for `nodejs`; missing (scripts, seed) → `buildRevalidateHook` does not revalidate | do not set by hand |
|
||||
|
||||
@@ -12,7 +12,7 @@ project wires: `../SKILL.md`. Module details: `node_modules/@intecion/ipal-kit/d
|
||||
|---|---|---|
|
||||
| `ipalKit(options)` | `@intecion/ipal-kit` | Payload 3 plugin (`plugins: [ipalKit({...})]`) — the only wiring point: adds globals (SiteSettings, SiteIntegrations, CookieSettings, Notifications), roles, enforced 2FA, SEO, forms, i18n (localization), white-label, stats, consent log, `/api/ipal/*` endpoints; no auth collection → injects a simple `users`. Validates `i18n` right away (fail fast). `enabled: false` = schema stays, behaviour off. |
|
||||
|
||||
**Types:** `IpalOptions` — `ipalKit()` options: `i18n`, `access`, `twoFactor` (`{ issuer, plugin: payloadTotp }` or `false`), `whiteLabel`, `adminRoute`, `consentLog`, `content`, `forms`, `pages`, `seo`, `searchSettings`, `stats`, `indexNow`, `siteSettingsFields`, `integrationsFields`, `globalOverrides`, `revalidatePath`, `enabled`. `GlobalOverride`, `GlobalOverrides`, `IpalGlobalSlug` — see Payload globals below.
|
||||
**Types:** `IpalOptions` — `ipalKit()` options: `i18n`, `access`, `twoFactor` (`{ issuer, plugin: payloadTotp }` or `false`), `whiteLabel`, `adminRoute`, `consentLog`, `content`, `cookieScanner`, `forms`, `pages`, `seo`, `searchSettings`, `stats`, `indexNow`, `siteSettingsFields`, `integrationsFields`, `globalOverrides`, `revalidatePath`, `enabled`. `GlobalOverride`, `GlobalOverrides`, `IpalGlobalSlug` — see Payload globals below.
|
||||
|
||||
## Admin (import map) (`admin`, `branding`, `admin-ui`, `globals/SiteIntegrations`) — details: `node_modules/@intecion/ipal-kit/docs/white-label.md`, `…/docs/integrations.md`, `…/docs/email.md`, `…/docs/links.md`
|
||||
|
||||
@@ -25,6 +25,8 @@ Admin panel components from `@intecion/ipal-kit/admin` — the project does NOT
|
||||
| `RowLabel` | `@intecion/ipal-kit/admin` | Array row title in the panel taken from the row content (e.g. "Fast delivery" instead of "Item 01"). Do not wire by hand — use `rowLabel()`; after adding, `pnpm generate:importmap`. |
|
||||
| `AdminLogo` | `@intecion/ipal-kit/admin` | Server Component: large panel logo (login screen) from SiteSettings `logo`, fallback `siteName`. Injected by the plugin with `whiteLabel`; after turning the option on, `pnpm generate:importmap`. |
|
||||
| `AdminIcon` | `@intecion/ipal-kit/admin` | Server Component: small panel nav icon from SiteSettings `favicon`, fallback initials. Injected by the plugin with `whiteLabel`; after turning the option on, `pnpm generate:importmap`. |
|
||||
| `CookieCrawlAlert` | `@intecion/ipal-kit/admin` | Server Component: dashboard warning after a cookie crawl with violations or new unknown cookies, or a failed crawl; renders nothing otherwise. Injected with `cookieScanner.crawl` (`dashboard: false` drops it); after turning it on, `pnpm generate:importmap`. |
|
||||
| `CookieScanButton` | `@intecion/ipal-kit/admin` | "Scan cookies" box above the *Cookie review* list: integrations in use, optional extra names, runs `POST /api/ipal/cookie-scan`. Injected by the plugin with `cookieScanner`; after turning it on, `pnpm generate:importmap`. |
|
||||
| `IntecionCredit` | `@intecion/ipal-kit/admin` | The line "Technology supported by Intecion.com" below the nav and below the login form (`variant: 'nav' \| 'login'`). Injected by the plugin with `whiteLabel`; turn off: `whiteLabel: { credit: false }`. |
|
||||
|
||||
## Readable array rows in the panel (`admin-ui`) — details: `node_modules/@intecion/ipal-kit/docs/links.md`
|
||||
@@ -128,6 +130,46 @@ Admin panel components from `@intecion/ipal-kit/admin` — the project does NOT
|
||||
|
||||
**Types:** `ConsentCategory`, `ConsentState`, `ConsentTexts`, `CookieTableRow`, `ConsentLogOptions` (root) — categories, consent state, banner texts, cookie table row, log options; `CookieBannerAction`, `CookieSettingsAction`, `CookieBannerClassNames` (`/client`) — `CookieBanner` buttons and classes; `CookieTableLabels` (`/rsc`) — `CookieTable` column headers.
|
||||
|
||||
## Cookie scanner (`consent/scanner`) — details: `node_modules/@intecion/ipal-kit/docs/cookie-scanner.md`
|
||||
|
||||
Opt-in with `ipalKit({ cookieScanner: true })`; the plugin wires the collection, endpoints and admin box. The exports are building blocks for a CLI, a scheduled job or your own admin view.
|
||||
|
||||
| Export | Import from | What it does / when |
|
||||
|---|---|---|
|
||||
| `runCookieScan({ payload, plugin, options?, names?, req? })` | `@intecion/ipal-kit` | The whole scan as `POST /api/ipal/cookie-scan` runs it → `{ enabled, summary }` (`plugin` = `{ localeCount, stats }`). |
|
||||
| `collectCookieFindings({ ctx, integrations?, declarations?, names?, database?, databaseCategories? })` | `@intecion/ipal-kit` | Findings for the project without writing: enabled integrations' cookies, project declarations, extra names looked up (declarations → built-ins → Open Cookie Database → `unknown`). |
|
||||
| `applyCookieFindings({ payload, findings, req?, collection? })` | `@intecion/ipal-kit` | Writes findings to `cookie-review` as drafts: new names created, existing ones updated only where the editor did not change the value; status untouched, nothing deleted → `CookieScanSummary`. |
|
||||
| `cookieScanContext(payload, plugin, req?)` | `@intecion/ipal-kit` | Builds the `CookieScanContext` (Site Integrations + module switches). |
|
||||
| `parseCookieNames(input)` | `@intecion/ipal-kit` | Text box / array → clean, unique names (max 200; no spaces, `;`, `,`, `=`). |
|
||||
| `mergeCookieReview(current, previous, next)` | `@intecion/ipal-kit` | Pure "never overwrite an edit" rule, per field and per locale. |
|
||||
| `suggestionFor(finding, locales)` | `@intecion/ipal-kit` | A finding's values resolved per locale (own language → English → first). |
|
||||
| `addToCookieList({ payload, entry, req? })` | `@intecion/ipal-kit` | What accepting does: adds the row to Cookie Settings → Cookies or fills only its empty text, every locale → `'added' \| 'filled' \| 'unchanged'`. |
|
||||
| `loadCookieDatabase()` / `indexCookieDatabase(rows)` / `lookupCookie(index, name, categories?)` | `@intecion/ipal-kit` | Bundled Open Cookie Database (Apache-2.0, loaded on first use): exact name, then the longest wildcard prefix → `CookieFinding \| null`. |
|
||||
| `DEFAULT_DATABASE_CATEGORIES` | `@intecion/ipal-kit` | Database → consent category map (Functional → `functional` on purpose; override with `cookieScanner.databaseCategories`). |
|
||||
| `DEFAULT_COOKIE_INTEGRATIONS` | `@intecion/ipal-kit` | Built-in declarations: consent cookie, admin login, `NEXT_LOCALE`, `ipal_vid`, GA4, GTM, Meta Pixel, Clarity, LinkedIn, TikTok, Turnstile — each with its `isEnabled` check. |
|
||||
| `cookieNameMatches(pattern, name)` | `@intecion/ipal-kit` | `*` at the end = prefix, else exact. |
|
||||
| `buildCookieReviewCollection(options)` / `buildCookieScanEndpoints(options, plugin)` | `@intecion/ipal-kit` | The collection and the GET/POST endpoints — the plugin wires them with `cookieScanner`; call only to wire by hand. |
|
||||
| `COOKIE_REVIEW_SLUG` / `COOKIE_SCAN_PATH` | `@intecion/ipal-kit` | `'cookie-review'` / `'/ipal/cookie-scan'`. |
|
||||
| `COOKIE_SCAN_LABELS` / `mergeCookieScanLabels(overrides)` | `@intecion/ipal-kit` | Admin labels (`en`, `pl`) and the merge `cookieScanner.labels` uses. |
|
||||
|
||||
**Browser crawl** (`cookieScanner.crawl`; the browser runs in the shared service `services/cookie-crawler`, never in the site):
|
||||
|
||||
| Export | Import from | What it does / when |
|
||||
|---|---|---|
|
||||
| `buildCookieCrawlGlobal(labels)` / `buildCookieCrawlEndpoints({ labels, options, plugin })` | `@intecion/ipal-kit` | The `cookie-crawl` global (latest result only) and the three crawl endpoints — the plugin wires them with `crawl`; call only to wire by hand. |
|
||||
| `resolveCrawlConfig(crawlOptions, payload)` | `@intecion/ipal-kit` | Options → env (`IPAL_COOKIE_SCAN_URL`, `IPAL_COOKIE_SCAN_TOKEN`) → `serverURL` / `NEXT_PUBLIC_SERVER_URL` → `ResolvedCrawlConfig` (null = missing). |
|
||||
| `parseCrawlResult(body)` | `@intecion/ipal-kit` | Validates the service's JSON → `CrawlResult` (`CrawlObservation`, `CrawlRequest`) or null; junk dropped. |
|
||||
| `ingestCrawlResult({ payload, result, options, config, labels, plugin, req? })` | `@intecion/ipal-kit` | Applies a result: clears the previous flags, drafts for new names (same merge rules), `seenBeforeConsent` / `violation` / `violationDetail` → `CrawlIngestSummary`. |
|
||||
| `finishCrawl({ payload, labels, result, summary?, siteUrl?, req? })` | `@intecion/ipal-kit` | Writes the `cookie-crawl` global (done / failed) and sends the e-mail warning when recipients are set. |
|
||||
| `findCrawlViolations({ observations, requests, categoryOf, consentMode?, trackerHosts? })` | `@intecion/ipal-kit` | Pure rule: stored before consent and not `necessary` (unclassified counts), tracker requests before consent → `CrawlViolation[]`. |
|
||||
| `DEFAULT_TRACKER_HOSTS` / `GOOGLE_TAG_HOSTS` | `@intecion/ipal-kit` | Request hosts that are violations before consent; Google's only with `consentMode: 'basic'`. |
|
||||
| `sendCrawlWarning({ payload, labels, siteUrl, summary, to })` | `@intecion/ipal-kit` | The warning e-mail through `payload.sendEmail` (the project's mail adapter); never throws. |
|
||||
| `bearerMatches(header, token)` | `@intecion/ipal-kit` | Constant-time `Authorization: Bearer` check. |
|
||||
| `COOKIE_CRAWL_SLUG` / `COOKIE_CRAWL_PATH` / `COOKIE_CRAWL_RESULTS_PATH` | `@intecion/ipal-kit` | `'cookie-crawl'` / `'/ipal/cookie-crawl'` / `'/ipal/cookie-crawl/results'`. |
|
||||
| `COOKIE_SCAN_URL_ENV` / `COOKIE_SCAN_TOKEN_ENV` | `@intecion/ipal-kit` | `'IPAL_COOKIE_SCAN_URL'` / `'IPAL_COOKIE_SCAN_TOKEN'`. |
|
||||
|
||||
**Types:** `CookieScannerOptions` (the option), `CookieDeclaration`, `CookieIntegration`, `CookieScanContext`, `CookieFinding`, `CookieFindingSource`, `CookieStorage`, `LocalizedText`, `CookieScanSummary`, `CookieReviewValues`, `CookieDatabaseIndex`, `CookieScanLabels`, `OpenCookieCategory`, `CookieObservation` (a name with `storage` / `domain` for `collectCookieFindings`), `CookieReviewEntryRef` (`applyCookieFindings` `entries`); crawl: `CookieCrawlOptions`, `ResolvedCrawlConfig`, `CrawlResult`, `CrawlObservation`, `CrawlRequest`, `CrawlViolation`, `CrawlIngestSummary`.
|
||||
|
||||
## Under construction (`construction`) — details: `node_modules/@intecion/ipal-kit/docs/construction.md`
|
||||
|
||||
| Export | Import from | What it does / when |
|
||||
@@ -194,11 +236,11 @@ Admin panel components from `@intecion/ipal-kit/admin` — the project does NOT
|
||||
| `createPageRoute(content, { blocks, notFound, permanentRedirect, redirect?, … })` | `@intecion/ipal-kit/rsc` | ready `[[...slug]]` catch-all page → `{ Page, generateMetadata, generateStaticParams }` (blocks, slug history redirects, JSON-LD, under-construction mode); does not paginate `?page=` |
|
||||
| `createNotFoundPage(content, { load } \| { blocks, fallback?, … })` | `@intecion/ipal-kit/rsc` | default export of `not-found.tsx` — the 404 page chosen in the panel or a fallback (the lazy `load` variant is recommended) |
|
||||
| `renderNotFoundView(content, { blocks, fallback?, blockProps?, layoutField? }, locale)` | `@intecion/ipal-kit/rsc` | 404 content in one language — called from a server action for the lazy `createNotFoundPage({ load })` (pages.md) |
|
||||
| `SiteProviders` | `@intecion/ipal-kit/rsc` | layout component: `shell={await getSiteShell(locale)}` mounts consent, cookie banner, analytics, Turnstile, site JSON-LD, theme script; does not mount `AlternateLinksProvider` |
|
||||
| `SiteProviders` | `@intecion/ipal-kit/rsc` | layout component: `shell={await getSiteShell(locale)}` mounts consent, cookie banner, analytics, Turnstile, site JSON-LD, theme script (and `lightbox` → `LightboxProvider`); does not mount `AlternateLinksProvider` |
|
||||
|
||||
Full option lists of `createContentHelpers` / `createPageRoute` / `SiteProviders` and the returned `@/lib/content` keys: `node_modules/@intecion/ipal-kit/docs/frontend.md`.
|
||||
|
||||
**Types:** `ContentHelpers` — `createContentHelpers` result; `SiteShell` — layout data from `getSiteShell` (consent, analytics, theme, jsonLd, settings, formTexts, turnstileSiteKey); `PageJsonLdOptions`, `EntryJsonLdContext` — `getPageJsonLd` options / your own JSON-LD nodes for entries (root); `PageRouteOptions`, `NotFoundPageOptions`, `NotFoundViewOptions`, `SiteProvidersProps` (`/rsc`) — options of `createPageRoute`, `createNotFoundPage`, `renderNotFoundView` and `SiteProviders` props.
|
||||
**Types:** `ContentHelpers` — `createContentHelpers` result; `SiteShell` — layout data from `getSiteShell` (consent, analytics, theme, jsonLd, settings, formTexts, lightboxTexts, turnstileSiteKey); `PageJsonLdOptions`, `EntryJsonLdContext` — `getPageJsonLd` options / your own JSON-LD nodes for entries (root); `PageRouteOptions`, `NotFoundPageOptions`, `NotFoundViewOptions`, `SiteProvidersProps` (`/rsc`) — options of `createPageRoute`, `createNotFoundPage`, `renderNotFoundView` and `SiteProviders` props.
|
||||
|
||||
## Health check (`health`) — details: `node_modules/@intecion/ipal-kit/docs/deployment.md`
|
||||
|
||||
@@ -355,6 +397,23 @@ The editor builds forms in the panel (Forms collection). The project does NOT wr
|
||||
|---|---|---|
|
||||
| `createMcpRoute({ getCachedPayload, config, baseUrl?, serverName?, … })` | `@intecion/ipal-kit` | Read-only MCP server for the site (JSON-RPC: `get_site_info`, `list_pages`, `search_content`, `get_page`) as a route handler → `{ GET, POST }` in `app/api/mcp/route.ts`; with a per-IP rate limit. Usually through `mcpGET`/`mcpPOST` from `lib/content` |
|
||||
|
||||
## Image lightbox (`lightbox`) — details: `node_modules/@intecion/ipal-kit/docs/lightbox.md`
|
||||
|
||||
| Export | Import from | What it does / when |
|
||||
|---|---|---|
|
||||
| `LightboxProvider({ texts?, classNames?, icons?, loop?, unstyled?, renderImage?, renderDialog? })` | `@intecion/ipal-kit/client` | One shared viewer for the site (or `<SiteProviders lightbox>`); renders nothing until an image is opened |
|
||||
| `LightboxTrigger({ image, group?, children, className?, style?, unstyled?, texts?, 'aria-label'? })` | `@intecion/ipal-kit/client` | `<button>` around any thumbnail that opens the large image; same `group` = one gallery in page order; works without a provider (own viewer) |
|
||||
| `useLightbox()` / `useOptionalLightbox()` | `@intecion/ipal-kit/client` | `open(images, index, returnFocus)`, `openGroup(group, start)`, `next`, `previous`, `close`, `isOpen`, `index`, `images`, `texts` — for your own controls; the optional one returns `null` outside a provider |
|
||||
| `LightboxDialog({ images, index, onClose, onIndexChange, … })` | `@intecion/ipal-kit/client` | The viewer itself, controlled (dialog role, focus trap and return, Esc, arrows, Home/End, swipe, counter, caption, scroll lock, reduced motion) |
|
||||
| `lightboxImage(media, { size?, sizes?, srcSet?, alt?, caption? })` | `@intecion/ipal-kit`, `@intecion/ipal-kit/client` | Payload media doc → `LightboxImage` (`src` from `size`, `srcSet` from every Payload size + original, alt, caption) or `null` (video, PDF, id) |
|
||||
| `withLightboxUploads(converters?, { group?, image?, triggerClassName? })` | `@intecion/ipal-kit/rsc` | Wraps rich text image uploads in `LightboxTrigger` on top of your converters (`RenderRichText lightbox` uses it) |
|
||||
| `LIGHTBOX_FALLBACK`, `resolveLightboxTexts(texts)` | `@intecion/ipal-kit`, `@intecion/ipal-kit/client` | English labels; partial texts → full set (empty → fallback) |
|
||||
| `lightboxIndex(index, delta, total, loop?)`, `formatLightboxCounter(template, current, total)` | `@intecion/ipal-kit`, `@intecion/ipal-kit/client` | Wrap / clamp a gallery index; "{current} / {total}" → "2 / 5" |
|
||||
| `prefersReducedMotion()` | `@intecion/ipal-kit/client` | OS reduced motion or the AccessibilityWidget switch (`data-a11y-motion="reduce"`) |
|
||||
| `lightboxNotificationFields` | `@intecion/ipal-kit` | The Notifications → Lightbox field group (added by `ipalKit({ lightbox: true })`) — to place in your own global |
|
||||
|
||||
**Types:** `LightboxImage`, `LightboxTexts`, `LightboxClassNames`, `LightboxRenderImage`, `LightboxImageOptions` (root and `/client`); `LightboxApi`, `LightboxProviderProps`, `LightboxTriggerProps`, `LightboxDialogProps` (`/client`); `RichTextLightboxOptions` (`/rsc`). Styling: `--ipal-lightbox-*` CSS variables, `data-ipal="lightbox…"` hooks.
|
||||
|
||||
## Media (`media`) — details: `node_modules/@intecion/ipal-kit/docs/media.md`
|
||||
|
||||
| Export | Import from | What it does / when |
|
||||
@@ -379,7 +438,7 @@ The editor builds forms in the panel (Forms collection). The project does NOT wr
|
||||
| `resolveFormMessage(result, texts)` | `@intecion/ipal-kit` | `SubmitFormResult` code → text from the panel (`{field}` filled in for `validation`, `error` without exception details); `createSubmitAction` calls it itself |
|
||||
| `NOTIFICATION_FALLBACK` | `@intecion/ipal-kit` | Constant: built-in English `form.*` texts used when a panel field is empty |
|
||||
|
||||
**Types:** `NotificationTexts`, `FormNotificationTexts` — resolved notification texts (`form` group).
|
||||
**Types:** `NotificationTexts`, `FormNotificationTexts` — resolved notification texts (`form` group; `lightbox` group = `LightboxTexts`, see Image lightbox).
|
||||
|
||||
## System pages (`pages`) — details: `node_modules/@intecion/ipal-kit/docs/pages.md`
|
||||
|
||||
@@ -410,7 +469,7 @@ The editor builds forms in the panel (Forms collection). The project does NOT wr
|
||||
|
||||
| Export | Import from | What it does / when |
|
||||
|---|---|---|
|
||||
| `RenderRichText({ data, converters?, className?, headingIds?, safeLinks? })` | `@intecion/ipal-kit/rsc` | Renders a richText (Lexical) field through Payload's official converter; your own classes via `converters`, `headingIds` adds anchors to headings (the same ids as `extractHeadings`). Unsafe link URLs (`javascript:`, `data:`…) render as `#`; `safeLinks={false}` turns that off (fully trusted content only). Instead of a hand-written renderer. |
|
||||
| `RenderRichText({ data, converters?, className?, headingIds?, lightbox?, safeLinks? })` | `@intecion/ipal-kit/rsc` | Renders a richText (Lexical) field through Payload's official converter; `lightbox` = click-to-enlarge images (lightbox.md); your own classes via `converters`, `headingIds` adds anchors to headings (the same ids as `extractHeadings`). Unsafe link URLs (`javascript:`, `data:`…) render as `#`; `safeLinks={false}` turns that off (fully trusted content only). Instead of a hand-written renderer. |
|
||||
| `extractHeadings(data, { levels? })` | `@intecion/ipal-kit`, `@intecion/ipal-kit/rsc` | List of headings `{ id, level, text }` (h2 by default) for a table of contents — ids match `RenderRichText headingIds`. |
|
||||
| `headingText(node)` | `@intecion/ipal-kit` | Plain text of a Lexical node (a heading with bold, links…). |
|
||||
| `buildTableOfContentsField({ name? })` | `@intecion/ipal-kit` | `tableOfContents` group field (show + localized label) for a text block/section — table of contents toggle in the panel. |
|
||||
|
||||
@@ -55,6 +55,11 @@ between phases. Before each phase, go through the "Anticipate" table in AGENT.md
|
||||
Order: Hero → recurring sections (FeatureGrid, CTA, FAQ…) → specific ones.
|
||||
Every block: schema from the field dictionary, composition of primitives, zero text in JSX
|
||||
(`ipal-audit --quick` after every block — fix errors right away).
|
||||
**Enlarged images** (gallery, cards, product photos, certificates, rich text): the shared lightbox,
|
||||
never a hand-made modal or a lightbox library — `ipalKit({ lightbox: true })` + migration,
|
||||
`<SiteProviders lightbox>` once, `<LightboxTrigger group={`gallery-${id}`} image={lightboxImage(media, { size })}>`
|
||||
around the thumbnail, `RenderRichText lightbox` for article images, Notifications → Lightbox labels
|
||||
in every language (lightbox.md). Check with the keyboard: Enter opens, ←/→ browse, Esc returns focus.
|
||||
|
||||
## Phase 5 — Forms → **ipal-form**
|
||||
Every form = a seed from `ipal-form/resources/seed-form.template.ts` (fields, confirmation, email to the
|
||||
|
||||
+10
-3
@@ -252,7 +252,8 @@ window width `max-w-4xl` — change it with `classNames.dialog`.
|
||||
|
||||
Which mode to choose: the project design decides. If the brief is silent → `'detailed'` (at the moment of
|
||||
consent the user sees which cookies are set and by whom — full information where the decision is made),
|
||||
provided the Cookies list is filled from a scan (`ipal-consent-check` → cookie-scan); an empty list = a
|
||||
provided the Cookies list is filled from a scan (`ipalKit({ cookieScanner: true })` → *Cookie review* → **Scan cookies**,
|
||||
[cookie-scanner.md](./cookie-scanner.md), or `ipal-consent-check` → cookie-scan); an empty list = a
|
||||
window without expandable lists, then `'modal'` is enough. Record the decision in `AGENTS.md` →
|
||||
"Project decisions".
|
||||
|
||||
@@ -342,8 +343,9 @@ independent consent state).
|
||||
choices, the policy version and the time — **no IP and no user agent**. *Consent records* collection
|
||||
(admin only), automatic cleanup after `retentionDays` (default 1095). Details below. Postgres:
|
||||
`migrate:create`.
|
||||
- **Cookie table** for the policy page: Cookie Settings → *Cookies* (filled by a scan,
|
||||
skill `ipal-consent-check` → cookie-scan) + `getCookieTable` + `<CookieTable>` from `/rsc`.
|
||||
- **Cookie table** for the policy page: Cookie Settings → *Cookies* + `getCookieTable` + `<CookieTable>` from `/rsc`.
|
||||
Fill the list from the panel with the cookie scanner (`cookieScanner` option — drafts an editor accepts,
|
||||
[cookie-scanner.md](./cookie-scanner.md)) and check the real site with `ipal-consent-check` → cookie-scan.
|
||||
- Consent cookie: `cookie-consent` (`CONSENT_COOKIE`), JSON `{ id, state, timestamp, version }`,
|
||||
`max-age` 180 days (`CONSENT_MAX_AGE`), `samesite=lax`, `Secure` on HTTPS. Consent with another
|
||||
policy version is treated as no decision.
|
||||
@@ -389,6 +391,11 @@ ipalKit({
|
||||
global (write access is `admin` + `editor` by default, hooks, admin options):
|
||||
`ipalKit({ globalOverrides: { 'cookie-settings': { access: { update } } } })` — your access rules win,
|
||||
your hooks run after the plugin's; a function gets the plugin's global and returns the one to use.
|
||||
- **Cookie list from the panel:** `ipalKit({ cookieScanner: true })` — opt-in, see
|
||||
[cookie-scanner.md](./cookie-scanner.md) (off, overrides and building blocks there).
|
||||
- **Pre-consent check in a real browser:** `cookieScanner: { crawl: true }` + the shared scanner service
|
||||
— **Crawl site** in the panel, violations (non-necessary cookies or trackers before consent), dashboard
|
||||
warning, optional e-mail ([cookie-scanner.md → Browser crawl](./cookie-scanner.md#browser-crawl)).
|
||||
- **Extend:** `cookieMap` (your own cookies to delete), `ConsentScript` (scripts without Consent
|
||||
Mode), `useConsentContext()` (your own UI: `state`, `acceptAll`, `rejectAll`, `savePreferences`,
|
||||
`reopen`, `texts`), server-safe helpers (`parseConsent`, `readConsentRecord`, `CONSENT_COOKIE`,
|
||||
|
||||
@@ -0,0 +1,399 @@
|
||||
# cookie scanner
|
||||
|
||||
Fills the cookie list (Cookie Settings → Cookies) from the admin panel. A scan lists the cookies of
|
||||
every integration the project switches on, plus any extra names, as **drafts** in a review list. An
|
||||
editor accepts, edits or rejects each one; accepting adds it to the cookie list, which feeds the
|
||||
`<CookieBanner settings="detailed">` window and `<CookieTable>` on the policy page
|
||||
([consent.md](./consent.md)).
|
||||
|
||||
What a scan never does: delete an entry, change text an editor edited, change an entry's status, or
|
||||
publish anything by itself.
|
||||
|
||||
Opt-in (`cookieScanner`, default off). Nothing is fetched at runtime and no browser is needed.
|
||||
|
||||
A second, also opt-in step — **Crawl site** (`cookieScanner.crawl`, see [Browser crawl](#browser-crawl)) —
|
||||
opens the site in a real browser twice (no consent / after "Accept all") through a shared scanner
|
||||
service, reports every non-necessary cookie or tracker present before consent as a violation, and adds
|
||||
what it finds to the same review list. The browser runs in the service, never in the site.
|
||||
|
||||
## Turn it on
|
||||
|
||||
```ts
|
||||
// payload.config.ts
|
||||
ipalKit({
|
||||
// …
|
||||
cookieScanner: true,
|
||||
})
|
||||
```
|
||||
|
||||
Then, in the project:
|
||||
|
||||
1. **Import map** — the "Scan cookies" box above the list is an admin component
|
||||
(`@intecion/ipal-kit/admin#CookieScanButton`). Run `pnpm generate:importmap`.
|
||||
2. **Postgres / SQLite migration** — the option adds the `cookie-review` collection (with localized
|
||||
`purpose` and `retention`). Run `pnpm payload migrate:create cookie-scanner`, commit the migration;
|
||||
Coolify runs `payload migrate` on deploy (deployment.md). MongoDB: nothing to do.
|
||||
3. **Verify** — log in as an editor, open *Settings → Cookie review*. The box lists "Integrations in
|
||||
use" (e.g. Cookie banner, Admin panel login, Google Analytics 4). Click **Scan cookies**: drafts
|
||||
appear, each with *Found by* = Plugin integration. Set one to *Accepted*, save, open *Cookie
|
||||
Settings → Cookies*: the cookie is there, with purpose and retention in every language.
|
||||
|
||||
## How editors use it
|
||||
|
||||
| Step | What happens |
|
||||
|---|---|
|
||||
| **Scan cookies** | One draft per cookie of the integrations in use. Cookies already in Cookie Settings → Cookies are looked up too (*In the cookie list* is ticked). |
|
||||
| **More cookie names** (optional text box) | Names seen in the browser (DevTools → Application → Cookies), one per line. Each is looked up in the project's declarations, every built-in integration, then the Open Cookie Database. A name nothing knows becomes an entry with *Found by* = "Unknown — fill in" and no category. |
|
||||
| Edit a draft | Change provider, category, purpose, retention. A later scan keeps every value you changed (per language) and still updates values you left as suggested. |
|
||||
| **Accepted** | The cookie is added to Cookie Settings → Cookies in every language. When a row with that name already exists, only its empty provider / purpose / retention are filled — text written there stays, its category is not changed. An entry without a category cannot be accepted. |
|
||||
| **Rejected** | Stays in the list as rejected; later scans do not bring it back to draft. Rejecting never removes a row from Cookie Settings — delete it there. |
|
||||
|
||||
Status changes work in the list's bulk edit too. Deleting review entries is admin-only and never done
|
||||
by the plugin.
|
||||
|
||||
Labels are in English and Polish and follow the editor's admin language; `cookieScanner.labels` adds
|
||||
languages or changes text.
|
||||
|
||||
## What the plugin declares
|
||||
|
||||
Each integration the plugin injects declares its cookies in one place
|
||||
(`DEFAULT_COOKIE_INTEGRATIONS`): name or pattern (`*` at the end = prefix), provider, category,
|
||||
purpose and retention (English and Polish), and whether it may be set before consent. Only the
|
||||
integrations switched on in this project are part of a scan:
|
||||
|
||||
| Integration | On when | Cookies |
|
||||
|---|---|---|
|
||||
| Cookie banner | always | `cookie-consent` (necessary, 6 months) |
|
||||
| Admin panel login | always | `payload-token` (`<cookiePrefix>-token`, necessary, editors only) |
|
||||
| Language choice | more than one locale in `i18n` | `NEXT_LOCALE` (functional, session) |
|
||||
| Built-in statistics | `stats` option | `ipal_vid` (analytics, 6 months) |
|
||||
| Google Analytics 4 | GA4 ID in Site Integrations | `_ga`, `_ga_*` (analytics, 2 years) |
|
||||
| Google Tag Manager | GTM ID in Site Integrations | `_gcl_*` (marketing — the Conversion Linker; other tags in the container: add their names or declare them) |
|
||||
| Meta Pixel | Pixel ID | `_fbp`, `_fbc` (marketing, 3 months) |
|
||||
| Microsoft Clarity | Clarity ID | `_clck`, `_clsk`, `CLID`, `MUID` |
|
||||
| LinkedIn Insight Tag | partner ID | `li_fat_id`, `bcookie`, `lidc`, `UserMatchHistory` |
|
||||
| TikTok Pixel | Pixel ID | `_ttp`, `_tt_enable_cookie` |
|
||||
| Cloudflare Turnstile | both Turnstile keys set | `cf_clearance` (necessary; only when pre-clearance is on in Cloudflare) |
|
||||
|
||||
An ID that fails its format check counts as off. The theme switcher (`ipal-theme` in localStorage)
|
||||
and the accessibility widget (`a11y-prefs`) have no plugin option, so they are not declared: add
|
||||
them with `declarations` when the site uses them.
|
||||
|
||||
## Open Cookie Database
|
||||
|
||||
Unknown names are looked up in a bundled copy of the
|
||||
[Open Cookie Database](https://github.com/jkwakman/Open-Cookie-Database) (about 2,300 entries,
|
||||
Apache License 2.0). The package ships the license text in
|
||||
[licenses/open-cookie-database-LICENSE.txt](./licenses/open-cookie-database-LICENSE.txt); the
|
||||
data module names the upstream commit and the changes made (converted from CSV, two columns left
|
||||
out). The table is loaded only when a scan runs.
|
||||
|
||||
Category mapping (`DEFAULT_DATABASE_CATEGORIES`):
|
||||
|
||||
| Database | Consent category |
|
||||
|---|---|
|
||||
| Analytics | analytics |
|
||||
| Marketing | marketing |
|
||||
| Necessary, Security | necessary |
|
||||
| Functional, Personalization | functional |
|
||||
|
||||
"Functional" is **not** mapped to necessary on purpose: the database files some trackers there
|
||||
(Hotjar's user id), and a lookup nobody checked yet must not skip consent. The editor lowers the
|
||||
category when a cookie really is necessary, or the project changes the map:
|
||||
`cookieScanner: { databaseCategories: { Functional: 'necessary' } }`.
|
||||
|
||||
Refresh the copy (maintainers of ipal-kit, not projects):
|
||||
|
||||
```bash
|
||||
pnpm cookie-db:refresh
|
||||
```
|
||||
|
||||
`scripts/refresh-cookie-database.mjs` downloads the CSV and the license at the latest commit (or
|
||||
`--ref <sha>`), refuses to write if the license is no longer Apache-2.0, and rewrites
|
||||
`src/modules/consent/scanner/data/openCookieDatabase.ts` and the license file. Review the diff,
|
||||
run the tests, commit.
|
||||
|
||||
## Options
|
||||
|
||||
`cookieScanner: true` or an object (`CookieScannerOptions`, every key optional):
|
||||
|
||||
| Key | Default | What it does |
|
||||
|---|---|---|
|
||||
| `declarations` | `[]` | The project's own cookies (custom embeds, chat, YouTube): `CookieDeclaration[]`, always part of a scan |
|
||||
| `integrations` | built-ins | `(defaults) => integrations` — filter, change or add `CookieIntegration`s (each: `key`, `label`, `declarations`, `isEnabled(ctx)`) |
|
||||
| `database` | `true` | `false` = no Open Cookie Database lookup |
|
||||
| `databaseCategories` | table above | Partial map from database category to consent category |
|
||||
| `access` | editor and up | `({ req }) => boolean` — who may scan, start a crawl and read its status |
|
||||
| `collectionOverrides` | — | Change `cookie-review`: an object merges `access` / `admin` / `hooks` key by key (your keys win), a function takes over (keep the slug) |
|
||||
| `labels` | `en`, `pl` | `{ de: { scanButton: 'Cookies scannen', … } }` — merged over the plugin's labels (`CookieScanLabels`) |
|
||||
| `syncAccepted` | `true` | `false` = accepting only marks the entry; nothing is written to Cookie Settings |
|
||||
| `crawl` | off | browser crawl through the scanner service — [Browser crawl](#browser-crawl) |
|
||||
|
||||
A project declaration:
|
||||
|
||||
```ts
|
||||
import type { CookieDeclaration } from '@intecion/ipal-kit'
|
||||
|
||||
const youtube: CookieDeclaration = {
|
||||
name: 'VISITOR_INFO1_LIVE',
|
||||
vendor: 'Google (YouTube)',
|
||||
category: 'marketing',
|
||||
domain: 'youtube.com',
|
||||
purpose: { en: 'YouTube: player preferences and bandwidth estimate.', pl: 'YouTube: preferencje odtwarzacza.' },
|
||||
retention: { en: '6 months', pl: '6 mies.' },
|
||||
setBeforeConsent: false,
|
||||
}
|
||||
|
||||
ipalKit({ cookieScanner: { declarations: [youtube] } })
|
||||
```
|
||||
|
||||
A project integration that is on only when a field is filled:
|
||||
|
||||
```ts
|
||||
import type { CookieIntegration } from '@intecion/ipal-kit'
|
||||
|
||||
const chat: CookieIntegration = {
|
||||
key: 'chat',
|
||||
label: 'Live chat',
|
||||
isEnabled: (ctx) => Boolean(ctx.integrations.chatWidgetId),
|
||||
declarations: [/* CookieDeclaration … */],
|
||||
}
|
||||
|
||||
ipalKit({ cookieScanner: { integrations: (defaults) => [...defaults, chat] } })
|
||||
```
|
||||
|
||||
`ctx` (`CookieScanContext`) has `payload`, `integrations` (the Site Integrations global, depth 0) and
|
||||
`plugin` (`{ localeCount, stats }`).
|
||||
|
||||
## Endpoint
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| `GET /api/ipal/cookie-scan` | `{ ok, integrations: [{ key, label }] }` — what a scan covers |
|
||||
| `POST /api/ipal/cookie-scan` | body `{ names?: string[] \| string }` (newline or comma separated, up to 200, names with spaces, `;`, `,` or `=` dropped) → `{ ok, summary: { created, updated, unchanged, unknown }, integrations }` |
|
||||
| Access | editor and up (`userMeetsRole`; without `access` every logged-in account), or `cookieScanner.access`; otherwise `403` |
|
||||
|
||||
The path is `COOKIE_SCAN_PATH` (`/ipal/cookie-scan`, under the API route).
|
||||
|
||||
## Collection `cookie-review`
|
||||
|
||||
`COOKIE_REVIEW_SLUG`, group *Settings*. Fields: `name`, `storage` (`cookie` / `localStorage` /
|
||||
`sessionStorage`), `category`, `vendor`, `domain`, `purpose` (localized), `retention` (localized),
|
||||
`setBeforeConsent`, `status` (`draft` / `accepted` / `rejected`), and read-only `source`
|
||||
(`integration` / `project` / `database` / `unknown` / `manual`), `sourceDetail`, `listed`,
|
||||
`lastScannedAt`; hidden `key` (`storage:name`, unique — what a rescan matches) and `suggested` (the
|
||||
last scan's values — a value still equal to it was not edited). Access: create / read / update
|
||||
editor and up, delete admin.
|
||||
|
||||
## Building blocks
|
||||
|
||||
All from `@intecion/ipal-kit` (server-safe), for your own admin view, a CLI or a scheduled job:
|
||||
|
||||
| Export | What it does |
|
||||
|---|---|
|
||||
| `runCookieScan({ payload, plugin, options?, names?, req? })` | the whole scan as the endpoint runs it → `{ enabled, summary }` |
|
||||
| `collectCookieFindings({ ctx, integrations?, declarations?, names?, database?, databaseCategories? })` | findings without writing anything; `names` are strings or `CookieObservation`s (`{ name, storage?, domain? }`); `matches` maps each to its review key |
|
||||
| `applyCookieFindings({ payload, findings, entries?, req?, collection? })` | writes findings as drafts with the merge rules above → `CookieScanSummary` (`created`, `updated`, `unchanged`, `unknown`, `newUnknown`); `entries` collects `CookieReviewEntryRef`s |
|
||||
| `cookieScanContext(payload, plugin, req?)` | the `CookieScanContext` a scan uses |
|
||||
| `parseCookieNames(input)` | the panel's text box → clean names |
|
||||
| `mergeCookieReview(current, previous, next)`, `suggestionFor(finding, locales)` | the "never overwrite an edit" rule, pure |
|
||||
| `addToCookieList({ payload, entry, req? })` | what accepting does: add the row or fill its empty text → `'added' \| 'filled' \| 'unchanged'` |
|
||||
| `loadCookieDatabase()`, `indexCookieDatabase(rows)`, `lookupCookie(index, name, categories?)` | the Open Cookie Database lookup |
|
||||
| `DEFAULT_COOKIE_INTEGRATIONS`, `DEFAULT_DATABASE_CATEGORIES`, `cookieNameMatches(pattern, name)` | declarations and matching |
|
||||
| `buildCookieReviewCollection(options)`, `buildCookieScanEndpoints(options, plugin)` | the collection and endpoints, to wire by hand |
|
||||
| `COOKIE_SCAN_LABELS`, `mergeCookieScanLabels(overrides)` | admin labels |
|
||||
| `CookieScanButton` (`/admin`) | the box above the list (with **Crawl site** when `crawl` is on) |
|
||||
| `CookieCrawlAlert` (`/admin`) | the dashboard warning (injected with `crawl`) |
|
||||
| `buildCookieCrawlGlobal(labels)`, `buildCookieCrawlEndpoints({ labels, options, plugin })` | the crawl's global and endpoints, to wire by hand |
|
||||
| `resolveCrawlConfig(crawlOptions, payload)` | options + env + `serverURL` → `ResolvedCrawlConfig` (what is missing) |
|
||||
| `parseCrawlResult(body)` | validates the service's JSON (`CrawlResult`, `CrawlObservation`, `CrawlRequest`) |
|
||||
| `ingestCrawlResult({ payload, result, options, config, labels, plugin })`, `finishCrawl(…)` | applies a result: drafts, flags (→ `CrawlIngestSummary`), then the global and the e-mail |
|
||||
| `findCrawlViolations({ observations, requests, categoryOf, consentMode?, trackerHosts? })` | the violation rule, pure (`CrawlViolation`) |
|
||||
| `DEFAULT_TRACKER_HOSTS`, `GOOGLE_TAG_HOSTS` | request hosts that count before consent |
|
||||
| `sendCrawlWarning({ payload, labels, siteUrl, summary, to })` | the e-mail, through `payload.sendEmail` |
|
||||
| `bearerMatches(header, token)` | constant-time bearer check |
|
||||
|
||||
Types: `CookieDeclaration`, `CookieIntegration`, `CookieScanContext`, `CookieFinding`,
|
||||
`CookieFindingSource`, `CookieStorage`, `LocalizedText`, `CookieScannerOptions`, `CookieScanSummary`,
|
||||
`CookieReviewValues`, `CookieDatabaseIndex`, `CookieScanLabels`, `OpenCookieCategory`,
|
||||
`CookieObservation`, `CookieReviewEntryRef`; crawl: `CookieCrawlOptions`, `ResolvedCrawlConfig`,
|
||||
`CrawlResult`, `CrawlObservation`, `CrawlRequest`, `CrawlViolation`, `CrawlIngestSummary`.
|
||||
|
||||
## Browser crawl
|
||||
|
||||
What a page really sets — a GTM tag, an iframe, a script pasted into a block — shows only in a
|
||||
browser. `cookieScanner.crawl` adds **Crawl site** to the *Cookie review* box. One shared **scanner
|
||||
service** (`services/cookie-crawler` in the ipal-kit repository, run by the team on Coolify) does the
|
||||
browsing for every site:
|
||||
|
||||
```
|
||||
editor ── Crawl site ──▶ site POST /api/ipal/cookie-crawl
|
||||
site ── POST {IPAL_COOKIE_SCAN_URL}/crawl (Bearer token) ──▶ scanner service
|
||||
crawls the sitemap pages twice:
|
||||
1. fresh profile, no decision
|
||||
2. fresh profile, clicks "Accept all"
|
||||
site POST /api/ipal/cookie-crawl/results (Bearer token) ◀── cookies, storage keys, third-party hosts
|
||||
→ drafts in Cookie review, violations, Cookie crawl global, dashboard warning, e-mail
|
||||
```
|
||||
|
||||
### Turn it on in a site
|
||||
|
||||
```ts
|
||||
ipalKit({
|
||||
cookieScanner: { crawl: true },
|
||||
})
|
||||
```
|
||||
|
||||
1. **Env** (Coolify → the site → Environment Variables):
|
||||
|
||||
| Variable | Value |
|
||||
|---|---|
|
||||
| `IPAL_COOKIE_SCAN_URL` | the service's URL, e.g. `https://cookie-crawler.intecion.net` |
|
||||
| `IPAL_COOKIE_SCAN_TOKEN` | a random token of at least 16 characters (`openssl rand -hex 32`), the same one as in the service's `IPAL_CRAWLER_SITES` entry for this site |
|
||||
| `NEXT_PUBLIC_SERVER_URL` | already set — the public origin the service crawls and calls back (or Payload `serverURL`, or `crawl.siteUrl`) |
|
||||
|
||||
Validate them at startup: `assertEnv(ipalEnvRules({ cookieCrawl: true }))` (required in production).
|
||||
2. **Import map:** `pnpm generate:importmap` (the dashboard warning `CookieCrawlAlert`).
|
||||
3. **Migration (Postgres / SQLite):** `crawl` adds the `cookie-crawl` global and three fields to
|
||||
`cookie-review` (`violation`, `violationDetail`, `seenBeforeConsent`):
|
||||
`pnpm payload migrate:create cookie-crawl`, commit; Coolify runs `payload migrate` on deploy.
|
||||
4. **Service:** add the site to the service's `IPAL_CRAWLER_SITES` (below) and redeploy the service.
|
||||
5. **Verify:** *Cookie review* shows "Crawl site" enabled (when disabled, the box names the missing env
|
||||
var). Click it: the status says "Crawling…", then after one to a few minutes "Last crawl …: N pages,
|
||||
N violations, N new unknown" and the list reloads. *Settings → Cookie crawl* shows the latest
|
||||
result. A test: put a `<script>document.cookie='_fbp=x'</script>` in a block on a staging page →
|
||||
the next crawl reports `_fbp` as a violation and the dashboard shows the warning.
|
||||
|
||||
### What a crawl records and reports
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| Pages | the site URL + up to `maxPages` (default 20, max 100) same-origin URLs from `/sitemap.xml` (one level of sitemap index) |
|
||||
| Recorded per run | cookies (name, domain), `localStorage` and `sessionStorage` keys, hosts of third-party requests, with the first pages they appeared on |
|
||||
| New findings | every cookie / key goes through the same lookup and merge rules as **Scan cookies** — new names become **drafts**, edited text is kept, status is never changed, nothing is deleted |
|
||||
| Violation (cookie or key) | seen **before consent** and its review entry's category is not `necessary` — an entry without a category counts too, until an editor classifies it |
|
||||
| Violation (request) | a request **before consent** to a tracker host (`DEFAULT_TRACKER_HOSTS`: Meta, LinkedIn, TikTok, Clarity, Bing, Hotjar, YouTube). Google's tag hosts (`GOOGLE_TAG_HOSTS`) count only with `consentMode: 'basic'` — in `advanced` (the plugin's default) the Google tag may load before consent with every signal denied |
|
||||
| Review entries | `seenBeforeConsent`, `violation` and `violationDetail` ("before consent on /, /about") — from the **latest crawl only**: every crawl clears the previous flags |
|
||||
| Cookie crawl global | latest result only (no history): status, started / finished, by whom, pages, counts, violations, third-party hosts, error |
|
||||
| "Accept all" not found | the second run had no consent — the global's error says so (`crawl.acceptSelector` for a custom banner) |
|
||||
| Dashboard | a warning above the dashboard after a crawl with violations or new unknown cookies, or a failed crawl (`crawl.dashboard: false` turns it off) |
|
||||
| E-mail | opt-in per site: *Settings → Cookie crawl → E-mail warnings to* (admin; comma-separated). Sent after a crawl with violations or new unknown cookies, through the project's Payload email adapter (`email: mailAdapter()`, email.md). Empty = no e-mail |
|
||||
|
||||
A crawl still "running" after 30 minutes counts as failed (the service never reported back), and a new
|
||||
one may start. One crawl per site at a time (`409` otherwise).
|
||||
|
||||
### Scheduled crawls
|
||||
|
||||
A Coolify **Scheduled Task** on the site's application (or any cron) starts a crawl with the token —
|
||||
no editor session needed:
|
||||
|
||||
```bash
|
||||
curl -fsS -X POST -H "Authorization: Bearer $IPAL_COOKIE_SCAN_TOKEN" "$NEXT_PUBLIC_SERVER_URL/api/ipal/cookie-crawl"
|
||||
```
|
||||
|
||||
Weekly is plenty (`0 6 * * 1`). New violations or unknown cookies then show on the dashboard and, when
|
||||
recipients are set, by e-mail.
|
||||
|
||||
### `crawl` options
|
||||
|
||||
`crawl: true` or `CookieCrawlOptions`:
|
||||
|
||||
| Key | Default | What it does |
|
||||
|---|---|---|
|
||||
| `serviceUrl` | env `IPAL_COOKIE_SCAN_URL` | scanner service base URL |
|
||||
| `token` | env `IPAL_COOKIE_SCAN_TOKEN` | shared secret (≥ 16 characters); shorter = not configured |
|
||||
| `siteUrl` | Payload `serverURL`, else `NEXT_PUBLIC_SERVER_URL` | public origin to crawl; the callback goes to `<siteUrl>/api/ipal/cookie-crawl/results` |
|
||||
| `maxPages` | `20` (max 100) | sitemap pages besides the site URL |
|
||||
| `acceptSelector` | `[data-ipal="accept"]` | the banner's "Accept all" button (the plugin's `CookieBanner` has it in every mode) |
|
||||
| `consentMode` | `'advanced'` | `'basic'` = Google tag requests before consent are violations too — match the project's `SiteProviders analytics={{ consentMode }}` |
|
||||
| `trackerHosts` | `DEFAULT_TRACKER_HOSTS` | `(defaults) => [...defaults, 'widget.chat.example']` |
|
||||
| `dashboard` | `true` | `false` = no dashboard warning |
|
||||
| `globalOverride` | — | change the `cookie-crawl` global like `globalOverrides` (object merges `access` / `admin` / `hooks`, a function takes over) |
|
||||
|
||||
Access: start a crawl and read its status — editor and up (`cookieScanner.access`), or the bearer
|
||||
token; the results endpoint — the bearer token only, and only for the running job id; the
|
||||
`cookie-crawl` global — read editor and up, update (the e-mail field) admin.
|
||||
|
||||
### Endpoints
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| `GET /api/ipal/cookie-crawl` | `{ configured, missing, status, startedAt, finishedAt, summary, error }` |
|
||||
| `POST /api/ipal/cookie-crawl` | starts a crawl → `202`; `403`, `409` (one is running), `503` (not configured), `502` (service unreachable — the global says why) |
|
||||
| `POST /api/ipal/cookie-crawl/results` | the service's callback: `Authorization: Bearer <token>`, body = the wire format (`CrawlResult`) → `200`; `401`, `400`, `409` (not the running job) |
|
||||
|
||||
Paths: `COOKIE_CRAWL_PATH`, `COOKIE_CRAWL_RESULTS_PATH`; env names: `COOKIE_SCAN_URL_ENV`,
|
||||
`COOKIE_SCAN_TOKEN_ENV`; global slug `COOKIE_CRAWL_SLUG`.
|
||||
|
||||
### Scanner service on Coolify
|
||||
|
||||
One service for every site the team runs. Code: `services/cookie-crawler/` in the ipal-kit repository
|
||||
(Node + Playwright, no other dependency; not part of the npm package).
|
||||
|
||||
1. **Coolify → Project → New Resource → Application** from the ipal-kit Git repository.
|
||||
- Build pack: **Dockerfile**; base directory `services/cookie-crawler`; Dockerfile `Dockerfile`.
|
||||
- Port: `3000`. Health check path: `/health` (the image also has a Docker `HEALTHCHECK`).
|
||||
- Domain: e.g. `https://cookie-crawler.intecion.net` (Coolify issues the certificate).
|
||||
- Resources: 1–2 GB RAM, 1 CPU per concurrent crawl (Chromium). Keep `CRAWLER_CONCURRENCY=1`
|
||||
unless the server has room.
|
||||
2. **Environment variables:**
|
||||
|
||||
| Variable | Default | |
|
||||
|---|---|---|
|
||||
| `IPAL_CRAWLER_SITES` | — (required) | `acme.pl=TOKEN1,shop.example.com=TOKEN2` — the sites it may crawl, each with its own token (≥ 16 characters; `www.` is ignored). A token only opens its own site |
|
||||
| `PORT` | `3000` | |
|
||||
| `CRAWLER_CONCURRENCY` | `1` | crawls at the same time |
|
||||
| `CRAWLER_QUEUE_MAX` | `20` | waiting crawls; more → `429` |
|
||||
| `CRAWLER_JOB_TIMEOUT_MS` | `600000` | a longer crawl is reported as failed |
|
||||
| `CRAWLER_WAIT_MS` | `3000` | wait on every page for late tags (`defer` analytics) |
|
||||
| `CRAWLER_ALLOW_HTTP` | unset | `1` only for local tests; sites must be https |
|
||||
|
||||
3. **Deploy**, then check: `curl https://cookie-crawler.intecion.net/health` → `{"ok":true,…}`.
|
||||
4. **Adding a site:** generate a token, add `host=token` to `IPAL_CRAWLER_SITES`, redeploy the service;
|
||||
set the same token as the site's `IPAL_COOKIE_SCAN_TOKEN`.
|
||||
5. **Updating Playwright:** the npm version in `services/cookie-crawler/package.json` and the image tag
|
||||
in its `Dockerfile` (`mcr.microsoft.com/playwright:v1.64.0-noble`) must match; change both, redeploy.
|
||||
|
||||
What the service refuses: a site not in `IPAL_CRAWLER_SITES`, a token that is not that site's, a
|
||||
callback URL on another origin than the site, plain http. It crawls only the listed origins (no
|
||||
open proxy), runs Chromium as the image's non-root user, and keeps nothing after a crawl.
|
||||
|
||||
**DNS and network:**
|
||||
|
||||
- One DNS record for the service: `cookie-crawler.<team domain>` → `A`/`AAAA` to the Coolify server
|
||||
(the team runs the zone; add it with the other records, deployment.md §6). No record is needed per
|
||||
site.
|
||||
- The **site** must reach the service URL (outbound HTTPS from the site container), and the **service**
|
||||
must reach each site's public URL (outbound HTTPS) — the crawl must go through the public domain,
|
||||
CDN and proxy, as a visitor's browser does. On the same Coolify server both go out and back through
|
||||
the public domain; do not point `siteUrl` at an internal container name (cookies are set for the
|
||||
public domain).
|
||||
- Sites behind Cloudflare (WAF, Bot Fight Mode, "Under Attack"): allow the Coolify server's IP, or the
|
||||
crawl sees a challenge page instead of the site. Every crawler request carries the header
|
||||
`X-Ipal-Cookie-Crawler: 1` for a WAF rule.
|
||||
- The crawler's page views land in the site's stats and analytics like any visitor without consent
|
||||
(cookieless) and with consent on the second run. Filter the Coolify server's IP in GA4 if it matters.
|
||||
|
||||
### From a laptop or CI
|
||||
|
||||
The same crawl, without the service: `cd services/cookie-crawler && npm install && npx playwright
|
||||
install chromium`, then `node cli.mjs https://acme.pl --pages 10` prints the result as JSON (exit code
|
||||
1 when anything but the consent cookie is stored before consent). It does not know the site's
|
||||
categories — the panel's **Crawl site** gives the verdict. `ipal-consent-check` → cookie-scan
|
||||
(`cookie-scan.mjs`) stays the quick check for projects without the service; paste the names it reports
|
||||
as unknown into **More cookie names**.
|
||||
|
||||
## Turn off, override, extend
|
||||
|
||||
- **Turn off the crawl only:** omit `crawl` (default) — no `cookie-crawl` global, no crawl endpoints, no
|
||||
dashboard warning, no violation fields; `dashboard: false` keeps the crawl without the warning.
|
||||
- **Turn off:** omit `cookieScanner` (default). Turning it off later keeps no endpoint and no
|
||||
collection; Cookie Settings → Cookies keeps every row (it is still edited by hand or by the skill's
|
||||
import script).
|
||||
- **Override:** `collectionOverrides` (access, admin, hooks), `access` (who scans), `labels`,
|
||||
`databaseCategories`, `integrations` (change or drop a built-in), `syncAccepted: false`; for the
|
||||
crawl `serviceUrl`, `token`, `siteUrl`, `maxPages`, `acceptSelector`, `consentMode`, `trackerHosts`,
|
||||
`globalOverride`.
|
||||
- **Extend:** `declarations` and `integrations` for the project's own cookies; the building blocks
|
||||
above for your own UI, CLI or scheduled scan; the crawl's wire format (`CrawlResult`) to feed results
|
||||
from another crawler.
|
||||
@@ -74,6 +74,7 @@ URLs point at that domain. Outside production, `R2_PUBLIC_URL` alone → read-on
|
||||
| `IPAL_IP_HEADER` | ⬜ (✅ prod) | forms | header with the real IP for the rate limit (`cf-connecting-ip`, `x-forwarded-for`); without it, a warning in the log |
|
||||
| `NEXT_PUBLIC_TURNSTILE_SITE_KEY`, `TURNSTILE_SECRET_KEY` | ⬜ | forms | fallback when the Turnstile keys are not in Site Integrations |
|
||||
| `INDEXNOW_KEY` | ⬜ | SEO | IndexNow key (takes precedence over the key from the panel) |
|
||||
| `IPAL_COOKIE_SCAN_URL`, `IPAL_COOKIE_SCAN_TOKEN` | ⬜ (✅ prod with `ipalEnvRules({ cookieCrawl: true })`) | consent | cookie crawl (`cookieScanner.crawl`): the shared scanner service's URL and this site's token ([cookie-scanner.md](./cookie-scanner.md#browser-crawl)) |
|
||||
| `IPAL_NOINDEX` | ⬜ | SEO | `1`/`true`/`yes` **on staging only** — the whole site is noindex (robots, meta, `X-Robots-Tag`) |
|
||||
|
||||
"✅ prod" = required by `ipalEnvRules({ storage: true })` / `({ ipHeader: true })` with
|
||||
@@ -446,6 +447,8 @@ be attached. Options, in order of preference:
|
||||
3. A reverse proxy/cache on the Coolify server (`media.klient.pl` → the bucket) — possible, more moving parts.
|
||||
4. `*.r2.dev` — rate-limited, **dev/testing only**, never production.
|
||||
|
||||
**Cookie crawler (once per team, not per site):** `cookie-crawler.<team domain>` → `A`/`AAAA` to the Coolify server running the scanner service ([cookie-scanner.md](./cookie-scanner.md#scanner-service-on-coolify)). A site using `cookieScanner.crawl` needs no record of its own.
|
||||
|
||||
**No DNS records needed:** Turnstile (hostname list set in the Cloudflare panel on the widget, not in
|
||||
DNS), IndexNow (key file served by the app), llms.txt, MCP, Markdown, sitemap.
|
||||
|
||||
|
||||
@@ -645,6 +645,7 @@ Do one item at a time, build, check. Order by importance:
|
||||
| 45 | **1.11.1** — format description in a form field label / time as text | the **Placeholder** field in the admin panel, the **Time** type; Postgres: `migrate:create` | forms.md |
|
||||
| 46 | **1.12.3** — own cookie settings window / cookie list in the banner written in the project | `<CookieBanner settings="detailed">` (list from Cookie Settings → Cookies, captions: Detail labels); delete your own version; Postgres: `migrate:create` | consent.md |
|
||||
| 47 | **1.13.0** — staff access, Search & AI, seed scripts, workarounds around plugin globals | without `access`: every logged-in account gets the staff features → `access` or `globalOverrides` / `formOverrides` / `formSubmissionOverrides` / `collectionOverrides`; with `access`: staff need `editor`/`admin`; Postgres: `migrate:create`; check `settingsDepth`, `sitemap()` throwing, 2FA slug, client IP; own seed code → `@intecion/ipal-kit/seed`; global hooks/access plugins → `revalidatePath` / `globalOverrides` | CHANGELOG 1.13.0, AGENT.md §7.1, seo.md, seeding.md |
|
||||
| 48 | **image lightbox** (release after 1.13.0) — own image modal (`useState(index)` + `div role="dialog"`), `glightbox` / other lightbox library, thumbnails linking to the raw file in a new tab | `ipalKit({ lightbox: true })` + Postgres `migrate:create`; `<SiteProviders lightbox>`; `<LightboxTrigger group image={lightboxImage(media, { size })}>` around the thumbnail; delete the old dialog and `pnpm remove glightbox`; old label fields → Notifications → Lightbox | lightbox.md → "Replacing a hand-made modal" |
|
||||
|
||||
After updating the package: `pnpm ipal:skills` (new skill versions), `pnpm payload generate:importmap`, `rm -rf .next`, restart dev, grep for the new symbol in
|
||||
`node_modules/@intecion/ipal-kit/dist`.
|
||||
|
||||
@@ -61,6 +61,7 @@ use).
|
||||
ipalEnvRules({
|
||||
storage?: boolean | { requirePublicUrl?: boolean }, // R2_* (R2_BUCKET, R2_ACCESS_KEY_ID, R2_SECRET_ACCESS_KEY, R2_ENDPOINT; R2_PUBLIC_URL optional)
|
||||
emailGraph?: boolean, // GRAPH_* (GRAPH_TENANT_ID, GRAPH_CLIENT_ID, GRAPH_CLIENT_SECRET, GRAPH_SENDER — e-mail)
|
||||
cookieCrawl?: boolean, // IPAL_COOKIE_SCAN_URL (url), IPAL_COOKIE_SCAN_TOKEN (≥ 16 chars) — required in production; cookieScanner.crawl (cookie-scanner.md)
|
||||
ipHeader?: boolean, // IPAL_IP_HEADER — required in production, optional outside it (header name [a-z0-9-])
|
||||
turnstile?: boolean | { siteKeyVar?: string; secretVar?: string }, // NEXT_PUBLIC_TURNSTILE_SITE_KEY, TURNSTILE_SECRET_KEY
|
||||
serverUrlVar?: string, // default 'NEXT_PUBLIC_SERVER_URL'
|
||||
|
||||
+3
-1
@@ -145,7 +145,7 @@ import { getSiteShell } from '@/lib/content'
|
||||
```
|
||||
|
||||
Renders: `<ThemeScript>` (when `theme`), `<MediaPreconnect>`, `<JsonLdGraph>` (site JSON-LD + `jsonLd`),
|
||||
`<ConsentProvider>` with `<TurnstileProvider>`, `<CookieBanner>`, `<CookieButton>`, `<Analytics>`, `<PageStats>`.
|
||||
`<ConsentProvider>` with `<TurnstileProvider>` (and `<LightboxProvider>` when `lightbox`), `<CookieBanner>`, `<CookieButton>`, `<Analytics>`, `<PageStats>`.
|
||||
It does not mount `AlternateLinksProvider` (i18n.md) — add it yourself if you use `LanguageSwitcher`.
|
||||
|
||||
| Prop | Default | What it does |
|
||||
@@ -157,6 +157,7 @@ It does not mount `AlternateLinksProvider` (i18n.md) — add it yourself if you
|
||||
| `analytics` | on | extra `<Analytics>` props or `false` = no tags |
|
||||
| `cookieMap` | — | extra cookies per category to clean up after consent is withdrawn |
|
||||
| `jsonLd` | `[]` | extra JSON-LD nodes |
|
||||
| `lightbox` | off | `true` / `{ texts, classNames, icons, loop, unstyled }` → one `<LightboxProvider>` for the site; texts from `shell.lightboxTexts` (Notifications → Lightbox) — lightbox.md |
|
||||
| `preconnect` | `true` | `<link rel=preconnect>` to the media origin |
|
||||
| `stats` | off | `true`/props → `<PageStats>` (stats.md) |
|
||||
| `theme` | `false` | `<ThemeScript>` before the first paint (theme.md) |
|
||||
@@ -168,6 +169,7 @@ It does not mount `AlternateLinksProvider` (i18n.md) — add it yourself if you
|
||||
- Any key from `createContentHelpers` can be left out of the destructuring or replaced with your own function
|
||||
of the same name in `src/lib/content.ts` (e.g. your own `generateStaticParams` with entries).
|
||||
- `createPageRoute`: your own view through `render`, your own 404/redirect through `onMissing`, extra block props through `blockProps`, JSON-LD through `jsonLd`.
|
||||
- `SiteProviders`: `lightbox` is off by default; for `renderImage` / `renderDialog` (functions) mount `<LightboxProvider>` yourself in a client component instead (lightbox.md).
|
||||
- `SiteProviders`: `banner`, `cookieButton`, `analytics` accept your own element or `false`; `analytics={{ consentMode: 'basic' }}` = no request to Google before consent (default `'advanced'`: the tag loads with every signal `denied`).
|
||||
- Search & AI from the panel: `robots` instead of `getRobots` ignores it; your own robots: `buildRobots({ ...robotsOptionsFrom(settings), … })`; drop the verification tags: `const { verification, ...meta } = await generatePageMetadata(…)`.
|
||||
- Construction filter in Markdown / MCP: `markdown: { isPathVisible: () => true }`, `mcp: { isPathVisible: () => true }`; in the sitemap and llms.txt: `underConstructionSeo: false`.
|
||||
|
||||
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -0,0 +1,215 @@
|
||||
# Image lightbox
|
||||
|
||||
One shared viewer for images that appear small — a card, a gallery grid, a product thumbnail, an
|
||||
image inside rich text. The visitor clicks the thumbnail and sees the large version; images in the
|
||||
same group browse with arrows, keys and swipe. Optional: nothing renders and nothing is added to the
|
||||
schema until you use it.
|
||||
|
||||
- `<LightboxProvider>` (`/client`) — one per layout; owns the viewer.
|
||||
- `<LightboxTrigger>` (`/client`) — a `<button>` around any thumbnail (`next/image`, `<img>`, your
|
||||
`<Media>`). Works without a provider too (brings its own viewer).
|
||||
- `lightboxImage(media, options)` (main entry and `/client`) — a Payload media doc → the large image,
|
||||
with a `srcSet` from every Payload image size.
|
||||
- `RenderRichText lightbox` (`/rsc`) — click-to-enlarge for images in rich text.
|
||||
- `useLightbox()` (`/client`) — open, close, next, previous for your own controls.
|
||||
- `<LightboxDialog>` (`/client`) — the viewer itself, controlled, for full control.
|
||||
|
||||
## What the visitor gets
|
||||
|
||||
- A full-screen dialog over the page (portal to `<body>`): `role="dialog"`, `aria-modal`, a name from
|
||||
the texts, the caption linked with `aria-describedby`.
|
||||
- Focus moves to Close, Tab and Shift+Tab stay inside the dialog, focus returns to the trigger on close.
|
||||
- Esc closes, ← / → browse, Home / End jump to the first / last image; a click outside the image closes.
|
||||
- Swipe left / right on touch screens (40 px threshold; vertical scrolling and pinch-zoom still work).
|
||||
- Visible controls (44 px targets, the browser's focus ring kept), a live "2 / 5" counter, an
|
||||
optional caption.
|
||||
- The page does not scroll behind the dialog (scrollbar gap compensated).
|
||||
- No animation when the visitor asked for reduced motion — the OS setting or the plugin's
|
||||
AccessibilityWidget (`data-a11y-motion="reduce"`).
|
||||
- The neighbouring images preload, so the next arrow press is instant.
|
||||
- The browser picks the right file from `srcSet` (a phone does not download the 4K original).
|
||||
|
||||
## Setup
|
||||
|
||||
### 1. One provider for the site
|
||||
|
||||
```tsx
|
||||
// app/(frontend)/[locale]/layout.tsx — Server Component
|
||||
import { getNotificationTexts } from '@intecion/ipal-kit'
|
||||
import { SiteProviders } from '@intecion/ipal-kit/rsc'
|
||||
|
||||
const payload = await getCachedPayload()
|
||||
const { lightbox } = await getNotificationTexts({ payload, locale })
|
||||
<SiteProviders shell={shell} lightbox={{ texts: lightbox }}>…</SiteProviders>
|
||||
```
|
||||
|
||||
Without `SiteProviders`, mount it yourself: `<LightboxProvider texts={lightbox}>` from `/client`.
|
||||
The provider renders nothing until an image is opened.
|
||||
|
||||
### 2. Labels in every language (the plugin's i18n)
|
||||
|
||||
```ts
|
||||
// payload.config.ts
|
||||
ipalKit({ …, lightbox: true })
|
||||
```
|
||||
|
||||
Adds the **Lightbox** group to **Settings → Notifications**: trigger name ("Enlarge image"), dialog
|
||||
name ("Image viewer"), Previous, Next, Close and the counter (`{current} / {total}`) — localized per
|
||||
language. `getNotificationTexts(...).lightbox` reads them; an empty field falls back to English
|
||||
(`LIGHTBOX_FALLBACK`). On Postgres this adds columns: run `pnpm payload migrate:create` and commit the
|
||||
migration (Coolify runs `migrate` on deploy). Fill the labels in every language, or seed them.
|
||||
|
||||
Without `lightbox: true` the components still work: they use the `texts` you pass and English for the
|
||||
rest. The field group is exported (`lightboxNotificationFields`) if you prefer it in your own global.
|
||||
|
||||
### 3. Wrap thumbnails
|
||||
|
||||
```tsx
|
||||
import { lightboxImage, LightboxTrigger } from '@intecion/ipal-kit/client'
|
||||
import { MEDIA_SIZES, mediaImageProps } from '@intecion/ipal-kit'
|
||||
import Image from 'next/image'
|
||||
|
||||
// a gallery block — every image in one group, browsed in page order
|
||||
{images.map(({ id, image }) => {
|
||||
const thumb = mediaImageProps(image, { sizes: MEDIA_SIZES.third })
|
||||
const large = lightboxImage(image, { size: 'hero' })
|
||||
if (!thumb || !large) return null
|
||||
return (
|
||||
<LightboxTrigger key={id} group={`gallery-${blockId}`} image={large} className="group block overflow-hidden rounded-lg">
|
||||
<Image {...thumb} className="transition group-hover:scale-105" />
|
||||
</LightboxTrigger>
|
||||
)
|
||||
})}
|
||||
```
|
||||
|
||||
- `group` — triggers with the same group form one gallery, in page order (whatever order they
|
||||
mounted in). One group per block (`gallery-${id}`) keeps two galleries apart. No group = that image
|
||||
alone.
|
||||
- `image` — plain data (`{ src, srcSet?, sizes?, width?, height?, alt, caption? }`), so a Server
|
||||
Component can render the trigger. `lightboxImage` builds it from a Payload doc; any other source works.
|
||||
- `children` — the thumbnail, rendered as you like. With `next/image` `fill`, give the trigger a size
|
||||
(`className="relative aspect-[4/3]"`).
|
||||
- The button's accessible name is `texts.open + ": " + alt` ("Enlarge image: Red sofa"); pass
|
||||
`aria-label` to change it.
|
||||
|
||||
### 4. Rich text images (opt-in)
|
||||
|
||||
```tsx
|
||||
<RenderRichText data={post.content} lightbox />
|
||||
<RenderRichText data={post.content} lightbox={{ group: 'post', image: { size: 'hero' }, triggerClassName: 'my-8' }} />
|
||||
```
|
||||
|
||||
Every image upload becomes a trigger; PDFs and videos are left alone. Your own `upload` converter
|
||||
still renders the inline image — the plugin only wraps what it returns. Default group: `'richtext'`
|
||||
(every rich text on the page is one gallery); `group: false` opens each image alone. A caption or alt
|
||||
from the upload node's fields wins over the document's. For your own renderer:
|
||||
`converters={withLightboxUploads(myConverters, options)}` (`/rsc`).
|
||||
|
||||
### 5. Your own controls
|
||||
|
||||
```tsx
|
||||
'use client'
|
||||
import { useLightbox } from '@intecion/ipal-kit/client'
|
||||
|
||||
const box = useLightbox()
|
||||
<button onClick={(e) => box.open(images, 0, e.currentTarget)}>{labels.viewAll}</button>
|
||||
// box.openGroup('gallery-1', 2) · box.next() · box.previous() · box.close() · box.isOpen · box.index
|
||||
```
|
||||
|
||||
A product page with a stage image: the stage can be the trigger, and the thumbnail strip keeps
|
||||
choosing the stage image — `box.open(productImages, activeIndex, e.currentTarget)`.
|
||||
|
||||
## Media sizes
|
||||
|
||||
`lightboxImage(media, { size?, sizes?, srcSet?, alt?, caption? })`:
|
||||
|
||||
| option | default | effect |
|
||||
|---|---|---|
|
||||
| `size` | original file | the Payload image size used as `src` (fallback when the browser ignores `srcSet`), e.g. `'hero'` |
|
||||
| `srcSet` | `true` | every generated size + the original as `url 768w, …`; `false` = `src` only |
|
||||
| `sizes` | `'100vw'` | `sizes` of the large image |
|
||||
| `alt` | the doc's `alt` | override |
|
||||
| `caption` | the doc's `caption` when it is a string | override; `false` = none |
|
||||
|
||||
Returns `null` for a video, PDF or unpopulated id — render the thumbnail without a trigger.
|
||||
A collection without `imageSizes` still works: the original file is the large image. For a phone-
|
||||
friendly viewer add at least one large size (e.g. `hero` 1920 wide) to the Media collection.
|
||||
|
||||
## Styling
|
||||
|
||||
Out of the box the viewer is styled inline from CSS variables — override them on `:root` or any parent:
|
||||
|
||||
| variable | default |
|
||||
|---|---|
|
||||
| `--ipal-lightbox-backdrop` | `rgb(0 0 0 / 0.9)` |
|
||||
| `--ipal-lightbox-color` | `#fff` |
|
||||
| `--ipal-lightbox-padding` | `4rem 1rem` |
|
||||
| `--ipal-lightbox-z-index` | `1000` |
|
||||
| `--ipal-lightbox-image-max-height` | `calc(100dvh - 9rem)` |
|
||||
| `--ipal-lightbox-control-bg` | `rgb(255 255 255 / 0.14)` |
|
||||
| `--ipal-lightbox-control-color` | `inherit` |
|
||||
| `--ipal-lightbox-control-size` | `2.75rem` |
|
||||
| `--ipal-lightbox-control-radius` | `999px` |
|
||||
| `--ipal-lightbox-inset` | `1rem` |
|
||||
| `--ipal-lightbox-caption-color` | `inherit` |
|
||||
| `--ipal-lightbox-caption-size` | `0.95rem` |
|
||||
| `--ipal-lightbox-duration` | `200ms` (fade; none with reduced motion) |
|
||||
|
||||
```css
|
||||
:root { --ipal-lightbox-backdrop: rgb(15 23 42 / 0.95); --ipal-lightbox-control-bg: var(--color-brand); }
|
||||
```
|
||||
|
||||
Full control: `unstyled` (on the provider — applies to triggers too — or on one trigger / dialog)
|
||||
drops every inline style; style with `classNames` (`dialog`, `figure`, `image`, `caption`, `counter`,
|
||||
`button`, `close`, `previous`, `next`) and the `data-ipal` hooks: `lightbox`, `lightbox-backdrop`,
|
||||
`lightbox-figure`, `lightbox-caption`, `lightbox-counter`, `lightbox-previous`, `lightbox-next`,
|
||||
`lightbox-close`, `lightbox-trigger` (+ `data-group`). Icons: `icons={{ close, previous, next }}`.
|
||||
|
||||
## Turn off, override, extend
|
||||
|
||||
| Feature | Default | Turn off / override |
|
||||
|---|---|---|
|
||||
| Whole feature | off — nothing renders without a trigger | don't use the components |
|
||||
| Notifications → Lightbox labels | off | `ipalKit({ lightbox: true })`; `lightboxNotificationFields` for your own global; `globalOverrides.notifications` |
|
||||
| Texts | panel → `LIGHTBOX_FALLBACK` (English) | `texts` on the provider / trigger / dialog; `resolveLightboxTexts` |
|
||||
| Provider in `SiteProviders` | off | `lightbox` prop; or your own `<LightboxProvider>` in a client component |
|
||||
| Large image markup | `<img srcSet>` | `renderImage={({ image, imgProps, index }) => <Image … />}` (provider, client only) |
|
||||
| The whole viewer | `LightboxDialog` | `renderDialog={(props) => <MyViewer {...props} />}` — same props, your markup |
|
||||
| Wrap-around | on | `loop={false}` |
|
||||
| Swipe threshold | 40 px | `swipeThreshold` on `LightboxDialog` |
|
||||
| Rich text | off | `RenderRichText lightbox`; `withLightboxUploads(converters, options)` |
|
||||
| Look | inline styles from `--ipal-lightbox-*` | CSS variables; `unstyled` + `classNames` + `data-ipal` |
|
||||
|
||||
Building blocks: `lightboxImage`, `lightboxIndex` (wrap / clamp), `formatLightboxCounter`,
|
||||
`resolveLightboxTexts`, `LIGHTBOX_FALLBACK`, `prefersReducedMotion`, `useOptionalLightbox` (null
|
||||
outside a provider), `useLightbox`, `LightboxDialog`.
|
||||
|
||||
## Replacing a hand-made modal (migration)
|
||||
|
||||
Projects built before this feature open images in different ways: a `glightbox` wrapper, an inline
|
||||
`div role="dialog"` with `next/image fill`, a link to the raw file in a new tab, or nothing. Move them
|
||||
to the shared lightbox:
|
||||
|
||||
1. **Config:** `ipalKit({ lightbox: true })`, then `pnpm payload migrate:create` (Postgres) and commit
|
||||
the migration. Fill **Settings → Notifications → Lightbox** in every language — copy the labels
|
||||
from the old block fields (e.g. `closeLabel`, `prevLabel`, `nextLabel`) or seed them.
|
||||
2. **Layout:** `<SiteProviders lightbox={{ texts: (await getNotificationTexts({ payload, locale })).lightbox }}>`.
|
||||
3. **Gallery block:** replace the clickable `<div>` / custom `<button>` + `useState(index)` + dialog
|
||||
with `<LightboxTrigger group={`gallery-${id}`} image={lightboxImage(image, { size: 'hero' })!}>`
|
||||
around the existing thumbnail. Delete the dialog, its keydown listener, its scroll lock and its
|
||||
`useState`. Keep the thumbnail markup and its hover effect (`ZoomIn` icon overlay can stay inside
|
||||
the trigger as `aria-hidden`).
|
||||
4. **glightbox:** remove the wrapper, the dynamic `import('glightbox')`, its CSS and the
|
||||
`glightbox` dependency (`pnpm remove glightbox`).
|
||||
5. **"Open in a new tab" links** (certificates, diplomas): swap `<a href={image.url} target="_blank">`
|
||||
for a `LightboxTrigger` — the visitor stays on the page.
|
||||
6. **Block label fields** for close / previous / next that only served the old modal: stop reading
|
||||
them; remove them in a later release with a migration (skill **ipal-migrate-fields**) once the
|
||||
panel texts are filled.
|
||||
7. **Check:** keyboard only — Tab to a thumbnail, Enter opens, focus is on Close, ← / → browse, Tab
|
||||
stays in the dialog, Esc closes and focus is back on the thumbnail; the page does not scroll behind
|
||||
the dialog; on a phone, swipe browses; DevTools → Network shows a resized file, not the original,
|
||||
on a narrow screen.
|
||||
|
||||
Source: `src/modules/lightbox/`, `src/modules/richtext/withLightboxUploads.tsx`. Tests:
|
||||
`test/lightbox.test.ts`.
|
||||
@@ -148,5 +148,9 @@ props or `null` (video, PDF, a bare id, no `width`/`height`):
|
||||
- `'background'`: `autoPlay` (off with `reducedMotion: true`), `muted`, `loop`, `preload="metadata"`;
|
||||
- always `playsInline`; `poster` — a URL or a Media document.
|
||||
|
||||
**Enlarging an image** (card, gallery, product thumbnail): wrap the `<Media>` in `<LightboxTrigger
|
||||
image={lightboxImage(resource, { size: 'hero' })}>` — `lightboxImage` builds the large image with a
|
||||
`srcSet` from every Payload size. Do not build your own modal: [lightbox.md](./lightbox.md).
|
||||
|
||||
**`MEDIA_SIZES`** — starting points for `sizes`: `full` (`100vw`), `half`, `third`, `quarter`,
|
||||
`thumb` (`160px`). You can replace any value with your own string.
|
||||
|
||||
@@ -21,6 +21,12 @@ the texts in the panel (Notifications tab), grouped per context. Group `form`:
|
||||
exported from `@intecion/ipal-kit`).
|
||||
For forms: `getFormTexts(locale)` from `lib/content` = the `form` group in the given language.
|
||||
|
||||
Group `lightbox` (only with `ipalKit({ lightbox: true })` — adds columns, run a migration on Postgres):
|
||||
`open` ("Enlarge image"), `dialog` ("Image viewer"), `previous`, `next`, `close`, `counter`
|
||||
("{current} / {total}"). `getNotificationTexts(...).lightbox` always returns the full set (fallback
|
||||
`LIGHTBOX_FALLBACK`), and `getSiteShell(locale).lightboxTexts` carries it to `<SiteProviders lightbox>`.
|
||||
Details: [lightbox.md](./lightbox.md).
|
||||
|
||||
## Helper — getNotificationTexts
|
||||
|
||||
Reads the texts from the global per language, with a fallback per field. The counterpart of `getConsentTexts`:
|
||||
@@ -29,7 +35,7 @@ Reads the texts from the global per language, with a fallback per field. The cou
|
||||
import { getNotificationTexts } from '@intecion/ipal-kit'
|
||||
|
||||
const notifications = await getNotificationTexts({ payload, locale }) // in lib/content: getFormTexts(locale) = .form
|
||||
// notifications.form.error, notifications.form.success, ...
|
||||
// notifications.form.error, notifications.form.success, ..., notifications.lightbox.close
|
||||
```
|
||||
|
||||
## Mapping the result — resolveFormMessage
|
||||
@@ -74,7 +80,7 @@ users), so the frontend reads them without a session. Write: `editor+` (`adminOr
|
||||
|
||||
## Turn off, override, extend
|
||||
|
||||
- **Turn off:** none — the `notifications` global is currently always added (also without the `forms` option).
|
||||
- **Turn off:** none — the `notifications` global is currently always added (also without the `forms` option). The `lightbox` group is opt-in (`ipalKit({ lightbox: true })`); `lightboxNotificationFields` puts it in your own global instead.
|
||||
- **Override texts:** in the panel, per language; empty field → `NOTIFICATION_FALLBACK` (EN).
|
||||
The fallbacks cannot be swapped with a plugin option — apply your own default texts in the project
|
||||
on the result of `getNotificationTexts` (e.g. `texts.form.error ||= '…'`).
|
||||
|
||||
@@ -89,6 +89,18 @@ const items = block.tableOfContents?.show ? extractHeadings(block.content) : []
|
||||
- `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`).
|
||||
|
||||
## Click-to-enlarge images (lightbox, opt-in)
|
||||
|
||||
```tsx
|
||||
<RenderRichText data={post.content} lightbox />
|
||||
<RenderRichText data={post.content} lightbox={{ group: 'post', image: { size: 'hero' }, triggerClassName: 'my-8' }} />
|
||||
```
|
||||
|
||||
Each image upload is wrapped in `<LightboxTrigger>` (`/client`); the images of the page browse as one
|
||||
gallery (default group `'richtext'`, `group: false` = each alone). Your own `upload` converter still
|
||||
renders the inline image. Your own renderer: `converters={withLightboxUploads(myConverters, options)}`
|
||||
(`/rsc`). Details, labels and styling: [lightbox.md](./lightbox.md).
|
||||
|
||||
## lexicalToMarkdown — richText → Markdown (for AI)
|
||||
|
||||
For readability by AI agents (Markdown per page, llms-full) you need
|
||||
@@ -127,6 +139,7 @@ project already has (it is the editor). No extra dependencies.
|
||||
|
||||
- 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`).
|
||||
- Image lightbox: off by default; `lightbox` turns it on, `withLightboxUploads` is the building block (lightbox.md).
|
||||
- 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.
|
||||
|
||||
Reference in New Issue
Block a user