Compare commits

...
4 Commits
Author SHA1 Message Date
Radosław Smoliński 46d30d4ecd 1.10.1
CI / check (push) Canceled after 0s
2026-10-19 00:07:40 +02:00
Radosław SmolińskiandClaude Opus 5.5 a6eda2e3a3 Pass siteDescription to page metadata; document media cache rule
createPageMetadata read Site Settings → siteDescription but never passed it to
buildMetadata, so pages without their own meta description had no
<meta name="description"> or og:description. Regression test in seo.test.ts.

storage.md: Cloudflare Cache Rule for the media domain (R2 objects carry no
Cache-Control; storage-s3 cannot set it, Cloudflare defaults to 4 h).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-19 00:07:28 +02:00
radoslaw.smolinski d28cbe2570 1.10.0
CI / check (push) Canceled after 0s
2026-10-17 03:20:12 +02:00
radoslaw.smolinskiandClaude Opus 5.5 2bd9d60822 Cookie banner layout options; keep admin UI out of /client
CookieBanner: order, settings="modal", controls="switch",
settingsActions, icon and a class slot for every element. Cookie
Settings gains eyebrow, title, settingsDescription, alwaysActiveLabel
and buttons.close.

MaskedField, TestEmailButton and IntegrationStatusBanner import
@payloadcms/ui and moved from /client to /admin; with sideEffects in
package.json the site bundle no longer ships ~235 KB gz of admin code.
A test walks the /client import graph to keep it that way.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-17 03:20:11 +02:00
19 changed files with 543 additions and 100 deletions
+37
View File
@@ -8,6 +8,43 @@ wersji naraz przejdź po kolei wszystkie sekcje „Wymaga zmian w projekcie” o
wersji, którą masz. Nowe wydanie = nowa sekcja na górze; najstarsze usuwamy wersji, którą masz. Nowe wydanie = nowa sekcja na górze; najstarsze usuwamy
dopiero powyżej 20. dopiero powyżej 20.
## 1.10.1
### Poprawki
- **Zapasowy metaopis działa.** `createPageMetadata` (a więc `createPageRoute` / `generatePageMetadata`) czytał
Site Settings → `siteDescription`, ale nie przekazywał go do `buildMetadata` — strona bez własnego
`meta.description` nie miała `<meta name="description">` ani `og:description` (Lighthouse SEO: „Dokument nie
ma metaopisu”). Test regresyjny w `test/seo.test.ts`.
### Dokumentacja
- storage.md → „Pamięć podręczna mediów”: reguła Cache Rules w Cloudflare dla domeny mediów (1 rok). Pliki w R2
nie mają `Cache-Control` (adapter S3 nie pozwala go ustawić), a Cloudflare daje domyślnie 4 h.
### Wymaga zmian w projekcie
- Obejście metaopisu w projekcie (własne uzupełnianie `description` w `generateMetadata`) można usunąć —
wystarczy `export const generateMetadata = route.generateMetadata`.
- Cloudflare: dodaj regułę Cache Rules dla domeny mediów (storage.md).
## 1.10.0
### Nowe
- **Baner cookies pod projekt** — `CookieBanner`: `order` (kolejność przycisków), `settings="modal"` (ustawienia
w oknie na środku: ✕, Escape, klik w tło), `controls="switch"` (przełączniki `role="switch"`),
`settingsActions` (np. Zapisz / Tylko niezbędne / Akceptuj), `icon={false}`; `classNames` ma slot dla każdego
elementu (tekst, każdy przycisk, modal, karta kategorii, przełącznik, znacznik). Cookie Settings: `eyebrow`,
`title`, `settingsDescription`, `alwaysActiveLabel`, `buttons.close`. Opis: consent.md → „Układ”.
### Poprawki
- **`/client` nie wciąga panelu admina do strony.** `MaskedField`, `TestEmailButton`, `IntegrationStatusBanner`
(importują `@payloadcms/ui`) są teraz w `/admin`; `sideEffects` w package.json. Każda strona importująca
cokolwiek z `/client` (CookieBanner, LanguageSwitcher…) ładowała ~235 KB gz kodu panelu. Test pilnuje regresji.
### Wymaga zmian w projekcie
- `pnpm payload generate:importmap` (ścieżki komponentów panelu: `/client#…` → `/admin#…`), `rm -rf .next`.
- Import `MaskedField` / `TestEmailButton` / `IntegrationStatusBanner` z `@intecion/ipal-kit/client` →
`@intecion/ipal-kit/admin`.
- Nowe pola Cookie Settings: Postgres/SQLite → `pnpm payload migrate:create`; MongoDB bez zmian.
## 1.9.9 ## 1.9.9
### Nowe ### Nowe
+44 -4
View File
@@ -168,15 +168,55 @@ zmienna po zmiennej. Na większe zmiany są `classNames`:
<CookieButton className="fixed bottom-6 right-6 ..." /> <CookieButton className="fixed bottom-6 right-6 ..." />
``` ```
Sloty: `root`, `primaryButton`, `secondaryButton`. Podany className zastępuje Podany className zastępuje domyślny (nie dokleja się). Każdy element ma swój slot (1.10.0):
domyślny (nie dokleja się).
| Slot | Element |
|---|---|
| `root`, `body`, `content` | pasek, wewnętrzna szerokość, rząd tekst + przyciski |
| `text`, `icon`, `eyebrow`, `title`, `message`, `link` | blok tekstu banera |
| `actions` | rząd przycisków banera |
| `primaryButton`, `secondaryButton` | dwa style przycisków (domyślne dla wszystkich) |
| `acceptButton`, `rejectButton`, `settingsButton`, `saveButton`, `backButton` | pojedyncze przyciski — puste → `primaryButton` / `secondaryButton` |
| `overlay`, `dialog`, `closeButton` | modal ustawień (`settings="modal"`) |
| `settingsTitle`, `settingsDescription`, `categories`, `category`, `categoryTitle`, `categoryDescription` | widok ustawień |
| `control`, `controlThumb`, `badge` | checkbox / przełącznik, kciuk przełącznika, znacznik „Zawsze aktywne” |
| `settingsActions` | rząd przycisków pod kategoriami |
### Układ: kolejność przycisków, modal, przełączniki (1.10.0)
```tsx
<CookieBanner
equalChoice
icon={false} // bez ikony ciasteczka
order={['accept', 'reject', 'settings']} // przyciski banera w tej kolejności
settings="modal" // ustawienia w oknie na środku (✕, Escape, klik w tło)
controls="switch" // przełączniki role="switch" zamiast checkboxów
settingsActions={['save', 'reject', 'accept']} // przyciski pod kategoriami
classNames={{ … }}
/>
```
Domyślnie (bez tych propsów) baner wygląda i działa jak przed 1.10.0.
Teksty z panelu (**Cookie Settings**, per język) — puste pole = element się nie pokazuje:
| Pole | Gdzie |
|---|---|
| `eyebrow` | mały napis nad tytułem banera („Prywatność i cookies”) |
| `title` | tytuł banera („Szanujemy Twoją prywatność”) |
| `settingsDescription` | opis pod tytułem ustawień |
| `alwaysActiveLabel` | znacznik przy „Niezbędne” zamiast wyłączonego przełącznika |
| `buttons.close` | etykieta przycisku ✕ dla czytników ekranu (puste → „Close”) |
Nowe pola w globalu = migracja w projektach na Postgres/SQLite (`payload migrate:create`); MongoDB bez zmian.
Elementy mają też stabilne uchwyty `data-ipal` do CSS i testów e2e (używa ich Elementy mają też stabilne uchwyty `data-ipal` do CSS i testów e2e (używa ich
`ipal-consent-check`): `banner`, `cookie-button` oraz przyciski `settings`, `reject`, `ipal-consent-check`): `banner`, `cookie-button` oraz przyciski `settings`, `reject`,
`accept`, `back`, `save`. `accept`, `back`, `save`; w trybie modal także `consent-overlay`, `consent-dialog`, `close`.
Dostępność: dialog banera i `CookieButton` mają `aria-label` z **Cookie Settings → Dostępność: dialog banera i `CookieButton` mają `aria-label` z **Cookie Settings →
settingsTitle** (per język) — bez tekstów na sztywno w komponentach. title** albo **settingsTitle** (per język) — bez tekstów na sztywno w komponentach. Modal ma
`aria-modal`, fokus na ✕ po otwarciu i zamyka się Escape; przełączniki mają `role="switch"` i `aria-checked`.
## Locale jako cookie functional (wbudowane) ## Locale jako cookie functional (wbudowane)
+1 -1
View File
@@ -88,7 +88,7 @@ przyciskiem Reveal/Hide. To maskowanie UI, NIE hashowanie ani szyfrowanie:
wartość w bazie jest plaintext (musi być odzyskiwalna do autentykacji SMTP/R2). wartość w bazie jest plaintext (musi być odzyskiwalna do autentykacji SMTP/R2).
Chroni przed patrzeniem przez ramię i przypadkowym pokazaniem panelu. Chroni przed patrzeniem przez ramię i przypadkowym pokazaniem panelu.
Podpięte przez `admin.components.Field: '@intecion/ipal-kit/client#MaskedField'`. Podpięte przez `admin.components.Field: '@intecion/ipal-kit/admin#MaskedField'`.
Działa na dowolnym polu `text`. Po wpięciu w projekcie może być konieczne Działa na dowolnym polu `text`. Po wpięciu w projekcie może być konieczne
`payload generate:importmap`, żeby panel rozpoznał komponent. `payload generate:importmap`, żeby panel rozpoznał komponent.
+21
View File
@@ -132,6 +132,27 @@ ustawiona). Bez niej Payload zwróci URL wskazujący na prywatny endpoint S3 →
Bez tego media wgrają się do R2, ale front pokaże 403. Konfiguracja domeny jest Bez tego media wgrają się do R2, ale front pokaże 403. Konfiguracja domeny jest
po stronie Cloudflare, publiczny URL po stronie projektu (.env). po stronie Cloudflare, publiczny URL po stronie projektu (.env).
### Pamięć podręczna mediów (Cache Rule — obowiązkowo)
Pliki w R2 nie mają nagłówka `Cache-Control`: `@payloadcms/storage-s3` przy wysyłce ustawia tylko
`ContentType` i `ACL`, bez opcji na nagłówki. Cloudflare daje wtedy przeglądarce domyślne **4 h** —
Lighthouse: „Używaj efektywnego czasu przechowywania w pamięci podręcznej” (wideo, logo, tła pobierane od
nowa przy każdej wizycie po 4 h). Nazwy plików są stałe (nowa wersja = nowy plik z `normalizeFilename`),
więc długi czas jest bezpieczny.
Cloudflare → strefa domeny → **Caching → Cache Rules → Create rule**:
- *When incoming requests match*: `Hostname` equals `media.klient.pl` (domena z `R2_PUBLIC_URL`);
- *Cache eligibility*: Eligible for cache;
- *Edge TTL*: Ignore cache-control header and use this TTL → **1 year**;
- *Browser TTL*: Override origin and use this TTL → **1 year**.
Sprawdzenie (po kilku minutach):
```bash
curl -sI https://media.klient.pl/<plik> | grep -iE 'cache-control|cf-cache-status'
# cache-control: max-age=31536000 cf-cache-status: HIT (przy drugim zapytaniu)
```
Podmiana pliku pod TĄ SAMĄ nazwą (rzadkie — panel nadaje nową) wymaga Caching → Purge → Custom (URL).
## Migracja istniejących mediów ## Migracja istniejących mediów
Jeśli projekt miał media lokalnie i przełączasz na R2 — nowe uploady idą do R2, Jeśli projekt miał media lokalnie i przełączasz na R2 — nowe uploady idą do R2,
+4 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@intecion/ipal-kit", "name": "@intecion/ipal-kit",
"version": "1.9.9", "version": "1.10.1",
"description": "Intecion Payload Advanced Library — a Payload CMS 3 plugin: i18n, SEO, forms, consent, analytics, blog/archives.", "description": "Intecion Payload Advanced Library — a Payload CMS 3 plugin: i18n, SEO, forms, consent, analytics, blog/archives.",
"license": "MIT", "license": "MIT",
"repository": { "repository": {
@@ -57,6 +57,9 @@
"docs", "docs",
"bin" "bin"
], ],
"sideEffects": [
"**/*.css"
],
"scripts": { "scripts": {
"build": "pnpm copyfiles && pnpm build:types && pnpm build:swc", "build": "pnpm copyfiles && pnpm build:types && pnpm build:swc",
"build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths", "build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
+7 -4
View File
@@ -1,10 +1,13 @@
export { RowLabel } from '../modules/admin-ui/RowLabelComponent.js'
/** /**
* Entry point: @intecion/ipal-kit/admin * Entry point: @intecion/ipal-kit/admin
* *
* Admin-panel UI components (white-label branding, array row labels). Separate export so Payload's * Admin-panel UI components (white-label branding, array row labels, integration fields and
* importMap can resolve them by a stable path when ipalKit injects * banners). Separate export so Payload's importMap can resolve them by a stable path, and so
* admin.components.graphics.Logo/Icon. * nothing importing @payloadcms/ui ends up in /client — that entry ships to every site visitor.
*/ */
export { MaskedField } from '../globals/SiteIntegrations/components/MaskedField.js'
export { TestEmailButton } from '../globals/SiteIntegrations/components/TestEmailButton.js'
export { RowLabel } from '../modules/admin-ui/RowLabelComponent.js'
export { AdminIcon, AdminLogo, IntecionCredit } from '../modules/branding/index.js' export { AdminIcon, AdminLogo, IntecionCredit } from '../modules/branding/index.js'
export { IntegrationAlerts } from '../modules/integrations/IntegrationAlerts.js' export { IntegrationAlerts } from '../modules/integrations/IntegrationAlerts.js'
export { IntegrationStatusBanner } from '../modules/integrations/IntegrationStatusBanner.js'
+1 -4
View File
@@ -1,6 +1,4 @@
'use client' 'use client'
export { MaskedField } from '../globals/SiteIntegrations/components/MaskedField.js'
export { TestEmailButton } from '../globals/SiteIntegrations/components/TestEmailButton.js'
export { AccessibilityProvider, AccessibilityWidget, useAccessibility } from '../modules/accessibility/client.js' export { AccessibilityProvider, AccessibilityWidget, useAccessibility } from '../modules/accessibility/client.js'
export type { A11yClassNames, A11yState, A11yTexts } from '../modules/accessibility/client.js' export type { A11yClassNames, A11yState, A11yTexts } from '../modules/accessibility/client.js'
export { Analytics } from '../modules/analytics/client.js' export { Analytics } from '../modules/analytics/client.js'
@@ -23,7 +21,7 @@ export {
useConsent, useConsent,
useConsentContext, useConsentContext,
} from '../modules/consent/client.js' } from '../modules/consent/client.js'
export type { CookieBannerClassNames } from '../modules/consent/client.js' export type { CookieBannerAction, CookieBannerClassNames, CookieSettingsAction } from '../modules/consent/client.js'
export { ConstructionNotice } from '../modules/construction/ConstructionNotice.js' export { ConstructionNotice } from '../modules/construction/ConstructionNotice.js'
export type { ConstructionNoticeClassNames } from '../modules/construction/ConstructionNotice.js' export type { ConstructionNoticeClassNames } from '../modules/construction/ConstructionNotice.js'
export type { ConstructionMode } from '../modules/construction/types.js' export type { ConstructionMode } from '../modules/construction/types.js'
@@ -77,7 +75,6 @@ export {
useSetAlternateLinks, useSetAlternateLinks,
} from '../modules/i18n/index.js' } from '../modules/i18n/index.js'
export type { AlternateLinks, LanguageSwitcherClassNames } from '../modules/i18n/index.js' export type { AlternateLinks, LanguageSwitcherClassNames } from '../modules/i18n/index.js'
export { IntegrationStatusBanner } from '../modules/integrations/IntegrationStatusBanner.js'
export { LocaleView } from '../modules/pages/LocaleView.js' export { LocaleView } from '../modules/pages/LocaleView.js'
export { YouTubeEmbed } from '../modules/storage/YouTubeEmbed.js' export { YouTubeEmbed } from '../modules/storage/YouTubeEmbed.js'
export { Turnstile } from '../modules/turnstile/client.js' export { Turnstile } from '../modules/turnstile/client.js'
+38
View File
@@ -22,6 +22,22 @@ export const cookieSettingsFields: Field[] = [
min: 1, min: 1,
required: true, required: true,
}, },
{
name: 'eyebrow',
type: 'text',
admin: {
description: 'Small label above the banner title, e.g. "Privacy & cookies". Empty → not shown.',
},
localized: true,
},
{
name: 'title',
type: 'text',
admin: {
description: 'Banner heading, e.g. "We respect your privacy". Empty → not shown.',
},
localized: true,
},
{ {
name: 'message', name: 'message',
type: 'textarea', type: 'textarea',
@@ -38,6 +54,22 @@ export const cookieSettingsFields: Field[] = [
}, },
localized: true, localized: true,
}, },
{
name: 'settingsDescription',
type: 'textarea',
admin: {
description: 'Intro under the settings heading — what cookies are for and that the choice can be changed later.',
},
localized: true,
},
{
name: 'alwaysActiveLabel',
type: 'text',
admin: {
description: 'Badge next to the Necessary category, e.g. "Always active". Empty → a disabled switch/checkbox is shown instead.',
},
localized: true,
},
{ {
name: 'privacyLinkLabel', name: 'privacyLinkLabel',
type: 'text', type: 'text',
@@ -59,6 +91,12 @@ export const cookieSettingsFields: Field[] = [
{ name: 'settings', type: 'text', localized: true }, { name: 'settings', type: 'text', localized: true },
{ name: 'save', type: 'text', localized: true }, { name: 'save', type: 'text', localized: true },
{ name: 'back', type: 'text', localized: true }, { name: 'back', type: 'text', localized: true },
{
name: 'close',
type: 'text',
admin: { description: 'Screen-reader label of the ✕ button in the settings dialog.' },
localized: true,
},
], ],
}, },
{ {
+2 -2
View File
@@ -64,7 +64,7 @@ export const smtpFields: Field[] = [
description: 'SMTP account password.', description: 'SMTP account password.',
// Masked in the UI (••••) — stored plaintext, readable for SMTP auth. // Masked in the UI (••••) — stored plaintext, readable for SMTP auth.
components: { components: {
Field: '@intecion/ipal-kit/client#MaskedField', Field: '@intecion/ipal-kit/admin#MaskedField',
}, },
}, },
}, },
@@ -87,7 +87,7 @@ export const smtpFields: Field[] = [
type: 'ui', type: 'ui',
admin: { admin: {
components: { components: {
Field: '@intecion/ipal-kit/client#TestEmailButton', Field: '@intecion/ipal-kit/admin#TestEmailButton',
}, },
}, },
}, },
@@ -27,7 +27,7 @@ export const turnstileFields: Field[] = [
description: 'Secret key used for server-side verification.', description: 'Secret key used for server-side verification.',
// Masked in the UI (••••) — stored plaintext, readable for verification. // Masked in the UI (••••) — stored plaintext, readable for verification.
components: { components: {
Field: '@intecion/ipal-kit/client#MaskedField', Field: '@intecion/ipal-kit/admin#MaskedField',
}, },
}, },
}, },
+273 -80
View File
@@ -1,19 +1,76 @@
'use client' 'use client'
import { Cookie } from 'lucide-react' import { Cookie } from 'lucide-react'
import { useEffect, useState } from 'react' import { useEffect, useRef, useState } from 'react'
import { CONSENT_CATEGORIES, type ConsentCategory } from './categories.js' import { CONSENT_CATEGORIES, type ConsentCategory } from './categories.js'
import { useConsentContext } from './ConsentContext.js' import { useConsentContext } from './ConsentContext.js'
import { useIsMounted } from './useIsMounted.js' import { useIsMounted } from './useIsMounted.js'
/** A button on the banner (first level). */
export type CookieBannerAction = 'accept' | 'reject' | 'settings'
/** A button under the category list (settings view). */
export type CookieSettingsAction = 'accept' | 'back' | 'reject' | 'save'
/** /**
* Optional class overrides — for when tokens aren't enough, e.g. turning the * Optional class overrides — for when tokens aren't enough, e.g. turning the
* bottom bar into a centred modal. Replaces the slot's classes outright. * bottom bar into a centred modal. Each slot replaces its default classes
* outright. Per-button slots (acceptButton, rejectButton…) fall back to
* primaryButton / secondaryButton, so styling those two still restyles all.
*/ */
export type CookieBannerClassNames = { export type CookieBannerClassNames = {
/** Button "Accept all" — falls back to primaryButton. */
acceptButton?: string
/** Button row on the banner. */
actions?: string
/** Settings view: button "Back" (closes the dialog in modal mode) — falls back to secondaryButton. */
backButton?: string
/** Settings view: badge next to Necessary (CookieSettings → alwaysActiveLabel). */
badge?: string
/** Banner inner wrapper (width / centring). */
body?: string
/** Settings view: list of categories. */
categories?: string
/** Settings view: one category row/card. */
category?: string
categoryDescription?: string
categoryTitle?: string
/** Settings dialog (modal mode): the ✕ button. */
closeButton?: string
/** Banner: text + buttons row. */
content?: string
/** Settings view: the switch track or the checkbox. */
control?: string
/** Settings view: the switch knob (controls="switch"). */
controlThumb?: string
/** Settings dialog box (modal mode). */
dialog?: string
/** Small label above the banner title (CookieSettings → eyebrow). */
eyebrow?: string
/** Cookie icon next to the banner text and the settings title. */
icon?: string
/** Privacy-policy link inside the message. */
link?: string
message?: string
/** Backdrop behind the settings dialog (modal mode). */
overlay?: string
primaryButton?: string primaryButton?: string
/** Button "Reject" — falls back to primaryButton with equalChoice, else secondaryButton. */
rejectButton?: string
root?: string root?: string
/** Settings view: button "Save preferences" — falls back to primaryButton. */
saveButton?: string
secondaryButton?: string secondaryButton?: string
/** Settings view: button row under the categories. */
settingsActions?: string
/** Button "Settings" on the banner — falls back to secondaryButton. */
settingsButton?: string
/** Settings view: intro under the title (CookieSettings → settingsDescription). */
settingsDescription?: string
settingsTitle?: string
/** Banner: block with eyebrow, title and message. */
text?: string
/** Banner heading (CookieSettings → title). */
title?: string
} }
/** /**
@@ -35,131 +92,267 @@ export type CookieBannerClassNames = {
* *
* Layout stays in Tailwind: spacing and flow aren't things a brand changes, and * Layout stays in Tailwind: spacing and flow aren't things a brand changes, and
* exposing them as tokens would mean re-inventing CSS one variable at a time. * exposing them as tokens would mean re-inventing CSS one variable at a time.
* For a different layout use classNames (every element has a slot).
*/ */
const surface = 'bg-[var(--ipal-surface,#fff)] dark:bg-[var(--ipal-surface-dark,#171717)]' const surface = 'bg-[var(--ipal-surface,#fff)] dark:bg-[var(--ipal-surface-dark,#171717)]'
const border = 'border-[var(--ipal-border,#e5e5e5)] dark:border-[var(--ipal-border-dark,#262626)]' const border = 'border-[var(--ipal-border,#e5e5e5)] dark:border-[var(--ipal-border-dark,#262626)]'
const radius = 'rounded-[var(--ipal-radius,0.375rem)]' const radius = 'rounded-[var(--ipal-radius,0.375rem)]'
const accent = 'text-[var(--ipal-primary,#2563eb)]' const accent = 'text-[var(--ipal-primary,#2563eb)]'
const bodyText = 'text-[var(--ipal-text,#404040)] dark:text-[var(--ipal-text-dark,#d4d4d4)]'
const strongText = 'text-[var(--ipal-text-strong,#171717)] dark:text-[var(--ipal-text-strong-dark,#f5f5f5)]'
const mutedText = 'text-[var(--ipal-text-muted,#737373)] dark:text-[var(--ipal-text-muted-dark,#a3a3a3)]'
const primaryBg = 'bg-[var(--ipal-primary,#2563eb)]'
const defaults = { const defaults: Required<CookieBannerClassNames> = {
primaryButton: `${radius} px-3 py-1.5 text-sm font-medium bg-[var(--ipal-primary,#2563eb)] text-[var(--ipal-primary-text,#fff)] hover:bg-[var(--ipal-primary-hover,#1d4ed8)]`, acceptButton: '',
actions: 'flex shrink-0 gap-2',
backButton: '',
badge: `shrink-0 rounded-full border px-2 py-0.5 text-xs font-medium ${border} ${accent}`,
body: 'mx-auto max-w-4xl',
categories: 'flex flex-col gap-3',
category: 'flex items-start justify-between gap-4',
categoryDescription: `text-xs ${mutedText}`,
categoryTitle: `text-sm font-medium ${strongText}`,
closeButton: `shrink-0 ${radius} p-1 ${mutedText} hover:bg-[var(--ipal-hover,#f5f5f5)] dark:hover:bg-[var(--ipal-hover-dark,#262626)]`,
content: 'flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between',
control: 'mt-1 h-4 w-4 shrink-0 accent-[var(--ipal-primary,#2563eb)]',
controlThumb: 'pointer-events-none inline-block size-5 rounded-full bg-white shadow transition-transform translate-x-0.5 data-[checked=true]:translate-x-[1.375rem]',
dialog: `relative max-h-[90vh] w-full max-w-2xl overflow-y-auto ${radius} border p-6 shadow-2xl ${surface} ${border}`,
eyebrow: `mb-1 text-xs font-semibold uppercase tracking-wider ${accent}`,
icon: `h-6 w-6 shrink-0 ${accent}`,
link: `${accent} underline hover:no-underline`,
message: `text-justify text-sm ${bodyText}`,
overlay: 'fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4',
primaryButton: `${radius} px-3 py-1.5 text-sm font-medium ${primaryBg} text-[var(--ipal-primary-text,#fff)] hover:bg-[var(--ipal-primary-hover,#1d4ed8)]`,
rejectButton: '',
root: `fixed inset-x-0 bottom-0 z-50 border-t p-4 shadow-lg ${surface} ${border}`, root: `fixed inset-x-0 bottom-0 z-50 border-t p-4 shadow-lg ${surface} ${border}`,
saveButton: '',
secondaryButton: `${radius} px-3 py-1.5 text-sm font-medium text-[var(--ipal-text,#404040)] hover:bg-[var(--ipal-hover,#f5f5f5)] dark:text-[var(--ipal-text-dark,#e5e5e5)] dark:hover:bg-[var(--ipal-hover-dark,#262626)]`, secondaryButton: `${radius} px-3 py-1.5 text-sm font-medium text-[var(--ipal-text,#404040)] hover:bg-[var(--ipal-hover,#f5f5f5)] dark:text-[var(--ipal-text-dark,#e5e5e5)] dark:hover:bg-[var(--ipal-hover-dark,#262626)]`,
settingsActions: 'flex justify-end gap-2',
settingsButton: '',
settingsDescription: `text-sm ${bodyText}`,
settingsTitle: `flex items-center gap-2 text-base font-semibold ${strongText}`,
text: 'flex items-start gap-3',
title: `mb-1 text-base font-semibold ${strongText}`,
} }
const bodyText = 'text-[var(--ipal-text,#404040)] dark:text-[var(--ipal-text-dark,#d4d4d4)]' /** Default switch track (controls="switch") — the checkbox default doesn't fit a <button>. */
const strongText = const SWITCH_TRACK =
'text-[var(--ipal-text-strong,#171717)] dark:text-[var(--ipal-text-strong-dark,#f5f5f5)]' 'relative inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full bg-[var(--ipal-border,#d4d4d4)] transition-colors data-[checked=true]:bg-[var(--ipal-primary,#2563eb)] disabled:cursor-default disabled:opacity-60 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--ipal-primary,#2563eb)]'
const mutedText =
'text-[var(--ipal-text-muted,#737373)] dark:text-[var(--ipal-text-muted-dark,#a3a3a3)]'
type CookieBannerProps = { type CookieBannerProps = {
classNames?: CookieBannerClassNames classNames?: CookieBannerClassNames
/** Category controls: native checkboxes (default) or accessible switches (role="switch"). */
controls?: 'checkbox' | 'switch'
/** /**
* Style "Reject" like "Accept all" (primary). Polish and EU regulators (UODO, * Style "Reject" like "Accept all" (primary). Polish and EU regulators (UODO,
* EDPB) expect refusing to be as easy and visible as accepting. Default false * EDPB) expect refusing to be as easy and visible as accepting. Default false
* keeps the existing look; recommended true. * keeps the existing look; recommended true.
*/ */
equalChoice?: boolean equalChoice?: boolean
/** Cookie icon next to the banner text and the settings title. Default true. */
icon?: boolean
/** Banner buttons, in this order. Default ['settings', 'reject', 'accept']. */
order?: CookieBannerAction[]
/**
* Where category settings open: in the banner itself (default) or in a centred
* dialog over a dimmed page ('modal' — closes with ✕, Escape or a click outside).
*/
settings?: 'inline' | 'modal'
/** Buttons under the categories, in this order. Default ['back', 'save']. */
settingsActions?: CookieSettingsAction[]
} }
export function CookieBanner({ classNames, equalChoice = false }: CookieBannerProps = {}) { const DEFAULT_ORDER: CookieBannerAction[] = ['settings', 'reject', 'accept']
const DEFAULT_SETTINGS_ACTIONS: CookieSettingsAction[] = ['back', 'save']
export function CookieBanner({
classNames,
controls = 'checkbox',
equalChoice = false,
icon = true,
order = DEFAULT_ORDER,
settings = 'inline',
settingsActions = DEFAULT_SETTINGS_ACTIONS,
}: CookieBannerProps = {}) {
const isMounted = useIsMounted() const isMounted = useIsMounted()
const { acceptAll, decided, rejectAll, savePreferences, state, texts } = useConsentContext() const { acceptAll, decided, rejectAll, savePreferences, state, texts } = useConsentContext()
const [showSettings, setShowSettings] = useState(false) const [showSettings, setShowSettings] = useState(false)
const [choices, setChoices] = useState<Record<ConsentCategory, boolean>>(state) const [choices, setChoices] = useState<Record<ConsentCategory, boolean>>(state)
const closeRef = useRef<HTMLButtonElement>(null)
const modal = settings === 'modal'
useEffect(() => { useEffect(() => {
setChoices(state) setChoices(state)
}, [state]) }, [state])
// Modal: focus the ✕ on open, Escape closes (back to the banner)
useEffect(() => {
if (!modal || !showSettings) {return}
closeRef.current?.focus()
const onKey = (event: KeyboardEvent) => {
if (event.key === 'Escape') {setShowSettings(false)}
}
document.addEventListener('keydown', onKey)
return () => document.removeEventListener('keydown', onKey)
}, [modal, showSettings])
// Render nothing until mounted — avoids the React 19 hydration mismatch that // Render nothing until mounted — avoids the React 19 hydration mismatch that
// projects used to work around with a setTimeout ConsentWrapper. No wrapper // projects used to work around with a setTimeout ConsentWrapper. No wrapper
// needed now. // needed now.
if (!isMounted) {return null} if (!isMounted) {return null}
if (decided) {return null} if (decided) {return null}
const cn = (slot: keyof CookieBannerClassNames) => classNames?.[slot] ?? defaults[slot]
const primary = cn('primaryButton')
const secondary = cn('secondaryButton')
const buttonClass: Record<CookieBannerAction | CookieSettingsAction, string> = {
accept: classNames?.acceptButton ?? primary,
back: classNames?.backButton ?? secondary,
reject: classNames?.rejectButton ?? (equalChoice ? primary : secondary),
save: classNames?.saveButton ?? primary,
settings: classNames?.settingsButton ?? secondary,
}
const run: Record<CookieBannerAction | CookieSettingsAction, () => void> = {
accept: acceptAll,
back: () => setShowSettings(false),
reject: rejectAll,
save: () => savePreferences(choices),
settings: () => setShowSettings(true),
}
const label: Record<CookieBannerAction | CookieSettingsAction, string> = {
accept: texts.buttons.acceptAll,
back: texts.buttons.back,
reject: texts.buttons.reject,
save: texts.buttons.save,
settings: texts.buttons.settings,
}
const button = (action: CookieBannerAction | CookieSettingsAction) => (
<button className={buttonClass[action]} data-ipal={action} key={action} onClick={run[action]} type="button">
{label[action]}
</button>
)
const toggle = (cat: ConsentCategory) => { const toggle = (cat: ConsentCategory) => {
if (cat === 'necessary') {return} if (cat === 'necessary') {return}
setChoices((prev) => ({ ...prev, [cat]: !prev[cat] })) setChoices((prev) => ({ ...prev, [cat]: !prev[cat] }))
} }
const rootClass = classNames?.root ?? defaults.root const control = (cat: ConsentCategory) => {
const primaryClass = classNames?.primaryButton ?? defaults.primaryButton const checked = cat === 'necessary' ? true : choices[cat]
const secondaryClass = classNames?.secondaryButton ?? defaults.secondaryButton if (cat === 'necessary' && texts.alwaysActiveLabel) {
return <span className={cn('badge')}>{texts.alwaysActiveLabel}</span>
}
if (controls === 'switch') {
return (
<button
aria-checked={checked}
aria-describedby={`ipal-consent-${cat}-desc`}
aria-labelledby={`ipal-consent-${cat}`}
className={classNames?.control ?? SWITCH_TRACK}
data-checked={checked}
disabled={cat === 'necessary'}
onClick={() => toggle(cat)}
role="switch"
type="button"
>
<span aria-hidden="true" className={cn('controlThumb')} data-checked={checked} />
</button>
)
}
return (
<input
aria-describedby={`ipal-consent-${cat}-desc`}
aria-labelledby={`ipal-consent-${cat}`}
checked={checked}
className={cn('control')}
disabled={cat === 'necessary'}
onChange={() => toggle(cat)}
type="checkbox"
/>
)
}
return ( const settingsView = (
<div aria-label={texts.settingsTitle} className={rootClass} data-ipal="banner" role="dialog"> <div className="flex flex-col gap-4">
<div className="mx-auto max-w-4xl"> <div className="flex items-start justify-between gap-4">
{!showSettings ? ( <h2 className={cn('settingsTitle')} id="ipal-consent-title">
<div className="flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between"> {icon && !modal && <Cookie aria-hidden="true" className={cn('icon')} />}
<div className="flex items-start gap-3"> {texts.settingsTitle}
<Cookie aria-hidden="true" className={`h-6 w-6 shrink-0 ${accent}`} /> </h2>
<p className={`text-justify text-sm ${bodyText}`}> {modal && (
{texts.message} <button aria-label={texts.buttons.close} className={cn('closeButton')} data-ipal="close" onClick={() => setShowSettings(false)} ref={closeRef} type="button">
{texts.privacyLink && ( <svg aria-hidden="true" fill="none" height="20" stroke="currentColor" strokeLinecap="round" strokeWidth="2" viewBox="0 0 24 24" width="20">
<> <path d="M18 6 6 18M6 6l12 12" />
{' '} </svg>
<a </button>
className={`${accent} underline hover:no-underline`} )}
href={texts.privacyLink.href} </div>
> {texts.settingsDescription && <p className={cn('settingsDescription')}>{texts.settingsDescription}</p>}
{texts.privacyLink.label} <ul className={cn('categories')}>
</a> {CONSENT_CATEGORIES.map((cat) => (
</> <li className={cn('category')} key={cat}>
)} <div>
<p className={cn('categoryTitle')} id={`ipal-consent-${cat}`}>
{texts.categories[cat].title}
</p>
<p className={cn('categoryDescription')} id={`ipal-consent-${cat}-desc`}>
{texts.categories[cat].description}
</p> </p>
</div> </div>
<div className="flex shrink-0 gap-2"> {control(cat)}
<button className={secondaryClass} data-ipal="settings" onClick={() => setShowSettings(true)} type="button"> </li>
{texts.buttons.settings} ))}
</button> </ul>
<button className={equalChoice ? primaryClass : secondaryClass} data-ipal="reject" onClick={rejectAll} type="button"> <div className={cn('settingsActions')}>{settingsActions.map(button)}</div>
{texts.buttons.reject} </div>
</button> )
<button className={primaryClass} data-ipal="accept" onClick={acceptAll} type="button">
{texts.buttons.acceptAll} if (modal && showSettings) {
</button> return (
<div
className={cn('overlay')}
data-ipal="consent-overlay"
onClick={(event) => {
if (event.target === event.currentTarget) {setShowSettings(false)}
}}
// klik w tło zamyka dialog; klawiatura: Escape (listener wyżej) i przycisk ✕
role="presentation"
>
<div aria-labelledby="ipal-consent-title" aria-modal="true" className={cn('dialog')} data-ipal="consent-dialog" role="dialog">
{settingsView}
</div>
</div>
)
}
return (
<div aria-label={texts.title || texts.settingsTitle} className={cn('root')} data-ipal="banner" role="dialog">
<div className={cn('body')}>
{!showSettings ? (
<div className={cn('content')}>
<div className={cn('text')}>
{icon && <Cookie aria-hidden="true" className={cn('icon')} />}
<div>
{texts.eyebrow && <p className={cn('eyebrow')}>{texts.eyebrow}</p>}
{texts.title && <h2 className={cn('title')}>{texts.title}</h2>}
<p className={cn('message')}>
{texts.message}
{texts.privacyLink && (
<>
{' '}
<a className={cn('link')} href={texts.privacyLink.href}>
{texts.privacyLink.label}
</a>
</>
)}
</p>
</div>
</div> </div>
<div className={cn('actions')}>{order.map(button)}</div>
</div> </div>
) : ( ) : (
<div className="flex flex-col gap-4"> settingsView
<h2 className={`flex items-center gap-2 text-base font-semibold ${strongText}`}>
<Cookie aria-hidden="true" className={`h-5 w-5 ${accent}`} />
{texts.settingsTitle}
</h2>
<ul className="flex flex-col gap-3">
{CONSENT_CATEGORIES.map((cat) => (
<li className="flex items-start justify-between gap-4" key={cat}>
<div>
<p className={`text-sm font-medium ${strongText}`} id={`ipal-consent-${cat}`}>
{texts.categories[cat].title}
</p>
<p className={`text-xs ${mutedText}`} id={`ipal-consent-${cat}-desc`}>
{texts.categories[cat].description}
</p>
</div>
<input
aria-describedby={`ipal-consent-${cat}-desc`}
aria-labelledby={`ipal-consent-${cat}`}
checked={cat === 'necessary' ? true : choices[cat]}
className="mt-1 h-4 w-4 shrink-0 accent-[var(--ipal-primary,#2563eb)]"
disabled={cat === 'necessary'}
onChange={() => toggle(cat)}
type="checkbox"
/>
</li>
))}
</ul>
<div className="flex justify-end gap-2">
<button className={secondaryClass} data-ipal="back" onClick={() => setShowSettings(false)} type="button">
{texts.buttons.back}
</button>
<button className={primaryClass} data-ipal="save" onClick={() => savePreferences(choices)} type="button">
{texts.buttons.save}
</button>
</div>
</div>
)} )}
</div> </div>
</div> </div>
+1 -1
View File
@@ -2,7 +2,7 @@
export { ConsentProvider, useConsentContext } from './ConsentContext.js' export { ConsentProvider, useConsentContext } from './ConsentContext.js'
export { ConsentScript } from './ConsentScript.js' export { ConsentScript } from './ConsentScript.js'
export { CookieBanner } from './CookieBanner.js' export { CookieBanner } from './CookieBanner.js'
export type { CookieBannerClassNames } from './CookieBanner.js' export type { CookieBannerAction, CookieBannerClassNames, CookieSettingsAction } from './CookieBanner.js'
export { CookieButton } from './CookieButton.js' export { CookieButton } from './CookieButton.js'
// Client-only consent exports — hook, provider, and UI components. // Client-only consent exports — hook, provider, and UI components.
export { DEFAULT_COOKIE_MAP, useConsent } from './useConsent.js' export { DEFAULT_COOKIE_MAP, useConsent } from './useConsent.js'
+11
View File
@@ -13,6 +13,7 @@ const FALLBACK: ConsentTexts = {
buttons: { buttons: {
acceptAll: 'Accept all', acceptAll: 'Accept all',
back: 'Back', back: 'Back',
close: 'Close',
reject: 'Reject', reject: 'Reject',
save: 'Save preferences', save: 'Save preferences',
settings: 'Settings', settings: 'Settings',
@@ -37,13 +38,17 @@ const FALLBACK: ConsentTexts = {
const FALLBACK_PRIVACY_LABEL = 'Privacy policy' const FALLBACK_PRIVACY_LABEL = 'Privacy policy'
type CookieSettingsData = { type CookieSettingsData = {
alwaysActiveLabel?: null | string
buttons?: null | Partial<ConsentTexts['buttons']> buttons?: null | Partial<ConsentTexts['buttons']>
categories?: Array<{ description?: null | string; key: string; title?: null | string }> | null categories?: Array<{ description?: null | string; key: string; title?: null | string }> | null
cookies?: Array<{ category?: null | string; duration?: null | string; name?: null | string; provider?: null | string; purpose?: null | string }> | null cookies?: Array<{ category?: null | string; duration?: null | string; name?: null | string; provider?: null | string; purpose?: null | string }> | null
eyebrow?: null | string
message?: null | string message?: null | string
policyVersion?: null | number policyVersion?: null | number
privacyLinkLabel?: null | string privacyLinkLabel?: null | string
settingsDescription?: null | string
settingsTitle?: null | string settingsTitle?: null | string
title?: null | string
} }
type PrivacyPage = { slug?: null | Record<string, unknown>; title?: unknown } | null type PrivacyPage = { slug?: null | Record<string, unknown>; title?: unknown } | null
@@ -135,6 +140,7 @@ export async function getConsentTexts({
buttons: { buttons: {
acceptAll: g.buttons?.acceptAll || FALLBACK.buttons.acceptAll, acceptAll: g.buttons?.acceptAll || FALLBACK.buttons.acceptAll,
back: g.buttons?.back || FALLBACK.buttons.back, back: g.buttons?.back || FALLBACK.buttons.back,
close: g.buttons?.close || FALLBACK.buttons.close,
reject: g.buttons?.reject || FALLBACK.buttons.reject, reject: g.buttons?.reject || FALLBACK.buttons.reject,
save: g.buttons?.save || FALLBACK.buttons.save, save: g.buttons?.save || FALLBACK.buttons.save,
settings: g.buttons?.settings || FALLBACK.buttons.settings, settings: g.buttons?.settings || FALLBACK.buttons.settings,
@@ -143,6 +149,11 @@ export async function getConsentTexts({
message: g.message || FALLBACK.message, message: g.message || FALLBACK.message,
privacyLink, privacyLink,
settingsTitle: g.settingsTitle || FALLBACK.settingsTitle, settingsTitle: g.settingsTitle || FALLBACK.settingsTitle,
// optional copy — no English fallback: empty in the panel = element not rendered
...(g.eyebrow?.trim() ? { eyebrow: g.eyebrow.trim() } : {}),
...(g.title?.trim() ? { title: g.title.trim() } : {}),
...(g.settingsDescription?.trim() ? { settingsDescription: g.settingsDescription.trim() } : {}),
...(g.alwaysActiveLabel?.trim() ? { alwaysActiveLabel: g.alwaysActiveLabel.trim() } : {}),
...(typeof g.policyVersion === 'number' && g.policyVersion >= 1 ? { version: Math.trunc(g.policyVersion) } : {}), ...(typeof g.policyVersion === 'number' && g.policyVersion >= 1 ? { version: Math.trunc(g.policyVersion) } : {}),
} }
} }
+10
View File
@@ -1,18 +1,28 @@
import type { ConsentCategory } from './categories.js' import type { ConsentCategory } from './categories.js'
export type ConsentTexts = { export type ConsentTexts = {
/** Badge next to the necessary category (e.g. "Always active"). Empty = no badge. */
alwaysActiveLabel?: string
buttons: { buttons: {
acceptAll: string acceptAll: string
back: string back: string
/** Accessible label of the ✕ button closing the settings dialog. */
close: string
reject: string reject: string
save: string save: string
settings: string settings: string
} }
categories: Record<ConsentCategory, { description: string; title: string }> categories: Record<ConsentCategory, { description: string; title: string }>
/** Small label above the banner title (e.g. "Privacy & cookies"). Empty = not shown. */
eyebrow?: string
message: string message: string
/** null = no privacy-policy link shown */ /** null = no privacy-policy link shown */
privacyLink: { href: string; label: string } | null privacyLink: { href: string; label: string } | null
/** Intro under the settings title. Empty = not shown. */
settingsDescription?: string
settingsTitle: string settingsTitle: string
/** Banner heading (e.g. "We respect your privacy"). Empty = not shown. */
title?: string
/** Policy version from the panel — a stored consent from another version asks again. */ /** Policy version from the panel — a stored consent from another version asks again. */
version?: number version?: number
} }
+1 -1
View File
@@ -54,7 +54,7 @@ export function buildIntegrationStatusBanner(statusField: string, label: string)
components: { components: {
Field: { Field: {
clientProps: { label, statusField }, clientProps: { label, statusField },
path: '@intecion/ipal-kit/client#IntegrationStatusBanner', path: '@intecion/ipal-kit/admin#IntegrationStatusBanner',
}, },
}, },
}, },
+2
View File
@@ -142,6 +142,8 @@ export function createPageMetadata(args: CreatePageMetadataArgs) {
locale, locale,
order: site.order, order: site.order,
separator: site.separator, separator: site.separator,
// fallback opisu: strona bez meta.description dostaje Site Settings → siteDescription (seo.md)
siteDescription: site.siteDescription,
siteName: site.siteName, siteName: site.siteName,
} }
+26
View File
@@ -35,3 +35,29 @@ describe('package exports', () => {
} }
}) })
}) })
describe('client entry', () => {
// Wszystko, co importuje /client, trafia do bundla strony publicznej — panel (@payloadcms/ui) to ~235 KB gz
test('does not pull admin UI (@payloadcms/ui, @payloadcms/next) into the site bundle', () => {
const seen = new Set<string>()
const offenders: string[] = []
const resolve = (from: string, spec: string) => {
const base = path.resolve(path.dirname(from), spec).replace(/\.js$/, '')
return ['.ts', '.tsx', '/index.ts', '/index.tsx'].map((ext) => base + ext).find((f) => existsSync(f))
}
const walk = (file: string) => {
if (seen.has(file)) {return}
seen.add(file)
for (const m of readFileSync(file, 'utf8').matchAll(/(?:import|export)\s[^'"]*?from\s+['"](?<spec>[^'"]+)['"]/g)) {
const spec = m.groups!.spec
if (/^@payloadcms\/(?:ui|next)(?:\/|$)/.test(spec)) {offenders.push(`${path.relative(root, file)} → ${spec}`)}
if (spec.startsWith('.')) {
const next = resolve(file, spec)
if (next) {walk(next)}
}
}
}
walk(path.join(root, 'src/exports/client.ts'))
expect(offenders).toEqual([])
})
})
+34 -1
View File
@@ -13,7 +13,7 @@ import { buildConfig, getPayload } from 'payload'
import { afterAll, beforeAll, describe, expect, test, vi } from 'vitest' import { afterAll, beforeAll, describe, expect, test, vi } from 'vitest'
import { buildConsentLogEndpoint } from '../src/modules/consent/consentLog.js' import { buildConsentLogEndpoint } from '../src/modules/consent/consentLog.js'
import { getCookieTable } from '../src/modules/consent/getConsentTexts.js' import { getConsentTexts, getCookieTable } from '../src/modules/consent/getConsentTexts.js'
import { submitForm } from '../src/modules/forms/submitForm.js' import { submitForm } from '../src/modules/forms/submitForm.js'
import { createContentHelpers } from '../src/modules/frontend/createContentHelpers.js' import { createContentHelpers } from '../src/modules/frontend/createContentHelpers.js'
import { createPageRoute } from '../src/modules/frontend/pageRoute.js' import { createPageRoute } from '../src/modules/frontend/pageRoute.js'
@@ -304,6 +304,39 @@ describe('consent log', () => {
}) })
}) })
describe('consent texts', () => {
const config = { defaultLocale: 'pl', locales: [{ code: 'pl', label: 'Polski' }] } as const
test('optional banner copy is omitted when empty and passed through when set', async () => {
const empty = await getConsentTexts({ config, locale: 'pl', payload, privacyPolicy: false })
expect(empty.eyebrow).toBeUndefined()
expect(empty.title).toBeUndefined()
expect(empty.settingsDescription).toBeUndefined()
expect(empty.alwaysActiveLabel).toBeUndefined()
expect(empty.buttons.close).toBe('Close')
await payload.updateGlobal({
slug: 'cookie-settings' as never,
data: {
alwaysActiveLabel: 'Zawsze aktywne',
buttons: { close: 'Zamknij' },
eyebrow: 'Prywatność i cookies',
settingsDescription: 'Możesz zmienić wybór w dowolnym momencie.',
title: 'Szanujemy Twoją prywatność',
} as never,
locale: 'pl' as never,
})
const texts = await getConsentTexts({ config, locale: 'pl', payload, privacyPolicy: false })
expect(texts).toMatchObject({
alwaysActiveLabel: 'Zawsze aktywne',
buttons: { close: 'Zamknij' },
eyebrow: 'Prywatność i cookies',
settingsDescription: 'Możesz zmienić wybór w dowolnym momencie.',
title: 'Szanujemy Twoją prywatność',
})
})
})
describe('cookie table', () => { describe('cookie table', () => {
test('rows from Cookie Settings in the requested language', async () => { test('rows from Cookie Settings in the requested language', async () => {
await payload.updateGlobal({ await payload.updateGlobal({
+29
View File
@@ -9,6 +9,7 @@ import { buildCsp } from '../src/modules/security/buildCsp.js'
import { buildSecurityHeaders } from '../src/modules/security/buildSecurityHeaders.js' import { buildSecurityHeaders } from '../src/modules/security/buildSecurityHeaders.js'
import { AI_TRAINING_BOTS, buildRobots } from '../src/modules/seo/buildRobots.js' import { AI_TRAINING_BOTS, buildRobots } from '../src/modules/seo/buildRobots.js'
import { buildSitemapXml } from '../src/modules/seo/buildSitemapXml.js' import { buildSitemapXml } from '../src/modules/seo/buildSitemapXml.js'
import { createPageMetadata } from '../src/modules/seo/createPageMetadata.js'
import { buildHreflangAlternates } from '../src/modules/seo/hreflang.js' import { buildHreflangAlternates } from '../src/modules/seo/hreflang.js'
const config: I18nConfig = { const config: I18nConfig = {
@@ -259,3 +260,31 @@ describe('site-wide noindex (IPAL_NOINDEX) and Markdown headers', () => {
expect(res.headers.get('link')).toBe('<https://acme.pl/pl/o-nas>; rel="canonical"') expect(res.headers.get('link')).toBe('<https://acme.pl/pl/o-nas>; rel="canonical"')
}) })
}) })
describe('createPageMetadata — siteDescription fallback', () => {
// Regresja 1.10.0: readSiteMetaConfig czytał siteDescription, ale nie trafiał do buildMetadata —
// strona bez meta.description nie miała <meta name="description"> (Lighthouse SEO).
const settings = { homepage: null, siteDescription: 'Opis firmy z Site Settings', siteName: 'Acme' }
const payload = {} as never
test('page without its own description gets Site Settings → siteDescription', async () => {
const pageMetadata = createPageMetadata({
baseUrl: 'https://acme.pl',
config,
loaders: { getSettings: async () => settings, resolveRoute: async () => null },
})
const metadata = await pageMetadata({ slug: ['o-nas'], locale: 'pl', payload })
expect(metadata.description).toBe('Opis firmy z Site Settings')
expect(metadata.openGraph?.description).toBe('Opis firmy z Site Settings')
})
test('no siteDescription → no description (field omitted, not invented)', async () => {
const pageMetadata = createPageMetadata({
baseUrl: 'https://acme.pl',
config,
loaders: { getSettings: async () => ({ ...settings, siteDescription: null }), resolveRoute: async () => null },
})
const metadata = await pageMetadata({ slug: ['o-nas'], locale: 'pl', payload })
expect(metadata.description).toBeUndefined()
})
})