Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7f5ed75f9e | ||
|
|
4eb2b627f0 | ||
|
|
a92fc02cdf | ||
|
|
7aebe24236 | ||
|
|
c852d7bdae | ||
|
|
24fa3fdcdf | ||
|
|
73eacb09c2 | ||
|
|
2665cfa7b6 | ||
|
|
5c466b664c | ||
|
|
78e2f8fc7f | ||
|
|
13d669b757 |
@@ -194,7 +194,7 @@ Wpinaj w kolekcje gdzie dotyczy (patrz `hooks.md`):
|
||||
|
||||
- **buildSecurityHeaders** w next.config — HSTS, COOP, nosniff, Referrer-Policy (z automatu, uniwersalne).
|
||||
- **buildCsp** — generator CSP z twardymi regułami (base-uri, object-src, frame-ancestors). Flagi: turnstile, analytics, youtube, r2Url. Wdrażaj przez `report-only` → sprawdź konsolę → `enforce`.
|
||||
- **2FA WYMUSZONE** — `ipalKit({ twoFactor: { issuer: 'Nazwa Firmy' } })` + `pnpm add @clocklimited/payload-2fa@3.0.0-beta.7`. Wymuszone dla WSZYSTKICH użytkowników (forceSetup), bez opcji wyłączenia per user. NIE ustawiaj `twoFactor: false` (chyba że klient wprost odmawia). Bez zależności = błąd buildu. Patrz security.md.
|
||||
- **2FA WYMUSZONE** — `pnpm add @clocklimited/payload-2fa@3.0.0-beta.7`, potem WSTRZYKNIJ: `import { payloadTotp } from '@clocklimited/payload-2fa'` + `ipalKit({ twoFactor: { issuer: 'Nazwa Firmy', plugin: payloadTotp } })`. Wstrzyknięcie obowiązkowe — bez niego plugin robi dynamiczny import, którego Next nie wbundluje → „Cannot find module" na froncie. (Ewentualnie zamiast wstrzyknięcia: `serverExternalPackages: ['@clocklimited/payload-2fa']` w next.config.) Wymuszone dla WSZYSTKICH (forceSetup), bez opcji per user. NIE `twoFactor: false` (chyba że klient wprost odmawia). Patrz security.md.
|
||||
- **Ścieżka panelu** — `ipalKit({ adminRoute: '/its' })` ukrywa panel. WYMAGA przeniesienia folderu `app/(payload)/admin/` → `app/(payload)/its/`. To obscurity, nie security (2FA to prawdziwa ochrona).
|
||||
- CSP zostaje w projekcie (domeny), ale skeleton z pluginu. NIE Trusted Types (psuje Turnstile/GA).
|
||||
|
||||
|
||||
Vendored
+2
@@ -3,7 +3,9 @@ export { TestEmailButton } from '../globals/SiteIntegrations/components/TestEmai
|
||||
export { AccessibilityProvider, AccessibilityWidget, useAccessibility, } from '../modules/accessibility/client.js';
|
||||
export type { A11yClassNames, A11yState, A11yTexts } from '../modules/accessibility/client.js';
|
||||
export { Analytics } from '../modules/analytics/client.js';
|
||||
export type { AnalyticsProps } from '../modules/analytics/client.js';
|
||||
export { pushDataLayer } from '../modules/analytics/client.js';
|
||||
export { loadClarity, loadLinkedIn, loadMetaPixel, loadTikTok, } from '../modules/analytics/client.js';
|
||||
/**
|
||||
* Entry point: ipal-kit/client
|
||||
*
|
||||
|
||||
Vendored
+1
@@ -4,6 +4,7 @@ export { TestEmailButton } from '../globals/SiteIntegrations/components/TestEmai
|
||||
export { AccessibilityProvider, AccessibilityWidget, useAccessibility } from '../modules/accessibility/client.js';
|
||||
export { Analytics } from '../modules/analytics/client.js';
|
||||
export { pushDataLayer } from '../modules/analytics/client.js';
|
||||
export { loadClarity, loadLinkedIn, loadMetaPixel, loadTikTok } from '../modules/analytics/client.js';
|
||||
/**
|
||||
* Entry point: ipal-kit/client
|
||||
*
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"sources":["../../src/exports/client.ts"],"sourcesContent":["'use client'\nexport { MaskedField } from '../globals/SiteIntegrations/components/MaskedField.js'\nexport { TestEmailButton } from '../globals/SiteIntegrations/components/TestEmailButton.js'\nexport {\n AccessibilityProvider,\n AccessibilityWidget,\n useAccessibility,\n} from '../modules/accessibility/client.js'\nexport type { A11yClassNames, A11yState, A11yTexts } from '../modules/accessibility/client.js'\nexport { Analytics } from '../modules/analytics/client.js'\nexport { pushDataLayer } from '../modules/analytics/client.js'\n\n/**\n * Entry point: ipal-kit/client\n *\n * Client-side ('use client') exports — React hooks, providers, and UI\n * components. Kept separate from the main entry so server bundles don't pull in\n * client-only code.\n */\nexport {\n ConsentProvider,\n ConsentScript,\n CookieBanner,\n CookieButton,\n useConsent,\n useConsentContext,\n} from '../modules/consent/client.js'\nexport type { CookieBannerClassNames } from '../modules/consent/client.js'\nexport { formAnalyticsOnSuccess } from '../modules/forms/formAnalytics.js'\nexport type { FormAnalyticsConfig } from '../modules/forms/formAnalytics.js'\nexport { HONEYPOT_FIELD, honeypotInputProps, isHoneypotTripped } from '../modules/forms/honeypot.js'\nexport { useContactForm } from '../modules/forms/useContactForm.js'\nexport type {\n ContactFormErrors,\n ContactFormValues,\n SubmitAction,\n} from '../modules/forms/useContactForm.js'\nexport { useForm } from '../modules/forms/useForm.js'\nexport type { FormErrors, FormSubmitAction, Validator } from '../modules/forms/useForm.js'\nexport {\n buildValidator,\n checked,\n custom,\n email,\n isEmail,\n maxLength,\n minLength,\n pattern,\n required,\n} from '../modules/forms/validators.js'\nexport type { Rule } from '../modules/forms/validators.js'\n// Pure i18n path helpers — no server/RSC deps, safe to import in client\n// components (e.g. a LanguageSwitcher that computes locale URLs on the client).\nexport {\n buildLocalizedPath,\n getLocaleCodes,\n getLocalizedSlugs,\n switchLocalePath,\n} from '../modules/i18n/index.js'\nexport type { I18nConfig, LocalizedSlugs } from '../modules/i18n/index.js'\nexport {\n AlternateLinksProvider,\n AlternateLinksUpdater,\n LanguageSwitcher,\n useAlternateLinks,\n useSetAlternateLinks,\n} from '../modules/i18n/index.js'\nexport type { AlternateLinks, LanguageSwitcherClassNames } from '../modules/i18n/index.js'\nexport { Turnstile } from '../modules/turnstile/client.js'\nexport { TurnstileProvider, useTurnstile } from '../modules/turnstile/client.js'\nexport type { TurnstileProps } from '../modules/turnstile/client.js'\n"],"names":["MaskedField","TestEmailButton","AccessibilityProvider","AccessibilityWidget","useAccessibility","Analytics","pushDataLayer","ConsentProvider","ConsentScript","CookieBanner","CookieButton","useConsent","useConsentContext","formAnalyticsOnSuccess","HONEYPOT_FIELD","honeypotInputProps","isHoneypotTripped","useContactForm","useForm","buildValidator","checked","custom","email","isEmail","maxLength","minLength","pattern","required","buildLocalizedPath","getLocaleCodes","getLocalizedSlugs","switchLocalePath","AlternateLinksProvider","AlternateLinksUpdater","LanguageSwitcher","useAlternateLinks","useSetAlternateLinks","Turnstile","TurnstileProvider","useTurnstile"],"mappings":"AAAA;AACA,SAASA,WAAW,QAAQ,wDAAuD;AACnF,SAASC,eAAe,QAAQ,4DAA2D;AAC3F,SACEC,qBAAqB,EACrBC,mBAAmB,EACnBC,gBAAgB,QACX,qCAAoC;AAE3C,SAASC,SAAS,QAAQ,iCAAgC;AAC1D,SAASC,aAAa,QAAQ,iCAAgC;AAE9D;;;;;;CAMC,GACD,SACEC,eAAe,EACfC,aAAa,EACbC,YAAY,EACZC,YAAY,EACZC,UAAU,EACVC,iBAAiB,QACZ,+BAA8B;AAErC,SAASC,sBAAsB,QAAQ,oCAAmC;AAE1E,SAASC,cAAc,EAAEC,kBAAkB,EAAEC,iBAAiB,QAAQ,+BAA8B;AACpG,SAASC,cAAc,QAAQ,qCAAoC;AAMnE,SAASC,OAAO,QAAQ,8BAA6B;AAErD,SACEC,cAAc,EACdC,OAAO,EACPC,MAAM,EACNC,KAAK,EACLC,OAAO,EACPC,SAAS,EACTC,SAAS,EACTC,OAAO,EACPC,QAAQ,QACH,iCAAgC;AAEvC,wEAAwE;AACxE,gFAAgF;AAChF,SACEC,kBAAkB,EAClBC,cAAc,EACdC,iBAAiB,EACjBC,gBAAgB,QACX,2BAA0B;AAEjC,SACEC,sBAAsB,EACtBC,qBAAqB,EACrBC,gBAAgB,EAChBC,iBAAiB,EACjBC,oBAAoB,QACf,2BAA0B;AAEjC,SAASC,SAAS,QAAQ,iCAAgC;AAC1D,SAASC,iBAAiB,EAAEC,YAAY,QAAQ,iCAAgC"}
|
||||
{"version":3,"sources":["../../src/exports/client.ts"],"sourcesContent":["'use client'\nexport { MaskedField } from '../globals/SiteIntegrations/components/MaskedField.js'\nexport { TestEmailButton } from '../globals/SiteIntegrations/components/TestEmailButton.js'\nexport {\n AccessibilityProvider,\n AccessibilityWidget,\n useAccessibility,\n} from '../modules/accessibility/client.js'\nexport type { A11yClassNames, A11yState, A11yTexts } from '../modules/accessibility/client.js'\nexport { Analytics } from '../modules/analytics/client.js'\nexport type { AnalyticsProps } from '../modules/analytics/client.js'\n\nexport { pushDataLayer } from '../modules/analytics/client.js'\nexport {\n loadClarity,\n loadLinkedIn,\n loadMetaPixel,\n loadTikTok,\n} from '../modules/analytics/client.js'\n/**\n * Entry point: ipal-kit/client\n *\n * Client-side ('use client') exports — React hooks, providers, and UI\n * components. Kept separate from the main entry so server bundles don't pull in\n * client-only code.\n */\nexport {\n ConsentProvider,\n ConsentScript,\n CookieBanner,\n CookieButton,\n useConsent,\n useConsentContext,\n} from '../modules/consent/client.js'\nexport type { CookieBannerClassNames } from '../modules/consent/client.js'\nexport { formAnalyticsOnSuccess } from '../modules/forms/formAnalytics.js'\nexport type { FormAnalyticsConfig } from '../modules/forms/formAnalytics.js'\nexport { HONEYPOT_FIELD, honeypotInputProps, isHoneypotTripped } from '../modules/forms/honeypot.js'\nexport { useContactForm } from '../modules/forms/useContactForm.js'\nexport type {\n ContactFormErrors,\n ContactFormValues,\n SubmitAction,\n} from '../modules/forms/useContactForm.js'\nexport { useForm } from '../modules/forms/useForm.js'\nexport type { FormErrors, FormSubmitAction, Validator } from '../modules/forms/useForm.js'\nexport {\n buildValidator,\n checked,\n custom,\n email,\n isEmail,\n maxLength,\n minLength,\n pattern,\n required,\n} from '../modules/forms/validators.js'\nexport type { Rule } from '../modules/forms/validators.js'\n// Pure i18n path helpers — no server/RSC deps, safe to import in client\n// components (e.g. a LanguageSwitcher that computes locale URLs on the client).\nexport {\n buildLocalizedPath,\n getLocaleCodes,\n getLocalizedSlugs,\n switchLocalePath,\n} from '../modules/i18n/index.js'\nexport type { I18nConfig, LocalizedSlugs } from '../modules/i18n/index.js'\nexport {\n AlternateLinksProvider,\n AlternateLinksUpdater,\n LanguageSwitcher,\n useAlternateLinks,\n useSetAlternateLinks,\n} from '../modules/i18n/index.js'\nexport type { AlternateLinks, LanguageSwitcherClassNames } from '../modules/i18n/index.js'\nexport { Turnstile } from '../modules/turnstile/client.js'\nexport { TurnstileProvider, useTurnstile } from '../modules/turnstile/client.js'\nexport type { TurnstileProps } from '../modules/turnstile/client.js'\n"],"names":["MaskedField","TestEmailButton","AccessibilityProvider","AccessibilityWidget","useAccessibility","Analytics","pushDataLayer","loadClarity","loadLinkedIn","loadMetaPixel","loadTikTok","ConsentProvider","ConsentScript","CookieBanner","CookieButton","useConsent","useConsentContext","formAnalyticsOnSuccess","HONEYPOT_FIELD","honeypotInputProps","isHoneypotTripped","useContactForm","useForm","buildValidator","checked","custom","email","isEmail","maxLength","minLength","pattern","required","buildLocalizedPath","getLocaleCodes","getLocalizedSlugs","switchLocalePath","AlternateLinksProvider","AlternateLinksUpdater","LanguageSwitcher","useAlternateLinks","useSetAlternateLinks","Turnstile","TurnstileProvider","useTurnstile"],"mappings":"AAAA;AACA,SAASA,WAAW,QAAQ,wDAAuD;AACnF,SAASC,eAAe,QAAQ,4DAA2D;AAC3F,SACEC,qBAAqB,EACrBC,mBAAmB,EACnBC,gBAAgB,QACX,qCAAoC;AAE3C,SAASC,SAAS,QAAQ,iCAAgC;AAG1D,SAASC,aAAa,QAAQ,iCAAgC;AAC9D,SACEC,WAAW,EACXC,YAAY,EACZC,aAAa,EACbC,UAAU,QACL,iCAAgC;AACvC;;;;;;CAMC,GACD,SACEC,eAAe,EACfC,aAAa,EACbC,YAAY,EACZC,YAAY,EACZC,UAAU,EACVC,iBAAiB,QACZ,+BAA8B;AAErC,SAASC,sBAAsB,QAAQ,oCAAmC;AAE1E,SAASC,cAAc,EAAEC,kBAAkB,EAAEC,iBAAiB,QAAQ,+BAA8B;AACpG,SAASC,cAAc,QAAQ,qCAAoC;AAMnE,SAASC,OAAO,QAAQ,8BAA6B;AAErD,SACEC,cAAc,EACdC,OAAO,EACPC,MAAM,EACNC,KAAK,EACLC,OAAO,EACPC,SAAS,EACTC,SAAS,EACTC,OAAO,EACPC,QAAQ,QACH,iCAAgC;AAEvC,wEAAwE;AACxE,gFAAgF;AAChF,SACEC,kBAAkB,EAClBC,cAAc,EACdC,iBAAiB,EACjBC,gBAAgB,QACX,2BAA0B;AAEjC,SACEC,sBAAsB,EACtBC,qBAAqB,EACrBC,gBAAgB,EAChBC,iBAAiB,EACjBC,oBAAoB,QACf,2BAA0B;AAEjC,SAASC,SAAS,QAAQ,iCAAgC;AAC1D,SAASC,iBAAiB,EAAEC,YAAY,QAAQ,iCAAgC"}
|
||||
+3
-2
@@ -1,6 +1,7 @@
|
||||
import type { Field } from 'payload';
|
||||
/**
|
||||
* Analytics configuration — GA4 measurement ID and GTM container ID.
|
||||
* IDs are public (exposed client-side), so no read restriction needed.
|
||||
* Analytics / marketing tag IDs. All are PUBLIC (exposed client-side), so no
|
||||
* read restriction. Google tags (GA4/GTM) use Consent Mode; the rest load only
|
||||
* after the matching consent category is granted (see modules/analytics).
|
||||
*/
|
||||
export declare const analyticsFields: Field[];
|
||||
|
||||
+37
-4
@@ -1,12 +1,13 @@
|
||||
/**
|
||||
* Analytics configuration — GA4 measurement ID and GTM container ID.
|
||||
* IDs are public (exposed client-side), so no read restriction needed.
|
||||
* Analytics / marketing tag IDs. All are PUBLIC (exposed client-side), so no
|
||||
* read restriction. Google tags (GA4/GTM) use Consent Mode; the rest load only
|
||||
* after the matching consent category is granted (see modules/analytics).
|
||||
*/ export const analyticsFields = [
|
||||
{
|
||||
name: 'ga4MeasurementId',
|
||||
type: 'text',
|
||||
admin: {
|
||||
description: 'Google Analytics 4 Measurement ID.',
|
||||
description: 'Google Analytics 4 Measurement ID. (Google — Consent Mode)',
|
||||
placeholder: 'G-XXXXXXXXXX'
|
||||
}
|
||||
},
|
||||
@@ -14,9 +15,41 @@
|
||||
name: 'gtmContainerId',
|
||||
type: 'text',
|
||||
admin: {
|
||||
description: 'Google Tag Manager container ID.',
|
||||
description: 'Google Tag Manager container ID. (Google — Consent Mode)',
|
||||
placeholder: 'GTM-XXXXXXX'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'metaPixelId',
|
||||
type: 'text',
|
||||
admin: {
|
||||
description: 'Meta (Facebook) Pixel ID. Loads only after MARKETING consent.',
|
||||
placeholder: '1234567890123456'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'clarityProjectId',
|
||||
type: 'text',
|
||||
admin: {
|
||||
description: 'Microsoft Clarity project ID (heatmaps). Loads only after ANALYTICS consent.',
|
||||
placeholder: 'abcdefghij'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'linkedInPartnerId',
|
||||
type: 'text',
|
||||
admin: {
|
||||
description: 'LinkedIn Insight Tag partner ID. Loads only after MARKETING consent.',
|
||||
placeholder: '1234567'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'tiktokPixelId',
|
||||
type: 'text',
|
||||
admin: {
|
||||
description: 'TikTok Pixel ID. Loads only after MARKETING consent.',
|
||||
placeholder: 'CXXXXXXXXXXXXXXXXXXX'
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"sources":["../../../../src/globals/SiteIntegrations/fields/analytics.ts"],"sourcesContent":["import type { Field } from 'payload'\n\n/**\n * Analytics configuration — GA4 measurement ID and GTM container ID.\n * IDs are public (exposed client-side), so no read restriction needed.\n */\nexport const analyticsFields: Field[] = [\n {\n name: 'ga4MeasurementId',\n type: 'text',\n admin: {\n description: 'Google Analytics 4 Measurement ID.',\n placeholder: 'G-XXXXXXXXXX',\n },\n },\n {\n name: 'gtmContainerId',\n type: 'text',\n admin: {\n description: 'Google Tag Manager container ID.',\n placeholder: 'GTM-XXXXXXX',\n },\n },\n]\n"],"names":["analyticsFields","name","type","admin","description","placeholder"],"mappings":"AAEA;;;CAGC,GACD,OAAO,MAAMA,kBAA2B;IACtC;QACEC,MAAM;QACNC,MAAM;QACNC,OAAO;YACLC,aAAa;YACbC,aAAa;QACf;IACF;IACA;QACEJ,MAAM;QACNC,MAAM;QACNC,OAAO;YACLC,aAAa;YACbC,aAAa;QACf;IACF;CACD,CAAA"}
|
||||
{"version":3,"sources":["../../../../src/globals/SiteIntegrations/fields/analytics.ts"],"sourcesContent":["import type { Field } from 'payload'\n\n/**\n * Analytics / marketing tag IDs. All are PUBLIC (exposed client-side), so no\n * read restriction. Google tags (GA4/GTM) use Consent Mode; the rest load only\n * after the matching consent category is granted (see modules/analytics).\n */\nexport const analyticsFields: Field[] = [\n {\n name: 'ga4MeasurementId',\n type: 'text',\n admin: {\n description: 'Google Analytics 4 Measurement ID. (Google — Consent Mode)',\n placeholder: 'G-XXXXXXXXXX',\n },\n },\n {\n name: 'gtmContainerId',\n type: 'text',\n admin: {\n description: 'Google Tag Manager container ID. (Google — Consent Mode)',\n placeholder: 'GTM-XXXXXXX',\n },\n },\n {\n name: 'metaPixelId',\n type: 'text',\n admin: {\n description: 'Meta (Facebook) Pixel ID. Loads only after MARKETING consent.',\n placeholder: '1234567890123456',\n },\n },\n {\n name: 'clarityProjectId',\n type: 'text',\n admin: {\n description: 'Microsoft Clarity project ID (heatmaps). Loads only after ANALYTICS consent.',\n placeholder: 'abcdefghij',\n },\n },\n {\n name: 'linkedInPartnerId',\n type: 'text',\n admin: {\n description: 'LinkedIn Insight Tag partner ID. Loads only after MARKETING consent.',\n placeholder: '1234567',\n },\n },\n {\n name: 'tiktokPixelId',\n type: 'text',\n admin: {\n description: 'TikTok Pixel ID. Loads only after MARKETING consent.',\n placeholder: 'CXXXXXXXXXXXXXXXXXXX',\n },\n },\n]\n"],"names":["analyticsFields","name","type","admin","description","placeholder"],"mappings":"AAEA;;;;CAIC,GACD,OAAO,MAAMA,kBAA2B;IACtC;QACEC,MAAM;QACNC,MAAM;QACNC,OAAO;YACLC,aAAa;YACbC,aAAa;QACf;IACF;IACA;QACEJ,MAAM;QACNC,MAAM;QACNC,OAAO;YACLC,aAAa;YACbC,aAAa;QACf;IACF;IACA;QACEJ,MAAM;QACNC,MAAM;QACNC,OAAO;YACLC,aAAa;YACbC,aAAa;QACf;IACF;IACA;QACEJ,MAAM;QACNC,MAAM;QACNC,OAAO;YACLC,aAAa;YACbC,aAAa;QACf;IACF;IACA;QACEJ,MAAM;QACNC,MAAM;QACNC,OAAO;YACLC,aAAa;YACbC,aAAa;QACf;IACF;IACA;QACEJ,MAAM;QACNC,MAAM;QACNC,OAAO;YACLC,aAAa;YACbC,aAAa;QACf;IACF;CACD,CAAA"}
|
||||
Vendored
+1
-1
@@ -7,7 +7,7 @@ export { getAnalyticsConfig } from './modules/analytics/index.js';
|
||||
export { ACCEPT_ALL_CONSENT, CONSENT_CATEGORIES, CONSENT_COOKIE, CONSENT_MAX_AGE, CONSENT_VERSION, DEFAULT_CONSENT, getConsentTexts, parseConsent, REJECT_ALL_CONSENT, serializeConsent, setDefaultConsent, updateConsent, } from './modules/consent/index.js';
|
||||
export type { ConsentCategory, ConsentState, ConsentTexts } from './modules/consent/index.js';
|
||||
export type { ContentCollectionOption, ContentOption, ResolvedRoute, } from './modules/content/index.js';
|
||||
export { archiveFieldName, blocksToMarkdown, buildArchivePath, buildEntryPath, createMarkdownRenderer, createSearchRoute, getArchiveEntries, MARKDOWN_PREFIX, markdownHref, markdownResponse, parsePageParam, prefersMarkdown, resolveRedirect, resolveRoute, searchContent, } from './modules/content/index.js';
|
||||
export { archiveFieldName, blocksToMarkdown, buildArchivePath, buildEntryPath, createMarkdownRenderer, createSearchRoute, getArchiveEntries, MARKDOWN_PREFIX, markdownHref, markdownResponse, parsePageParam, prefersMarkdown, resolveNotFoundPage, resolveRedirect, resolveRoute, searchContent, } from './modules/content/index.js';
|
||||
export type { ArchiveEntries } from './modules/content/index.js';
|
||||
export type { SearchResult } from './modules/content/index.js';
|
||||
export { graphAdapter } from './modules/email/graphAdapter.js';
|
||||
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@ export { adminOnly, adminOnlyField, adminOrEditor, adminOrEditorField, adminOrSe
|
||||
export { A11Y_COOKIE, A11Y_DEFAULT, a11yAttributes, parseA11y, serializeA11y } from './modules/accessibility/index.js';
|
||||
export { getAnalyticsConfig } from './modules/analytics/index.js';
|
||||
export { ACCEPT_ALL_CONSENT, CONSENT_CATEGORIES, CONSENT_COOKIE, CONSENT_MAX_AGE, CONSENT_VERSION, DEFAULT_CONSENT, getConsentTexts, parseConsent, REJECT_ALL_CONSENT, serializeConsent, setDefaultConsent, updateConsent } from './modules/consent/index.js';
|
||||
export { archiveFieldName, blocksToMarkdown, buildArchivePath, buildEntryPath, createMarkdownRenderer, createSearchRoute, getArchiveEntries, MARKDOWN_PREFIX, markdownHref, markdownResponse, parsePageParam, prefersMarkdown, resolveRedirect, resolveRoute, searchContent } from './modules/content/index.js';
|
||||
export { archiveFieldName, blocksToMarkdown, buildArchivePath, buildEntryPath, createMarkdownRenderer, createSearchRoute, getArchiveEntries, MARKDOWN_PREFIX, markdownHref, markdownResponse, parsePageParam, prefersMarkdown, resolveNotFoundPage, resolveRedirect, resolveRoute, searchContent } from './modules/content/index.js';
|
||||
export { graphAdapter } from './modules/email/graphAdapter.js';
|
||||
export { mailAdapter } from './modules/email/mailAdapter.js';
|
||||
// Imported straight from the file, NOT from ./modules/email/index.js — that
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+32
-9
@@ -4,16 +4,39 @@ declare global {
|
||||
dataLayer?: unknown[];
|
||||
}
|
||||
}
|
||||
export type AnalyticsProps = {
|
||||
/**
|
||||
* Core Web Vitals mode: hold back every tag's NETWORK load until the first
|
||||
* user interaction (scroll, pointer, touch, key) or `deferTimeoutMs` after the
|
||||
* window `load` event — whichever comes first. Keeps ~100+ KiB of third-party
|
||||
* JS out of the FCP/LCP window.
|
||||
*
|
||||
* Consent is unaffected: the Consent Mode default is still pushed immediately
|
||||
* (a synchronous dataLayer push, no network), and non-Google pixels still
|
||||
* require their consent category. Defer changes WHEN a tag loads, never WHETHER.
|
||||
*
|
||||
* Trade-off: visitors who leave before interacting and before the timeout are
|
||||
* not counted (slightly fewer sessions in GA). Default false.
|
||||
*/
|
||||
defer?: boolean;
|
||||
/** Fallback delay after window `load`, in ms. Default 3500. */
|
||||
deferTimeoutMs?: number;
|
||||
} & AnalyticsConfig;
|
||||
/**
|
||||
* Loads Google Analytics — GTM if a container ID is set, otherwise GA4 gtag.
|
||||
* Loads every configured analytics / marketing tag, each respecting consent:
|
||||
*
|
||||
* Consent Mode is initialised to the visitor's stored consent BEFORE the tag
|
||||
* loads (via setDefaultConsent from the consent module), so tags respect the
|
||||
* choice from the first hit; useConsent sends an update the moment the visitor
|
||||
* decides. IDs are public and come from SiteIntegrations, passed in as props
|
||||
* (the client project reads them server-side).
|
||||
* - **Google (GA4 / GTM)** — Consent Mode: the visitor's stored choice is set as
|
||||
* the default BEFORE the tag loads (always immediately, even with `defer`),
|
||||
* and useConsent pushes an update the moment they decide. GTM wins if both
|
||||
* IDs are set.
|
||||
* - **Non-Google (Meta Pixel, Clarity, LinkedIn, TikTok)** — no Consent Mode, so
|
||||
* each loads ONLY after its category is granted (marketing for
|
||||
* Pixel/LinkedIn/TikTok, analytics for Clarity). Reacts live to the banner.
|
||||
* - **`defer`** (opt-in) — additionally waits for first interaction / idle
|
||||
* after load, for better LCP/INP. See AnalyticsProps.defer.
|
||||
*
|
||||
* Renders nothing — it only injects the scripts. Mount once, high in the tree
|
||||
* (e.g. root layout), inside ConsentProvider.
|
||||
* All IDs are public and come from SiteIntegrations (getAnalyticsConfig), passed
|
||||
* in as props. Renders nothing. Mount once, high in the tree, INSIDE
|
||||
* <ConsentProvider> (required — it reads live consent state).
|
||||
*/
|
||||
export declare function Analytics({ ga4MeasurementId, gtmContainerId }: AnalyticsConfig): null;
|
||||
export declare function Analytics(props: AnalyticsProps): null;
|
||||
|
||||
Vendored
+129
-17
@@ -1,7 +1,9 @@
|
||||
'use client';
|
||||
import { useEffect } from 'react';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { useConsentContext } from '../consent/client.js';
|
||||
import { gtag } from '../consent/googleConsent.js';
|
||||
import { CONSENT_COOKIE, DEFAULT_CONSENT, parseConsent, setDefaultConsent } from '../consent/index.js';
|
||||
import { loadClarity, loadLinkedIn, loadMetaPixel, loadTikTok } from './pixels.js';
|
||||
const GTM_SCRIPT = (id)=>`https://www.googletagmanager.com/gtm.js?id=${id}`;
|
||||
const GA4_SCRIPT = (id)=>`https://www.googletagmanager.com/gtag/js?id=${id}`;
|
||||
/** Reads the current consent state from cookie, or defaults if none. */ function readConsent() {
|
||||
@@ -20,25 +22,106 @@ function injectScript(src) {
|
||||
s.async = true;
|
||||
document.head.appendChild(s);
|
||||
}
|
||||
/**
|
||||
* Loads Google Analytics — GTM if a container ID is set, otherwise GA4 gtag.
|
||||
*
|
||||
* Consent Mode is initialised to the visitor's stored consent BEFORE the tag
|
||||
* loads (via setDefaultConsent from the consent module), so tags respect the
|
||||
* choice from the first hit; useConsent sends an update the moment the visitor
|
||||
* decides. IDs are public and come from SiteIntegrations, passed in as props
|
||||
* (the client project reads them server-side).
|
||||
*
|
||||
* Renders nothing — it only injects the scripts. Mount once, high in the tree
|
||||
* (e.g. root layout), inside ConsentProvider.
|
||||
*/ export function Analytics({ ga4MeasurementId, gtmContainerId }) {
|
||||
const INTERACTION_EVENTS = [
|
||||
'scroll',
|
||||
'pointerdown',
|
||||
'touchstart',
|
||||
'keydown'
|
||||
];
|
||||
/** True once third-party tags may load (immediately, or per `defer` rules). */ function useDeferredReady(defer, timeoutMs) {
|
||||
const [ready, setReady] = useState(!defer);
|
||||
useEffect(()=>{
|
||||
if (!defer || ready) {
|
||||
return;
|
||||
}
|
||||
let timer;
|
||||
const fire = ()=>setReady(true);
|
||||
const onLoad = ()=>{
|
||||
timer = setTimeout(()=>{
|
||||
if ('requestIdleCallback' in window) {
|
||||
window.requestIdleCallback(fire, {
|
||||
timeout: 1000
|
||||
});
|
||||
} else {
|
||||
fire();
|
||||
}
|
||||
}, timeoutMs);
|
||||
};
|
||||
for (const e of INTERACTION_EVENTS){
|
||||
window.addEventListener(e, fire, {
|
||||
once: true,
|
||||
passive: true
|
||||
});
|
||||
}
|
||||
if (document.readyState === 'complete') {
|
||||
onLoad();
|
||||
} else {
|
||||
window.addEventListener('load', onLoad, {
|
||||
once: true
|
||||
});
|
||||
}
|
||||
return ()=>{
|
||||
for (const e of INTERACTION_EVENTS){
|
||||
window.removeEventListener(e, fire);
|
||||
}
|
||||
window.removeEventListener('load', onLoad);
|
||||
if (timer) {
|
||||
clearTimeout(timer);
|
||||
}
|
||||
};
|
||||
}, [
|
||||
defer,
|
||||
ready,
|
||||
timeoutMs
|
||||
]);
|
||||
return ready;
|
||||
}
|
||||
/**
|
||||
* Loads every configured analytics / marketing tag, each respecting consent:
|
||||
*
|
||||
* - **Google (GA4 / GTM)** — Consent Mode: the visitor's stored choice is set as
|
||||
* the default BEFORE the tag loads (always immediately, even with `defer`),
|
||||
* and useConsent pushes an update the moment they decide. GTM wins if both
|
||||
* IDs are set.
|
||||
* - **Non-Google (Meta Pixel, Clarity, LinkedIn, TikTok)** — no Consent Mode, so
|
||||
* each loads ONLY after its category is granted (marketing for
|
||||
* Pixel/LinkedIn/TikTok, analytics for Clarity). Reacts live to the banner.
|
||||
* - **`defer`** (opt-in) — additionally waits for first interaction / idle
|
||||
* after load, for better LCP/INP. See AnalyticsProps.defer.
|
||||
*
|
||||
* All IDs are public and come from SiteIntegrations (getAnalyticsConfig), passed
|
||||
* in as props. Renders nothing. Mount once, high in the tree, INSIDE
|
||||
* <ConsentProvider> (required — it reads live consent state).
|
||||
*/ export function Analytics(props) {
|
||||
const { clarityProjectId, defer = false, deferTimeoutMs = 3500, ga4MeasurementId, gtmContainerId, linkedInPartnerId, metaPixelId, tiktokPixelId } = props;
|
||||
// Live consent state — drives the non-Google pixels.
|
||||
const { state } = useConsentContext();
|
||||
const ready = useDeferredReady(defer, deferTimeoutMs);
|
||||
const defaultConsentSet = useRef(false);
|
||||
// --- Consent Mode default: immediately, once — never deferred ---
|
||||
// No network cost, and it must precede any gtag('config') / GTM start, or
|
||||
// Google assumes "granted".
|
||||
useEffect(()=>{
|
||||
if (defaultConsentSet.current) {
|
||||
return;
|
||||
}
|
||||
if (!ga4MeasurementId && !gtmContainerId) {
|
||||
return;
|
||||
}
|
||||
// 1. Consent Mode default = the visitor's stored choice, before tags load.
|
||||
setDefaultConsent(readConsent());
|
||||
// 2. Load the tag.
|
||||
defaultConsentSet.current = true;
|
||||
}, [
|
||||
ga4MeasurementId,
|
||||
gtmContainerId
|
||||
]);
|
||||
// --- Google: load once `ready`; Consent Mode handles gating ---
|
||||
useEffect(()=>{
|
||||
if (!ready) {
|
||||
return;
|
||||
}
|
||||
if (!ga4MeasurementId && !gtmContainerId) {
|
||||
return;
|
||||
}
|
||||
if (gtmContainerId) {
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
window.dataLayer.push({
|
||||
@@ -48,15 +131,44 @@ function injectScript(src) {
|
||||
injectScript(GTM_SCRIPT(gtmContainerId));
|
||||
} else if (ga4MeasurementId) {
|
||||
injectScript(GA4_SCRIPT(ga4MeasurementId));
|
||||
// Uses the shared gtag (pushes `arguments`, as Google's tags expect);
|
||||
// real gtag.js wires itself up once the script loads.
|
||||
gtag('js', new Date());
|
||||
gtag('config', ga4MeasurementId);
|
||||
}
|
||||
}, [
|
||||
ready,
|
||||
ga4MeasurementId,
|
||||
gtmContainerId
|
||||
]);
|
||||
// --- Non-Google: each when `ready` AND its consent category is granted ---
|
||||
// Loaders are idempotent, so re-running on state changes is safe; a tag loads
|
||||
// the first time both conditions hold and never doubles up.
|
||||
useEffect(()=>{
|
||||
if (!ready) {
|
||||
return;
|
||||
}
|
||||
if (state.marketing) {
|
||||
if (metaPixelId) {
|
||||
loadMetaPixel(metaPixelId);
|
||||
}
|
||||
if (linkedInPartnerId) {
|
||||
loadLinkedIn(linkedInPartnerId);
|
||||
}
|
||||
if (tiktokPixelId) {
|
||||
loadTikTok(tiktokPixelId);
|
||||
}
|
||||
}
|
||||
if (state.analytics && clarityProjectId) {
|
||||
loadClarity(clarityProjectId);
|
||||
}
|
||||
}, [
|
||||
ready,
|
||||
state.marketing,
|
||||
state.analytics,
|
||||
metaPixelId,
|
||||
linkedInPartnerId,
|
||||
tiktokPixelId,
|
||||
clarityProjectId
|
||||
]);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+2
@@ -1,2 +1,4 @@
|
||||
export { Analytics } from './Analytics.js';
|
||||
export type { AnalyticsProps } from './Analytics.js';
|
||||
export { loadClarity, loadLinkedIn, loadMetaPixel, loadTikTok } from './pixels.js';
|
||||
export { pushDataLayer } from './pushDataLayer.js';
|
||||
|
||||
Vendored
+3
@@ -1,5 +1,8 @@
|
||||
'use client';
|
||||
export { Analytics } from './Analytics.js';
|
||||
// Low-level pixel loaders — exported for manual conversion events if a project
|
||||
// needs them (Analytics loads them automatically, consent-gated).
|
||||
export { loadClarity, loadLinkedIn, loadMetaPixel, loadTikTok } from './pixels.js';
|
||||
export { pushDataLayer } from './pushDataLayer.js';
|
||||
|
||||
//# sourceMappingURL=client.js.map
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"sources":["../../../src/modules/analytics/client.ts"],"sourcesContent":["'use client'\nexport { Analytics } from './Analytics.js'\nexport { pushDataLayer } from './pushDataLayer.js'\n"],"names":["Analytics","pushDataLayer"],"mappings":"AAAA;AACA,SAASA,SAAS,QAAQ,iBAAgB;AAC1C,SAASC,aAAa,QAAQ,qBAAoB"}
|
||||
{"version":3,"sources":["../../../src/modules/analytics/client.ts"],"sourcesContent":["'use client'\nexport { Analytics } from './Analytics.js'\nexport type { AnalyticsProps } from './Analytics.js'\n// Low-level pixel loaders — exported for manual conversion events if a project\n// needs them (Analytics loads them automatically, consent-gated).\nexport { loadClarity, loadLinkedIn, loadMetaPixel, loadTikTok } from './pixels.js'\nexport { pushDataLayer } from './pushDataLayer.js'\n"],"names":["Analytics","loadClarity","loadLinkedIn","loadMetaPixel","loadTikTok","pushDataLayer"],"mappings":"AAAA;AACA,SAASA,SAAS,QAAQ,iBAAgB;AAE1C,+EAA+E;AAC/E,kEAAkE;AAClE,SAASC,WAAW,EAAEC,YAAY,EAAEC,aAAa,EAAEC,UAAU,QAAQ,cAAa;AAClF,SAASC,aAAa,QAAQ,qBAAoB"}
|
||||
+2
-3
@@ -1,9 +1,8 @@
|
||||
import type { BasePayload } from 'payload';
|
||||
import type { AnalyticsConfig } from './types.js';
|
||||
/**
|
||||
* Reads the public analytics IDs from SiteIntegrations, server-side.
|
||||
*
|
||||
* Returns only the two public IDs (GA4 / GTM) — safe to pass to the client
|
||||
* Reads the public analytics / marketing tag IDs from SiteIntegrations,
|
||||
* server-side. All are public (exposed client-side), so safe to pass to the
|
||||
* <Analytics> component. Does NOT expose any secret from SiteIntegrations.
|
||||
*/
|
||||
export declare function getAnalyticsConfig(payload: BasePayload): Promise<AnalyticsConfig>;
|
||||
|
||||
+7
-4
@@ -1,14 +1,17 @@
|
||||
import { getSiteIntegrations } from '../payload/index.js';
|
||||
/**
|
||||
* Reads the public analytics IDs from SiteIntegrations, server-side.
|
||||
*
|
||||
* Returns only the two public IDs (GA4 / GTM) — safe to pass to the client
|
||||
* Reads the public analytics / marketing tag IDs from SiteIntegrations,
|
||||
* server-side. All are public (exposed client-side), so safe to pass to the
|
||||
* <Analytics> component. Does NOT expose any secret from SiteIntegrations.
|
||||
*/ export async function getAnalyticsConfig(payload) {
|
||||
const integrations = await getSiteIntegrations(payload);
|
||||
return {
|
||||
clarityProjectId: integrations.clarityProjectId ?? null,
|
||||
ga4MeasurementId: integrations.ga4MeasurementId ?? null,
|
||||
gtmContainerId: integrations.gtmContainerId ?? null
|
||||
gtmContainerId: integrations.gtmContainerId ?? null,
|
||||
linkedInPartnerId: integrations.linkedInPartnerId ?? null,
|
||||
metaPixelId: integrations.metaPixelId ?? null,
|
||||
tiktokPixelId: integrations.tiktokPixelId ?? null
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"sources":["../../../src/modules/analytics/getAnalyticsConfig.ts"],"sourcesContent":["import type { BasePayload } from 'payload'\n\nimport type { AnalyticsConfig } from './types.js'\n\nimport { getSiteIntegrations } from '../payload/index.js'\n\n/**\n * Reads the public analytics IDs from SiteIntegrations, server-side.\n *\n * Returns only the two public IDs (GA4 / GTM) — safe to pass to the client\n * <Analytics> component. Does NOT expose any secret from SiteIntegrations.\n */\nexport async function getAnalyticsConfig(payload: BasePayload): Promise<AnalyticsConfig> {\n const integrations = await getSiteIntegrations<AnalyticsConfig>(payload)\n return {\n ga4MeasurementId: integrations.ga4MeasurementId ?? null,\n gtmContainerId: integrations.gtmContainerId ?? null,\n }\n}\n"],"names":["getSiteIntegrations","getAnalyticsConfig","payload","integrations","ga4MeasurementId","gtmContainerId"],"mappings":"AAIA,SAASA,mBAAmB,QAAQ,sBAAqB;AAEzD;;;;;CAKC,GACD,OAAO,eAAeC,mBAAmBC,OAAoB;IAC3D,MAAMC,eAAe,MAAMH,oBAAqCE;IAChE,OAAO;QACLE,kBAAkBD,aAAaC,gBAAgB,IAAI;QACnDC,gBAAgBF,aAAaE,cAAc,IAAI;IACjD;AACF"}
|
||||
{"version":3,"sources":["../../../src/modules/analytics/getAnalyticsConfig.ts"],"sourcesContent":["import type { BasePayload } from 'payload'\n\nimport type { AnalyticsConfig } from './types.js'\n\nimport { getSiteIntegrations } from '../payload/index.js'\n\n/**\n * Reads the public analytics / marketing tag IDs from SiteIntegrations,\n * server-side. All are public (exposed client-side), so safe to pass to the\n * <Analytics> component. Does NOT expose any secret from SiteIntegrations.\n */\nexport async function getAnalyticsConfig(payload: BasePayload): Promise<AnalyticsConfig> {\n const integrations = await getSiteIntegrations<AnalyticsConfig>(payload)\n return {\n clarityProjectId: integrations.clarityProjectId ?? null,\n ga4MeasurementId: integrations.ga4MeasurementId ?? null,\n gtmContainerId: integrations.gtmContainerId ?? null,\n linkedInPartnerId: integrations.linkedInPartnerId ?? null,\n metaPixelId: integrations.metaPixelId ?? null,\n tiktokPixelId: integrations.tiktokPixelId ?? null,\n }\n}\n"],"names":["getSiteIntegrations","getAnalyticsConfig","payload","integrations","clarityProjectId","ga4MeasurementId","gtmContainerId","linkedInPartnerId","metaPixelId","tiktokPixelId"],"mappings":"AAIA,SAASA,mBAAmB,QAAQ,sBAAqB;AAEzD;;;;CAIC,GACD,OAAO,eAAeC,mBAAmBC,OAAoB;IAC3D,MAAMC,eAAe,MAAMH,oBAAqCE;IAChE,OAAO;QACLE,kBAAkBD,aAAaC,gBAAgB,IAAI;QACnDC,kBAAkBF,aAAaE,gBAAgB,IAAI;QACnDC,gBAAgBH,aAAaG,cAAc,IAAI;QAC/CC,mBAAmBJ,aAAaI,iBAAiB,IAAI;QACrDC,aAAaL,aAAaK,WAAW,IAAI;QACzCC,eAAeN,aAAaM,aAAa,IAAI;IAC/C;AACF"}
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Loaders for non-Google marketing/analytics pixels. Each is idempotent (guards
|
||||
* against double-init) and loads the vendor's own script + bootstrap.
|
||||
*
|
||||
* These are the one place `any` is unavoidable: vendor SDK bootstraps attach
|
||||
* untyped globals (fbq, clarity, lintrk, ttq) to `window`. Casts are contained
|
||||
* here; nothing else in the kit uses `any`.
|
||||
*
|
||||
* CONSENT: these vendors have no Google Consent Mode — the caller (Analytics)
|
||||
* loads each ONLY after the matching consent category is granted:
|
||||
* Meta Pixel / LinkedIn / TikTok → marketing
|
||||
* Microsoft Clarity → analytics
|
||||
*/
|
||||
/** Meta (Facebook) Pixel — fires PageView on load. */
|
||||
export declare function loadMetaPixel(id: string): void;
|
||||
/** Microsoft Clarity — heatmaps / session recordings (analytics category). */
|
||||
export declare function loadClarity(id: string): void;
|
||||
/** LinkedIn Insight Tag (marketing). */
|
||||
export declare function loadLinkedIn(partnerId: string): void;
|
||||
/** TikTok Pixel (marketing) — fires page view on load. */
|
||||
export declare function loadTikTok(id: string): void;
|
||||
Vendored
+134
@@ -0,0 +1,134 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */ /**
|
||||
* Loaders for non-Google marketing/analytics pixels. Each is idempotent (guards
|
||||
* against double-init) and loads the vendor's own script + bootstrap.
|
||||
*
|
||||
* These are the one place `any` is unavoidable: vendor SDK bootstraps attach
|
||||
* untyped globals (fbq, clarity, lintrk, ttq) to `window`. Casts are contained
|
||||
* here; nothing else in the kit uses `any`.
|
||||
*
|
||||
* CONSENT: these vendors have no Google Consent Mode — the caller (Analytics)
|
||||
* loads each ONLY after the matching consent category is granted:
|
||||
* Meta Pixel / LinkedIn / TikTok → marketing
|
||||
* Microsoft Clarity → analytics
|
||||
*/ /** Meta (Facebook) Pixel — fires PageView on load. */ export function loadMetaPixel(id) {
|
||||
if (typeof window === 'undefined') {
|
||||
return;
|
||||
}
|
||||
const w = window;
|
||||
if (w.fbq) {
|
||||
return;
|
||||
}
|
||||
const n = w.fbq = function(...args) {
|
||||
if (n.callMethod) {
|
||||
n.callMethod.apply(n, args);
|
||||
} else {
|
||||
n.queue.push(args);
|
||||
}
|
||||
};
|
||||
if (!w._fbq) {
|
||||
w._fbq = n;
|
||||
}
|
||||
n.push = n;
|
||||
n.loaded = true;
|
||||
n.version = '2.0';
|
||||
n.queue = [];
|
||||
const s = document.createElement('script');
|
||||
s.async = true;
|
||||
s.src = 'https://connect.facebook.net/en_US/fbevents.js';
|
||||
document.head.appendChild(s);
|
||||
w.fbq('init', id);
|
||||
w.fbq('track', 'PageView');
|
||||
}
|
||||
/** Microsoft Clarity — heatmaps / session recordings (analytics category). */ export function loadClarity(id) {
|
||||
if (typeof window === 'undefined') {
|
||||
return;
|
||||
}
|
||||
const w = window;
|
||||
if (w.clarity) {
|
||||
return;
|
||||
}
|
||||
w.clarity = function(...a) {
|
||||
;
|
||||
(w.clarity.q = w.clarity.q || []).push(a);
|
||||
};
|
||||
const s = document.createElement('script');
|
||||
s.async = true;
|
||||
s.src = `https://www.clarity.ms/tag/${id}`;
|
||||
document.head.appendChild(s);
|
||||
}
|
||||
/** LinkedIn Insight Tag (marketing). */ export function loadLinkedIn(partnerId) {
|
||||
if (typeof window === 'undefined') {
|
||||
return;
|
||||
}
|
||||
const w = window;
|
||||
w._linkedin_partner_id = partnerId;
|
||||
w._linkedin_data_partner_ids = w._linkedin_data_partner_ids || [];
|
||||
if (w._linkedin_data_partner_ids.includes(partnerId)) {
|
||||
if (document.getElementById('ipal-linkedin-insight')) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
w._linkedin_data_partner_ids.push(partnerId);
|
||||
}
|
||||
if (document.getElementById('ipal-linkedin-insight')) {
|
||||
return;
|
||||
}
|
||||
const s = document.createElement('script');
|
||||
s.async = true;
|
||||
s.id = 'ipal-linkedin-insight';
|
||||
s.src = 'https://snap.licdn.com/li.lms-analytics/insight.min.js';
|
||||
document.head.appendChild(s);
|
||||
}
|
||||
/** TikTok Pixel (marketing) — fires page view on load. */ export function loadTikTok(id) {
|
||||
if (typeof window === 'undefined') {
|
||||
return;
|
||||
}
|
||||
const w = window;
|
||||
if (w.ttq) {
|
||||
return;
|
||||
}
|
||||
w.TiktokAnalyticsObject = 'ttq';
|
||||
const ttq = w.ttq = [];
|
||||
ttq.methods = [
|
||||
'page',
|
||||
'track',
|
||||
'identify',
|
||||
'instances',
|
||||
'debug',
|
||||
'on',
|
||||
'off',
|
||||
'once',
|
||||
'ready',
|
||||
'alias',
|
||||
'group',
|
||||
'enableCookie',
|
||||
'disableCookie'
|
||||
];
|
||||
ttq.setAndDefer = function(t, e) {
|
||||
t[e] = function(...args) {
|
||||
t.push([
|
||||
e,
|
||||
...args
|
||||
]);
|
||||
};
|
||||
};
|
||||
for (const m of ttq.methods){
|
||||
ttq.setAndDefer(ttq, m);
|
||||
}
|
||||
ttq.load = function(e) {
|
||||
const url = 'https://analytics.tiktok.com/i18n/pixel/events.js';
|
||||
ttq._i = ttq._i || {};
|
||||
ttq._i[e] = [];
|
||||
ttq._i[e]._u = url;
|
||||
ttq._t = ttq._t || {};
|
||||
ttq._t[e] = Number(new Date());
|
||||
const s = document.createElement('script');
|
||||
s.async = true;
|
||||
s.src = `${url}?sdkid=${e}&lib=ttq`;
|
||||
document.head.appendChild(s);
|
||||
};
|
||||
ttq.load(id);
|
||||
ttq.page();
|
||||
}
|
||||
|
||||
//# sourceMappingURL=pixels.js.map
|
||||
Vendored
+1
File diff suppressed because one or more lines are too long
Vendored
+13
-3
@@ -1,9 +1,19 @@
|
||||
/**
|
||||
* Analytics IDs, read from SiteIntegrations (public — safe on the client).
|
||||
* Analytics / marketing tag IDs, read from SiteIntegrations (all public — safe
|
||||
* on the client). Google tags (GA4/GTM) use Consent Mode; the rest load only
|
||||
* after the matching consent category is granted (see Analytics).
|
||||
*/
|
||||
export type AnalyticsConfig = {
|
||||
/** GA4 Measurement ID, e.g. 'G-XXXXXXXXXX'. */
|
||||
/** Microsoft Clarity project ID. (analytics consent) */
|
||||
clarityProjectId?: null | string;
|
||||
/** GA4 Measurement ID, e.g. 'G-XXXXXXXXXX'. (Google — Consent Mode) */
|
||||
ga4MeasurementId?: null | string;
|
||||
/** GTM Container ID, e.g. 'GTM-XXXXXXX'. */
|
||||
/** GTM Container ID, e.g. 'GTM-XXXXXXX'. (Google — Consent Mode) */
|
||||
gtmContainerId?: null | string;
|
||||
/** LinkedIn Insight Tag partner ID. (marketing consent) */
|
||||
linkedInPartnerId?: null | string;
|
||||
/** Meta (Facebook) Pixel ID, ~15–16 digits. (marketing consent) */
|
||||
metaPixelId?: null | string;
|
||||
/** TikTok Pixel ID. (marketing consent) */
|
||||
tiktokPixelId?: null | string;
|
||||
};
|
||||
|
||||
Vendored
+3
-1
@@ -1,5 +1,7 @@
|
||||
/**
|
||||
* Analytics IDs, read from SiteIntegrations (public — safe on the client).
|
||||
* Analytics / marketing tag IDs, read from SiteIntegrations (all public — safe
|
||||
* on the client). Google tags (GA4/GTM) use Consent Mode; the rest load only
|
||||
* after the matching consent category is granted (see Analytics).
|
||||
*/ export { };
|
||||
|
||||
//# sourceMappingURL=types.js.map
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"sources":["../../../src/modules/analytics/types.ts"],"sourcesContent":["/**\n * Analytics IDs, read from SiteIntegrations (public — safe on the client).\n */\nexport type AnalyticsConfig = {\n /** GA4 Measurement ID, e.g. 'G-XXXXXXXXXX'. */\n ga4MeasurementId?: null | string\n /** GTM Container ID, e.g. 'GTM-XXXXXXX'. */\n gtmContainerId?: null | string\n}\n"],"names":[],"mappings":"AAAA;;CAEC,GACD,WAKC"}
|
||||
{"version":3,"sources":["../../../src/modules/analytics/types.ts"],"sourcesContent":["/**\n * Analytics / marketing tag IDs, read from SiteIntegrations (all public — safe\n * on the client). Google tags (GA4/GTM) use Consent Mode; the rest load only\n * after the matching consent category is granted (see Analytics).\n */\nexport type AnalyticsConfig = {\n /** Microsoft Clarity project ID. (analytics consent) */\n clarityProjectId?: null | string\n /** GA4 Measurement ID, e.g. 'G-XXXXXXXXXX'. (Google — Consent Mode) */\n ga4MeasurementId?: null | string\n /** GTM Container ID, e.g. 'GTM-XXXXXXX'. (Google — Consent Mode) */\n gtmContainerId?: null | string\n /** LinkedIn Insight Tag partner ID. (marketing consent) */\n linkedInPartnerId?: null | string\n /** Meta (Facebook) Pixel ID, ~15–16 digits. (marketing consent) */\n metaPixelId?: null | string\n /** TikTok Pixel ID. (marketing consent) */\n tiktokPixelId?: null | string\n}\n"],"names":[],"mappings":"AAAA;;;;CAIC,GACD,WAaC"}
|
||||
+19
-12
@@ -17,29 +17,36 @@
|
||||
* set, nothing is forced.
|
||||
*/
|
||||
type BrandingProps = {
|
||||
/** SiteSettings global slug. Default 'site-settings'. */
|
||||
settingsSlug?: string;
|
||||
/** Field holding the site name. Default 'siteName'. */
|
||||
nameField?: string;
|
||||
/** Upload field to render as the image. Default 'logo' (Logo) / 'favicon' (Icon). */
|
||||
imageField?: string;
|
||||
/** Field holding the site name. Default 'siteName'. */
|
||||
nameField?: string;
|
||||
/** SiteSettings global slug. Default 'site-settings'. */
|
||||
settingsSlug?: string;
|
||||
};
|
||||
/** Admin panel logo (login screen + nav). SiteSettings `logo`, falls back to `siteName`. */
|
||||
/**
|
||||
* Admin panel logo — this is the LARGE logo on the login / unauthorized screens
|
||||
* (Payload uses `graphics.Icon` for the small nav glyph). SiteSettings `logo`,
|
||||
* falls back to `siteName` text. Sized generously for the login screen.
|
||||
*/
|
||||
export declare function AdminLogo(props?: BrandingProps): Promise<import("react/jsx-runtime").JSX.Element | null>;
|
||||
/** Admin panel icon (small nav glyph). SiteSettings `favicon`, falls back to initials. */
|
||||
export declare function AdminIcon(props?: BrandingProps): Promise<import("react/jsx-runtime").JSX.Element | null>;
|
||||
/**
|
||||
* Discreet vendor credit shown at the bottom of the admin nav: "Technology by
|
||||
* Intecion.com". This is the PLUGIN VENDOR's credit (Intecion ships ipal-kit),
|
||||
* not client data — so a sensible default here is fine and A0-safe. The client's
|
||||
* own brand still owns the logo/name above (AdminLogo); this is a small line
|
||||
* stating who provides the technology. Text/URL overridable; turn it off with
|
||||
* `whiteLabel: { credit: false }`.
|
||||
* Discreet vendor credit: "Technology supported by Intecion.com". This is the
|
||||
* PLUGIN VENDOR's credit (Intecion ships ipal-kit, the framework), not client
|
||||
* data — a sensible default here is fine and A0-safe. The client's own brand
|
||||
* still owns the logo/name; this is a small line stating who supports the tech.
|
||||
* Text/URL overridable; turn it off with `whiteLabel: { credit: false }`.
|
||||
*
|
||||
* Wired by ipalKit into admin.components.afterNavLinks.
|
||||
* Wired by ipalKit into admin.components.afterNavLinks (nav) AND afterLogin
|
||||
* (login screen footer). `variant` adjusts placement:
|
||||
* - 'nav' → left-aligned line under the nav links
|
||||
* - 'login' → centered line below the login form
|
||||
*/
|
||||
export declare function IntecionCredit(props?: {
|
||||
text?: string;
|
||||
url?: string;
|
||||
variant?: 'login' | 'nav';
|
||||
}): import("react/jsx-runtime").JSX.Element;
|
||||
export {};
|
||||
|
||||
+61
-40
@@ -26,76 +26,97 @@ async function loadBranding(settingsSlug, nameField, imageField) {
|
||||
};
|
||||
}
|
||||
}
|
||||
/** Admin panel logo (login screen + nav). SiteSettings `logo`, falls back to `siteName`. */ export async function AdminLogo(props = {}) {
|
||||
const { settingsSlug = 'site-settings', nameField = 'siteName', imageField = 'logo' } = props;
|
||||
/**
|
||||
* Admin panel logo — this is the LARGE logo on the login / unauthorized screens
|
||||
* (Payload uses `graphics.Icon` for the small nav glyph). SiteSettings `logo`,
|
||||
* falls back to `siteName` text. Sized generously for the login screen.
|
||||
*/ export async function AdminLogo(props = {}) {
|
||||
const { imageField = 'logo', nameField = 'siteName', settingsSlug = 'site-settings' } = props;
|
||||
const { name, url } = await loadBranding(settingsSlug, nameField, imageField);
|
||||
if (url) {
|
||||
return /*#__PURE__*/ _jsx("img", {
|
||||
src: url,
|
||||
alt: name ?? '',
|
||||
src: url,
|
||||
style: {
|
||||
maxHeight: 60,
|
||||
maxWidth: 240,
|
||||
width: 'auto',
|
||||
height: 'auto'
|
||||
height: 'auto',
|
||||
maxHeight: 120,
|
||||
maxWidth: 420,
|
||||
width: 'auto'
|
||||
}
|
||||
});
|
||||
}
|
||||
if (name) return /*#__PURE__*/ _jsx("div", {
|
||||
style: {
|
||||
fontSize: '1.5rem',
|
||||
fontWeight: 600
|
||||
},
|
||||
children: name
|
||||
});
|
||||
if (name) {
|
||||
return /*#__PURE__*/ _jsx("div", {
|
||||
style: {
|
||||
fontSize: '2rem',
|
||||
fontWeight: 600
|
||||
},
|
||||
children: name
|
||||
});
|
||||
}
|
||||
return null // nothing configured → Payload's default
|
||||
;
|
||||
}
|
||||
/** Admin panel icon (small nav glyph). SiteSettings `favicon`, falls back to initials. */ export async function AdminIcon(props = {}) {
|
||||
const { settingsSlug = 'site-settings', nameField = 'siteName', imageField = 'favicon' } = props;
|
||||
const { imageField = 'favicon', nameField = 'siteName', settingsSlug = 'site-settings' } = props;
|
||||
const { name, url } = await loadBranding(settingsSlug, nameField, imageField);
|
||||
if (url) {
|
||||
return /*#__PURE__*/ _jsx("img", {
|
||||
src: url,
|
||||
alt: name ?? '',
|
||||
src: url,
|
||||
style: {
|
||||
height: 'auto',
|
||||
maxHeight: 28,
|
||||
maxWidth: 28,
|
||||
width: 'auto',
|
||||
height: 'auto'
|
||||
width: 'auto'
|
||||
}
|
||||
});
|
||||
}
|
||||
if (name) return /*#__PURE__*/ _jsx("div", {
|
||||
style: {
|
||||
fontWeight: 700
|
||||
},
|
||||
children: name.slice(0, 2).toUpperCase()
|
||||
});
|
||||
if (name) {
|
||||
return /*#__PURE__*/ _jsx("div", {
|
||||
style: {
|
||||
fontWeight: 700
|
||||
},
|
||||
children: name.slice(0, 2).toUpperCase()
|
||||
});
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Discreet vendor credit shown at the bottom of the admin nav: "Technology by
|
||||
* Intecion.com". This is the PLUGIN VENDOR's credit (Intecion ships ipal-kit),
|
||||
* not client data — so a sensible default here is fine and A0-safe. The client's
|
||||
* own brand still owns the logo/name above (AdminLogo); this is a small line
|
||||
* stating who provides the technology. Text/URL overridable; turn it off with
|
||||
* `whiteLabel: { credit: false }`.
|
||||
* Discreet vendor credit: "Technology supported by Intecion.com". This is the
|
||||
* PLUGIN VENDOR's credit (Intecion ships ipal-kit, the framework), not client
|
||||
* data — a sensible default here is fine and A0-safe. The client's own brand
|
||||
* still owns the logo/name; this is a small line stating who supports the tech.
|
||||
* Text/URL overridable; turn it off with `whiteLabel: { credit: false }`.
|
||||
*
|
||||
* Wired by ipalKit into admin.components.afterNavLinks.
|
||||
* Wired by ipalKit into admin.components.afterNavLinks (nav) AND afterLogin
|
||||
* (login screen footer). `variant` adjusts placement:
|
||||
* - 'nav' → left-aligned line under the nav links
|
||||
* - 'login' → centered line below the login form
|
||||
*/ export function IntecionCredit(props = {}) {
|
||||
const { text = 'Technology by Intecion.com', url = 'https://intecion.com' } = props;
|
||||
const { text = 'Technology supported by Intecion.com', url = 'https://intecion.com', variant = 'nav' } = props;
|
||||
const style = variant === 'login' ? {
|
||||
color: 'inherit',
|
||||
display: 'block',
|
||||
fontSize: '0.75rem',
|
||||
marginTop: '2rem',
|
||||
opacity: 0.6,
|
||||
padding: '0.5rem',
|
||||
textAlign: 'center',
|
||||
textDecoration: 'none'
|
||||
} : {
|
||||
color: 'inherit',
|
||||
display: 'block',
|
||||
fontSize: '0.75rem',
|
||||
opacity: 0.6,
|
||||
padding: '0.75rem 1rem',
|
||||
textDecoration: 'none'
|
||||
};
|
||||
return /*#__PURE__*/ _jsx("a", {
|
||||
href: url,
|
||||
target: "_blank",
|
||||
rel: "noopener noreferrer",
|
||||
style: {
|
||||
display: 'block',
|
||||
padding: '0.75rem 1rem',
|
||||
fontSize: '0.75rem',
|
||||
opacity: 0.6,
|
||||
textDecoration: 'none'
|
||||
},
|
||||
style: style,
|
||||
target: "_blank",
|
||||
children: text
|
||||
});
|
||||
}
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
@@ -6,6 +6,7 @@ export { getArchiveEntries } from './getArchiveEntries.js';
|
||||
export type { ArchiveEntries } from './getArchiveEntries.js';
|
||||
export { MARKDOWN_PREFIX, markdownHref, prefersMarkdown } from './markdownNegotiation.js';
|
||||
export { buildArchivePath, buildEntryPath, parsePageParam } from './paths.js';
|
||||
export { resolveNotFoundPage } from './resolveNotFoundPage.js';
|
||||
export { resolveRedirect } from './resolveRedirect.js';
|
||||
export { resolveRoute } from './resolveRoute.js';
|
||||
export type { ResolvedRoute } from './resolveRoute.js';
|
||||
|
||||
Vendored
+1
@@ -5,6 +5,7 @@ export { createSearchRoute } from './createSearchRoute.js';
|
||||
export { getArchiveEntries } from './getArchiveEntries.js';
|
||||
export { MARKDOWN_PREFIX, markdownHref, prefersMarkdown } from './markdownNegotiation.js';
|
||||
export { buildArchivePath, buildEntryPath, parsePageParam } from './paths.js';
|
||||
export { resolveNotFoundPage } from './resolveNotFoundPage.js';
|
||||
export { resolveRedirect } from './resolveRedirect.js';
|
||||
export { resolveRoute } from './resolveRoute.js';
|
||||
export { searchContent } from './searchContent.js';
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"sources":["../../../src/modules/content/index.ts"],"sourcesContent":["export { buildArchiveFields } from './archiveFields.js'\nexport { blocksToMarkdown } from './blocksToMarkdown.js'\nexport { createMarkdownRenderer, markdownResponse } from './createMarkdownRenderer.js'\nexport { createSearchRoute } from './createSearchRoute.js'\nexport { getArchiveEntries } from './getArchiveEntries.js'\nexport type { ArchiveEntries } from './getArchiveEntries.js'\nexport { MARKDOWN_PREFIX, markdownHref, prefersMarkdown } from './markdownNegotiation.js'\nexport { buildArchivePath, buildEntryPath, parsePageParam } from './paths.js'\nexport { resolveRedirect } from './resolveRedirect.js'\nexport { resolveRoute } from './resolveRoute.js'\nexport type { ResolvedRoute } from './resolveRoute.js'\nexport { searchContent } from './searchContent.js'\nexport type { SearchResult } from './searchContent.js'\nexport type { ContentCollectionOption, ContentOption } from './types.js'\nexport { archiveFieldName } from './types.js'\n"],"names":["buildArchiveFields","blocksToMarkdown","createMarkdownRenderer","markdownResponse","createSearchRoute","getArchiveEntries","MARKDOWN_PREFIX","markdownHref","prefersMarkdown","buildArchivePath","buildEntryPath","parsePageParam","resolveRedirect","resolveRoute","searchContent","archiveFieldName"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,qBAAoB;AACvD,SAASC,gBAAgB,QAAQ,wBAAuB;AACxD,SAASC,sBAAsB,EAAEC,gBAAgB,QAAQ,8BAA6B;AACtF,SAASC,iBAAiB,QAAQ,yBAAwB;AAC1D,SAASC,iBAAiB,QAAQ,yBAAwB;AAE1D,SAASC,eAAe,EAAEC,YAAY,EAAEC,eAAe,QAAQ,2BAA0B;AACzF,SAASC,gBAAgB,EAAEC,cAAc,EAAEC,cAAc,QAAQ,aAAY;AAC7E,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,YAAY,QAAQ,oBAAmB;AAEhD,SAASC,aAAa,QAAQ,qBAAoB;AAGlD,SAASC,gBAAgB,QAAQ,aAAY"}
|
||||
{"version":3,"sources":["../../../src/modules/content/index.ts"],"sourcesContent":["export { buildArchiveFields } from './archiveFields.js'\nexport { blocksToMarkdown } from './blocksToMarkdown.js'\nexport { createMarkdownRenderer, markdownResponse } from './createMarkdownRenderer.js'\nexport { createSearchRoute } from './createSearchRoute.js'\nexport { getArchiveEntries } from './getArchiveEntries.js'\nexport type { ArchiveEntries } from './getArchiveEntries.js'\nexport { MARKDOWN_PREFIX, markdownHref, prefersMarkdown } from './markdownNegotiation.js'\nexport { buildArchivePath, buildEntryPath, parsePageParam } from './paths.js'\nexport { resolveNotFoundPage } from './resolveNotFoundPage.js'\nexport { resolveRedirect } from './resolveRedirect.js'\nexport { resolveRoute } from './resolveRoute.js'\nexport type { ResolvedRoute } from './resolveRoute.js'\nexport { searchContent } from './searchContent.js'\nexport type { SearchResult } from './searchContent.js'\nexport type { ContentCollectionOption, ContentOption } from './types.js'\nexport { archiveFieldName } from './types.js'\n"],"names":["buildArchiveFields","blocksToMarkdown","createMarkdownRenderer","markdownResponse","createSearchRoute","getArchiveEntries","MARKDOWN_PREFIX","markdownHref","prefersMarkdown","buildArchivePath","buildEntryPath","parsePageParam","resolveNotFoundPage","resolveRedirect","resolveRoute","searchContent","archiveFieldName"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,qBAAoB;AACvD,SAASC,gBAAgB,QAAQ,wBAAuB;AACxD,SAASC,sBAAsB,EAAEC,gBAAgB,QAAQ,8BAA6B;AACtF,SAASC,iBAAiB,QAAQ,yBAAwB;AAC1D,SAASC,iBAAiB,QAAQ,yBAAwB;AAE1D,SAASC,eAAe,EAAEC,YAAY,EAAEC,eAAe,QAAQ,2BAA0B;AACzF,SAASC,gBAAgB,EAAEC,cAAc,EAAEC,cAAc,QAAQ,aAAY;AAC7E,SAASC,mBAAmB,QAAQ,2BAA0B;AAC9D,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,YAAY,QAAQ,oBAAmB;AAEhD,SAASC,aAAa,QAAQ,qBAAoB;AAGlD,SAASC,gBAAgB,QAAQ,aAAY"}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
import type { BasePayload } from 'payload';
|
||||
type ResolveNotFoundPageArgs = {
|
||||
locale: string;
|
||||
/** Client's Pages collection slug. Defaults to 'pages'. */
|
||||
pagesSlug?: string;
|
||||
payload: BasePayload;
|
||||
/** SiteSettings global slug. Defaults to 'site-settings'. */
|
||||
settingsSlug?: string;
|
||||
};
|
||||
/**
|
||||
* Returns the page the editor assigned as **404 (Not Found)** in System Pages,
|
||||
* fully populated (depth 2, same shape as resolveRoute's pages), or null when
|
||||
* the role is unassigned.
|
||||
*
|
||||
* Used by the project's `not-found.tsx`. The editor decides what a 404 looks
|
||||
* like: a dedicated "Not found" page, or simply the homepage. Null means
|
||||
* "render the project's built-in fallback view".
|
||||
*
|
||||
* Never throws — a missing DB (container build prerendering not-found) or a
|
||||
* deleted page just yields null, so the 404 view can't crash the build.
|
||||
*/
|
||||
export declare function resolveNotFoundPage({ locale, pagesSlug, payload, settingsSlug, }: ResolveNotFoundPageArgs): Promise<null | Record<string, unknown>>;
|
||||
export {};
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* Returns the page the editor assigned as **404 (Not Found)** in System Pages,
|
||||
* fully populated (depth 2, same shape as resolveRoute's pages), or null when
|
||||
* the role is unassigned.
|
||||
*
|
||||
* Used by the project's `not-found.tsx`. The editor decides what a 404 looks
|
||||
* like: a dedicated "Not found" page, or simply the homepage. Null means
|
||||
* "render the project's built-in fallback view".
|
||||
*
|
||||
* Never throws — a missing DB (container build prerendering not-found) or a
|
||||
* deleted page just yields null, so the 404 view can't crash the build.
|
||||
*/ export async function resolveNotFoundPage({ locale, pagesSlug = 'pages', payload, settingsSlug = 'site-settings' }) {
|
||||
try {
|
||||
const settings = await payload.findGlobal({
|
||||
slug: settingsSlug,
|
||||
depth: 0,
|
||||
locale: locale
|
||||
});
|
||||
const rel = settings.notFound;
|
||||
const id = typeof rel === 'string' || typeof rel === 'number' ? rel : rel && typeof rel === 'object' ? rel.id : undefined;
|
||||
if (id === undefined) {
|
||||
return null;
|
||||
}
|
||||
const doc = await payload.findByID({
|
||||
id,
|
||||
collection: pagesSlug,
|
||||
depth: 2,
|
||||
locale: locale
|
||||
});
|
||||
return doc ?? null;
|
||||
} catch (error) {
|
||||
console.warn('[ipal] resolveNotFoundPage: falling back to built-in 404 view:', error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=resolveNotFoundPage.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/modules/content/resolveNotFoundPage.ts"],"sourcesContent":["import type { BasePayload } from 'payload'\n\ntype ResolveNotFoundPageArgs = {\n locale: string\n /** Client's Pages collection slug. Defaults to 'pages'. */\n pagesSlug?: string\n payload: BasePayload\n /** SiteSettings global slug. Defaults to 'site-settings'. */\n settingsSlug?: string\n}\n\n/**\n * Returns the page the editor assigned as **404 (Not Found)** in System Pages,\n * fully populated (depth 2, same shape as resolveRoute's pages), or null when\n * the role is unassigned.\n *\n * Used by the project's `not-found.tsx`. The editor decides what a 404 looks\n * like: a dedicated \"Not found\" page, or simply the homepage. Null means\n * \"render the project's built-in fallback view\".\n *\n * Never throws — a missing DB (container build prerendering not-found) or a\n * deleted page just yields null, so the 404 view can't crash the build.\n */\nexport async function resolveNotFoundPage({\n locale,\n pagesSlug = 'pages',\n payload,\n settingsSlug = 'site-settings',\n}: ResolveNotFoundPageArgs): Promise<null | Record<string, unknown>> {\n try {\n const settings = (await payload.findGlobal({\n slug: settingsSlug as never,\n depth: 0,\n locale: locale as never,\n })) as Record<string, unknown>\n\n const rel = settings.notFound\n const id =\n typeof rel === 'string' || typeof rel === 'number'\n ? rel\n : rel && typeof rel === 'object'\n ? (rel as { id?: number | string }).id\n : undefined\n if (id === undefined) {return null}\n\n const doc = await payload.findByID({\n id,\n collection: pagesSlug as never,\n depth: 2,\n locale: locale as never,\n })\n return (doc as null | Record<string, unknown>) ?? null\n } catch (error) {\n console.warn('[ipal] resolveNotFoundPage: falling back to built-in 404 view:', error)\n return null\n }\n}\n"],"names":["resolveNotFoundPage","locale","pagesSlug","payload","settingsSlug","settings","findGlobal","slug","depth","rel","notFound","id","undefined","doc","findByID","collection","error","console","warn"],"mappings":"AAWA;;;;;;;;;;;CAWC,GACD,OAAO,eAAeA,oBAAoB,EACxCC,MAAM,EACNC,YAAY,OAAO,EACnBC,OAAO,EACPC,eAAe,eAAe,EACN;IACxB,IAAI;QACF,MAAMC,WAAY,MAAMF,QAAQG,UAAU,CAAC;YACzCC,MAAMH;YACNI,OAAO;YACPP,QAAQA;QACV;QAEA,MAAMQ,MAAMJ,SAASK,QAAQ;QAC7B,MAAMC,KACJ,OAAOF,QAAQ,YAAY,OAAOA,QAAQ,WACtCA,MACAA,OAAO,OAAOA,QAAQ,WACpB,AAACA,IAAiCE,EAAE,GACpCC;QACR,IAAID,OAAOC,WAAW;YAAC,OAAO;QAAI;QAElC,MAAMC,MAAM,MAAMV,QAAQW,QAAQ,CAAC;YACjCH;YACAI,YAAYb;YACZM,OAAO;YACPP,QAAQA;QACV;QACA,OAAO,AAACY,OAA0C;IACpD,EAAE,OAAOG,OAAO;QACdC,QAAQC,IAAI,CAAC,kEAAkEF;QAC/E,OAAO;IACT;AACF"}
|
||||
Vendored
+14
@@ -114,6 +114,20 @@ import { archiveFieldName } from './types.js';
|
||||
if (!doc) {
|
||||
return null;
|
||||
}
|
||||
// The page assigned as 404 in System Pages must not be reachable as a normal
|
||||
// 200 URL (/pl/strona-nie-znaleziona) — that's a soft-404 / duplicate. Treat
|
||||
// it as not found, so the route calls notFound() and not-found.tsx renders
|
||||
// that same page with a real 404 status. (If 404 = homepage, the homepage is
|
||||
// served from the root branch above and never reaches here by its own slug
|
||||
// in a way that matters — but guard anyway so we never hide the homepage.)
|
||||
const notFound = settings.notFound;
|
||||
const homepage = settings.homepage;
|
||||
const notFoundId = notFound && typeof notFound === 'object' ? notFound.id : notFound;
|
||||
const homepageId = homepage && typeof homepage === 'object' ? homepage.id : homepage;
|
||||
const docId = doc.id;
|
||||
if (notFoundId != null && notFoundId === docId && notFoundId !== homepageId) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
type: 'page',
|
||||
doc: doc
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
@@ -47,7 +47,7 @@ import { buildLocalizedPath, getDefaultLocale, isValidLocale } from '../i18n/ind
|
||||
if (doc._status && doc._status !== 'published') {
|
||||
continue;
|
||||
}
|
||||
if (doc.meta?.noindex) {
|
||||
if (doc.noindex || doc.meta?.noindex) {
|
||||
continue;
|
||||
}
|
||||
const title = typeof doc.title === 'string' ? doc.title : undefined;
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
@@ -62,6 +62,7 @@ export declare function createContentHelpers({ baseUrl, config, content, i18n, p
|
||||
getCachedPayload: () => Promise<BasePayload>;
|
||||
getConfiguredLocales: () => Promise<string[]>;
|
||||
getEntries: (collection: string, locale: string, page: number, perPage: number) => Promise<ArchiveEntries>;
|
||||
getNotFoundPage: (locale: string) => Promise<Record<string, unknown> | null>;
|
||||
getSettings: (locale: string) => Promise<import("payload").JsonObject>;
|
||||
resolveRoute: (locale: string, segments: string[] | undefined, page: number) => Promise<null | ResolvedRoute>;
|
||||
robots: () => RobotsRules;
|
||||
|
||||
+25
-1
@@ -1,6 +1,6 @@
|
||||
import { getPayload } from 'payload';
|
||||
import { cache } from 'react';
|
||||
import { getArchiveEntries, resolveRoute as resolveRouteRaw } from '../content/index.js';
|
||||
import { getArchiveEntries, resolveNotFoundPage, resolveRoute as resolveRouteRaw } from '../content/index.js';
|
||||
import { buildRobots, buildSitemapEntries } from '../seo/index.js';
|
||||
/**
|
||||
* Bundles the per-request data helpers a frontend needs — the same cached
|
||||
@@ -56,6 +56,24 @@ import { buildRobots, buildSitemapEntries } from '../seo/index.js';
|
||||
settingsSlug
|
||||
});
|
||||
});
|
||||
/**
|
||||
* The page assigned as 404 in System Pages (or null → built-in fallback).
|
||||
* For app/not-found.tsx; never throws. Locale comes from the x-locale header
|
||||
* set by createProxy (not-found.tsx receives no params).
|
||||
*/ const getNotFoundPage = cache(async (locale)=>{
|
||||
try {
|
||||
const payload = await getCachedPayload();
|
||||
return await resolveNotFoundPage({
|
||||
locale,
|
||||
pagesSlug,
|
||||
payload,
|
||||
settingsSlug
|
||||
});
|
||||
} catch {
|
||||
return null // DB unreachable (container build) — fallback view
|
||||
;
|
||||
}
|
||||
});
|
||||
/** One page of a collection's entries, for an archive listing. */ const getEntries = cache(async (collection, locale, page, perPage)=>{
|
||||
const payload = await getCachedPayload();
|
||||
return getArchiveEntries({
|
||||
@@ -154,6 +172,8 @@ import { buildRobots, buildSitemapEntries } from '../seo/index.js';
|
||||
locale: 'all'
|
||||
}).catch(()=>null);
|
||||
const homeId = settings?.homepage?.id;
|
||||
// The assigned 404 page renders via not-found.tsx, never as its own URL.
|
||||
const notFoundId = settings?.notFound?.id !== undefined && settings.notFound.id !== homeId ? settings.notFound.id : undefined;
|
||||
const EXCLUDED = new Set([
|
||||
'404',
|
||||
'500',
|
||||
@@ -177,6 +197,9 @@ import { buildRobots, buildSitemapEntries } from '../seo/index.js';
|
||||
if (raw._status && raw._status !== 'published') {
|
||||
continue;
|
||||
}
|
||||
if (notFoundId !== undefined && raw.id === notFoundId) {
|
||||
continue;
|
||||
}
|
||||
// NOTE: unlike the sitemap, we do NOT skip meta.noindex here. A noindex
|
||||
// page (privacy, cookies, terms) still needs to render — users reach it
|
||||
// from the footer and crawlers read its <meta robots=noindex>. Pre-render
|
||||
@@ -230,6 +253,7 @@ import { buildRobots, buildSitemapEntries } from '../seo/index.js';
|
||||
getCachedPayload,
|
||||
getConfiguredLocales,
|
||||
getEntries,
|
||||
getNotFoundPage,
|
||||
getSettings,
|
||||
resolveRoute,
|
||||
robots,
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+4
-1
@@ -41,9 +41,12 @@
|
||||
status: 200
|
||||
});
|
||||
} catch (err) {
|
||||
// Log the real error for ops; keep the PUBLIC body generic — a 503 with
|
||||
// `db: 'down'` is all an orchestrator needs, and raw DB error text (host,
|
||||
// credentials-in-URL, driver internals) must not leak on a public route.
|
||||
console.warn('[ipal] createHealthRoute: database unreachable:', err);
|
||||
const body = {
|
||||
db: 'down',
|
||||
error: err instanceof Error ? err.message : 'unknown',
|
||||
status: 'error',
|
||||
timestamp: new Date().toISOString(),
|
||||
tookMs: Date.now() - startedAt
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"sources":["../../../src/modules/health/createHealthRoute.ts"],"sourcesContent":["import type { BasePayload } from 'payload'\n\ntype CreateHealthRouteArgs = {\n /**\n * Collection to ping for a real DB round-trip. Default 'pages'. Pick any\n * collection that always exists in the project.\n */\n collection?: string\n /**\n * Optional extra checks merged into the body (e.g. a cache or queue ping).\n * Throwing marks the whole healthcheck unhealthy.\n */\n extra?: () => Promise<Record<string, unknown>>\n /** Same cached accessor the rest of the app uses. */\n getCachedPayload: () => Promise<BasePayload>\n}\n\n/**\n * A liveness/readiness route for Coolify/Docker healthchecks and uptime\n * monitors. Does a real DB round-trip (not just \"process is up\") and returns\n * 200 when reachable, 503 when not — so an orchestrator can restart or hold\n * traffic off a container whose database is down.\n *\n * // app/api/health/route.ts\n * import { createHealthRoute } from '@intecion/ipal-kit'\n * import { getCachedPayload } from '@/lib/content'\n * export const dynamic = 'force-dynamic' // never prerender/cache a healthcheck\n * export const GET = createHealthRoute({ getCachedPayload })\n *\n * Point Coolify's healthcheck at /api/health. Uses the global `Response`\n * (standard in Next route handlers) — no next/server import, peer-dep clean.\n */\nexport function createHealthRoute(args: CreateHealthRouteArgs): () => Promise<Response> {\n const { collection = 'pages', extra, getCachedPayload } = args\n\n return async () => {\n const startedAt = Date.now()\n try {\n const payload = await getCachedPayload()\n // Cheapest real round-trip: ask for at most one row, no population.\n await payload.find({\n collection: collection as never,\n depth: 0,\n limit: 1,\n pagination: false,\n })\n\n const extraData = extra ? await extra() : {}\n const body = {\n db: 'up',\n status: 'ok',\n timestamp: new Date().toISOString(),\n tookMs: Date.now() - startedAt,\n ...extraData,\n }\n return new Response(JSON.stringify(body), {\n headers: { 'cache-control': 'no-store', 'content-type': 'application/json' },\n status: 200,\n })\n } catch (err) {\n const body = {\n db: 'down',\n error: err instanceof Error ? err.message : 'unknown',\n status: 'error',\n timestamp: new Date().toISOString(),\n tookMs: Date.now() - startedAt,\n }\n return new Response(JSON.stringify(body), {\n headers: { 'cache-control': 'no-store', 'content-type': 'application/json' },\n status: 503,\n })\n }\n }\n}\n"],"names":["createHealthRoute","args","collection","extra","getCachedPayload","startedAt","Date","now","payload","find","depth","limit","pagination","extraData","body","db","status","timestamp","toISOString","tookMs","Response","JSON","stringify","headers","err","error","Error","message"],"mappings":"AAiBA;;;;;;;;;;;;;;CAcC,GACD,OAAO,SAASA,kBAAkBC,IAA2B;IAC3D,MAAM,EAAEC,aAAa,OAAO,EAAEC,KAAK,EAAEC,gBAAgB,EAAE,GAAGH;IAE1D,OAAO;QACL,MAAMI,YAAYC,KAAKC,GAAG;QAC1B,IAAI;YACF,MAAMC,UAAU,MAAMJ;YACtB,oEAAoE;YACpE,MAAMI,QAAQC,IAAI,CAAC;gBACjBP,YAAYA;gBACZQ,OAAO;gBACPC,OAAO;gBACPC,YAAY;YACd;YAEA,MAAMC,YAAYV,QAAQ,MAAMA,UAAU,CAAC;YAC3C,MAAMW,OAAO;gBACXC,IAAI;gBACJC,QAAQ;gBACRC,WAAW,IAAIX,OAAOY,WAAW;gBACjCC,QAAQb,KAAKC,GAAG,KAAKF;gBACrB,GAAGQ,SAAS;YACd;YACA,OAAO,IAAIO,SAASC,KAAKC,SAAS,CAACR,OAAO;gBACxCS,SAAS;oBAAE,iBAAiB;oBAAY,gBAAgB;gBAAmB;gBAC3EP,QAAQ;YACV;QACF,EAAE,OAAOQ,KAAK;YACZ,MAAMV,OAAO;gBACXC,IAAI;gBACJU,OAAOD,eAAeE,QAAQF,IAAIG,OAAO,GAAG;gBAC5CX,QAAQ;gBACRC,WAAW,IAAIX,OAAOY,WAAW;gBACjCC,QAAQb,KAAKC,GAAG,KAAKF;YACvB;YACA,OAAO,IAAIe,SAASC,KAAKC,SAAS,CAACR,OAAO;gBACxCS,SAAS;oBAAE,iBAAiB;oBAAY,gBAAgB;gBAAmB;gBAC3EP,QAAQ;YACV;QACF;IACF;AACF"}
|
||||
{"version":3,"sources":["../../../src/modules/health/createHealthRoute.ts"],"sourcesContent":["import type { BasePayload } from 'payload'\n\ntype CreateHealthRouteArgs = {\n /**\n * Collection to ping for a real DB round-trip. Default 'pages'. Pick any\n * collection that always exists in the project.\n */\n collection?: string\n /**\n * Optional extra checks merged into the body (e.g. a cache or queue ping).\n * Throwing marks the whole healthcheck unhealthy.\n */\n extra?: () => Promise<Record<string, unknown>>\n /** Same cached accessor the rest of the app uses. */\n getCachedPayload: () => Promise<BasePayload>\n}\n\n/**\n * A liveness/readiness route for Coolify/Docker healthchecks and uptime\n * monitors. Does a real DB round-trip (not just \"process is up\") and returns\n * 200 when reachable, 503 when not — so an orchestrator can restart or hold\n * traffic off a container whose database is down.\n *\n * // app/api/health/route.ts\n * import { createHealthRoute } from '@intecion/ipal-kit'\n * import { getCachedPayload } from '@/lib/content'\n * export const dynamic = 'force-dynamic' // never prerender/cache a healthcheck\n * export const GET = createHealthRoute({ getCachedPayload })\n *\n * Point Coolify's healthcheck at /api/health. Uses the global `Response`\n * (standard in Next route handlers) — no next/server import, peer-dep clean.\n */\nexport function createHealthRoute(args: CreateHealthRouteArgs): () => Promise<Response> {\n const { collection = 'pages', extra, getCachedPayload } = args\n\n return async () => {\n const startedAt = Date.now()\n try {\n const payload = await getCachedPayload()\n // Cheapest real round-trip: ask for at most one row, no population.\n await payload.find({\n collection: collection as never,\n depth: 0,\n limit: 1,\n pagination: false,\n })\n\n const extraData = extra ? await extra() : {}\n const body = {\n db: 'up',\n status: 'ok',\n timestamp: new Date().toISOString(),\n tookMs: Date.now() - startedAt,\n ...extraData,\n }\n return new Response(JSON.stringify(body), {\n headers: { 'cache-control': 'no-store', 'content-type': 'application/json' },\n status: 200,\n })\n } catch (err) {\n // Log the real error for ops; keep the PUBLIC body generic — a 503 with\n // `db: 'down'` is all an orchestrator needs, and raw DB error text (host,\n // credentials-in-URL, driver internals) must not leak on a public route.\n console.warn('[ipal] createHealthRoute: database unreachable:', err)\n const body = {\n db: 'down',\n status: 'error',\n timestamp: new Date().toISOString(),\n tookMs: Date.now() - startedAt,\n }\n return new Response(JSON.stringify(body), {\n headers: { 'cache-control': 'no-store', 'content-type': 'application/json' },\n status: 503,\n })\n }\n }\n}\n"],"names":["createHealthRoute","args","collection","extra","getCachedPayload","startedAt","Date","now","payload","find","depth","limit","pagination","extraData","body","db","status","timestamp","toISOString","tookMs","Response","JSON","stringify","headers","err","console","warn"],"mappings":"AAiBA;;;;;;;;;;;;;;CAcC,GACD,OAAO,SAASA,kBAAkBC,IAA2B;IAC3D,MAAM,EAAEC,aAAa,OAAO,EAAEC,KAAK,EAAEC,gBAAgB,EAAE,GAAGH;IAE1D,OAAO;QACL,MAAMI,YAAYC,KAAKC,GAAG;QAC1B,IAAI;YACF,MAAMC,UAAU,MAAMJ;YACtB,oEAAoE;YACpE,MAAMI,QAAQC,IAAI,CAAC;gBACjBP,YAAYA;gBACZQ,OAAO;gBACPC,OAAO;gBACPC,YAAY;YACd;YAEA,MAAMC,YAAYV,QAAQ,MAAMA,UAAU,CAAC;YAC3C,MAAMW,OAAO;gBACXC,IAAI;gBACJC,QAAQ;gBACRC,WAAW,IAAIX,OAAOY,WAAW;gBACjCC,QAAQb,KAAKC,GAAG,KAAKF;gBACrB,GAAGQ,SAAS;YACd;YACA,OAAO,IAAIO,SAASC,KAAKC,SAAS,CAACR,OAAO;gBACxCS,SAAS;oBAAE,iBAAiB;oBAAY,gBAAgB;gBAAmB;gBAC3EP,QAAQ;YACV;QACF,EAAE,OAAOQ,KAAK;YACZ,wEAAwE;YACxE,0EAA0E;YAC1E,yEAAyE;YACzEC,QAAQC,IAAI,CAAC,mDAAmDF;YAChE,MAAMV,OAAO;gBACXC,IAAI;gBACJC,QAAQ;gBACRC,WAAW,IAAIX,OAAOY,WAAW;gBACjCC,QAAQb,KAAKC,GAAG,KAAKF;YACvB;YACA,OAAO,IAAIe,SAASC,KAAKC,SAAS,CAACR,OAAO;gBACxCS,SAAS;oBAAE,iBAAiB;oBAAY,gBAAgB;gBAAmB;gBAC3EP,QAAQ;YACV;QACF;IACF;AACF"}
|
||||
Vendored
+5
-1
@@ -190,7 +190,11 @@ export function createMcpRoute(args) {
|
||||
}
|
||||
return rpcResult(id, toolText(`Unknown tool: ${p.name}`, true));
|
||||
} catch (err) {
|
||||
return rpcResult(id, toolText(err instanceof Error ? err.message : 'Tool error', true));
|
||||
// Log the real error server-side; return a GENERIC message to the
|
||||
// (anonymous) caller so internal details — DB schema, host, stack —
|
||||
// never leak over a public endpoint.
|
||||
console.warn('[ipal] createMcpRoute: tool execution failed:', err);
|
||||
return rpcResult(id, toolText('Tool execution failed.', true));
|
||||
}
|
||||
}
|
||||
case 'tools/list':
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+2
@@ -2,12 +2,14 @@ import { ALL_SYSTEM_PAGE_ROLES } from './types.js';
|
||||
/** Admin-facing labels per role. */ const ROLE_LABELS = {
|
||||
cookiePolicy: 'Cookie Policy',
|
||||
homepage: 'Homepage',
|
||||
notFound: '404 (Not Found)',
|
||||
privacyPolicy: 'Privacy Policy',
|
||||
termsOfService: 'Terms of Service'
|
||||
};
|
||||
/** Admin descriptions per role. */ const ROLE_DESCRIPTIONS = {
|
||||
cookiePolicy: 'Page linked from the cookie consent banner.',
|
||||
homepage: 'Page served at the locale root (e.g. /pl, /en).',
|
||||
notFound: 'Page shown for unknown URLs (404). Pick a dedicated "Not found" page, or reuse the homepage. If left empty, the project falls back to its built-in not-found view.',
|
||||
privacyPolicy: 'Page linked as the privacy policy.',
|
||||
termsOfService: 'Page linked as the terms of service / site regulations.'
|
||||
};
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"sources":["../../../src/modules/pages/systemPagesFields.ts"],"sourcesContent":["import type { Field, RelationshipField } from 'payload'\n\nimport type { PagesOption, SystemPageRole } from './types.js'\n\nimport { ALL_SYSTEM_PAGE_ROLES } from './types.js'\n\n/** Admin-facing labels per role. */\nconst ROLE_LABELS: Record<SystemPageRole, string> = {\n cookiePolicy: 'Cookie Policy',\n homepage: 'Homepage',\n privacyPolicy: 'Privacy Policy',\n termsOfService: 'Terms of Service',\n}\n\n/** Admin descriptions per role. */\nconst ROLE_DESCRIPTIONS: Record<SystemPageRole, string> = {\n cookiePolicy: 'Page linked from the cookie consent banner.',\n homepage: 'Page served at the locale root (e.g. /pl, /en).',\n privacyPolicy: 'Page linked as the privacy policy.',\n termsOfService: 'Page linked as the terms of service / site regulations.',\n}\n\n/**\n * Builds one relationship field per configured system-page role.\n *\n * Each field points at the client's Pages collection (via the provided slug)\n * and holds a single document reference. The referenced document's slug is\n * localized, so the same assignment resolves to /pl/strona-glowna and\n * /en/home at runtime — role assignment is locale-agnostic, path resolution\n * is locale-aware (see getSystemPagePath).\n */\nexport function buildSystemPagesFields(pages: PagesOption): Field[] {\n const roles = pages.roles?.length ? pages.roles : [...ALL_SYSTEM_PAGE_ROLES]\n\n return roles.map((role): RelationshipField => ({\n name: role,\n type: 'relationship',\n admin: {\n description: ROLE_DESCRIPTIONS[role],\n },\n label: ROLE_LABELS[role],\n maxDepth: 1,\n relationTo: pages.slug,\n }))\n}\n"],"names":["ALL_SYSTEM_PAGE_ROLES","ROLE_LABELS","cookiePolicy","homepage","privacyPolicy","termsOfService","ROLE_DESCRIPTIONS","buildSystemPagesFields","pages","roles","length","map","role","name","type","admin","description","label","maxDepth","relationTo","slug"],"mappings":"AAIA,SAASA,qBAAqB,QAAQ,aAAY;AAElD,kCAAkC,GAClC,MAAMC,cAA8C;IAClDC,cAAc;IACdC,UAAU;IACVC,eAAe;IACfC,gBAAgB;AAClB;AAEA,iCAAiC,GACjC,MAAMC,oBAAoD;IACxDJ,cAAc;IACdC,UAAU;IACVC,eAAe;IACfC,gBAAgB;AAClB;AAEA;;;;;;;;CAQC,GACD,OAAO,SAASE,uBAAuBC,KAAkB;IACvD,MAAMC,QAAQD,MAAMC,KAAK,EAAEC,SAASF,MAAMC,KAAK,GAAG;WAAIT;KAAsB;IAE5E,OAAOS,MAAME,GAAG,CAAC,CAACC,OAA6B,CAAA;YAC7CC,MAAMD;YACNE,MAAM;YACNC,OAAO;gBACLC,aAAaV,iBAAiB,CAACM,KAAK;YACtC;YACAK,OAAOhB,WAAW,CAACW,KAAK;YACxBM,UAAU;YACVC,YAAYX,MAAMY,IAAI;QACxB,CAAA;AACF"}
|
||||
{"version":3,"sources":["../../../src/modules/pages/systemPagesFields.ts"],"sourcesContent":["import type { Field, RelationshipField } from 'payload'\n\nimport type { PagesOption, SystemPageRole } from './types.js'\n\nimport { ALL_SYSTEM_PAGE_ROLES } from './types.js'\n\n/** Admin-facing labels per role. */\nconst ROLE_LABELS: Record<SystemPageRole, string> = {\n cookiePolicy: 'Cookie Policy',\n homepage: 'Homepage',\n notFound: '404 (Not Found)',\n privacyPolicy: 'Privacy Policy',\n termsOfService: 'Terms of Service',\n}\n\n/** Admin descriptions per role. */\nconst ROLE_DESCRIPTIONS: Record<SystemPageRole, string> = {\n cookiePolicy: 'Page linked from the cookie consent banner.',\n homepage: 'Page served at the locale root (e.g. /pl, /en).',\n notFound:\n 'Page shown for unknown URLs (404). Pick a dedicated \"Not found\" page, or reuse the homepage. If left empty, the project falls back to its built-in not-found view.',\n privacyPolicy: 'Page linked as the privacy policy.',\n termsOfService: 'Page linked as the terms of service / site regulations.',\n}\n\n/**\n * Builds one relationship field per configured system-page role.\n *\n * Each field points at the client's Pages collection (via the provided slug)\n * and holds a single document reference. The referenced document's slug is\n * localized, so the same assignment resolves to /pl/strona-glowna and\n * /en/home at runtime — role assignment is locale-agnostic, path resolution\n * is locale-aware (see getSystemPagePath).\n */\nexport function buildSystemPagesFields(pages: PagesOption): Field[] {\n const roles = pages.roles?.length ? pages.roles : [...ALL_SYSTEM_PAGE_ROLES]\n\n return roles.map((role): RelationshipField => ({\n name: role,\n type: 'relationship',\n admin: {\n description: ROLE_DESCRIPTIONS[role],\n },\n label: ROLE_LABELS[role],\n maxDepth: 1,\n relationTo: pages.slug,\n }))\n}\n"],"names":["ALL_SYSTEM_PAGE_ROLES","ROLE_LABELS","cookiePolicy","homepage","notFound","privacyPolicy","termsOfService","ROLE_DESCRIPTIONS","buildSystemPagesFields","pages","roles","length","map","role","name","type","admin","description","label","maxDepth","relationTo","slug"],"mappings":"AAIA,SAASA,qBAAqB,QAAQ,aAAY;AAElD,kCAAkC,GAClC,MAAMC,cAA8C;IAClDC,cAAc;IACdC,UAAU;IACVC,UAAU;IACVC,eAAe;IACfC,gBAAgB;AAClB;AAEA,iCAAiC,GACjC,MAAMC,oBAAoD;IACxDL,cAAc;IACdC,UAAU;IACVC,UACE;IACFC,eAAe;IACfC,gBAAgB;AAClB;AAEA;;;;;;;;CAQC,GACD,OAAO,SAASE,uBAAuBC,KAAkB;IACvD,MAAMC,QAAQD,MAAMC,KAAK,EAAEC,SAASF,MAAMC,KAAK,GAAG;WAAIV;KAAsB;IAE5E,OAAOU,MAAME,GAAG,CAAC,CAACC,OAA6B,CAAA;YAC7CC,MAAMD;YACNE,MAAM;YACNC,OAAO;gBACLC,aAAaV,iBAAiB,CAACM,KAAK;YACtC;YACAK,OAAOjB,WAAW,CAACY,KAAK;YACxBM,UAAU;YACVC,YAAYX,MAAMY,IAAI;QACxB,CAAA;AACF"}
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
||||
* Built-in "system page" roles — documents from the client's Pages
|
||||
* collection that the site references by function rather than by slug.
|
||||
*/
|
||||
export type SystemPageRole = 'cookiePolicy' | 'homepage' | 'privacyPolicy' | 'termsOfService';
|
||||
export type SystemPageRole = 'cookiePolicy' | 'homepage' | 'notFound' | 'privacyPolicy' | 'termsOfService';
|
||||
/**
|
||||
* All system roles in a stable order (used when no subset is configured).
|
||||
*/
|
||||
|
||||
Vendored
+1
@@ -5,6 +5,7 @@
|
||||
* All system roles in a stable order (used when no subset is configured).
|
||||
*/ export const ALL_SYSTEM_PAGE_ROLES = [
|
||||
'homepage',
|
||||
'notFound',
|
||||
'privacyPolicy',
|
||||
'cookiePolicy',
|
||||
'termsOfService'
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"sources":["../../../src/modules/pages/types.ts"],"sourcesContent":["/**\n * Built-in \"system page\" roles — documents from the client's Pages\n * collection that the site references by function rather than by slug.\n */\nexport type SystemPageRole = 'cookiePolicy' | 'homepage' | 'privacyPolicy' | 'termsOfService'\n\n/**\n * All system roles in a stable order (used when no subset is configured).\n */\nexport const ALL_SYSTEM_PAGE_ROLES: readonly SystemPageRole[] = [\n 'homepage',\n 'privacyPolicy',\n 'cookiePolicy',\n 'termsOfService',\n]\n\n/**\n * Plugin option enabling system-page assignments in SiteSettings.\n *\n * The plugin doesn't own the Pages collection — the client creates it in\n * their own project. This option hands the plugin the collection's slug so\n * it can build relationship fields pointing at it. No hardcoding: the slug\n * always comes from the client.\n */\nexport type PagesOption = {\n /**\n * Which system roles to expose as assignable fields.\n * Defaults to all roles when omitted.\n */\n roles?: SystemPageRole[]\n /** Slug of the client's Pages collection, e.g. 'pages'. */\n slug: string\n}\n"],"names":["ALL_SYSTEM_PAGE_ROLES"],"mappings":"AAAA;;;CAGC,GAGD;;CAEC,GACD,OAAO,MAAMA,wBAAmD;IAC9D;IACA;IACA;IACA;CACD,CAAA"}
|
||||
{"version":3,"sources":["../../../src/modules/pages/types.ts"],"sourcesContent":["/**\n * Built-in \"system page\" roles — documents from the client's Pages\n * collection that the site references by function rather than by slug.\n */\nexport type SystemPageRole =\n 'cookiePolicy' | 'homepage' | 'notFound' | 'privacyPolicy' | 'termsOfService'\n\n/**\n * All system roles in a stable order (used when no subset is configured).\n */\nexport const ALL_SYSTEM_PAGE_ROLES: readonly SystemPageRole[] = [\n 'homepage',\n 'notFound',\n 'privacyPolicy',\n 'cookiePolicy',\n 'termsOfService',\n]\n\n/**\n * Plugin option enabling system-page assignments in SiteSettings.\n *\n * The plugin doesn't own the Pages collection — the client creates it in\n * their own project. This option hands the plugin the collection's slug so\n * it can build relationship fields pointing at it. No hardcoding: the slug\n * always comes from the client.\n */\nexport type PagesOption = {\n /**\n * Which system roles to expose as assignable fields.\n * Defaults to all roles when omitted.\n */\n roles?: SystemPageRole[]\n /** Slug of the client's Pages collection, e.g. 'pages'. */\n slug: string\n}\n"],"names":["ALL_SYSTEM_PAGE_ROLES"],"mappings":"AAAA;;;CAGC,GAID;;CAEC,GACD,OAAO,MAAMA,wBAAmD;IAC9D;IACA;IACA;IACA;IACA;CACD,CAAA"}
|
||||
Vendored
+2
-2
@@ -70,7 +70,7 @@ import { buildLocalizedPath } from '../i18n/index.js';
|
||||
if (raw._status && raw._status !== 'published') {
|
||||
continue;
|
||||
}
|
||||
if (raw.meta?.noindex) {
|
||||
if (raw.noindex || raw.meta?.noindex) {
|
||||
continue;
|
||||
}
|
||||
const title = typeof raw.title === 'string' ? raw.title : undefined;
|
||||
@@ -111,7 +111,7 @@ import { buildLocalizedPath } from '../i18n/index.js';
|
||||
if (raw._status && raw._status !== 'published') {
|
||||
continue;
|
||||
}
|
||||
if (raw.meta?.noindex) {
|
||||
if (raw.noindex || raw.meta?.noindex) {
|
||||
continue;
|
||||
}
|
||||
const title = typeof raw.title === 'string' ? raw.title : undefined;
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+8
-1
@@ -53,6 +53,13 @@ type BuildMetadataArgs = {
|
||||
locale: string;
|
||||
/** SEO meta from the document (plugin-seo group). */
|
||||
meta?: null | SeoMeta;
|
||||
/**
|
||||
* Top-level noindex flag (buildNoindexField). Checked alongside meta.noindex:
|
||||
* plugin-seo's meta group doesn't declare noindex, so a mirror into
|
||||
* meta.noindex is stripped on save — the top-level field is the one that
|
||||
* persists. Either being true emits robots index:false.
|
||||
*/
|
||||
noindex?: boolean | null;
|
||||
/** Page title or site name first. Defaults to 'page-first'. */
|
||||
order?: TitleOrder;
|
||||
/**
|
||||
@@ -98,5 +105,5 @@ type BuildMetadataArgs = {
|
||||
* pieces (meta group, site name, image URL, localized slugs) and passes them
|
||||
* in — the plugin composes, it doesn't fetch.
|
||||
*/
|
||||
export declare function buildMetadata({ baseUrl, config, homeSlug, imageUrl, locale, meta, order, pageTitle, prefix, query, separator, siteDescription, siteName, slugs, }: BuildMetadataArgs): PageMetadata;
|
||||
export declare function buildMetadata({ baseUrl, config, homeSlug, imageUrl, locale, meta, noindex, order, pageTitle, prefix, query, separator, siteDescription, siteName, slugs, }: BuildMetadataArgs): PageMetadata;
|
||||
export {};
|
||||
|
||||
Vendored
+2
-2
@@ -9,7 +9,7 @@ import { buildHreflangAlternates } from './hreflang.js';
|
||||
* Designed for use inside Next.js `generateMetadata`. The caller resolves the
|
||||
* pieces (meta group, site name, image URL, localized slugs) and passes them
|
||||
* in — the plugin composes, it doesn't fetch.
|
||||
*/ export function buildMetadata({ baseUrl, config, homeSlug = 'home', imageUrl, locale, meta, order, pageTitle, prefix, query, separator, siteDescription, siteName, slugs }) {
|
||||
*/ export function buildMetadata({ baseUrl, config, homeSlug = 'home', imageUrl, locale, meta, noindex, order, pageTitle, prefix, query, separator, siteDescription, siteName, slugs }) {
|
||||
// Title source priority: titleOverride (exact, wins outright) > meta.title
|
||||
// (SEO title an editor set) > pageTitle (the document's own name). This means
|
||||
// a page with no SEO title still shows its name (e.g. 'Sprzątanie biur')
|
||||
@@ -83,7 +83,7 @@ import { buildHreflangAlternates } from './hreflang.js';
|
||||
// robots: noindex pages are excluded (follow keeps link authority). Indexed
|
||||
// pages get generous snippet/preview limits so Google can show rich results
|
||||
// (long snippets, large image previews, full video previews).
|
||||
...meta?.noindex ? {
|
||||
...noindex || meta?.noindex ? {
|
||||
robots: {
|
||||
follow: true,
|
||||
index: false
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+12
-15
@@ -2,29 +2,26 @@ import type { CheckboxField, Field } from 'payload';
|
||||
type BuildNoindexFieldArgs = {
|
||||
/** Help text under the checkbox. */
|
||||
description?: string;
|
||||
/** Sidebar label. Default 'Wyklucz z indeksowania (noindex)'. */
|
||||
/** Sidebar label. Default 'Exclude from indexing (noindex)'. */
|
||||
label?: string;
|
||||
/**
|
||||
* Dotted path, inside the document, that the SEO read path (metadata +
|
||||
* sitemap) consumes. Default 'meta.noindex' — the plugin-seo `meta` group.
|
||||
* The checkbox value is mirrored here on every save, so editors toggle one
|
||||
* friendly switch and the machinery reads a stable location.
|
||||
*/
|
||||
metaPath?: string;
|
||||
/** Field name for the editor-facing checkbox. Default 'noindex'. */
|
||||
name?: string;
|
||||
/** Extend/override the generated checkbox (position, access, etc.). */
|
||||
overrides?: Partial<CheckboxField>;
|
||||
};
|
||||
/**
|
||||
* A sidebar `noindex` checkbox that mirrors into `meta.noindex` (what the
|
||||
* sitemap and metadata generators actually read). Replaces the hand-rolled
|
||||
* checkbox + `beforeChange` hook with its `(data as any).meta.noindex = …`
|
||||
* glue copied into every project — no `any`, one source of truth for editors,
|
||||
* one stable read location for the engine.
|
||||
* A top-level sidebar `noindex` checkbox. When ticked, the page is excluded from
|
||||
* `sitemap.xml`, `llms.txt`, site search, and gets `robots: noindex, follow` —
|
||||
* ALL automatically, no per-project filtering.
|
||||
*
|
||||
* Idempotent and order-independent: if either the checkbox OR an existing
|
||||
* `meta.noindex` is set, the page ends up noindex; the two can't drift apart.
|
||||
* Why top-level (not mirrored into `meta.noindex`): plugin-seo's `meta` group
|
||||
* declares only title/description/image, so Payload silently strips any extra
|
||||
* key (`meta.noindex`) during sanitization — an earlier version mirrored there
|
||||
* and the value vanished, leaking noindex pages into the sitemap. The value now
|
||||
* lives on this top-level field, which persists; every reader in the kit
|
||||
* (buildSitemapEntries, buildMetadata/createPageMetadata, buildLlmsTxt,
|
||||
* searchContent) checks `doc.noindex` (and still tolerates a legacy
|
||||
* `meta.noindex`). One field, one source of truth, zero project glue.
|
||||
*
|
||||
* // collections/Pages.ts
|
||||
* import { buildNoindexField } from '@intecion/ipal-kit'
|
||||
|
||||
+13
-47
@@ -1,49 +1,23 @@
|
||||
/** Read a dotted path (e.g. 'meta.noindex') off a loosely-typed object. */ function readPath(obj, path) {
|
||||
let cur = obj;
|
||||
for (const key of path){
|
||||
if (cur == null || typeof cur !== 'object') {
|
||||
return undefined;
|
||||
}
|
||||
cur = cur[key];
|
||||
}
|
||||
return cur;
|
||||
}
|
||||
/** Write a dotted path, creating intermediate objects as needed. */ function writePath(obj, path, value) {
|
||||
let cur = obj;
|
||||
for(let i = 0; i < path.length - 1; i++){
|
||||
const key = path[i];
|
||||
const next = cur[key];
|
||||
if (next == null || typeof next !== 'object') {
|
||||
cur[key] = {};
|
||||
}
|
||||
cur = cur[key];
|
||||
}
|
||||
cur[path[path.length - 1]] = value;
|
||||
}
|
||||
/**
|
||||
* A sidebar `noindex` checkbox that mirrors into `meta.noindex` (what the
|
||||
* sitemap and metadata generators actually read). Replaces the hand-rolled
|
||||
* checkbox + `beforeChange` hook with its `(data as any).meta.noindex = …`
|
||||
* glue copied into every project — no `any`, one source of truth for editors,
|
||||
* one stable read location for the engine.
|
||||
* A top-level sidebar `noindex` checkbox. When ticked, the page is excluded from
|
||||
* `sitemap.xml`, `llms.txt`, site search, and gets `robots: noindex, follow` —
|
||||
* ALL automatically, no per-project filtering.
|
||||
*
|
||||
* Idempotent and order-independent: if either the checkbox OR an existing
|
||||
* `meta.noindex` is set, the page ends up noindex; the two can't drift apart.
|
||||
* Why top-level (not mirrored into `meta.noindex`): plugin-seo's `meta` group
|
||||
* declares only title/description/image, so Payload silently strips any extra
|
||||
* key (`meta.noindex`) during sanitization — an earlier version mirrored there
|
||||
* and the value vanished, leaking noindex pages into the sitemap. The value now
|
||||
* lives on this top-level field, which persists; every reader in the kit
|
||||
* (buildSitemapEntries, buildMetadata/createPageMetadata, buildLlmsTxt,
|
||||
* searchContent) checks `doc.noindex` (and still tolerates a legacy
|
||||
* `meta.noindex`). One field, one source of truth, zero project glue.
|
||||
*
|
||||
* // collections/Pages.ts
|
||||
* import { buildNoindexField } from '@intecion/ipal-kit'
|
||||
* fields: [ /* … *\/ buildNoindexField() ],
|
||||
*/ export function buildNoindexField(args = {}) {
|
||||
const { name = 'noindex', description = 'Check to exclude this page from indexing (robots: noindex, follow) and from sitemap.xml.', label = 'Exclude from indexing (noindex)', metaPath = 'meta.noindex', overrides = {} } = args;
|
||||
const segments = metaPath.split('.');
|
||||
const mirror = ({ data, value })=>{
|
||||
const shouldNoindex = Boolean(value ?? readPath(data, segments));
|
||||
if (data && typeof data === 'object') {
|
||||
writePath(data, segments, shouldNoindex);
|
||||
}
|
||||
return shouldNoindex;
|
||||
};
|
||||
const { admin: adminOverrides, hooks: hooksOverrides, ...restOverrides } = overrides;
|
||||
const { name = 'noindex', description = 'Check to exclude this page from indexing (robots: noindex, follow), the sitemap, llms.txt and site search.', label = 'Exclude from indexing (noindex)', overrides = {} } = args;
|
||||
const { admin: adminOverrides, ...restOverrides } = overrides;
|
||||
return {
|
||||
name,
|
||||
type: 'checkbox',
|
||||
@@ -53,14 +27,6 @@
|
||||
...adminOverrides
|
||||
},
|
||||
defaultValue: false,
|
||||
hooks: {
|
||||
...hooksOverrides,
|
||||
// mirror runs first, then any project-supplied beforeChange hooks.
|
||||
beforeChange: [
|
||||
mirror,
|
||||
...hooksOverrides?.beforeChange ?? []
|
||||
]
|
||||
},
|
||||
label,
|
||||
...restOverrides
|
||||
};
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+5
-1
@@ -29,7 +29,11 @@ import { buildHreflangAlternates } from './hreflang.js';
|
||||
if (doc._status && doc._status !== 'published') {
|
||||
return false;
|
||||
}
|
||||
if (doc.meta?.noindex) {
|
||||
// Check BOTH the top-level checkbox (buildNoindexField, the field that
|
||||
// persists) AND meta.noindex — plugin-seo's meta group doesn't declare
|
||||
// noindex, so a mirror into meta.noindex is stripped on save. Reading both
|
||||
// makes exclusion automatic regardless of where the flag ended up.
|
||||
if (doc.noindex || doc.meta?.noindex) {
|
||||
return false;
|
||||
}
|
||||
if (hasExcludedSlug(doc.slug)) {
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+1
@@ -90,6 +90,7 @@ import { slugsAcrossLocales } from './slugsAcrossLocales.js';
|
||||
...base,
|
||||
imageUrl: resolveOgImage(doc),
|
||||
meta: doc.meta,
|
||||
noindex: doc.noindex,
|
||||
pageTitle: doc.title,
|
||||
prefix,
|
||||
query,
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+41
-22
@@ -62,29 +62,35 @@ import { buildSeoPlugin, injectAutoFillMeta, injectSeoTabs } from './modules/seo
|
||||
if (!tf?.issuer) {
|
||||
throw new Error('[ipal] twoFactor.issuer is required (name shown in the authenticator ' + 'app). Pass twoFactor: { issuer: "Your Site" }, or twoFactor: false to ' + 'opt out (discouraged).');
|
||||
}
|
||||
try {
|
||||
// Dynamic specifier via a variable so TS doesn't try to resolve this
|
||||
// optional peer dependency at build time (it isn't in the plugin's own
|
||||
// node_modules). Avoids TS2307 without @ts-expect-error; the module
|
||||
// exists at runtime in projects that installed it.
|
||||
const pkg = '@clocklimited/payload-2fa';
|
||||
const mod = await import(pkg);
|
||||
// The package exports `payloadTotp`; older/other builds may use
|
||||
// `totpPlugin`. Accept either so a rename doesn't break us.
|
||||
const totp = mod.payloadTotp ?? mod.totpPlugin;
|
||||
if (typeof totp !== 'function') {
|
||||
throw new Error('expected export payloadTotp (or totpPlugin) to be a function — ' + 'check the installed @clocklimited/payload-2fa version');
|
||||
// Prefer the INJECTED plugin factory (recommended): the project imports
|
||||
// payloadTotp from @clocklimited/payload-2fa and passes it in. Then the
|
||||
// plugin never imports the optional peer itself — no dynamic import, so
|
||||
// Next can't fail to bundle it (the cause of "Cannot find module
|
||||
// '@clocklimited/payload-2fa'" crashing even public frontend pages).
|
||||
let totp = tf.plugin;
|
||||
if (!totp) {
|
||||
// Fallback: dynamic import. Variable specifier dodges the plugin's own
|
||||
// TS2307, but Next may NOT trace it into the server bundle — projects
|
||||
// using this path MUST add '@clocklimited/payload-2fa' to
|
||||
// serverExternalPackages in next.config (see docs/security.md).
|
||||
try {
|
||||
const pkg = '@clocklimited/payload-2fa';
|
||||
const mod = await import(pkg);
|
||||
totp = mod.payloadTotp ?? mod.totpPlugin;
|
||||
} catch (err) {
|
||||
throw new Error('[ipal] 2FA is enforced but @clocklimited/payload-2fa could not be loaded. ' + 'Best fix — inject it: `import { payloadTotp } from "@clocklimited/payload-2fa"` ' + 'then `twoFactor: { issuer, plugin: payloadTotp }`. Or install it AND add ' + "'@clocklimited/payload-2fa' to serverExternalPackages in next.config. Or set " + `twoFactor: false to opt out (discouraged). Original error: ${String(err)}`);
|
||||
}
|
||||
config = await totp({
|
||||
collection: tf.collectionSlug ?? 'users',
|
||||
forceSetup: true,
|
||||
totp: {
|
||||
issuer: tf.issuer
|
||||
}
|
||||
})(config);
|
||||
} catch (err) {
|
||||
throw new Error('[ipal] 2FA is enforced but @clocklimited/payload-2fa is not installed. ' + 'Run: pnpm add @clocklimited/payload-2fa — or set twoFactor: false to ' + `opt out (discouraged). Original error: ${String(err)}`);
|
||||
}
|
||||
if (typeof totp !== 'function') {
|
||||
throw new Error('[ipal] 2FA: expected payloadTotp (or totpPlugin) to be a function — check the ' + 'injected `plugin` or the installed @clocklimited/payload-2fa version.');
|
||||
}
|
||||
config = await totp({
|
||||
collection: tf.collectionSlug ?? 'users',
|
||||
forceSetup: true,
|
||||
totp: {
|
||||
issuer: tf.issuer
|
||||
}
|
||||
})(config);
|
||||
}
|
||||
// --- white-label admin branding ---
|
||||
// Inject admin.components.graphics.Logo/Icon pointing at the plugin's
|
||||
@@ -139,11 +145,24 @@ import { buildSeoPlugin, injectAutoFillMeta, injectSeoTabs } from './modules/seo
|
||||
}
|
||||
},
|
||||
...creditOn ? {
|
||||
afterLogin: [
|
||||
...config.admin?.components?.afterLogin ?? [],
|
||||
{
|
||||
path: '@intecion/ipal-kit/admin#IntecionCredit',
|
||||
serverProps: {
|
||||
...creditProps,
|
||||
variant: 'login'
|
||||
}
|
||||
}
|
||||
],
|
||||
afterNavLinks: [
|
||||
...config.admin?.components?.afterNavLinks ?? [],
|
||||
{
|
||||
path: '@intecion/ipal-kit/admin#IntecionCredit',
|
||||
serverProps: creditProps
|
||||
serverProps: {
|
||||
...creditProps,
|
||||
variant: 'nav'
|
||||
}
|
||||
}
|
||||
]
|
||||
} : {}
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+24
-1
@@ -1,4 +1,15 @@
|
||||
import type { Field } from 'payload';
|
||||
import type { Field, Plugin } from 'payload';
|
||||
/**
|
||||
* Factory shape of @clocklimited/payload-2fa's `payloadTotp` export — injected
|
||||
* so the plugin never imports the optional peer itself.
|
||||
*/
|
||||
export type TotpPluginFactory = (options: {
|
||||
collection: string;
|
||||
forceSetup: boolean;
|
||||
totp: {
|
||||
issuer: string;
|
||||
};
|
||||
}) => Plugin;
|
||||
import type { AccessOption } from './modules/access/types.js';
|
||||
import type { ContentOption } from './modules/content/types.js';
|
||||
import type { FormsOption } from './modules/forms/types.js';
|
||||
@@ -71,6 +82,18 @@ export type IpalOptions = {
|
||||
collectionSlug?: string;
|
||||
/** Name shown in the authenticator app (e.g. company/site name). */
|
||||
issuer: string;
|
||||
/**
|
||||
* The 2FA plugin factory, INJECTED from the project:
|
||||
* `import { payloadTotp } from '@clocklimited/payload-2fa'`. Strongly
|
||||
* recommended — injecting it (the same pattern as NextResponse /
|
||||
* revalidatePath) means the plugin never dynamically imports the
|
||||
* optional peer, which Next can fail to bundle into the server chunks
|
||||
* ("Cannot find module '@clocklimited/payload-2fa'" at runtime, even on
|
||||
* public frontend pages). If omitted, the plugin falls back to a dynamic
|
||||
* import and you MUST add '@clocklimited/payload-2fa' to
|
||||
* serverExternalPackages in next.config. See docs/security.md.
|
||||
*/
|
||||
plugin?: TotpPluginFactory;
|
||||
} | false;
|
||||
/**
|
||||
* White-label the admin panel: show the CLIENT's brand (logo + name) in the
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -210,7 +210,7 @@ Wpinaj w kolekcje gdzie dotyczy (patrz `hooks.md`):
|
||||
|
||||
- **buildSecurityHeaders** w next.config — HSTS, COOP, nosniff, Referrer-Policy (z automatu, uniwersalne).
|
||||
- **buildCsp** — generator CSP z twardymi regułami (base-uri, object-src, frame-ancestors). Flagi: turnstile, analytics, youtube, r2Url. Wdrażaj przez `report-only` → sprawdź konsolę → `enforce`.
|
||||
- **2FA WYMUSZONE** — `ipalKit({ twoFactor: { issuer: 'Nazwa Firmy' } })` + `pnpm add @clocklimited/payload-2fa@3.0.0-beta.7`. Wymuszone dla WSZYSTKICH użytkowników (forceSetup), bez opcji wyłączenia per user. NIE ustawiaj `twoFactor: false` (chyba że klient wprost odmawia). Bez zależności = błąd buildu. Patrz security.md.
|
||||
- **2FA WYMUSZONE** — `pnpm add @clocklimited/payload-2fa@3.0.0-beta.7`, potem WSTRZYKNIJ: `import { payloadTotp } from '@clocklimited/payload-2fa'` + `ipalKit({ twoFactor: { issuer: 'Nazwa Firmy', plugin: payloadTotp } })`. Wstrzyknięcie obowiązkowe — bez niego plugin robi dynamiczny import, którego Next nie wbundluje → „Cannot find module" na froncie. (Ewentualnie: `serverExternalPackages: ['@clocklimited/payload-2fa']` w next.config.) Wymuszone dla WSZYSTKICH (forceSetup), bez opcji per user. NIE `twoFactor: false` (chyba że klient wprost odmawia). Patrz security.md.
|
||||
- **Ścieżka panelu** — `ipalKit({ adminRoute: '/its' })` ukrywa panel. WYMAGA przeniesienia folderu `app/(payload)/admin/` → `app/(payload)/its/`. To obscurity, nie security (2FA to prawdziwa ochrona).
|
||||
- CSP zostaje w projekcie (domeny), ale skeleton z pluginu. NIE Trusted Types (psuje Turnstile/GA).
|
||||
|
||||
|
||||
+75
-11
@@ -1,22 +1,58 @@
|
||||
# analytics
|
||||
|
||||
Ładuje GA4 albo Google Tag Manager, spięte z modułem consent: Consent Mode
|
||||
dostaje decyzję odwiedzającego, zanim tag się załaduje, i aktualizację w
|
||||
momencie kliknięcia w banerze.
|
||||
Ładuje tagi analityczne i marketingowe wpisane w panelu, każdy zgodnie ze
|
||||
zgodą z modułu consent:
|
||||
|
||||
- **Google (GA4 / GTM)** — przez Consent Mode v2: tag ładuje się od razu, ale
|
||||
dostaje decyzję odwiedzającego, zanim cokolwiek zmierzy.
|
||||
- **Pozostałe (Meta Pixel, Microsoft Clarity, LinkedIn Insight, TikTok Pixel)** —
|
||||
nie mają Consent Mode, więc ładują się **dopiero po zgodzie** na właściwą
|
||||
kategorię. Reagują na żywo: klik „Akceptuj” → tag startuje bez przeładowania.
|
||||
|
||||
## Config
|
||||
|
||||
Brak opcji w `payload.config` — plugin czyta ID z globala **Site Integrations**
|
||||
(Settings → Site Integrations):
|
||||
|
||||
- **GA4 Measurement ID** — `G-XXXXXXXXXX`
|
||||
- **GTM Container ID** — `GTM-XXXXXXX`
|
||||
| Pole | Format | Kategoria zgody |
|
||||
|---|---|---|
|
||||
| GA4 Measurement ID | `G-XXXXXXXXXX` | Consent Mode (analytics_storage) |
|
||||
| GTM Container ID | `GTM-XXXXXXX` | Consent Mode (wszystkie sygnały) |
|
||||
| Meta Pixel ID | `1234567890123456` | **marketing** |
|
||||
| Microsoft Clarity Project ID | `abcdefghij` | **analytics** |
|
||||
| LinkedIn Partner ID | `1234567` | **marketing** |
|
||||
| TikTok Pixel ID | `CXXXXXXXXXXXXXXXXXXX` | **marketing** |
|
||||
|
||||
Gdy ustawione są oba, wygrywa GTM. Gdy żadne — komponent nie robi nic.
|
||||
GA4 + GTM ustawione jednocześnie → wygrywa GTM. Puste pole = tag się nie ładuje.
|
||||
|
||||
To jedyne pola z Site Integrations, które trafiają na klienta — są publiczne
|
||||
(widać je w źródle każdej strony z GA). `getAnalyticsConfig` czyta wyłącznie je,
|
||||
więc sekrety (Turnstile, SMTP) nie mają jak wyciec.
|
||||
Wszystkie te ID są publiczne (widać je w źródle strony). `getAnalyticsConfig`
|
||||
czyta wyłącznie je, więc sekrety (Turnstile, SMTP) nie mają jak wyciec.
|
||||
|
||||
### Pixel w panelu czy w GTM?
|
||||
|
||||
**Jedno albo drugie, nigdy oba** — inaczej każde zdarzenie liczy się
|
||||
podwójnie. Zasada:
|
||||
|
||||
- Klient bez GTM / prosta strona → wpisz Pixel ID w panelu (najprościej,
|
||||
zgoda obsłużona automatycznie).
|
||||
- Klient ma agencję/marketera, który zarządza tagami w GTM → zostaw pole Pixel
|
||||
puste, Pixel konfiguruje się w GTM z warunkiem `ad_storage` (patrz
|
||||
[gtm-meta-pixel.md](./gtm-meta-pixel.md)).
|
||||
|
||||
### Zdarzenia konwersji (non-Google)
|
||||
|
||||
`Analytics` wysyła tylko `PageView`. Konwersje (np. Lead po formularzu) wołasz
|
||||
sam — globale istnieją dopiero po zgodzie, więc zawsze ze strażnikiem:
|
||||
|
||||
```ts
|
||||
window.fbq?.('track', 'Lead') // Meta
|
||||
window.ttq?.track('SubmitForm') // TikTok
|
||||
window.lintrk?.('track', { conversion_id: 123 }) // LinkedIn
|
||||
```
|
||||
|
||||
Niskopoziomowe loadery (`loadMetaPixel`, `loadClarity`, `loadLinkedIn`,
|
||||
`loadTikTok`) są eksportowane z `/client`, ale normalnie nie są potrzebne —
|
||||
NIE wołaj ich z pominięciem zgody.
|
||||
|
||||
## Front
|
||||
|
||||
@@ -41,7 +77,30 @@ export default async function LocaleLayout({ children, params }) {
|
||||
```
|
||||
|
||||
`Analytics` nie renderuje nic — wstrzykuje skrypty. Zamontuj raz, wysoko w
|
||||
drzewie.
|
||||
drzewie. **Musi być wewnątrz `ConsentProvider`** (od 1.8.0 czyta stan zgody na
|
||||
żywo — poza providerem rzuci błąd kontekstu).
|
||||
|
||||
## Tryb Core Web Vitals — `defer` (opcjonalny)
|
||||
|
||||
```tsx
|
||||
<Analytics {...analytics} defer /> // domyślnie 3500 ms
|
||||
<Analytics {...analytics} defer deferTimeoutMs={5000} />
|
||||
```
|
||||
|
||||
Wszystkie tagi (GA4/GTM i pixele) ładują się z sieci dopiero przy **pierwszej
|
||||
interakcji** (scroll, klik, dotyk, klawisz) albo `deferTimeoutMs` po `load`,
|
||||
w zależności od tego, co nastąpi pierwsze. ~100+ KiB JS wypada z okna FCP/LCP.
|
||||
|
||||
Defer zmienia **kiedy**, nigdy **czy**:
|
||||
- domyślny stan Consent Mode nadal idzie od razu (to tylko push do dataLayer, bez
|
||||
ruchu sieciowego), więc GA nigdy nie startuje bez niego;
|
||||
- pixele non-Google nadal wymagają zgody na swoją kategorię.
|
||||
|
||||
Koszt: odwiedzający, którzy wyjdą przed interakcją i przed upływem timeoutu, nie
|
||||
zostaną policzeni (trochę mniej sesji w GA). Domyślnie `defer` jest wyłączony.
|
||||
|
||||
**Nie kopiuj `Analytics` do projektu, żeby to zmienić.** Brakujące opcje dodajemy
|
||||
w ipal-kit (core = engine).
|
||||
|
||||
## Jak działa Consent Mode
|
||||
|
||||
@@ -68,6 +127,11 @@ W konsoli: `window.dataLayer` — powinien zawierać `Arguments(3)` z `consent`
|
||||
Ciasteczko `_ga` pojawia się dopiero po zgodzie na analytics — to jest sedno
|
||||
Consent Mode.
|
||||
|
||||
Pixele non-Google: przed zgodą w Network **nie może** być żądań do
|
||||
`connect.facebook.net`, `clarity.ms`, `snap.licdn.com`, `analytics.tiktok.com`.
|
||||
Po kliknięciu zgody pojawiają się od razu. Meta Pixel Helper (rozszerzenie
|
||||
Chrome) powinien pokazać `PageView` dopiero po akceptacji marketingu.
|
||||
|
||||
## Zdarzenia do GTM — pushDataLayer
|
||||
|
||||
Do wypchnięcia własnego zdarzenia (np. `form_submit` pod tag Lead w GTM) jest
|
||||
@@ -95,4 +159,4 @@ czysty event, na którym tag może się odpalić, gdy zgoda jest udzielona.
|
||||
Publish, nie sam zapis) tagu GA4 w kontenerze wszystko wygląda dobrze:
|
||||
`gtm.load` w dataLayer, Tag Assistant widzi kontener — a `_ga` nie ma, bo nic go
|
||||
nie tworzy. Przy debugowaniu warto tymczasowo wyczyścić GTM Container ID i
|
||||
zostawić samo GA4, żeby wyeliminować kontener jako zmienną.
|
||||
zostawić samo GA4, żeby wyeliminować kontener jako zmienną.
|
||||
+49
-3
@@ -1,7 +1,7 @@
|
||||
# pages
|
||||
|
||||
System pages: centralne przypisanie ról (homepage / privacyPolicy /
|
||||
cookiePolicy) do dokumentów z klienckiej kolekcji Pages, w SiteSettings.
|
||||
System pages: centralne przypisanie ról (homepage / notFound / privacyPolicy /
|
||||
cookiePolicy / termsOfService) do dokumentów z klienckiej kolekcji Pages, w SiteSettings.
|
||||
Front rozwiązuje rolę na ścieżkę locale-aware.
|
||||
|
||||
## Config (payload.config.ts)
|
||||
@@ -51,9 +51,55 @@ stopce / bannerze cookies bierzesz z `getSystemPagePath({ role: privacyPolicy })
|
||||
|
||||
```ts
|
||||
import { ALL_SYSTEM_PAGE_ROLES } from '@intecion/ipal-kit'
|
||||
// ['homepage', 'privacyPolicy', 'cookiePolicy']
|
||||
// ['homepage', 'notFound', 'privacyPolicy', 'cookiePolicy', 'termsOfService']
|
||||
```
|
||||
|
||||
## Strona 404 — wybierana w panelu (od 1.8.0)
|
||||
|
||||
Site Settings → System Pages → **404 (Not Found)**. Edytor wybiera:
|
||||
|
||||
- dedykowaną stronę „Nie znaleziono” (np. slug `strona-nie-znaleziona`), **albo**
|
||||
- stronę główną (część klientów tak woli), **albo**
|
||||
- nic → projekt pokazuje wbudowany fallback z `not-found.tsx`.
|
||||
|
||||
Projekt (`app/(frontend)/[locale]/not-found.tsx`) — gotowy przykład w
|
||||
`frontend/[locale]/not-found.tsx`:
|
||||
|
||||
```tsx
|
||||
import { headers } from 'next/headers'
|
||||
import { getNotFoundPage } from '@/lib/content' // z createContentHelpers
|
||||
|
||||
export default async function NotFound() {
|
||||
const locale = (await headers()).get('x-locale') ?? i18nConfig.defaultLocale
|
||||
const page = await getNotFoundPage(locale) // null → fallback
|
||||
if (page?.layout?.length) return <RenderBlocks blocks={page.layout} components={blockRegistry} />
|
||||
return <Fallback404 locale={locale} />
|
||||
}
|
||||
```
|
||||
|
||||
`not-found.tsx` nie dostaje `params` — locale bierzemy z nagłówka `x-locale`,
|
||||
który ustawia proxy z `createProxy`. Status HTTP zostaje **404** (renderuje go
|
||||
Next po `notFound()`), treść jest z panelu.
|
||||
|
||||
Co plugin robi automatycznie z przypisaną stroną 404:
|
||||
|
||||
| Miejsce | Zachowanie |
|
||||
|---|---|
|
||||
| `resolveRoute` | bezpośrednie wejście na `/pl/strona-nie-znaleziona` → `null` → `notFound()` → prawdziwy 404 (bez soft-404 / duplikatu z kodem 200) |
|
||||
| sitemap | wykluczona po ID (slug może być dowolny) |
|
||||
| `generateStaticParams` | pominięta (nie jest osobnym URL-em) |
|
||||
| `getNotFoundPage` / `resolveNotFoundPage` | nigdy nie rzuca — brak bazy w buildzie = fallback |
|
||||
|
||||
Gdy 404 = strona główna, nic z powyższego nie ukrywa strony głównej — dalej
|
||||
działa pod `/{locale}` i jest w sitemapie; dodatkowo jej treść pokazuje się pod
|
||||
nieznanymi URL-ami (z kodem 404).
|
||||
|
||||
Bez `createContentHelpers`: `resolveNotFoundPage({ payload, locale })` z
|
||||
`@intecion/ipal-kit`.
|
||||
|
||||
Wskazówka: zaznacz na dedykowanej stronie 404 **noindex** — wtedy wypada też z
|
||||
llms.txt i wyszukiwarki.
|
||||
|
||||
## KRYTYCZNE: generateStaticParams dla [[...slug]] (SEO + head)
|
||||
|
||||
Trasa `[[...slug]]` (opcjonalny catch-all) BEZ `generateStaticParams` jest przez
|
||||
|
||||
+24
-6
@@ -258,23 +258,41 @@ pnpm add @clocklimited/[email protected]
|
||||
Uwaga: pakiet nie ma jeszcze stabilnego 3.0.0 — użyj konkretnej wersji beta
|
||||
(albo `^3.0.0-0`, żeby dopuścić prereleasy). Sam `^3.0.0` da błąd
|
||||
ERR_PNPM_NO_MATCHING_VERSION.
|
||||
To PEER dependency — ipal-kit importuje ją dynamicznie tylko gdy 2FA włączone
|
||||
(domyślnie). Bez niej i z włączonym 2FA plugin rzuci jasny błąd.
|
||||
|
||||
### Konfiguracja (payload.config.ts)
|
||||
### Konfiguracja (payload.config.ts) — WSTRZYKNIJ plugin (zalecane)
|
||||
|
||||
```ts
|
||||
import { payloadTotp } from '@clocklimited/payload-2fa'
|
||||
|
||||
ipalKit({
|
||||
i18n: i18nConfig,
|
||||
twoFactor: {
|
||||
issuer: 'Nazwa Firmy', // pokazywane w aplikacji authenticator (Google Auth itp.)
|
||||
// collectionSlug: 'users', // domyślnie 'users'
|
||||
issuer: 'Nazwa Firmy', // pokazywane w aplikacji authenticator
|
||||
plugin: payloadTotp, // ← WSTRZYKNIJ — patrz niżej dlaczego
|
||||
// collectionSlug: 'users',
|
||||
},
|
||||
})
|
||||
```
|
||||
|
||||
**Dlaczego `plugin: payloadTotp` (wstrzyknięcie):** to ten sam wzorzec co
|
||||
`NextResponse`/`revalidatePath` — projekt podaje peer-dep, plugin go NIE
|
||||
importuje. Bez tego plugin robi dynamiczny import, którego **Next potrafi nie
|
||||
wbundlować** do server chunks → błąd runtime **„Cannot find module
|
||||
'@clocklimited/payload-2fa'"** lecący nawet na publicznych stronach frontu.
|
||||
Wstrzyknięcie eliminuje ten problem u źródła.
|
||||
|
||||
**Jeśli NIE wstrzykujesz** (zostawiasz dynamiczny import) — MUSISZ dodać pakiet do
|
||||
`serverExternalPackages` w `next.config`, żeby Next nie próbował go bundlować:
|
||||
|
||||
```ts
|
||||
// next.config.ts
|
||||
const nextConfig = {
|
||||
serverExternalPackages: ['@clocklimited/payload-2fa'],
|
||||
}
|
||||
```
|
||||
|
||||
Plugin ustawia `forceSetup: true` — każdy użytkownik MUSI skonfigurować TOTP po
|
||||
zalogowaniu (przekierowanie na setup). Nie ma opcji „włącz/wyłącz" dla użytkownika.
|
||||
zalogowaniu. Nie ma opcji „włącz/wyłącz" dla użytkownika.
|
||||
|
||||
### Wyłączenie (ODRADZANE)
|
||||
|
||||
|
||||
+20
-8
@@ -731,9 +731,9 @@ Alternatywnie: dodaj `noindex` do System Pages o rolach prawnych automatycznie.
|
||||
|
||||
### buildNoindexField — przyjazny checkbox w sidebarze
|
||||
|
||||
Zamiast własnego checkboxa + hooka z `(data as any).meta.noindex = …` użyj
|
||||
gotowego pola. Jeden przełącznik dla redaktora, zgrany z `meta.noindex` (to
|
||||
czyta sitemap i metadata), bez `any`, bez rozjazdu między dwoma miejscami:
|
||||
Jeden przełącznik w sidebarze. Zaznaczony → strona **automatycznie** wypada z:
|
||||
`sitemap.xml`, `llms.txt`, wyszukiwarki, i dostaje `robots: noindex, follow` —
|
||||
bez żadnego ręcznego filtrowania w projekcie.
|
||||
|
||||
```ts
|
||||
import { buildNoindexField } from '@intecion/ipal-kit'
|
||||
@@ -743,10 +743,22 @@ export const Pages: CollectionConfig = {
|
||||
}
|
||||
```
|
||||
|
||||
Idempotentne: jeśli ustawiony checkbox LUB istniejące `meta.noindex` — strona
|
||||
wychodzi `noindex`; nie da się ich rozjechać. Opcje: `name` (domyślnie
|
||||
`'noindex'`), `label`, `description`, `metaPath` (domyślnie `'meta.noindex'`),
|
||||
`overrides` (pozycja, access itp.).
|
||||
**Pole jest top-level (`doc.noindex`), NIE mirrorowane do `meta.noindex`.**
|
||||
Dlaczego: grupa `meta` z plugin-seo deklaruje tylko title/description/image, więc
|
||||
Payload przy sanityzacji **po cichu wycina** każdy dodatkowy klucz (`meta.noindex`)
|
||||
— wcześniejsza wersja mirrorowała tam wartość i znikała, przez co strony noindex
|
||||
trafiały do sitemapy. Teraz wartość żyje na polu top-level (które się zapisuje), a
|
||||
wszystkie czytniki kitu (`buildSitemapEntries`, `buildMetadata`/
|
||||
`createPageMetadata`, `buildLlmsTxt`, `searchContent`) sprawdzają `doc.noindex`
|
||||
(oraz, dla zgodności wstecznej, ewentualne `meta.noindex`). Jedno pole, jedno
|
||||
źródło prawdy, zero kleju w projekcie.
|
||||
|
||||
Opcje: `name` (domyślnie `'noindex'`), `label`, `description`, `overrides`
|
||||
(pozycja, access itp.).
|
||||
|
||||
> Naprawione w 1.7.5 — wcześniej (mirror do `meta.noindex`) strony noindex
|
||||
> potrafiły wyciekać do sitemapy. Po aktualizacji `app/sitemap.xml/route.ts`
|
||||
> wraca do czystej jednolinijki, bez ręcznego filtrowania.
|
||||
|
||||
## robots.txt — blokada parametrów (crawl budget)
|
||||
|
||||
@@ -1129,4 +1141,4 @@ const speakable = buildSpeakableJsonLd({
|
||||
W markupie projektu oznacz pasujące elementy (np. `className="speakable"` albo
|
||||
sekcja `.lead` ze streszczeniem). Selektory nietrafiające w nic są ignorowane —
|
||||
nie wskazuj nawigacji ani boilerplate'u, tylko samodzielny, czytelny tekst.
|
||||
Dopełnia Markdown/llms: asystent łatwiej wyciąga kluczową treść strony.
|
||||
Dopełnia Markdown/llms: asystent łatwiej wyciąga kluczową treść strony.
|
||||
+16
-6
@@ -37,20 +37,30 @@ whiteLabel: {
|
||||
}
|
||||
```
|
||||
|
||||
## Kredyt dostawcy — „Technology by Intecion.com"
|
||||
## Kredyt dostawcy — „Technology supported by Intecion.com"
|
||||
|
||||
Pod nawigacją panelu (`afterNavLinks`) wyświetla się dyskretny kredyt
|
||||
**„Technology by Intecion.com"** z linkiem do `https://intecion.com`. To kredyt
|
||||
DOSTAWCY technologii (Intecion dostarcza ipal-kit) — marka klienta nadal rządzi
|
||||
logiem i nazwą u góry; to tylko mała linijka „kto dostarcza technologię".
|
||||
Dyskretny kredyt **„Technology supported by Intecion.com"** (link do
|
||||
`https://intecion.com`) pojawia się w **dwóch miejscach**:
|
||||
- **pod nawigacją** panelu (`afterNavLinks`, wariant `nav` — wyrównany do lewej),
|
||||
- **na dole ekranu logowania** (`afterLogin`, wariant `login` — wyśrodkowany).
|
||||
|
||||
To kredyt DOSTAWCY technologii (Intecion dostarcza framework ipal-kit) — marka
|
||||
klienta nadal rządzi logiem i nazwą; to tylko linijka „kto wspiera technologię".
|
||||
|
||||
Domyślnie włączony z `whiteLabel`. Sterowanie:
|
||||
|
||||
```ts
|
||||
whiteLabel: { credit: false } // ukryj
|
||||
whiteLabel: { credit: false } // ukryj (oba miejsca)
|
||||
whiteLabel: { credit: { text: 'Powered by Intecion', url: 'https://intecion.com' } } // własny tekst/url
|
||||
```
|
||||
|
||||
## Logo na ekranie logowania
|
||||
|
||||
`AdminLogo` to DUŻE logo na ekranie logowania (Payload używa `graphics.Icon` do
|
||||
małej ikony w nawigacji). Renderuje się sporo większe (`maxHeight 120 / maxWidth
|
||||
420`), żeby marka klienta była wyraźna przy logowaniu. Mała ikona nav to `favicon`
|
||||
przez `AdminIcon`.
|
||||
|
||||
## Jak to działa
|
||||
|
||||
- `AdminLogo` / `AdminIcon` to **Server Components** czytające SiteSettings przy
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@intecion/ipal-kit",
|
||||
"version": "1.7.2",
|
||||
"version": "1.7.9",
|
||||
"description": "Intecion Payload Advanced Library — a Payload CMS 3 plugin: i18n, SEO, forms, consent, analytics, blog/archives.",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
|
||||
@@ -8,8 +8,15 @@ export {
|
||||
} from '../modules/accessibility/client.js'
|
||||
export type { A11yClassNames, A11yState, A11yTexts } from '../modules/accessibility/client.js'
|
||||
export { Analytics } from '../modules/analytics/client.js'
|
||||
export { pushDataLayer } from '../modules/analytics/client.js'
|
||||
export type { AnalyticsProps } from '../modules/analytics/client.js'
|
||||
|
||||
export { pushDataLayer } from '../modules/analytics/client.js'
|
||||
export {
|
||||
loadClarity,
|
||||
loadLinkedIn,
|
||||
loadMetaPixel,
|
||||
loadTikTok,
|
||||
} from '../modules/analytics/client.js'
|
||||
/**
|
||||
* Entry point: ipal-kit/client
|
||||
*
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
import type { Field } from 'payload'
|
||||
|
||||
/**
|
||||
* Analytics configuration — GA4 measurement ID and GTM container ID.
|
||||
* IDs are public (exposed client-side), so no read restriction needed.
|
||||
* Analytics / marketing tag IDs. All are PUBLIC (exposed client-side), so no
|
||||
* read restriction. Google tags (GA4/GTM) use Consent Mode; the rest load only
|
||||
* after the matching consent category is granted (see modules/analytics).
|
||||
*/
|
||||
export const analyticsFields: Field[] = [
|
||||
{
|
||||
name: 'ga4MeasurementId',
|
||||
type: 'text',
|
||||
admin: {
|
||||
description: 'Google Analytics 4 Measurement ID.',
|
||||
description: 'Google Analytics 4 Measurement ID. (Google — Consent Mode)',
|
||||
placeholder: 'G-XXXXXXXXXX',
|
||||
},
|
||||
},
|
||||
@@ -17,8 +18,40 @@ export const analyticsFields: Field[] = [
|
||||
name: 'gtmContainerId',
|
||||
type: 'text',
|
||||
admin: {
|
||||
description: 'Google Tag Manager container ID.',
|
||||
description: 'Google Tag Manager container ID. (Google — Consent Mode)',
|
||||
placeholder: 'GTM-XXXXXXX',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'metaPixelId',
|
||||
type: 'text',
|
||||
admin: {
|
||||
description: 'Meta (Facebook) Pixel ID. Loads only after MARKETING consent.',
|
||||
placeholder: '1234567890123456',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'clarityProjectId',
|
||||
type: 'text',
|
||||
admin: {
|
||||
description: 'Microsoft Clarity project ID (heatmaps). Loads only after ANALYTICS consent.',
|
||||
placeholder: 'abcdefghij',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'linkedInPartnerId',
|
||||
type: 'text',
|
||||
admin: {
|
||||
description: 'LinkedIn Insight Tag partner ID. Loads only after MARKETING consent.',
|
||||
placeholder: '1234567',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'tiktokPixelId',
|
||||
type: 'text',
|
||||
admin: {
|
||||
description: 'TikTok Pixel ID. Loads only after MARKETING consent.',
|
||||
placeholder: 'CXXXXXXXXXXXXXXXXXXX',
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
@@ -56,6 +56,7 @@ export {
|
||||
markdownResponse,
|
||||
parsePageParam,
|
||||
prefersMarkdown,
|
||||
resolveNotFoundPage,
|
||||
resolveRedirect,
|
||||
resolveRoute,
|
||||
searchContent,
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
'use client'
|
||||
import { useEffect } from 'react'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
|
||||
import type { AnalyticsConfig } from './types.js'
|
||||
|
||||
import { useConsentContext } from '../consent/client.js'
|
||||
import { gtag } from '../consent/googleConsent.js'
|
||||
import { CONSENT_COOKIE, DEFAULT_CONSENT, parseConsent, setDefaultConsent } from '../consent/index.js'
|
||||
import { loadClarity, loadLinkedIn, loadMetaPixel, loadTikTok } from './pixels.js'
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
@@ -33,38 +35,141 @@ function injectScript(src: string) {
|
||||
document.head.appendChild(s)
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads Google Analytics — GTM if a container ID is set, otherwise GA4 gtag.
|
||||
*
|
||||
* Consent Mode is initialised to the visitor's stored consent BEFORE the tag
|
||||
* loads (via setDefaultConsent from the consent module), so tags respect the
|
||||
* choice from the first hit; useConsent sends an update the moment the visitor
|
||||
* decides. IDs are public and come from SiteIntegrations, passed in as props
|
||||
* (the client project reads them server-side).
|
||||
*
|
||||
* Renders nothing — it only injects the scripts. Mount once, high in the tree
|
||||
* (e.g. root layout), inside ConsentProvider.
|
||||
*/
|
||||
export function Analytics({ ga4MeasurementId, gtmContainerId }: AnalyticsConfig) {
|
||||
export type AnalyticsProps = {
|
||||
/**
|
||||
* Core Web Vitals mode: hold back every tag's NETWORK load until the first
|
||||
* user interaction (scroll, pointer, touch, key) or `deferTimeoutMs` after the
|
||||
* window `load` event — whichever comes first. Keeps ~100+ KiB of third-party
|
||||
* JS out of the FCP/LCP window.
|
||||
*
|
||||
* Consent is unaffected: the Consent Mode default is still pushed immediately
|
||||
* (a synchronous dataLayer push, no network), and non-Google pixels still
|
||||
* require their consent category. Defer changes WHEN a tag loads, never WHETHER.
|
||||
*
|
||||
* Trade-off: visitors who leave before interacting and before the timeout are
|
||||
* not counted (slightly fewer sessions in GA). Default false.
|
||||
*/
|
||||
defer?: boolean
|
||||
/** Fallback delay after window `load`, in ms. Default 3500. */
|
||||
deferTimeoutMs?: number
|
||||
} & AnalyticsConfig
|
||||
|
||||
const INTERACTION_EVENTS = ['scroll', 'pointerdown', 'touchstart', 'keydown'] as const
|
||||
|
||||
/** True once third-party tags may load (immediately, or per `defer` rules). */
|
||||
function useDeferredReady(defer: boolean, timeoutMs: number): boolean {
|
||||
const [ready, setReady] = useState(!defer)
|
||||
|
||||
useEffect(() => {
|
||||
if (!defer || ready) {return}
|
||||
let timer: ReturnType<typeof setTimeout> | undefined
|
||||
|
||||
const fire = () => setReady(true)
|
||||
const onLoad = () => {
|
||||
timer = setTimeout(() => {
|
||||
if ('requestIdleCallback' in window) {
|
||||
window.requestIdleCallback(fire, { timeout: 1000 })
|
||||
} else {
|
||||
fire()
|
||||
}
|
||||
}, timeoutMs)
|
||||
}
|
||||
|
||||
for (const e of INTERACTION_EVENTS) {
|
||||
window.addEventListener(e, fire, { once: true, passive: true })
|
||||
}
|
||||
if (document.readyState === 'complete') {onLoad()}
|
||||
else {window.addEventListener('load', onLoad, { once: true })}
|
||||
|
||||
return () => {
|
||||
for (const e of INTERACTION_EVENTS) {window.removeEventListener(e, fire)}
|
||||
window.removeEventListener('load', onLoad)
|
||||
if (timer) {clearTimeout(timer)}
|
||||
}
|
||||
}, [defer, ready, timeoutMs])
|
||||
|
||||
return ready
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads every configured analytics / marketing tag, each respecting consent:
|
||||
*
|
||||
* - **Google (GA4 / GTM)** — Consent Mode: the visitor's stored choice is set as
|
||||
* the default BEFORE the tag loads (always immediately, even with `defer`),
|
||||
* and useConsent pushes an update the moment they decide. GTM wins if both
|
||||
* IDs are set.
|
||||
* - **Non-Google (Meta Pixel, Clarity, LinkedIn, TikTok)** — no Consent Mode, so
|
||||
* each loads ONLY after its category is granted (marketing for
|
||||
* Pixel/LinkedIn/TikTok, analytics for Clarity). Reacts live to the banner.
|
||||
* - **`defer`** (opt-in) — additionally waits for first interaction / idle
|
||||
* after load, for better LCP/INP. See AnalyticsProps.defer.
|
||||
*
|
||||
* All IDs are public and come from SiteIntegrations (getAnalyticsConfig), passed
|
||||
* in as props. Renders nothing. Mount once, high in the tree, INSIDE
|
||||
* <ConsentProvider> (required — it reads live consent state).
|
||||
*/
|
||||
export function Analytics(props: AnalyticsProps) {
|
||||
const {
|
||||
clarityProjectId,
|
||||
defer = false,
|
||||
deferTimeoutMs = 3500,
|
||||
ga4MeasurementId,
|
||||
gtmContainerId,
|
||||
linkedInPartnerId,
|
||||
metaPixelId,
|
||||
tiktokPixelId,
|
||||
} = props
|
||||
|
||||
// Live consent state — drives the non-Google pixels.
|
||||
const { state } = useConsentContext()
|
||||
const ready = useDeferredReady(defer, deferTimeoutMs)
|
||||
const defaultConsentSet = useRef(false)
|
||||
|
||||
// --- Consent Mode default: immediately, once — never deferred ---
|
||||
// No network cost, and it must precede any gtag('config') / GTM start, or
|
||||
// Google assumes "granted".
|
||||
useEffect(() => {
|
||||
if (defaultConsentSet.current) {return}
|
||||
if (!ga4MeasurementId && !gtmContainerId) {return}
|
||||
|
||||
// 1. Consent Mode default = the visitor's stored choice, before tags load.
|
||||
setDefaultConsent(readConsent())
|
||||
defaultConsentSet.current = true
|
||||
}, [ga4MeasurementId, gtmContainerId])
|
||||
|
||||
// 2. Load the tag.
|
||||
// --- Google: load once `ready`; Consent Mode handles gating ---
|
||||
useEffect(() => {
|
||||
if (!ready) {return}
|
||||
if (!ga4MeasurementId && !gtmContainerId) {return}
|
||||
if (gtmContainerId) {
|
||||
window.dataLayer = window.dataLayer || []
|
||||
window.dataLayer.push({ event: 'gtm.js', 'gtm.start': Date.now() })
|
||||
injectScript(GTM_SCRIPT(gtmContainerId))
|
||||
} else if (ga4MeasurementId) {
|
||||
injectScript(GA4_SCRIPT(ga4MeasurementId))
|
||||
// Uses the shared gtag (pushes `arguments`, as Google's tags expect);
|
||||
// real gtag.js wires itself up once the script loads.
|
||||
gtag('js', new Date())
|
||||
gtag('config', ga4MeasurementId)
|
||||
}
|
||||
}, [ga4MeasurementId, gtmContainerId])
|
||||
}, [ready, ga4MeasurementId, gtmContainerId])
|
||||
|
||||
// --- Non-Google: each when `ready` AND its consent category is granted ---
|
||||
// Loaders are idempotent, so re-running on state changes is safe; a tag loads
|
||||
// the first time both conditions hold and never doubles up.
|
||||
useEffect(() => {
|
||||
if (!ready) {return}
|
||||
if (state.marketing) {
|
||||
if (metaPixelId) {loadMetaPixel(metaPixelId)}
|
||||
if (linkedInPartnerId) {loadLinkedIn(linkedInPartnerId)}
|
||||
if (tiktokPixelId) {loadTikTok(tiktokPixelId)}
|
||||
}
|
||||
if (state.analytics && clarityProjectId) {loadClarity(clarityProjectId)}
|
||||
}, [
|
||||
ready,
|
||||
state.marketing,
|
||||
state.analytics,
|
||||
metaPixelId,
|
||||
linkedInPartnerId,
|
||||
tiktokPixelId,
|
||||
clarityProjectId,
|
||||
])
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
'use client'
|
||||
export { Analytics } from './Analytics.js'
|
||||
export type { AnalyticsProps } from './Analytics.js'
|
||||
// Low-level pixel loaders — exported for manual conversion events if a project
|
||||
// needs them (Analytics loads them automatically, consent-gated).
|
||||
export { loadClarity, loadLinkedIn, loadMetaPixel, loadTikTok } from './pixels.js'
|
||||
export { pushDataLayer } from './pushDataLayer.js'
|
||||
|
||||
@@ -5,15 +5,18 @@ import type { AnalyticsConfig } from './types.js'
|
||||
import { getSiteIntegrations } from '../payload/index.js'
|
||||
|
||||
/**
|
||||
* Reads the public analytics IDs from SiteIntegrations, server-side.
|
||||
*
|
||||
* Returns only the two public IDs (GA4 / GTM) — safe to pass to the client
|
||||
* Reads the public analytics / marketing tag IDs from SiteIntegrations,
|
||||
* server-side. All are public (exposed client-side), so safe to pass to the
|
||||
* <Analytics> component. Does NOT expose any secret from SiteIntegrations.
|
||||
*/
|
||||
export async function getAnalyticsConfig(payload: BasePayload): Promise<AnalyticsConfig> {
|
||||
const integrations = await getSiteIntegrations<AnalyticsConfig>(payload)
|
||||
return {
|
||||
clarityProjectId: integrations.clarityProjectId ?? null,
|
||||
ga4MeasurementId: integrations.ga4MeasurementId ?? null,
|
||||
gtmContainerId: integrations.gtmContainerId ?? null,
|
||||
linkedInPartnerId: integrations.linkedInPartnerId ?? null,
|
||||
metaPixelId: integrations.metaPixelId ?? null,
|
||||
tiktokPixelId: integrations.tiktokPixelId ?? null,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
/**
|
||||
* Loaders for non-Google marketing/analytics pixels. Each is idempotent (guards
|
||||
* against double-init) and loads the vendor's own script + bootstrap.
|
||||
*
|
||||
* These are the one place `any` is unavoidable: vendor SDK bootstraps attach
|
||||
* untyped globals (fbq, clarity, lintrk, ttq) to `window`. Casts are contained
|
||||
* here; nothing else in the kit uses `any`.
|
||||
*
|
||||
* CONSENT: these vendors have no Google Consent Mode — the caller (Analytics)
|
||||
* loads each ONLY after the matching consent category is granted:
|
||||
* Meta Pixel / LinkedIn / TikTok → marketing
|
||||
* Microsoft Clarity → analytics
|
||||
*/
|
||||
|
||||
type Win = Record<string, any> & typeof window
|
||||
|
||||
/** Meta (Facebook) Pixel — fires PageView on load. */
|
||||
export function loadMetaPixel(id: string): void {
|
||||
if (typeof window === 'undefined') {return}
|
||||
const w = window as Win
|
||||
if (w.fbq) {return}
|
||||
const n: any = (w.fbq = function (...args: unknown[]) {
|
||||
if (n.callMethod) {
|
||||
n.callMethod.apply(n, args)
|
||||
} else {
|
||||
n.queue.push(args)
|
||||
}
|
||||
})
|
||||
if (!w._fbq) {w._fbq = n}
|
||||
n.push = n
|
||||
n.loaded = true
|
||||
n.version = '2.0'
|
||||
n.queue = []
|
||||
const s = document.createElement('script')
|
||||
s.async = true
|
||||
s.src = 'https://connect.facebook.net/en_US/fbevents.js'
|
||||
document.head.appendChild(s)
|
||||
w.fbq('init', id)
|
||||
w.fbq('track', 'PageView')
|
||||
}
|
||||
|
||||
/** Microsoft Clarity — heatmaps / session recordings (analytics category). */
|
||||
export function loadClarity(id: string): void {
|
||||
if (typeof window === 'undefined') {return}
|
||||
const w = window as Win
|
||||
if (w.clarity) {return}
|
||||
w.clarity = function (...a: unknown[]) {
|
||||
;(w.clarity.q = w.clarity.q || []).push(a)
|
||||
}
|
||||
const s = document.createElement('script')
|
||||
s.async = true
|
||||
s.src = `https://www.clarity.ms/tag/${id}`
|
||||
document.head.appendChild(s)
|
||||
}
|
||||
|
||||
/** LinkedIn Insight Tag (marketing). */
|
||||
export function loadLinkedIn(partnerId: string): void {
|
||||
if (typeof window === 'undefined') {return}
|
||||
const w = window as Win
|
||||
w._linkedin_partner_id = partnerId
|
||||
w._linkedin_data_partner_ids = w._linkedin_data_partner_ids || []
|
||||
if (w._linkedin_data_partner_ids.includes(partnerId)) {
|
||||
if (document.getElementById('ipal-linkedin-insight')) {return}
|
||||
} else {
|
||||
w._linkedin_data_partner_ids.push(partnerId)
|
||||
}
|
||||
if (document.getElementById('ipal-linkedin-insight')) {return}
|
||||
const s = document.createElement('script')
|
||||
s.async = true
|
||||
s.id = 'ipal-linkedin-insight'
|
||||
s.src = 'https://snap.licdn.com/li.lms-analytics/insight.min.js'
|
||||
document.head.appendChild(s)
|
||||
}
|
||||
|
||||
/** TikTok Pixel (marketing) — fires page view on load. */
|
||||
export function loadTikTok(id: string): void {
|
||||
if (typeof window === 'undefined') {return}
|
||||
const w = window as Win
|
||||
if (w.ttq) {return}
|
||||
w.TiktokAnalyticsObject = 'ttq'
|
||||
const ttq: any = (w.ttq = [])
|
||||
ttq.methods = [
|
||||
'page',
|
||||
'track',
|
||||
'identify',
|
||||
'instances',
|
||||
'debug',
|
||||
'on',
|
||||
'off',
|
||||
'once',
|
||||
'ready',
|
||||
'alias',
|
||||
'group',
|
||||
'enableCookie',
|
||||
'disableCookie',
|
||||
]
|
||||
ttq.setAndDefer = function (t: any, e: string) {
|
||||
t[e] = function (...args: unknown[]) {
|
||||
t.push([e, ...args])
|
||||
}
|
||||
}
|
||||
for (const m of ttq.methods) {ttq.setAndDefer(ttq, m)}
|
||||
ttq.load = function (e: string) {
|
||||
const url = 'https://analytics.tiktok.com/i18n/pixel/events.js'
|
||||
ttq._i = ttq._i || {}
|
||||
ttq._i[e] = []
|
||||
ttq._i[e]._u = url
|
||||
ttq._t = ttq._t || {}
|
||||
ttq._t[e] = Number(new Date())
|
||||
const s = document.createElement('script')
|
||||
s.async = true
|
||||
s.src = `${url}?sdkid=${e}&lib=ttq`
|
||||
document.head.appendChild(s)
|
||||
}
|
||||
ttq.load(id)
|
||||
ttq.page()
|
||||
}
|
||||
@@ -1,9 +1,19 @@
|
||||
/**
|
||||
* Analytics IDs, read from SiteIntegrations (public — safe on the client).
|
||||
* Analytics / marketing tag IDs, read from SiteIntegrations (all public — safe
|
||||
* on the client). Google tags (GA4/GTM) use Consent Mode; the rest load only
|
||||
* after the matching consent category is granted (see Analytics).
|
||||
*/
|
||||
export type AnalyticsConfig = {
|
||||
/** GA4 Measurement ID, e.g. 'G-XXXXXXXXXX'. */
|
||||
/** Microsoft Clarity project ID. (analytics consent) */
|
||||
clarityProjectId?: null | string
|
||||
/** GA4 Measurement ID, e.g. 'G-XXXXXXXXXX'. (Google — Consent Mode) */
|
||||
ga4MeasurementId?: null | string
|
||||
/** GTM Container ID, e.g. 'GTM-XXXXXXX'. */
|
||||
/** GTM Container ID, e.g. 'GTM-XXXXXXX'. (Google — Consent Mode) */
|
||||
gtmContainerId?: null | string
|
||||
/** LinkedIn Insight Tag partner ID. (marketing consent) */
|
||||
linkedInPartnerId?: null | string
|
||||
/** Meta (Facebook) Pixel ID, ~15–16 digits. (marketing consent) */
|
||||
metaPixelId?: null | string
|
||||
/** TikTok Pixel ID. (marketing consent) */
|
||||
tiktokPixelId?: null | string
|
||||
}
|
||||
|
||||
@@ -20,21 +20,21 @@ import { getPayload } from 'payload'
|
||||
*/
|
||||
|
||||
type BrandingProps = {
|
||||
/** SiteSettings global slug. Default 'site-settings'. */
|
||||
settingsSlug?: string
|
||||
/** Field holding the site name. Default 'siteName'. */
|
||||
nameField?: string
|
||||
/** Upload field to render as the image. Default 'logo' (Logo) / 'favicon' (Icon). */
|
||||
imageField?: string
|
||||
/** Field holding the site name. Default 'siteName'. */
|
||||
nameField?: string
|
||||
/** SiteSettings global slug. Default 'site-settings'. */
|
||||
settingsSlug?: string
|
||||
}
|
||||
|
||||
type MediaLike = { url?: string | null } | null | undefined
|
||||
type MediaLike = { url?: null | string } | null | undefined
|
||||
|
||||
async function loadBranding(
|
||||
settingsSlug: string,
|
||||
nameField: string,
|
||||
imageField: string,
|
||||
): Promise<{ name: string | null; url: string | null }> {
|
||||
): Promise<{ name: null | string; url: null | string }> {
|
||||
try {
|
||||
// Consumer alias — resolved in the project's build, hidden from plugin tsc.
|
||||
const spec = '@payload-config'
|
||||
@@ -45,7 +45,7 @@ async function loadBranding(
|
||||
depth: 1,
|
||||
})) as Record<string, unknown>
|
||||
|
||||
const name = typeof settings[nameField] === 'string' ? (settings[nameField] as string) : null
|
||||
const name = typeof settings[nameField] === 'string' ? (settings[nameField]) : null
|
||||
const image = settings[imageField] as MediaLike
|
||||
const url =
|
||||
image && typeof image === 'object' && typeof image.url === 'string' ? image.url : null
|
||||
@@ -55,65 +55,86 @@ async function loadBranding(
|
||||
}
|
||||
}
|
||||
|
||||
/** Admin panel logo (login screen + nav). SiteSettings `logo`, falls back to `siteName`. */
|
||||
/**
|
||||
* Admin panel logo — this is the LARGE logo on the login / unauthorized screens
|
||||
* (Payload uses `graphics.Icon` for the small nav glyph). SiteSettings `logo`,
|
||||
* falls back to `siteName` text. Sized generously for the login screen.
|
||||
*/
|
||||
export async function AdminLogo(props: BrandingProps = {}) {
|
||||
const { settingsSlug = 'site-settings', nameField = 'siteName', imageField = 'logo' } = props
|
||||
const { imageField = 'logo', nameField = 'siteName', settingsSlug = 'site-settings' } = props
|
||||
const { name, url } = await loadBranding(settingsSlug, nameField, imageField)
|
||||
if (url) {
|
||||
return (
|
||||
<img
|
||||
src={url}
|
||||
alt={name ?? ''}
|
||||
style={{ maxHeight: 60, maxWidth: 240, width: 'auto', height: 'auto' }}
|
||||
src={url}
|
||||
style={{ height: 'auto', maxHeight: 120, maxWidth: 420, width: 'auto' }}
|
||||
/>
|
||||
)
|
||||
}
|
||||
if (name) return <div style={{ fontSize: '1.5rem', fontWeight: 600 }}>{name}</div>
|
||||
if (name) {return <div style={{ fontSize: '2rem', fontWeight: 600 }}>{name}</div>}
|
||||
return null // nothing configured → Payload's default
|
||||
}
|
||||
|
||||
/** Admin panel icon (small nav glyph). SiteSettings `favicon`, falls back to initials. */
|
||||
export async function AdminIcon(props: BrandingProps = {}) {
|
||||
const { settingsSlug = 'site-settings', nameField = 'siteName', imageField = 'favicon' } = props
|
||||
const { imageField = 'favicon', nameField = 'siteName', settingsSlug = 'site-settings' } = props
|
||||
const { name, url } = await loadBranding(settingsSlug, nameField, imageField)
|
||||
if (url) {
|
||||
return (
|
||||
<img
|
||||
src={url}
|
||||
alt={name ?? ''}
|
||||
style={{ maxHeight: 28, maxWidth: 28, width: 'auto', height: 'auto' }}
|
||||
src={url}
|
||||
style={{ height: 'auto', maxHeight: 28, maxWidth: 28, width: 'auto' }}
|
||||
/>
|
||||
)
|
||||
}
|
||||
if (name) return <div style={{ fontWeight: 700 }}>{name.slice(0, 2).toUpperCase()}</div>
|
||||
if (name) {return <div style={{ fontWeight: 700 }}>{name.slice(0, 2).toUpperCase()}</div>}
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* Discreet vendor credit shown at the bottom of the admin nav: "Technology by
|
||||
* Intecion.com". This is the PLUGIN VENDOR's credit (Intecion ships ipal-kit),
|
||||
* not client data — so a sensible default here is fine and A0-safe. The client's
|
||||
* own brand still owns the logo/name above (AdminLogo); this is a small line
|
||||
* stating who provides the technology. Text/URL overridable; turn it off with
|
||||
* `whiteLabel: { credit: false }`.
|
||||
* Discreet vendor credit: "Technology supported by Intecion.com". This is the
|
||||
* PLUGIN VENDOR's credit (Intecion ships ipal-kit, the framework), not client
|
||||
* data — a sensible default here is fine and A0-safe. The client's own brand
|
||||
* still owns the logo/name; this is a small line stating who supports the tech.
|
||||
* Text/URL overridable; turn it off with `whiteLabel: { credit: false }`.
|
||||
*
|
||||
* Wired by ipalKit into admin.components.afterNavLinks.
|
||||
* Wired by ipalKit into admin.components.afterNavLinks (nav) AND afterLogin
|
||||
* (login screen footer). `variant` adjusts placement:
|
||||
* - 'nav' → left-aligned line under the nav links
|
||||
* - 'login' → centered line below the login form
|
||||
*/
|
||||
export function IntecionCredit(props: { text?: string; url?: string } = {}) {
|
||||
const { text = 'Technology by Intecion.com', url = 'https://intecion.com' } = props
|
||||
export function IntecionCredit(
|
||||
props: { text?: string; url?: string; variant?: 'login' | 'nav' } = {},
|
||||
) {
|
||||
const {
|
||||
text = 'Technology supported by Intecion.com',
|
||||
url = 'https://intecion.com',
|
||||
variant = 'nav',
|
||||
} = props
|
||||
const style =
|
||||
variant === 'login'
|
||||
? {
|
||||
color: 'inherit' as const,
|
||||
display: 'block',
|
||||
fontSize: '0.75rem',
|
||||
marginTop: '2rem',
|
||||
opacity: 0.6,
|
||||
padding: '0.5rem',
|
||||
textAlign: 'center' as const,
|
||||
textDecoration: 'none',
|
||||
}
|
||||
: {
|
||||
color: 'inherit' as const,
|
||||
display: 'block',
|
||||
fontSize: '0.75rem',
|
||||
opacity: 0.6,
|
||||
padding: '0.75rem 1rem',
|
||||
textDecoration: 'none',
|
||||
}
|
||||
return (
|
||||
<a
|
||||
href={url}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
style={{
|
||||
display: 'block',
|
||||
padding: '0.75rem 1rem',
|
||||
fontSize: '0.75rem',
|
||||
opacity: 0.6,
|
||||
textDecoration: 'none',
|
||||
}}
|
||||
>
|
||||
<a href={url} rel="noopener noreferrer" style={style} target="_blank">
|
||||
{text}
|
||||
</a>
|
||||
)
|
||||
|
||||
@@ -6,6 +6,7 @@ export { getArchiveEntries } from './getArchiveEntries.js'
|
||||
export type { ArchiveEntries } from './getArchiveEntries.js'
|
||||
export { MARKDOWN_PREFIX, markdownHref, prefersMarkdown } from './markdownNegotiation.js'
|
||||
export { buildArchivePath, buildEntryPath, parsePageParam } from './paths.js'
|
||||
export { resolveNotFoundPage } from './resolveNotFoundPage.js'
|
||||
export { resolveRedirect } from './resolveRedirect.js'
|
||||
export { resolveRoute } from './resolveRoute.js'
|
||||
export type { ResolvedRoute } from './resolveRoute.js'
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
import type { BasePayload } from 'payload'
|
||||
|
||||
type ResolveNotFoundPageArgs = {
|
||||
locale: string
|
||||
/** Client's Pages collection slug. Defaults to 'pages'. */
|
||||
pagesSlug?: string
|
||||
payload: BasePayload
|
||||
/** SiteSettings global slug. Defaults to 'site-settings'. */
|
||||
settingsSlug?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the page the editor assigned as **404 (Not Found)** in System Pages,
|
||||
* fully populated (depth 2, same shape as resolveRoute's pages), or null when
|
||||
* the role is unassigned.
|
||||
*
|
||||
* Used by the project's `not-found.tsx`. The editor decides what a 404 looks
|
||||
* like: a dedicated "Not found" page, or simply the homepage. Null means
|
||||
* "render the project's built-in fallback view".
|
||||
*
|
||||
* Never throws — a missing DB (container build prerendering not-found) or a
|
||||
* deleted page just yields null, so the 404 view can't crash the build.
|
||||
*/
|
||||
export async function resolveNotFoundPage({
|
||||
locale,
|
||||
pagesSlug = 'pages',
|
||||
payload,
|
||||
settingsSlug = 'site-settings',
|
||||
}: ResolveNotFoundPageArgs): Promise<null | Record<string, unknown>> {
|
||||
try {
|
||||
const settings = (await payload.findGlobal({
|
||||
slug: settingsSlug as never,
|
||||
depth: 0,
|
||||
locale: locale as never,
|
||||
})) as Record<string, unknown>
|
||||
|
||||
const rel = settings.notFound
|
||||
const id =
|
||||
typeof rel === 'string' || typeof rel === 'number'
|
||||
? rel
|
||||
: rel && typeof rel === 'object'
|
||||
? (rel as { id?: number | string }).id
|
||||
: undefined
|
||||
if (id === undefined) {return null}
|
||||
|
||||
const doc = await payload.findByID({
|
||||
id,
|
||||
collection: pagesSlug as never,
|
||||
depth: 2,
|
||||
locale: locale as never,
|
||||
})
|
||||
return (doc as null | Record<string, unknown>) ?? null
|
||||
} catch (error) {
|
||||
console.warn('[ipal] resolveNotFoundPage: falling back to built-in 404 view:', error)
|
||||
return null
|
||||
}
|
||||
}
|
||||
@@ -160,5 +160,22 @@ export async function resolveRoute({
|
||||
const doc = found.docs[0]
|
||||
if (!doc) {return null}
|
||||
|
||||
// The page assigned as 404 in System Pages must not be reachable as a normal
|
||||
// 200 URL (/pl/strona-nie-znaleziona) — that's a soft-404 / duplicate. Treat
|
||||
// it as not found, so the route calls notFound() and not-found.tsx renders
|
||||
// that same page with a real 404 status. (If 404 = homepage, the homepage is
|
||||
// served from the root branch above and never reaches here by its own slug
|
||||
// in a way that matters — but guard anyway so we never hide the homepage.)
|
||||
const notFound = settings.notFound
|
||||
const homepage = settings.homepage
|
||||
const notFoundId =
|
||||
notFound && typeof notFound === 'object' ? (notFound as { id?: unknown }).id : notFound
|
||||
const homepageId =
|
||||
homepage && typeof homepage === 'object' ? (homepage as { id?: unknown }).id : homepage
|
||||
const docId = (doc as { id?: unknown }).id
|
||||
if (notFoundId != null && notFoundId === docId && notFoundId !== homepageId) {
|
||||
return null
|
||||
}
|
||||
|
||||
return { type: 'page', doc: doc as Record<string, unknown> }
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ type PageRow = {
|
||||
_status?: string
|
||||
id: number | string
|
||||
meta?: { description?: unknown; noindex?: boolean } | null
|
||||
noindex?: boolean | null
|
||||
slug?: unknown
|
||||
title?: unknown
|
||||
}
|
||||
@@ -91,7 +92,7 @@ export async function searchContent({
|
||||
const results: SearchResult[] = []
|
||||
for (const doc of docs) {
|
||||
if (doc._status && doc._status !== 'published') {continue}
|
||||
if (doc.meta?.noindex) {continue}
|
||||
if (doc.noindex || doc.meta?.noindex) {continue}
|
||||
const title = typeof doc.title === 'string' ? doc.title : undefined
|
||||
const slug = typeof doc.slug === 'string' ? doc.slug : undefined
|
||||
if (!title || !slug) {continue}
|
||||
|
||||
@@ -7,7 +7,11 @@ import type { ArchiveEntries, ContentOption, ResolvedRoute } from '../content/in
|
||||
import type { I18nConfig } from '../i18n/index.js'
|
||||
import type { RobotsRules, SitemapEntry } from '../seo/index.js'
|
||||
|
||||
import { getArchiveEntries, resolveRoute as resolveRouteRaw } from '../content/index.js'
|
||||
import {
|
||||
getArchiveEntries,
|
||||
resolveNotFoundPage,
|
||||
resolveRoute as resolveRouteRaw,
|
||||
} from '../content/index.js'
|
||||
import { buildRobots, buildSitemapEntries } from '../seo/index.js'
|
||||
|
||||
type CreateContentHelpersArgs = {
|
||||
@@ -96,6 +100,20 @@ export function createContentHelpers({
|
||||
},
|
||||
)
|
||||
|
||||
/**
|
||||
* The page assigned as 404 in System Pages (or null → built-in fallback).
|
||||
* For app/not-found.tsx; never throws. Locale comes from the x-locale header
|
||||
* set by createProxy (not-found.tsx receives no params).
|
||||
*/
|
||||
const getNotFoundPage = cache(async (locale: string) => {
|
||||
try {
|
||||
const payload = await getCachedPayload()
|
||||
return await resolveNotFoundPage({ locale, pagesSlug, payload, settingsSlug })
|
||||
} catch {
|
||||
return null // DB unreachable (container build) — fallback view
|
||||
}
|
||||
})
|
||||
|
||||
/** One page of a collection's entries, for an archive listing. */
|
||||
const getEntries = cache(
|
||||
async (
|
||||
@@ -202,8 +220,16 @@ export function createContentHelpers({
|
||||
// Home slug per locale, to exclude the homepage (it's the root, slug []).
|
||||
const settings = (await payload
|
||||
.findGlobal({ slug: settingsSlug as never, depth: 1, locale: 'all' as never })
|
||||
.catch(() => null)) as { homepage?: { id?: number | string; slug?: unknown } } | null
|
||||
.catch(() => null)) as {
|
||||
homepage?: { id?: number | string; slug?: unknown }
|
||||
notFound?: { id?: number | string } | null
|
||||
} | null
|
||||
const homeId = settings?.homepage?.id
|
||||
// The assigned 404 page renders via not-found.tsx, never as its own URL.
|
||||
const notFoundId =
|
||||
settings?.notFound?.id !== undefined && settings.notFound.id !== homeId
|
||||
? settings.notFound.id
|
||||
: undefined
|
||||
|
||||
const EXCLUDED = new Set(['404', '500', 'error', 'not-found'])
|
||||
const params: Array<{ locale: string; slug: string[] } | { slug: string[] }> = []
|
||||
@@ -228,6 +254,7 @@ export function createContentHelpers({
|
||||
}>) {
|
||||
// Draft filter in memory (safe whether or not the collection has drafts).
|
||||
if (raw._status && raw._status !== 'published') {continue}
|
||||
if (notFoundId !== undefined && raw.id === notFoundId) {continue}
|
||||
|
||||
// NOTE: unlike the sitemap, we do NOT skip meta.noindex here. A noindex
|
||||
// page (privacy, cookies, terms) still needs to render — users reach it
|
||||
@@ -286,6 +313,7 @@ export function createContentHelpers({
|
||||
getCachedPayload,
|
||||
getConfiguredLocales,
|
||||
getEntries,
|
||||
getNotFoundPage,
|
||||
getSettings,
|
||||
resolveRoute,
|
||||
robots,
|
||||
|
||||
@@ -58,9 +58,12 @@ export function createHealthRoute(args: CreateHealthRouteArgs): () => Promise<Re
|
||||
status: 200,
|
||||
})
|
||||
} catch (err) {
|
||||
// Log the real error for ops; keep the PUBLIC body generic — a 503 with
|
||||
// `db: 'down'` is all an orchestrator needs, and raw DB error text (host,
|
||||
// credentials-in-URL, driver internals) must not leak on a public route.
|
||||
console.warn('[ipal] createHealthRoute: database unreachable:', err)
|
||||
const body = {
|
||||
db: 'down',
|
||||
error: err instanceof Error ? err.message : 'unknown',
|
||||
status: 'error',
|
||||
timestamp: new Date().toISOString(),
|
||||
tookMs: Date.now() - startedAt,
|
||||
|
||||
@@ -187,7 +187,11 @@ export function createMcpRoute(args: CreateMcpRouteArgs) {
|
||||
if (p.name === 'get_page') {return rpcResult(id, toolText(await getPage(toolArgs)))}
|
||||
return rpcResult(id, toolText(`Unknown tool: ${p.name}`, true))
|
||||
} catch (err) {
|
||||
return rpcResult(id, toolText(err instanceof Error ? err.message : 'Tool error', true))
|
||||
// Log the real error server-side; return a GENERIC message to the
|
||||
// (anonymous) caller so internal details — DB schema, host, stack —
|
||||
// never leak over a public endpoint.
|
||||
console.warn('[ipal] createMcpRoute: tool execution failed:', err)
|
||||
return rpcResult(id, toolText('Tool execution failed.', true))
|
||||
}
|
||||
}
|
||||
case 'tools/list':
|
||||
|
||||
@@ -8,6 +8,7 @@ import { ALL_SYSTEM_PAGE_ROLES } from './types.js'
|
||||
const ROLE_LABELS: Record<SystemPageRole, string> = {
|
||||
cookiePolicy: 'Cookie Policy',
|
||||
homepage: 'Homepage',
|
||||
notFound: '404 (Not Found)',
|
||||
privacyPolicy: 'Privacy Policy',
|
||||
termsOfService: 'Terms of Service',
|
||||
}
|
||||
@@ -16,6 +17,8 @@ const ROLE_LABELS: Record<SystemPageRole, string> = {
|
||||
const ROLE_DESCRIPTIONS: Record<SystemPageRole, string> = {
|
||||
cookiePolicy: 'Page linked from the cookie consent banner.',
|
||||
homepage: 'Page served at the locale root (e.g. /pl, /en).',
|
||||
notFound:
|
||||
'Page shown for unknown URLs (404). Pick a dedicated "Not found" page, or reuse the homepage. If left empty, the project falls back to its built-in not-found view.',
|
||||
privacyPolicy: 'Page linked as the privacy policy.',
|
||||
termsOfService: 'Page linked as the terms of service / site regulations.',
|
||||
}
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
* Built-in "system page" roles — documents from the client's Pages
|
||||
* collection that the site references by function rather than by slug.
|
||||
*/
|
||||
export type SystemPageRole = 'cookiePolicy' | 'homepage' | 'privacyPolicy' | 'termsOfService'
|
||||
export type SystemPageRole =
|
||||
'cookiePolicy' | 'homepage' | 'notFound' | 'privacyPolicy' | 'termsOfService'
|
||||
|
||||
/**
|
||||
* All system roles in a stable order (used when no subset is configured).
|
||||
*/
|
||||
export const ALL_SYSTEM_PAGE_ROLES: readonly SystemPageRole[] = [
|
||||
'homepage',
|
||||
'notFound',
|
||||
'privacyPolicy',
|
||||
'cookiePolicy',
|
||||
'termsOfService',
|
||||
|
||||
@@ -42,6 +42,7 @@ type PageRow = {
|
||||
_status?: string
|
||||
id: number | string
|
||||
meta?: { description?: unknown; noindex?: boolean } | null
|
||||
noindex?: boolean | null
|
||||
slug?: unknown
|
||||
title?: unknown
|
||||
}
|
||||
@@ -131,7 +132,7 @@ export async function buildLlmsTxt({
|
||||
const sections: string[] = []
|
||||
for (const raw of result.docs as PageRow[]) {
|
||||
if (raw._status && raw._status !== 'published') {continue}
|
||||
if (raw.meta?.noindex) {continue}
|
||||
if (raw.noindex || raw.meta?.noindex) {continue}
|
||||
|
||||
const title = typeof raw.title === 'string' ? raw.title : undefined
|
||||
const slug = typeof raw.slug === 'string' ? raw.slug : undefined
|
||||
@@ -153,7 +154,7 @@ export async function buildLlmsTxt({
|
||||
const pageLinks: string[] = []
|
||||
for (const raw of result.docs as PageRow[]) {
|
||||
if (raw._status && raw._status !== 'published') {continue}
|
||||
if (raw.meta?.noindex) {continue}
|
||||
if (raw.noindex || raw.meta?.noindex) {continue}
|
||||
|
||||
const title = typeof raw.title === 'string' ? raw.title : undefined
|
||||
const slug = typeof raw.slug === 'string' ? raw.slug : undefined
|
||||
|
||||
@@ -57,6 +57,13 @@ type BuildMetadataArgs = {
|
||||
locale: string
|
||||
/** SEO meta from the document (plugin-seo group). */
|
||||
meta?: null | SeoMeta
|
||||
/**
|
||||
* Top-level noindex flag (buildNoindexField). Checked alongside meta.noindex:
|
||||
* plugin-seo's meta group doesn't declare noindex, so a mirror into
|
||||
* meta.noindex is stripped on save — the top-level field is the one that
|
||||
* persists. Either being true emits robots index:false.
|
||||
*/
|
||||
noindex?: boolean | null
|
||||
/** Page title or site name first. Defaults to 'page-first'. */
|
||||
order?: TitleOrder
|
||||
/**
|
||||
@@ -110,6 +117,7 @@ export function buildMetadata({
|
||||
imageUrl,
|
||||
locale,
|
||||
meta,
|
||||
noindex,
|
||||
order,
|
||||
pageTitle,
|
||||
prefix,
|
||||
@@ -163,7 +171,7 @@ export function buildMetadata({
|
||||
// robots: noindex pages are excluded (follow keeps link authority). Indexed
|
||||
// pages get generous snippet/preview limits so Google can show rich results
|
||||
// (long snippets, large image previews, full video previews).
|
||||
...(meta?.noindex
|
||||
...(noindex || meta?.noindex
|
||||
? { robots: { follow: true, index: false } }
|
||||
: {
|
||||
robots: {
|
||||
|
||||
@@ -1,54 +1,29 @@
|
||||
import type { CheckboxField, Field, FieldHook } from 'payload'
|
||||
import type { CheckboxField, Field } from 'payload'
|
||||
|
||||
type BuildNoindexFieldArgs = {
|
||||
/** Help text under the checkbox. */
|
||||
description?: string
|
||||
/** Sidebar label. Default 'Wyklucz z indeksowania (noindex)'. */
|
||||
/** Sidebar label. Default 'Exclude from indexing (noindex)'. */
|
||||
label?: string
|
||||
/**
|
||||
* Dotted path, inside the document, that the SEO read path (metadata +
|
||||
* sitemap) consumes. Default 'meta.noindex' — the plugin-seo `meta` group.
|
||||
* The checkbox value is mirrored here on every save, so editors toggle one
|
||||
* friendly switch and the machinery reads a stable location.
|
||||
*/
|
||||
metaPath?: string
|
||||
/** Field name for the editor-facing checkbox. Default 'noindex'. */
|
||||
name?: string
|
||||
/** Extend/override the generated checkbox (position, access, etc.). */
|
||||
overrides?: Partial<CheckboxField>
|
||||
}
|
||||
|
||||
/** Read a dotted path (e.g. 'meta.noindex') off a loosely-typed object. */
|
||||
function readPath(obj: null | Record<string, unknown> | undefined, path: string[]): unknown {
|
||||
let cur: unknown = obj
|
||||
for (const key of path) {
|
||||
if (cur == null || typeof cur !== 'object') {return undefined}
|
||||
cur = (cur as Record<string, unknown>)[key]
|
||||
}
|
||||
return cur
|
||||
}
|
||||
|
||||
/** Write a dotted path, creating intermediate objects as needed. */
|
||||
function writePath(obj: Record<string, unknown>, path: string[], value: unknown): void {
|
||||
let cur: Record<string, unknown> = obj
|
||||
for (let i = 0; i < path.length - 1; i++) {
|
||||
const key = path[i]
|
||||
const next = cur[key]
|
||||
if (next == null || typeof next !== 'object') {cur[key] = {}}
|
||||
cur = cur[key] as Record<string, unknown>
|
||||
}
|
||||
cur[path[path.length - 1]] = value
|
||||
}
|
||||
|
||||
/**
|
||||
* A sidebar `noindex` checkbox that mirrors into `meta.noindex` (what the
|
||||
* sitemap and metadata generators actually read). Replaces the hand-rolled
|
||||
* checkbox + `beforeChange` hook with its `(data as any).meta.noindex = …`
|
||||
* glue copied into every project — no `any`, one source of truth for editors,
|
||||
* one stable read location for the engine.
|
||||
* A top-level sidebar `noindex` checkbox. When ticked, the page is excluded from
|
||||
* `sitemap.xml`, `llms.txt`, site search, and gets `robots: noindex, follow` —
|
||||
* ALL automatically, no per-project filtering.
|
||||
*
|
||||
* Idempotent and order-independent: if either the checkbox OR an existing
|
||||
* `meta.noindex` is set, the page ends up noindex; the two can't drift apart.
|
||||
* Why top-level (not mirrored into `meta.noindex`): plugin-seo's `meta` group
|
||||
* declares only title/description/image, so Payload silently strips any extra
|
||||
* key (`meta.noindex`) during sanitization — an earlier version mirrored there
|
||||
* and the value vanished, leaking noindex pages into the sitemap. The value now
|
||||
* lives on this top-level field, which persists; every reader in the kit
|
||||
* (buildSitemapEntries, buildMetadata/createPageMetadata, buildLlmsTxt,
|
||||
* searchContent) checks `doc.noindex` (and still tolerates a legacy
|
||||
* `meta.noindex`). One field, one source of truth, zero project glue.
|
||||
*
|
||||
* // collections/Pages.ts
|
||||
* import { buildNoindexField } from '@intecion/ipal-kit'
|
||||
@@ -57,23 +32,12 @@ function writePath(obj: Record<string, unknown>, path: string[], value: unknown)
|
||||
export function buildNoindexField(args: BuildNoindexFieldArgs = {}): Field {
|
||||
const {
|
||||
name = 'noindex',
|
||||
description = 'Check to exclude this page from indexing (robots: noindex, follow) and from sitemap.xml.',
|
||||
description = 'Check to exclude this page from indexing (robots: noindex, follow), the sitemap, llms.txt and site search.',
|
||||
label = 'Exclude from indexing (noindex)',
|
||||
metaPath = 'meta.noindex',
|
||||
overrides = {},
|
||||
} = args
|
||||
|
||||
const segments = metaPath.split('.')
|
||||
|
||||
const mirror: FieldHook = ({ data, value }) => {
|
||||
const shouldNoindex = Boolean(value ?? readPath(data as Record<string, unknown>, segments))
|
||||
if (data && typeof data === 'object') {
|
||||
writePath(data as Record<string, unknown>, segments, shouldNoindex)
|
||||
}
|
||||
return shouldNoindex
|
||||
}
|
||||
|
||||
const { admin: adminOverrides, hooks: hooksOverrides, ...restOverrides } = overrides
|
||||
const { admin: adminOverrides, ...restOverrides } = overrides
|
||||
|
||||
return {
|
||||
name,
|
||||
@@ -84,11 +48,6 @@ export function buildNoindexField(args: BuildNoindexFieldArgs = {}): Field {
|
||||
...adminOverrides,
|
||||
},
|
||||
defaultValue: false,
|
||||
hooks: {
|
||||
...hooksOverrides,
|
||||
// mirror runs first, then any project-supplied beforeChange hooks.
|
||||
beforeChange: [mirror, ...(hooksOverrides?.beforeChange ?? [])],
|
||||
},
|
||||
label,
|
||||
...restOverrides,
|
||||
} as CheckboxField
|
||||
|
||||
@@ -52,6 +52,8 @@ type DocRow = {
|
||||
_status?: string
|
||||
id: number | string
|
||||
meta?: { noindex?: boolean } | null
|
||||
/** Top-level checkbox (buildNoindexField) — the field that actually persists. */
|
||||
noindex?: boolean | null
|
||||
slug?: unknown
|
||||
updatedAt?: string
|
||||
}
|
||||
@@ -78,7 +80,11 @@ function hasExcludedSlug(slug: unknown): boolean {
|
||||
/** Skip drafts, noindex, and system/error pages (404 etc.). */
|
||||
function isIndexable(doc: DocRow): boolean {
|
||||
if (doc._status && doc._status !== 'published') {return false}
|
||||
if (doc.meta?.noindex) {return false}
|
||||
// Check BOTH the top-level checkbox (buildNoindexField, the field that
|
||||
// persists) AND meta.noindex — plugin-seo's meta group doesn't declare
|
||||
// noindex, so a mirror into meta.noindex is stripped on save. Reading both
|
||||
// makes exclusion automatic regardless of where the flag ended up.
|
||||
if (doc.noindex || doc.meta?.noindex) {return false}
|
||||
if (hasExcludedSlug(doc.slug)) {return false}
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -43,6 +43,8 @@ type PageMetadataContext = {
|
||||
type DocShape = {
|
||||
id: number | string
|
||||
meta?: null | SeoMeta
|
||||
/** Top-level noindex checkbox (buildNoindexField) — the field that persists. */
|
||||
noindex?: boolean | null
|
||||
/** The document's own title (page name), used as the fallback page title. */
|
||||
title?: null | string
|
||||
}
|
||||
@@ -153,6 +155,7 @@ export function createPageMetadata(args: CreatePageMetadataArgs) {
|
||||
...base,
|
||||
imageUrl: resolveOgImage(doc),
|
||||
meta: doc.meta,
|
||||
noindex: doc.noindex,
|
||||
pageTitle: doc.title,
|
||||
prefix,
|
||||
query,
|
||||
|
||||
+48
-27
@@ -1,6 +1,6 @@
|
||||
import type { Config, Plugin } from 'payload'
|
||||
|
||||
import type { IpalOptions } from './types.js'
|
||||
import type { IpalOptions, TotpPluginFactory } from './types.js'
|
||||
|
||||
import { buildCookieSettings } from './globals/CookieSettings/index.js'
|
||||
import { buildNotifications } from './globals/Notifications/index.js'
|
||||
@@ -71,37 +71,48 @@ export const ipalKit = (options: IpalOptions): Plugin => {
|
||||
'opt out (discouraged).',
|
||||
)
|
||||
}
|
||||
try {
|
||||
// Dynamic specifier via a variable so TS doesn't try to resolve this
|
||||
// optional peer dependency at build time (it isn't in the plugin's own
|
||||
// node_modules). Avoids TS2307 without @ts-expect-error; the module
|
||||
// exists at runtime in projects that installed it.
|
||||
const pkg = '@clocklimited/payload-2fa'
|
||||
const mod = (await import(pkg)) as {
|
||||
payloadTotp?: (opts: Record<string, unknown>) => Plugin
|
||||
totpPlugin?: (opts: Record<string, unknown>) => Plugin
|
||||
}
|
||||
// The package exports `payloadTotp`; older/other builds may use
|
||||
// `totpPlugin`. Accept either so a rename doesn't break us.
|
||||
const totp = mod.payloadTotp ?? mod.totpPlugin
|
||||
if (typeof totp !== 'function') {
|
||||
// Prefer the INJECTED plugin factory (recommended): the project imports
|
||||
// payloadTotp from @clocklimited/payload-2fa and passes it in. Then the
|
||||
// plugin never imports the optional peer itself — no dynamic import, so
|
||||
// Next can't fail to bundle it (the cause of "Cannot find module
|
||||
// '@clocklimited/payload-2fa'" crashing even public frontend pages).
|
||||
let totp: TotpPluginFactory | undefined = tf.plugin
|
||||
|
||||
if (!totp) {
|
||||
// Fallback: dynamic import. Variable specifier dodges the plugin's own
|
||||
// TS2307, but Next may NOT trace it into the server bundle — projects
|
||||
// using this path MUST add '@clocklimited/payload-2fa' to
|
||||
// serverExternalPackages in next.config (see docs/security.md).
|
||||
try {
|
||||
const pkg = '@clocklimited/payload-2fa'
|
||||
const mod = (await import(pkg)) as {
|
||||
payloadTotp?: TotpPluginFactory
|
||||
totpPlugin?: TotpPluginFactory
|
||||
}
|
||||
totp = mod.payloadTotp ?? mod.totpPlugin
|
||||
} catch (err) {
|
||||
throw new Error(
|
||||
'expected export payloadTotp (or totpPlugin) to be a function — ' +
|
||||
'check the installed @clocklimited/payload-2fa version',
|
||||
'[ipal] 2FA is enforced but @clocklimited/payload-2fa could not be loaded. ' +
|
||||
'Best fix — inject it: `import { payloadTotp } from "@clocklimited/payload-2fa"` ' +
|
||||
'then `twoFactor: { issuer, plugin: payloadTotp }`. Or install it AND add ' +
|
||||
"'@clocklimited/payload-2fa' to serverExternalPackages in next.config. Or set " +
|
||||
`twoFactor: false to opt out (discouraged). Original error: ${String(err)}`,
|
||||
)
|
||||
}
|
||||
config = await totp({
|
||||
collection: tf.collectionSlug ?? 'users',
|
||||
forceSetup: true, // ENFORCED — every user must set up TOTP; no opt-out
|
||||
totp: { issuer: tf.issuer },
|
||||
})(config)
|
||||
} catch (err) {
|
||||
}
|
||||
|
||||
if (typeof totp !== 'function') {
|
||||
throw new Error(
|
||||
'[ipal] 2FA is enforced but @clocklimited/payload-2fa is not installed. ' +
|
||||
'Run: pnpm add @clocklimited/payload-2fa — or set twoFactor: false to ' +
|
||||
`opt out (discouraged). Original error: ${String(err)}`,
|
||||
'[ipal] 2FA: expected payloadTotp (or totpPlugin) to be a function — check the ' +
|
||||
'injected `plugin` or the installed @clocklimited/payload-2fa version.',
|
||||
)
|
||||
}
|
||||
|
||||
config = await totp({
|
||||
collection: tf.collectionSlug ?? 'users',
|
||||
forceSetup: true, // ENFORCED — every user must set up TOTP; no opt-out
|
||||
totp: { issuer: tf.issuer },
|
||||
})(config)
|
||||
}
|
||||
|
||||
// --- white-label admin branding ---
|
||||
@@ -139,9 +150,19 @@ export const ipalKit = (options: IpalOptions): Plugin => {
|
||||
},
|
||||
...(creditOn
|
||||
? {
|
||||
afterLogin: [
|
||||
...(config.admin?.components?.afterLogin ?? []),
|
||||
{
|
||||
path: '@intecion/ipal-kit/admin#IntecionCredit',
|
||||
serverProps: { ...creditProps, variant: 'login' },
|
||||
},
|
||||
],
|
||||
afterNavLinks: [
|
||||
...(config.admin?.components?.afterNavLinks ?? []),
|
||||
{ path: '@intecion/ipal-kit/admin#IntecionCredit', serverProps: creditProps },
|
||||
{
|
||||
path: '@intecion/ipal-kit/admin#IntecionCredit',
|
||||
serverProps: { ...creditProps, variant: 'nav' },
|
||||
},
|
||||
],
|
||||
}
|
||||
: {}),
|
||||
|
||||
+22
-1
@@ -1,5 +1,14 @@
|
||||
import type { Field } from 'payload'
|
||||
import type { Field, Plugin } from 'payload'
|
||||
|
||||
/**
|
||||
* Factory shape of @clocklimited/payload-2fa's `payloadTotp` export — injected
|
||||
* so the plugin never imports the optional peer itself.
|
||||
*/
|
||||
export type TotpPluginFactory = (options: {
|
||||
collection: string
|
||||
forceSetup: boolean
|
||||
totp: { issuer: string }
|
||||
}) => Plugin
|
||||
import type { AccessOption } from './modules/access/types.js'
|
||||
import type { ContentOption } from './modules/content/types.js'
|
||||
import type { FormsOption } from './modules/forms/types.js'
|
||||
@@ -84,6 +93,18 @@ export type IpalOptions = {
|
||||
collectionSlug?: string
|
||||
/** Name shown in the authenticator app (e.g. company/site name). */
|
||||
issuer: string
|
||||
/**
|
||||
* The 2FA plugin factory, INJECTED from the project:
|
||||
* `import { payloadTotp } from '@clocklimited/payload-2fa'`. Strongly
|
||||
* recommended — injecting it (the same pattern as NextResponse /
|
||||
* revalidatePath) means the plugin never dynamically imports the
|
||||
* optional peer, which Next can fail to bundle into the server chunks
|
||||
* ("Cannot find module '@clocklimited/payload-2fa'" at runtime, even on
|
||||
* public frontend pages). If omitted, the plugin falls back to a dynamic
|
||||
* import and you MUST add '@clocklimited/payload-2fa' to
|
||||
* serverExternalPackages in next.config. See docs/security.md.
|
||||
*/
|
||||
plugin?: TotpPluginFactory
|
||||
}
|
||||
| false
|
||||
|
||||
|
||||
Reference in New Issue
Block a user