Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
db05fe814b | ||
|
|
42df05af28 | ||
|
|
089b3a29ba | ||
|
|
ab16d459ed | ||
|
|
786dd346a9 | ||
|
|
86c873e4e7 | ||
|
|
efe8253f64 |
Vendored
+4
-3
@@ -1,11 +1,11 @@
|
||||
export { MaskedField } from '../globals/SiteIntegrations/components/MaskedField.js';
|
||||
export { TestEmailButton } from '../globals/SiteIntegrations/components/TestEmailButton.js';
|
||||
export { AccessibilityProvider, AccessibilityWidget, useAccessibility, } from '../modules/accessibility/client.js';
|
||||
export { AccessibilityProvider, AccessibilityWidget, useAccessibility } from '../modules/accessibility/client.js';
|
||||
export type { A11yClassNames, A11yState, A11yTexts } from '../modules/accessibility/client.js';
|
||||
export { 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';
|
||||
export { loadClarity, loadLinkedIn, loadMetaPixel, loadTikTok } from '../modules/analytics/client.js';
|
||||
/**
|
||||
* Entry point: ipal-kit/client
|
||||
*
|
||||
@@ -19,7 +19,7 @@ export { formAnalyticsOnSuccess } from '../modules/forms/formAnalytics.js';
|
||||
export type { FormAnalyticsConfig } from '../modules/forms/formAnalytics.js';
|
||||
export { HONEYPOT_FIELD, honeypotInputProps, isHoneypotTripped } from '../modules/forms/honeypot.js';
|
||||
export { useContactForm } from '../modules/forms/useContactForm.js';
|
||||
export type { ContactFormErrors, ContactFormValues, SubmitAction, } from '../modules/forms/useContactForm.js';
|
||||
export type { ContactFormErrors, ContactFormValues, SubmitAction } from '../modules/forms/useContactForm.js';
|
||||
export { useForm } from '../modules/forms/useForm.js';
|
||||
export type { FormErrors, FormSubmitAction, Validator } from '../modules/forms/useForm.js';
|
||||
export { buildValidator, checked, custom, email, isEmail, maxLength, minLength, pattern, required, } from '../modules/forms/validators.js';
|
||||
@@ -28,6 +28,7 @@ export { buildLocalizedPath, getLocaleCodes, getLocalizedSlugs, switchLocalePath
|
||||
export type { I18nConfig, LocalizedSlugs } from '../modules/i18n/index.js';
|
||||
export { AlternateLinksProvider, AlternateLinksUpdater, LanguageSwitcher, useAlternateLinks, useSetAlternateLinks, } from '../modules/i18n/index.js';
|
||||
export type { AlternateLinks, LanguageSwitcherClassNames } from '../modules/i18n/index.js';
|
||||
export { LocaleView } from '../modules/pages/LocaleView.js';
|
||||
export { Turnstile } from '../modules/turnstile/client.js';
|
||||
export { TurnstileProvider, useTurnstile } from '../modules/turnstile/client.js';
|
||||
export type { TurnstileProps } from '../modules/turnstile/client.js';
|
||||
|
||||
Vendored
+1
@@ -21,6 +21,7 @@ export { buildValidator, checked, custom, email, isEmail, maxLength, minLength,
|
||||
// components (e.g. a LanguageSwitcher that computes locale URLs on the client).
|
||||
export { buildLocalizedPath, getLocaleCodes, getLocalizedSlugs, switchLocalePath } from '../modules/i18n/index.js';
|
||||
export { AlternateLinksProvider, AlternateLinksUpdater, LanguageSwitcher, useAlternateLinks, useSetAlternateLinks } from '../modules/i18n/index.js';
|
||||
export { LocaleView } from '../modules/pages/LocaleView.js';
|
||||
export { Turnstile } from '../modules/turnstile/client.js';
|
||||
export { TurnstileProvider, useTurnstile } from '../modules/turnstile/client.js';
|
||||
|
||||
|
||||
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 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"}
|
||||
{"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 { AccessibilityProvider, AccessibilityWidget, useAccessibility } 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 { loadClarity, loadLinkedIn, loadMetaPixel, loadTikTok } 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 { ContactFormErrors, ContactFormValues, SubmitAction } 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 { LocaleView } from '../modules/pages/LocaleView.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","LocaleView","Turnstile","TurnstileProvider","useTurnstile"],"mappings":"AAAA;AACA,SAASA,WAAW,QAAQ,wDAAuD;AACnF,SAASC,eAAe,QAAQ,4DAA2D;AAC3F,SAASC,qBAAqB,EAAEC,mBAAmB,EAAEC,gBAAgB,QAAQ,qCAAoC;AAEjH,SAASC,SAAS,QAAQ,iCAAgC;AAG1D,SAASC,aAAa,QAAQ,iCAAgC;AAC9D,SAASC,WAAW,EAAEC,YAAY,EAAEC,aAAa,EAAEC,UAAU,QAAQ,iCAAgC;AACrG;;;;;;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;AAEnE,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,UAAU,QAAQ,iCAAgC;AAC3D,SAASC,SAAS,QAAQ,iCAAgC;AAC1D,SAASC,iBAAiB,EAAEC,YAAY,QAAQ,iCAAgC"}
|
||||
+3
-2
@@ -58,8 +58,9 @@ import { buildRobots, buildSitemapEntries } from '../seo/index.js';
|
||||
});
|
||||
/**
|
||||
* 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).
|
||||
* For app/not-found.tsx; never throws. not-found.tsx receives no params and
|
||||
* must NOT read headers() (breaks SSG/ISR) — call this for every configured
|
||||
* locale and let <LocaleView> (client) pick the one from the URL. See pages.md.
|
||||
*/ const getNotFoundPage = cache(async (locale)=>{
|
||||
try {
|
||||
const payload = await getCachedPayload();
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
import type { ReactNode } from 'react';
|
||||
type LocaleViewProps = {
|
||||
/** Used when the URL has no locale segment (single-locale site) or an unknown one. */
|
||||
defaultLocale: string;
|
||||
/**
|
||||
* One pre-rendered view per locale, e.g. { pl: <RenderBlocks …/>, en: … }.
|
||||
* Rendered on the SERVER (RSC) and passed in as props — this component only
|
||||
* picks one, so the content can come from the panel and the route stays static.
|
||||
*/
|
||||
views: Record<string, ReactNode>;
|
||||
};
|
||||
/**
|
||||
* Shows the view matching the locale in the current URL (`/en/...` → `en`).
|
||||
*
|
||||
* Made for `not-found.tsx`, which receives no `params`: reading the locale with
|
||||
* `headers()` there turns an SSG/ISR route dynamic ("Page changed from static
|
||||
* to dynamic at runtime"). `usePathname()` is client-side and static-safe, and
|
||||
* it also runs during SSR, so the HTML already contains the right language.
|
||||
*/
|
||||
export declare function LocaleView({ defaultLocale, views }: LocaleViewProps): import("react/jsx-runtime").JSX.Element;
|
||||
export {};
|
||||
Vendored
+23
@@ -0,0 +1,23 @@
|
||||
'use client';
|
||||
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
||||
// '.js' is required: `next` has no package.json "exports", so NodeNext resolution
|
||||
// (this plugin's tsconfig) can't find 'next/navigation' without the extension.
|
||||
// Bundlers in the project resolve the same file either way.
|
||||
import { usePathname } from 'next/navigation.js';
|
||||
/**
|
||||
* Shows the view matching the locale in the current URL (`/en/...` → `en`).
|
||||
*
|
||||
* Made for `not-found.tsx`, which receives no `params`: reading the locale with
|
||||
* `headers()` there turns an SSG/ISR route dynamic ("Page changed from static
|
||||
* to dynamic at runtime"). `usePathname()` is client-side and static-safe, and
|
||||
* it also runs during SSR, so the HTML already contains the right language.
|
||||
*/ export function LocaleView({ defaultLocale, views }) {
|
||||
const pathname = usePathname() ?? '';
|
||||
const segment = pathname.split('/').filter(Boolean)[0] ?? '';
|
||||
const locale = segment in views ? segment : defaultLocale;
|
||||
return /*#__PURE__*/ _jsx(_Fragment, {
|
||||
children: views[locale] ?? views[defaultLocale] ?? null
|
||||
});
|
||||
}
|
||||
|
||||
//# sourceMappingURL=LocaleView.js.map
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/modules/pages/LocaleView.tsx"],"sourcesContent":["'use client'\nimport type { ReactNode } from 'react'\n// '.js' is required: `next` has no package.json \"exports\", so NodeNext resolution\n// (this plugin's tsconfig) can't find 'next/navigation' without the extension.\n// Bundlers in the project resolve the same file either way.\nimport { usePathname } from 'next/navigation.js'\n\ntype LocaleViewProps = {\n /** Used when the URL has no locale segment (single-locale site) or an unknown one. */\n defaultLocale: string\n /**\n * One pre-rendered view per locale, e.g. { pl: <RenderBlocks …/>, en: … }.\n * Rendered on the SERVER (RSC) and passed in as props — this component only\n * picks one, so the content can come from the panel and the route stays static.\n */\n views: Record<string, ReactNode>\n}\n\n/**\n * Shows the view matching the locale in the current URL (`/en/...` → `en`).\n *\n * Made for `not-found.tsx`, which receives no `params`: reading the locale with\n * `headers()` there turns an SSG/ISR route dynamic (\"Page changed from static\n * to dynamic at runtime\"). `usePathname()` is client-side and static-safe, and\n * it also runs during SSR, so the HTML already contains the right language.\n */\nexport function LocaleView({ defaultLocale, views }: LocaleViewProps) {\n const pathname = usePathname() ?? ''\n const segment = pathname.split('/').filter(Boolean)[0] ?? ''\n const locale = segment in views ? segment : defaultLocale\n return <>{views[locale] ?? views[defaultLocale] ?? null}</>\n}\n"],"names":["usePathname","LocaleView","defaultLocale","views","pathname","segment","split","filter","Boolean","locale"],"mappings":"AAAA;;AAEA,kFAAkF;AAClF,+EAA+E;AAC/E,4DAA4D;AAC5D,SAASA,WAAW,QAAQ,qBAAoB;AAahD;;;;;;;CAOC,GACD,OAAO,SAASC,WAAW,EAAEC,aAAa,EAAEC,KAAK,EAAmB;IAClE,MAAMC,WAAWJ,iBAAiB;IAClC,MAAMK,UAAUD,SAASE,KAAK,CAAC,KAAKC,MAAM,CAACC,QAAQ,CAAC,EAAE,IAAI;IAC1D,MAAMC,SAASJ,WAAWF,QAAQE,UAAUH;IAC5C,qBAAO;kBAAGC,KAAK,CAACM,OAAO,IAAIN,KAAK,CAACD,cAAc,IAAI;;AACrD"}
|
||||
+40
-1
@@ -1,4 +1,32 @@
|
||||
import type { Plugin } from 'payload';
|
||||
type GenerateFileURL = (args: {
|
||||
filename: string;
|
||||
prefix?: string;
|
||||
}) => string;
|
||||
/**
|
||||
* Minimal shape of `s3Storage` from @payloadcms/storage-s3 — the plugin never
|
||||
* imports that package (it's optional: projects on local disk don't install it).
|
||||
* The project injects the real function; TypeScript checks it fits this shape.
|
||||
*/
|
||||
export type S3StorageFactory = (options: {
|
||||
bucket: string;
|
||||
collections: Record<string, {
|
||||
generateFileURL: GenerateFileURL;
|
||||
} | true>;
|
||||
config: {
|
||||
credentials: {
|
||||
accessKeyId: string;
|
||||
secretAccessKey: string;
|
||||
};
|
||||
endpoint: string;
|
||||
forcePathStyle: boolean;
|
||||
region: string;
|
||||
};
|
||||
}) => Plugin;
|
||||
export type BuildR2StorageDeps = {
|
||||
/** `import { s3Storage } from '@payloadcms/storage-s3'` — required when R2 env is set. */
|
||||
s3Storage?: S3StorageFactory;
|
||||
};
|
||||
/**
|
||||
* Cloudflare R2 media storage — configured from environment variables (agency
|
||||
* infrastructure, not per-project panel data). R2 is S3-compatible, so we use
|
||||
@@ -13,6 +41,17 @@ import type { Plugin } from 'payload';
|
||||
* storage (useful in dev without R2). This mirrors how mailAdapter degrades
|
||||
* gracefully when a transport isn't configured.
|
||||
*
|
||||
* The S3 adapter is INJECTED by the project (same pattern as 2FA / NextResponse):
|
||||
*
|
||||
* import { s3Storage } from '@payloadcms/storage-s3'
|
||||
* plugins: [buildR2Storage(['media'], { s3Storage })]
|
||||
*
|
||||
* A static import here would make @payloadcms/storage-s3 mandatory for every
|
||||
* project — including ones on local disk — because this module is exported
|
||||
* from the package's main entry.
|
||||
*
|
||||
* @param collections - slugs of upload collections to offload to R2 (e.g. ['media'])
|
||||
* @param deps - `{ s3Storage }` from @payloadcms/storage-s3 (needed only when R2 env is set)
|
||||
*/
|
||||
export declare const buildR2Storage: (collections?: string[]) => Plugin;
|
||||
export declare const buildR2Storage: (collections?: string[], deps?: BuildR2StorageDeps) => Plugin;
|
||||
export {};
|
||||
|
||||
+17
-2
@@ -1,4 +1,3 @@
|
||||
import { s3Storage } from '@payloadcms/storage-s3';
|
||||
/**
|
||||
* Cloudflare R2 media storage — configured from environment variables (agency
|
||||
* infrastructure, not per-project panel data). R2 is S3-compatible, so we use
|
||||
@@ -13,10 +12,20 @@ import { s3Storage } from '@payloadcms/storage-s3';
|
||||
* storage (useful in dev without R2). This mirrors how mailAdapter degrades
|
||||
* gracefully when a transport isn't configured.
|
||||
*
|
||||
* The S3 adapter is INJECTED by the project (same pattern as 2FA / NextResponse):
|
||||
*
|
||||
* import { s3Storage } from '@payloadcms/storage-s3'
|
||||
* plugins: [buildR2Storage(['media'], { s3Storage })]
|
||||
*
|
||||
* A static import here would make @payloadcms/storage-s3 mandatory for every
|
||||
* project — including ones on local disk — because this module is exported
|
||||
* from the package's main entry.
|
||||
*
|
||||
* @param collections - slugs of upload collections to offload to R2 (e.g. ['media'])
|
||||
* @param deps - `{ s3Storage }` from @payloadcms/storage-s3 (needed only when R2 env is set)
|
||||
*/ export const buildR2Storage = (collections = [
|
||||
'media'
|
||||
])=>{
|
||||
], deps = {})=>{
|
||||
const bucket = process.env.R2_BUCKET;
|
||||
const endpoint = process.env.R2_ENDPOINT;
|
||||
const accessKeyId = process.env.R2_ACCESS_KEY_ID;
|
||||
@@ -47,6 +56,12 @@ import { s3Storage } from '@payloadcms/storage-s3';
|
||||
prefix,
|
||||
filename
|
||||
].filter(Boolean).join('/') : undefined;
|
||||
// R2 env is complete → the adapter is required. Fail loudly at boot rather
|
||||
// than silently storing media on the container disk (lost on redeploy).
|
||||
const { s3Storage } = deps;
|
||||
if (!s3Storage) {
|
||||
throw new Error('[ipal] R2 storage: R2_* env is set but the S3 adapter was not injected. ' + "Install @payloadcms/storage-s3 and pass it: buildR2Storage(['media'], { s3Storage }) " + "with `import { s3Storage } from '@payloadcms/storage-s3'`. See docs/storage.md.");
|
||||
}
|
||||
const collectionsConfig = {};
|
||||
for (const slug of collections){
|
||||
collectionsConfig[slug] = generateFileURL ? {
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
@@ -1 +1,2 @@
|
||||
export { buildR2Storage } from './buildR2Storage.js';
|
||||
export type { BuildR2StorageDeps, S3StorageFactory } from './buildR2Storage.js';
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"sources":["../../../src/modules/storage/index.ts"],"sourcesContent":["export { buildR2Storage } from './buildR2Storage.js'\n"],"names":["buildR2Storage"],"mappings":"AAAA,SAASA,cAAc,QAAQ,sBAAqB"}
|
||||
{"version":3,"sources":["../../../src/modules/storage/index.ts"],"sourcesContent":["export { buildR2Storage } from './buildR2Storage.js'\nexport type { BuildR2StorageDeps, S3StorageFactory } from './buildR2Storage.js'\n"],"names":["buildR2Storage"],"mappings":"AAAA,SAASA,cAAc,QAAQ,sBAAqB"}
|
||||
+1
-1
@@ -36,4 +36,4 @@ Szczegóły API — jeden plik na moduł:
|
||||
|
||||
Zasada utrzymania: zmiana API modułu → aktualizacja jego pliku w tym samym
|
||||
commicie. Nowe reguły pracy → AGENT.md. Nowy krok procesu → PROGRAMISTA.md. Nowy etap budowy → vibe.md.
|
||||
Nie dodawaj kolejnych plików ogólnych.
|
||||
Nie dodawaj kolejnych plików ogólnych.
|
||||
|
||||
+1
-1
@@ -76,4 +76,4 @@ import { adminOnlyField, adminOrEditorField, requireRoleField } from '@intecion/
|
||||
```ts
|
||||
import { ROLE_HIERARCHY } from '@intecion/ipal-kit'
|
||||
// ['user', 'editor', 'admin'] — wyższa rola spełnia wymóg niższej
|
||||
```
|
||||
```
|
||||
|
||||
@@ -190,4 +190,4 @@ to **opcja, nie obowiązek** — dodawaj gdy klient wymaga, nie z automatu.
|
||||
Gdy dodajesz: widget sam w sobie NIE czyni strony w pełni dostępną — to pomoc dla
|
||||
użytkownika. Pełna dostępność to też semantyczny HTML, alt teksty, nawigacja
|
||||
klawiaturą, kontrast bazowy. Widget uzupełnia, nie zastępuje. Nie sprzedawaj
|
||||
klientowi „mamy widget = jesteśmy zgodni z WCAG". Patrz PROGRAMISTA.md §5.
|
||||
klientowi „mamy widget = jesteśmy zgodni z WCAG". Patrz PROGRAMISTA.md §5.
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
>
|
||||
> **W projekcie:**
|
||||
> - w roocie krótki `AGENTS.md` (szablon w §13), który wskazuje na ten plik w
|
||||
> `node_modules/@intecion/ipal-kit/docs/agent/AGENT.md` — nie kopiuj reguł, kopia się zestarzeje;
|
||||
> `node_modules/@intecion/ipal-kit/docs/agent/AGENT.md` — nie kopiuj reguł, kopia się zestarzeje;
|
||||
> - skille w `.agents/skills/` (§14) — kopiowane z pakietu jedną komendą, odświeżane
|
||||
> po każdej aktualizacji ipal-kit.
|
||||
> po każdej aktualizacji ipal-kit.
|
||||
|
||||
---
|
||||
|
||||
@@ -150,8 +150,11 @@ Bez skrótów (`HeroSection`, nie `HeroSec`). Nie twórz `lib/pages.ts`,
|
||||
dynamiczna → metadata w body.
|
||||
5. **`htmlLimitedBots`** w `next.config.ts` (seo.md).
|
||||
6. **Nie czytaj `searchParams`** w stronie bez paginacji — deoptymalizuje
|
||||
ISR/SSG. Nie czytaj `headers()` w komponentach bloków (to samo). Locale do
|
||||
bloków wstrzykuj przez `enhanceProps`.
|
||||
ISR/SSG. **Nie czytaj `headers()` / `cookies()`** nigdzie w drzewie stron
|
||||
statycznych — w blokach, komponentach, layoucie `[locale]` ani w
|
||||
`not-found.tsx` (Next 16: `Page changed from static to dynamic at runtime`).
|
||||
Locale do bloków → `enhanceProps`; w `not-found.tsx` (brak `params`) →
|
||||
wersja na każdy język + `<LocaleView>` (pages.md).
|
||||
7. **`export const dynamic = 'force-dynamic'`** na trasach czytających bazę:
|
||||
`manifest.ts`, `sitemap.ts`/`sitemap.xml`, `llms.txt`, `api/health`. Handlery
|
||||
pluginu mają try/catch, ale `dynamic` musi być w pliku trasy.
|
||||
@@ -1220,4 +1223,4 @@ pnpm ipal:skills
|
||||
```
|
||||
Commituj `.agents/skills/ipal-*` do repo projektu (agent ma je bez instalacji).
|
||||
Własne skille projektu nazywaj bez prefiksu `ipal-` — kopiowanie nadpisuje tylko
|
||||
skille pluginu.
|
||||
skille pluginu.
|
||||
@@ -0,0 +1,36 @@
|
||||
---
|
||||
name: ipal-audit
|
||||
description: Audits an ipal-kit (Payload 3 + Next 16) project against AGENT.md rules with a deterministic script — hardcoded texts/links, forbidden field names, monolithic sections, middleware.ts, missing ISR/generateStaticParams, hex colors, server imports in client components, extra collections, then tsc and build. Use before saying a task is done, after any block/collection/layout change, after an Impeccable pass, and when asked to review or audit the project.
|
||||
---
|
||||
|
||||
# ipal-audit
|
||||
|
||||
Kontrole z AGENT.md §11 jako skrypt — zawsze te same, bez interpretacji.
|
||||
|
||||
## Kroki
|
||||
|
||||
1. Z roota projektu uruchom:
|
||||
```bash
|
||||
bash .agents/skills/ipal-audit/scripts/audit.sh --quick # w trakcie pracy
|
||||
bash .agents/skills/ipal-audit/scripts/audit.sh # przed „gotowe” (+ tsc + build)
|
||||
```
|
||||
Opcje: `--help`. Nie czytaj źródła skryptu — wynik wystarczy.
|
||||
2. Pokaż użytkownikowi **pełny wynik** (podsumowanie + listę naruszeń).
|
||||
3. Każde `[ERROR]` napraw albo — jeśli to świadomy wyjątek — dodaj w kodzie
|
||||
komentarz z uzasadnieniem i wymień go w odpowiedzi.
|
||||
Reguła przy każdym naruszeniu wskazuje sekcję w
|
||||
`node_modules/@intecion/ipal-kit/docs/agent/AGENT.md` — przeczytaj ją przed poprawką.
|
||||
4. `[WARNING]` — oceń i powiedz użytkownikowi, co z nim zrobić; nie poprawiaj
|
||||
na ślepo (np. `searchParams` jest OK w trasie archiwum z paginacją).
|
||||
5. Uruchom ponownie, aż wynik to `0 error(s)`.
|
||||
|
||||
## Czego skrypt nie sprawdzi (zrób ręcznie)
|
||||
|
||||
- **Test redaktora** (AGENT.md §11): czy każdy tekst, obraz, przycisk, sekcja,
|
||||
menu, stopka i SEO zmienia się w panelu, w każdym języku.
|
||||
- **Zgoda cookies:** w Network przed akceptacją brak żądań do
|
||||
google-analytics / googletagmanager (poza Consent Mode), facebook.net,
|
||||
clarity.ms, licdn, tiktok.
|
||||
- **Treść**: czy fallbacki nie zawierają danych klienta (`|| 'Firma X'`).
|
||||
|
||||
Nie mów „gotowe”, dopóki pełny audyt (bez `--quick`) nie ma błędów.
|
||||
@@ -0,0 +1,157 @@
|
||||
#!/usr/bin/env bash
|
||||
# ipal-audit — deterministic checks of an ipal-kit project against AGENT.md.
|
||||
# Run from the project root:
|
||||
# bash .agents/skills/ipal-audit/scripts/audit.sh # all checks + tsc + build
|
||||
# bash .agents/skills/ipal-audit/scripts/audit.sh --quick # static checks only
|
||||
# bash .agents/skills/ipal-audit/scripts/audit.sh --help
|
||||
# Exit code: 0 = no errors (warnings allowed), 1 = at least one error.
|
||||
|
||||
set -u
|
||||
|
||||
QUICK=0
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
--quick) QUICK=1 ;;
|
||||
--help|-h)
|
||||
sed -n '2,7p' "$0" | sed 's/^# \{0,1\}//'
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ ! -d src ]; then
|
||||
echo "ipal-audit: run from the project root (no ./src found)." >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
ERRORS=0
|
||||
WARNINGS=0
|
||||
|
||||
# report LEVEL "title" "rule" <<< "$matches"
|
||||
report() {
|
||||
local level="$1" title="$2" rule="$3" matches="$4"
|
||||
[ -z "$matches" ] && return 0
|
||||
local count
|
||||
count=$(printf '%s\n' "$matches" | grep -c .)
|
||||
if [ "$level" = ERROR ]; then ERRORS=$((ERRORS + count)); else WARNINGS=$((WARNINGS + count)); fi
|
||||
printf '\n[%s] %s (%s) — %s\n' "$level" "$title" "$count" "$rule"
|
||||
printf '%s\n' "$matches" | head -20 | sed 's/^/ /'
|
||||
[ "$count" -gt 20 ] && printf ' … and %s more\n' "$((count - 20))"
|
||||
}
|
||||
|
||||
g() { grep -rnE "$@" 2>/dev/null || true; }
|
||||
# drop matches that sit inside a // or /* comment (keeps http:// URLs)
|
||||
nc() { grep -vE "(^|[^:])//.*$1|/\*.*$1" || true; }
|
||||
dirs() { for d in "$@"; do [ -d "$d" ] && printf '%s ' "$d"; done; }
|
||||
|
||||
BLOCKS=$(dirs src/blocks)
|
||||
UI=$(dirs src/blocks src/components)
|
||||
|
||||
echo "ipal-audit — $(pwd)"
|
||||
|
||||
# --- Architecture (AGENT.md §4) ---
|
||||
report ERROR "middleware.ts exists" "§4.1 Next 16 uses proxy.ts only" \
|
||||
"$(ls src/middleware.ts middleware.ts 2>/dev/null)"
|
||||
|
||||
report ERROR "<head> in app" "§4.2 no explicit <head> — metadata ends up in <body>" \
|
||||
"$(g '<head[ >]' src/app --include=*.tsx | nc '<head')"
|
||||
|
||||
PAGES=$(find src/app -path '*\[\[...slug\]\]*' -name 'page.tsx' 2>/dev/null)
|
||||
for p in $PAGES; do
|
||||
grep -q 'revalidate' "$p" || report ERROR "no ISR" "§4.3 export const revalidate" "$p"
|
||||
grep -q 'generateStaticParams' "$p" || report ERROR "no generateStaticParams" "§4.4 without it the route is dynamic and metadata lands in <body>" "$p"
|
||||
report WARNING "searchParams in catch-all page" "§4.6 deoptimizes SSG/ISR — only for paginated archives" \
|
||||
"$(grep -n 'searchParams' "$p" | nc 'searchParams' | sed "s|^|$p:|")"
|
||||
done
|
||||
|
||||
for r in src/app/sitemap.ts src/app/manifest.ts src/app/llms.txt/route.ts src/app/sitemap.xml/route.ts src/app/api/health/route.ts; do
|
||||
[ -f "$r" ] && ! grep -q "dynamic = 'force-dynamic'" "$r" && \
|
||||
report ERROR "DB route without force-dynamic" "§4.7 build without DB will crash" "$r"
|
||||
done
|
||||
|
||||
report ERROR "headers()/cookies() in blocks/components" "§4.6 forces dynamic rendering — pass locale via enhanceProps" \
|
||||
"$( [ -n "$UI" ] && g "from 'next/headers'" $UI)"
|
||||
|
||||
report ERROR "headers()/cookies() in static page tree" "§4.6 SSG/ISR → 'Page changed from static to dynamic' — not-found: LocaleView (pages.md)" \
|
||||
"$(g "from 'next/headers'" src/app --include=page.tsx --include=layout.tsx --include=not-found.tsx --include=template.tsx | grep -v '/api/\|(payload)')"
|
||||
|
||||
# --- Hardcoding & types (§2, §8) ---
|
||||
report ERROR "hardcoded locale map / any / ts-ignore" "§2, §8" \
|
||||
"$(g 'localizedRoutes|as any\b|@ts-ignore|: any\b' src --include=*.ts --include=*.tsx | grep -v '/payload-types.ts:')"
|
||||
|
||||
report ERROR "hardcoded locale list" "§2 languages come from i18n.config.ts" \
|
||||
"$(g "\[ *'(pl|en|de|fr|es|it)' *, *'(pl|en|de|fr|es|it)'" src --include=*.ts --include=*.tsx | grep -v 'i18n.config.ts')"
|
||||
|
||||
# --- Sections (§6) ---
|
||||
if [ -n "$BLOCKS" ]; then
|
||||
report ERROR "forbidden field names" "§6.5 use links/link/media (linksField, linkField, upload)" \
|
||||
"$(g "name: *'[a-zA-Z]*([cC]ta|[bB]utton|Url|Href|[pP]df|[iI]mage)[a-zA-Z]*'" $BLOCKS --include=config.ts)"
|
||||
|
||||
report ERROR "hardcoded href/src/file paths in blocks" "§2, §6 use CMSLink / Media" \
|
||||
"$(g 'href=\{?["`]/|<img |/files/|/images/|\.pdf' $BLOCKS --include=*.tsx | nc '(href|<img|/files/|/images/|\.pdf)')"
|
||||
|
||||
report ERROR "raw <a>/<Link> in blocks" "§6.3 links from the panel render via CMSLink" \
|
||||
"$(g '<(a|Link)[ >]' $BLOCKS --include=*.tsx)"
|
||||
|
||||
report WARNING "inline <svg> in blocks" "§6.10 icons via media upload or Icon map" \
|
||||
"$(g '<svg[ >]' $BLOCKS --include=*.tsx)"
|
||||
|
||||
report WARNING "large section component (>120 lines)" "§6.4 split into subcomponents" \
|
||||
"$(find $BLOCKS -name '*.tsx' -exec wc -l {} + 2>/dev/null | awk '$2 != "total" && $1 > 120 {print $2": "$1" lines"}')"
|
||||
|
||||
report ERROR "Component imported into block config" "§6.12 payload.config must not pull React components" \
|
||||
"$(g "from '\./Component'|/Component'" $BLOCKS --include=config.ts)"
|
||||
fi
|
||||
|
||||
if [ -n "$UI" ]; then
|
||||
report ERROR "hex colors in classes" "§6.11 use design tokens (bg-primary…)" \
|
||||
"$(g '(bg|text|border|from|to|via|fill|stroke)-\[#' $UI --include=*.tsx)"
|
||||
|
||||
report ERROR "barrel index.ts" "§6.12 import files directly" \
|
||||
"$(find $UI -name 'index.ts' 2>/dev/null)"
|
||||
|
||||
CLIENT=$(grep -rlE "^['\"]use client['\"]" $UI 2>/dev/null)
|
||||
for c in $CLIENT; do
|
||||
report ERROR "server import in client component" "§6.9 no payload / lib/content / server-only in 'use client'" \
|
||||
"$(grep -nE "from '(payload|server-only|@/lib/content|@/payload\.config)'" "$c" | grep -v 'import type' | sed "s|^|$c:|")"
|
||||
done
|
||||
fi
|
||||
|
||||
# --- Collections (§5.3) ---
|
||||
if [ -d src/collections ]; then
|
||||
report ERROR "forbidden collection" "§5.3 users are built in; settings/nav/footer are globals; FAQ/hero are blocks" \
|
||||
"$(ls src/collections | grep -iE '^(users|user|settings|navigation|nav|footer|header|faq|hero|company|danefirmy)\.ts$')"
|
||||
report WARNING "collections present — confirm each passed the §5.3 test" "minimum: Pages, Media" \
|
||||
"$(ls src/collections | grep -viE '^(pages|media|users|user|settings|navigation|nav|footer|header|faq|hero|company|danefirmy)\.ts$')"
|
||||
fi
|
||||
|
||||
# --- Plugin duplicates (§1, §7) ---
|
||||
report ERROR "own block renderer switch" "§7 use RenderBlocks + registry" \
|
||||
"$(g 'switch *\(.*blockType' src --include=*.tsx --include=*.ts)"
|
||||
report WARNING "files that usually duplicate the plugin" "§3 plugin has resolveRoute / getConfiguredLocales" \
|
||||
"$(ls src/lib/pages.ts src/lib/locales.ts 2>/dev/null)"
|
||||
report ERROR "manual Lexical rendering" "§7 use RenderRichText" \
|
||||
"$(g 'node\.type *===|dangerouslySetInnerHTML' src --include=*.tsx)"
|
||||
|
||||
# --- Compile & build ---
|
||||
if [ "$QUICK" -eq 0 ]; then
|
||||
echo
|
||||
echo "== pnpm generate:types && tsc --noEmit =="
|
||||
if ! (pnpm -s generate:types >/dev/null && pnpm -s exec tsc --noEmit); then
|
||||
ERRORS=$((ERRORS + 1)); echo "[ERROR] type check failed"
|
||||
fi
|
||||
echo
|
||||
echo "== pnpm build =="
|
||||
BUILD_LOG=$(mktemp)
|
||||
if pnpm -s build >"$BUILD_LOG" 2>&1; then
|
||||
DYN=$(grep -E '^[│├└ ]*ƒ .*\[locale\]' "$BUILD_LOG" || true)
|
||||
report WARNING "page routes rendered dynamically (ƒ)" "§4 expected ● SSG — does the build see the DB?" "$DYN"
|
||||
else
|
||||
ERRORS=$((ERRORS + 1)); echo "[ERROR] build failed — last lines:"; tail -30 "$BUILD_LOG" | sed 's/^/ /'
|
||||
fi
|
||||
rm -f "$BUILD_LOG"
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "ipal-audit: $ERRORS error(s), $WARNINGS warning(s)$( [ "$QUICK" -eq 1 ] && echo ' (quick: no tsc/build)')"
|
||||
[ "$ERRORS" -eq 0 ]
|
||||
@@ -0,0 +1,42 @@
|
||||
---
|
||||
name: ipal-block
|
||||
description: Builds or refactors one page section (Payload block + React component) in an ipal-kit project the correct way — shared fields (sectionHeaderField, linksField, linkField, sectionSettingsField), UI primitives (Section, SectionHeader, Media, CMSLink), fixed field vocabulary, max ~80 lines of JSX, subcomponents for repeated items, registry wiring. Use when creating a new section/block (hero, features, CTA, FAQ, gallery, pricing, testimonials…), changing a block's fields, or fixing a block with ctaLabel/buttonUrl/pdfUrl fields or a monolithic component.
|
||||
---
|
||||
|
||||
# ipal-block
|
||||
|
||||
Jedna sekcja na jedno użycie skilla. Szczegóły i gotowy kod:
|
||||
`node_modules/@intecion/ipal-kit/docs/agent/AGENT.md` §6.
|
||||
|
||||
## 0. Warunki wstępne
|
||||
Sprawdź, czy istnieją: `src/fields/link.ts`, `sectionHeader.ts`,
|
||||
`sectionSettings.ts`, `src/components/ui/{CMSLink,Button,Media,Section,SectionHeader}.tsx`,
|
||||
`src/lib/links.ts`. Brakuje → najpierw utwórz je 1:1 z AGENT.md §6.2–6.3
|
||||
(i powiedz o tym użytkownikowi). Nie pisz własnych wersji.
|
||||
|
||||
## 1. Plan (pokaż i czekaj na OK)
|
||||
- slug bloku (camelCase), nazwa folderu (PascalCase),
|
||||
- lista pól **tylko** ze słownika AGENT.md §6.5:
|
||||
`header`, `media`, `links`, `link`, `items` (+ `heading`, `text`, `content`), `settings`,
|
||||
- czy elementy `items` dostają podkomponent `<Nazwa>Card.tsx`,
|
||||
- czy potrzebna interakcja → osobny plik `'use client'` (najpierw `<details>`/`<dialog>`),
|
||||
- czy sekcja to wariant istniejącego bloku (wtedy pole `variant: select`, nie nowy blok).
|
||||
|
||||
## 2. Kod
|
||||
1. `src/blocks/<Nazwa>/config.ts` — `interfaceName: '<Nazwa>Block'`, pola z planu,
|
||||
zawsze `sectionSettingsField()`. CTA = `linksField()`, nigdy pola `cta*`/`button*`.
|
||||
Plik do pobrania = link typu `file`. Etykiety i opisy pól po angielsku.
|
||||
2. `src/blocks/<Nazwa>/Component.tsx` — nazwany eksport, typ z `@/payload-types`
|
||||
(`<Nazwa>Block & { locale: string }`), struktura:
|
||||
`<Section settings>` → `<SectionHeader header>` → treść z `<Media>`, `<CMSLink>`,
|
||||
`items.map(<Card/>)`. Zero tekstu, `href`, `<img>`, hexów, inline SVG.
|
||||
3. Podkomponenty w tym samym folderze; wspólne dla 2+ sekcji → `src/components/ui/`.
|
||||
4. Dodaj `config.ts` do `layout` w `src/collections/Pages.ts`,
|
||||
komponent do `src/blocks/registry.ts` (klucz = slug).
|
||||
5. `pnpm generate:types`.
|
||||
|
||||
## 3. Weryfikacja
|
||||
- `Component.tsx` ≤ ~80 linii JSX.
|
||||
- Uruchom skill **ipal-audit** (`--quick`), napraw wszystkie `[ERROR]`.
|
||||
- Refaktor istniejącego bloku ze zmianą nazw pól: **najpierw migracja danych**
|
||||
(stare pole → nowe), dopiero potem usunięcie starych pól (AGENT.md §6.7).
|
||||
@@ -0,0 +1,45 @@
|
||||
---
|
||||
name: ipal-collection
|
||||
description: Decides whether something should be a Payload collection, a global, or a block, and builds a content collection the ipal-kit way (title, buildSlugField, SEO tab, buildNoindexField, trackSlugHistoryHook, revalidate hook, archive page from System Pages, sitemap and routing via content option). Use when the user asks for a blog, news, products, portfolio, testimonials, authors, categories, or any new collection — and whenever you are about to create a file in src/collections.
|
||||
---
|
||||
|
||||
# ipal-collection
|
||||
|
||||
Źródła: `node_modules/@intecion/ipal-kit/docs/agent/AGENT.md` §5,
|
||||
`docs/content.md`, `docs/hooks.md`, `docs/seo.md`.
|
||||
|
||||
## 1. Test (zawsze, przed jakimkolwiek kodem)
|
||||
Odpowiedz użytkownikowi na 4 pytania — wszystkie muszą być TAK:
|
||||
1. Lista wielu rekordów tego samego typu?
|
||||
2. Każdy rekord ma **własny URL**?
|
||||
3. Klient **jawnie** tego wymaga?
|
||||
4. Payload nie ma tego wbudowanego?
|
||||
|
||||
Którekolwiek NIE → to nie kolekcja:
|
||||
- jeden zestaw danych (firma, menu, stopka, ustawienia) → **global**,
|
||||
- część strony (FAQ, hero, opinie w sekcji) → **blok** (skill ipal-block),
|
||||
- `users` → wbudowane w Payload, nie twórz.
|
||||
|
||||
Wyjątek: lista bez własnych URL-i zarządzana osobno (np. opinie używane w wielu
|
||||
blokach) — kolekcja **bez** wpięcia w `content`. Uzasadnij to w planie.
|
||||
|
||||
## 2. Plan (pokaż i czekaj na OK)
|
||||
slug (camelCase, l.mn.), pola, relacje, czy ma URL-e (archiwum), JSON-LD.
|
||||
|
||||
## 3. Kod
|
||||
1. `src/collections/<Nazwa>.ts`: `title` (localized), `buildSlugField({ from: 'title' })`,
|
||||
tab SEO (plugin-seo), `buildNoindexField()`, `trackSlugHistoryHook`,
|
||||
`buildRevalidateHook`, `setPublishedAtHook` (wpisy z datą), upload przez
|
||||
`media`, linki przez `linkField()`. Nazwy pól wg AGENT.md §6.5.
|
||||
2. Z URL-ami: dopisz do `content.config.ts` → `{ slug, perPage }`.
|
||||
**Prefiks URL nie w kodzie** — redaktor przypisuje stronę-archiwum w
|
||||
Site Settings (`<slug>Archive`). Plugin robi routing, sitemap,
|
||||
generateStaticParams, hreflang.
|
||||
3. Lista wpisów = blok (EntriesList) z `getEntries`; strona wpisu z
|
||||
`resolveRoute` (typ `entry`); JSON-LD wg seo.md (np. Article).
|
||||
4. `pnpm generate:types`, `pnpm payload generate:importmap`.
|
||||
5. Postgres z migracjami → `pnpm payload migrate:create`.
|
||||
|
||||
## 4. Weryfikacja
|
||||
Skill **ipal-audit**. Ręcznie: wpis w panelu → widoczny pod `/<locale>/<archiwum>/<slug>`,
|
||||
w sitemapie, zmiana sluga → 308 ze starego adresu.
|
||||
@@ -0,0 +1,34 @@
|
||||
---
|
||||
name: ipal-nav
|
||||
description: Builds the site header, footer, mobile menu and company data in an ipal-kit project — Header/Footer/Company globals with linkField, server-side link resolution (resolveNav), a small client MobileNav, legal links from System Pages, revalidation on change. Use when creating or changing navigation, menu, header, footer, contact details, social links or the company global.
|
||||
---
|
||||
|
||||
# ipal-nav
|
||||
|
||||
Gotowy kod: `node_modules/@intecion/ipal-kit/docs/agent/AGENT.md` §6.8.
|
||||
Wymaga prymitywów z §6.2–6.3 (jak skill ipal-block, krok 0).
|
||||
|
||||
## Plan (pokaż i czekaj na OK)
|
||||
- pozycje menu (jeden poziom podmenu, nie głębiej), CTA w nagłówku (`links`),
|
||||
- kolumny stopki, notka,
|
||||
- model `Company` dla rynku z AGENTS.md (PL: NIP/REGON, AU: ABN, US: EIN…),
|
||||
- etykiety a11y (przycisk menu itp.) — pola w panelu.
|
||||
|
||||
## Kod
|
||||
1. `src/globals/Header.ts`, `Footer.ts` — z §6.8; `Company.ts` — dane firmy
|
||||
(teksty localized), `access.read: () => true`.
|
||||
2. Hook `afterChange` na każdym globalu: `revalidatePath('/', 'layout')`
|
||||
(wstrzyknięty z `next/cache`, hooks.md).
|
||||
3. `src/lib/navigation.ts` (`resolveNav`) — linki rozwiązane na serwerze do
|
||||
`{ href, label, newTab, subItems }`.
|
||||
4. `src/components/layout/Header.tsx`, `Footer.tsx` (serwer), `MobileNav.tsx`
|
||||
(`'use client'`, tylko stan otwarcia, dane przez props, `import type` z lib).
|
||||
5. **Linki prawne w stopce** z ról System Pages (`getSystemPagePath` + tytuł
|
||||
strony) — nie jako ręczne pozycje. Rok w copyright z kodu, nazwa z `Company`.
|
||||
6. Logo z Site Settings przez `<Media>` — nie duplikuj pola w Header.
|
||||
7. Podepnij w `src/app/(frontend)/[locale]/layout.tsx` (pobranie globali przez
|
||||
cached gettery w `lib/`, przekazanie jako props).
|
||||
|
||||
## Weryfikacja
|
||||
Skill **ipal-audit**. Ręcznie: dodanie pozycji menu w panelu widać od razu po
|
||||
zapisie; menu mobilne działa z klawiatury (Tab, Enter, Esc).
|
||||
@@ -0,0 +1,38 @@
|
||||
---
|
||||
name: ipal-plugin-gap
|
||||
description: Handles the moment when @intecion/ipal-kit seems to lack a feature or behaves wrongly — verifies against the plugin docs and type definitions first, then writes a structured report for the plugin instead of patching the project with hooks, hardcoded values or copied plugin code. Use when tempted to work around the plugin, when a plugin function errors or is missing, or when the same need appears in several projects.
|
||||
---
|
||||
|
||||
# ipal-plugin-gap
|
||||
|
||||
Reguła: AGENT.md §1.3 — **nie łataj w projekcie**.
|
||||
|
||||
## 1. Sprawdź, czy plugin tego nie ma
|
||||
- `ls node_modules/@intecion/ipal-kit/docs/` — przeczytaj plik modułu,
|
||||
- `grep -rn "<słowo kluczowe>" node_modules/@intecion/ipal-kit/dist --include=*.d.ts`,
|
||||
- sprawdź wersję: `grep '"version"' node_modules/@intecion/ipal-kit/package.json`
|
||||
(może problem jest naprawiony w nowszej — skill **ipal-upgrade**).
|
||||
|
||||
Plugin to ma → użyj go i powiedz użytkownikowi, gdzie to było.
|
||||
|
||||
## 2. Raport (gdy naprawdę brakuje albo nie działa)
|
||||
Zapisz w `docs/plugin-requests/<data>-<temat>.md` projektu i pokaż użytkownikowi:
|
||||
|
||||
```markdown
|
||||
# <temat>
|
||||
**Projekt:** <nazwa> · **ipal-kit:** <wersja>
|
||||
## Problem
|
||||
<co nie działa / czego brakuje; komunikat błędu; kroki odtworzenia>
|
||||
## Dlaczego to do pluginu
|
||||
<czy przyda się w innych projektach — konkretnie>
|
||||
## Proponowane API
|
||||
<sygnatura funkcji / opcja ipalKit / pole w panelu; przykład użycia w projekcie>
|
||||
## Obejście tymczasowe (jeśli konieczne)
|
||||
<minimalne, w jednym pliku, z komentarzem TODO odsyłającym do tego raportu>
|
||||
```
|
||||
|
||||
## 3. Czego nie robić
|
||||
- hooka z zaszytą domeną/nazwą/kolorem klienta,
|
||||
- kopii komponentu pluginu do projektu (np. `Analytics`, `CookieBanner`),
|
||||
- `as any` / `@ts-ignore` żeby „przeszło”,
|
||||
- dynamicznego `import()` przez zmienną (nie wbundluje się).
|
||||
@@ -0,0 +1,38 @@
|
||||
---
|
||||
name: ipal-setup
|
||||
description: Sets up a new client project on Payload 3 + Next 16 + @intecion/ipal-kit from an empty folder — registry and dependencies, version overrides, i18n config, payload.config with ipalKit (2FA injected, white-label), core collections, design tokens, UI primitives, proxy, layout and catch-all page, SEO routes, security headers, env validation. Use when starting a new website project or when a project is missing its ipal-kit foundation.
|
||||
---
|
||||
|
||||
# ipal-setup
|
||||
|
||||
Kod i szczegóły: `node_modules/@intecion/ipal-kit/docs/dev/PROGRAMISTA.md` §1–2
|
||||
(przed instalacją pakietu: poproś użytkownika o ten plik albo działaj wg kroków
|
||||
poniżej i doczytaj po `pnpm add`). Reguły: `docs/agent/AGENT.md`.
|
||||
|
||||
**Jeden etap = jeden commit. Po każdym etapie pokaż wynik i czekaj na OK.**
|
||||
|
||||
1. **Instalacja** — `.npmrc` (`@intecion:registry=…`, `legacy-peer-deps=true`),
|
||||
`pnpm add @intecion/ipal-kit` + zależności z PROGRAMISTA §1, `pnpm.overrides`
|
||||
na wersję `payload` dla wszystkich `@payloadcms/*`, build z `--webpack`.
|
||||
Nigdy instalacja z gita. Nie twórz `middleware.ts`.
|
||||
2. **Skille i AGENTS.md** — skopiuj skille (AGENT.md §14), utwórz `AGENTS.md`
|
||||
wg AGENT.md §13 z danymi od użytkownika (zapytaj o: klient, domena, rynek,
|
||||
języki, R2/lokalnie, SMTP/Graph).
|
||||
3. **Konfiguracja** — `src/i18n.config.ts` (`as const satisfies I18nConfig`),
|
||||
`payload.config.ts` wg PROGRAMISTA §2.3: `twoFactor` z **wstrzykniętym**
|
||||
`payloadTotp`, `whiteLabel: true`, `email: mailAdapter()`.
|
||||
4. **Rdzeń** — wspólne pola i prymitywy (AGENT.md §6.2–6.3), `Pages`, `Media`
|
||||
(PROGRAMISTA §2.4). Żadnych innych kolekcji.
|
||||
5. **Style** — `styles.css` z `@theme` z `DESIGN.md` (jeśli brak — zapytaj o
|
||||
Impeccable albo załóż neutralne tokeny), `@source` na plugin (AGENT.md §6.11).
|
||||
6. **Routing** — `proxy.ts` (`createProxy`), `lib/content.ts`, layout bez
|
||||
`<head>`, catch-all z ISR + `generateStaticParams` + `resolveRedirect`,
|
||||
`not-found.tsx` z `LocaleView` — bez `headers()`, wersja na każdy język (PROGRAMISTA §2.6–2.8, pages.md).
|
||||
7. **SEO i bezpieczeństwo** — sitemap, robots, manifest, llms.txt, health
|
||||
(wszystkie z `force-dynamic`), `htmlLimitedBots`, `buildSecurityHeaders`,
|
||||
`instrumentation.ts` z `assertEnv` (PROGRAMISTA §2.8–2.9).
|
||||
8. **Nawigacja** — skill **ipal-nav**.
|
||||
9. `pnpm generate:types`, `pnpm payload generate:importmap`, skill **ipal-audit**
|
||||
(pełny), lista kroków w panelu dla użytkownika (PROGRAMISTA §2.11).
|
||||
|
||||
Dalej: bloki (skill **ipal-block**), kolekcje treści (**ipal-collection**).
|
||||
@@ -0,0 +1,36 @@
|
||||
---
|
||||
name: ipal-upgrade
|
||||
description: Upgrades an existing project to the latest @intecion/ipal-kit and replaces hand-written code that the plugin now provides — proxy, route handlers, consent wrapper, language switcher, rich text parser, form logic, noindex, redirects, env validation, privacy link label, 404 page, CTA field zoo. Use when the user asks to update ipal-kit, migrate an older project, or clean up duplicated logic in a project.
|
||||
---
|
||||
|
||||
# ipal-upgrade
|
||||
|
||||
Lista zmian: `node_modules/@intecion/ipal-kit/docs/dev/PROGRAMISTA.md` §6.
|
||||
Zasada: gdy plugin dostarcza coś, co projekt ma ręcznie — **usuń lokalną wersję**.
|
||||
|
||||
## 1. Aktualizacja pakietu
|
||||
```bash
|
||||
pnpm add @intecion/ipal-kit@latest
|
||||
rm -rf .next
|
||||
```
|
||||
Skopiuj skille na nowo (AGENT.md §14) — mogły się zmienić.
|
||||
Postgres z migracjami: nowe pola pluginu (np. `privacyLinkLabel`) →
|
||||
`pnpm payload migrate:create`.
|
||||
|
||||
## 2. Inwentaryzacja (bez zmian w kodzie)
|
||||
Dla **każdej** pozycji tabeli PROGRAMISTA §6 pokaż dowód (grep / plik), czy
|
||||
dotyczy projektu. Uruchom skill **ipal-audit** (`--quick`) i dołącz wynik.
|
||||
Wynik: lista do zrobienia z priorytetem. Czekaj na OK.
|
||||
|
||||
## 3. Pozycja po pozycji
|
||||
Jedna pozycja = jedna zmiana = jeden commit:
|
||||
1. przeczytaj wskazany plik docs,
|
||||
2. zastąp lokalny kod funkcją pluginu, usuń stary kod (nie zostawiaj obu),
|
||||
3. `pnpm build`, pokaż wynik.
|
||||
|
||||
Pozycje zmieniające nazwy pól w bazie (np. refaktor `ctaLabel` → `links`)
|
||||
wymagają **migracji danych przed** usunięciem starych pól — zapytaj
|
||||
użytkownika, czy projekt ma już treść.
|
||||
|
||||
## 4. Koniec
|
||||
Pełny **ipal-audit** bez błędów + lista rzeczy do sprawdzenia w panelu.
|
||||
+2
-2
@@ -77,7 +77,7 @@ export default async function LocaleLayout({ children, params }) {
|
||||
```
|
||||
|
||||
`Analytics` nie renderuje nic — wstrzykuje skrypty. Zamontuj raz, wysoko w
|
||||
drzewie. **Musi być wewnątrz `ConsentProvider`** (od 1.8.0 czyta stan zgody na
|
||||
drzewie. **Musi być wewnątrz `ConsentProvider`** (od 1.7.12 czyta stan zgody na
|
||||
żywo — poza providerem rzuci błąd kontekstu).
|
||||
|
||||
## Tryb Core Web Vitals — `defer` (opcjonalny)
|
||||
@@ -325,4 +325,4 @@ forms + analytics, nie konfiguracja GTM.
|
||||
| Event `form_submit` + parametry | panel Payload (grupa „Analytics" na formularzu) |
|
||||
| Pixel ID, tagi, triggery, warunki zgody | panel GTM |
|
||||
| Publikacja kontenera | panel GTM |
|
||||
| Kod projektu | nic (poza jednorazowym `onSuccess` w rendererze) |
|
||||
| Kod projektu | nic (poza jednorazowym `onSuccess` w rendererze) |
|
||||
|
||||
+1
-1
@@ -84,4 +84,4 @@ bloków żadnym markupem.
|
||||
export function Hero(props) {
|
||||
return <section className="py-16">{/* ... */}</section>
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
+2
-2
@@ -20,7 +20,7 @@ treścią bannera (message, przyciski, kategorie, settingsTitle) w panelu,
|
||||
localized. Link do polityki prywatności bierze się z system pages
|
||||
(`privacyPolicy`), nie z osobnego pola.
|
||||
|
||||
**Link do polityki prywatności w banerze (od 1.8.1)** — zero kodu:
|
||||
**Link do polityki prywatności w banerze (od 1.7.12)** — zero kodu:
|
||||
|
||||
| Co | Skąd |
|
||||
|---|---|
|
||||
@@ -199,4 +199,4 @@ Przekazana mapa zastępuje domyślną — pamiętaj dołączyć `NEXT_LOCALE`, j
|
||||
chcesz zachować sprzątanie locale (albo zaimportuj `LOCALE_COOKIE_NAME` i dodaj).
|
||||
|
||||
> Mechanizm zgody dla locale jest opisany też od strony i18n:
|
||||
> [i18n.md](./i18n.md#cookie-locale-a-zgoda-rodo).
|
||||
> [i18n.md](./i18n.md#cookie-locale-a-zgoda-rodo).
|
||||
|
||||
+1
-1
@@ -352,4 +352,4 @@ import {
|
||||
archiveFieldName,
|
||||
} from '@intecion/ipal-kit'
|
||||
import type { ContentOption, ResolvedRoute, ArchiveEntries } from '@intecion/ipal-kit'
|
||||
```
|
||||
```
|
||||
|
||||
@@ -168,6 +168,8 @@ export const proxy = createProxy(i18nConfig, { NextResponse })
|
||||
export const config = { matcher: ['/((?!api|admin|_next|.*\\..*).*)'] }
|
||||
```
|
||||
Ustawia `x-locale` / `x-pathname`, cookie języka za zgodą, przekierowuje `/`.
|
||||
Nagłówki są dla tras dynamicznych (API, route handlery) — w stronach SSG/ISR,
|
||||
layoutach i `not-found.tsx` **nie czytaj `headers()`** (AGENT.md §4.6).
|
||||
|
||||
### 2.7 Warstwa danych — jedno źródło
|
||||
```ts
|
||||
@@ -410,8 +412,8 @@ Klient na M365/Exchange → Graph (SMTP AUTH bywa wyłączony). Własny SMTP/Gma
|
||||
SMTP. Przełącznik w panelu (Site Integrations → SMTP → Email Transport).
|
||||
Graph jednorazowo: App registration w Azure, uprawnienie aplikacyjne `Mail.Send`
|
||||
+ **Grant admin consent**, zmienne `GRAPH_*`. `from.address` zawsze =
|
||||
`GRAPH_SENDER` (inaczej `ErrorSendAsDenied`); nazwa nadawcy z panelu; adres
|
||||
klienta idzie w `replyTo`. Więcej: email.md.
|
||||
`GRAPH_SENDER` (inaczej `ErrorSendAsDenied`); nazwa nadawcy z panelu; adres
|
||||
klienta idzie w `replyTo`. Więcej: email.md.
|
||||
|
||||
---
|
||||
|
||||
@@ -599,4 +601,4 @@ Git działa na katalogu, w którym jesteś — po `cd` zawsze `git status` i
|
||||
| `Unauthorized` / pytanie o hasło w kółko | użyj tokenu zamiast hasła; zakres `write:repository` |
|
||||
| `non-fast-forward`, „tip … is behind” | `git pull`, rozwiąż konflikty, `git push` |
|
||||
| `repository not found` | zły adres albo brak dostępu do repo |
|
||||
| 404 przy `pnpm add @intecion/…` | brak linii `@intecion:registry` w `.npmrc` projektu |
|
||||
| 404 przy `pnpm add @intecion/…` | brak linii `@intecion:registry` w `.npmrc` projektu |
|
||||
+2
-2
@@ -141,7 +141,7 @@ Zrób zgodnie z PROGRAMISTA.md §2.6–2.8 i AGENT.md §4:
|
||||
ConsentProvider + CookieBanner + CookieButton + Analytics wewnątrz providera,
|
||||
- [locale]/[[...slug]]/page.tsx: revalidate, generateStaticParams, BEZ searchParams,
|
||||
resolveRedirect przed notFound, enhanceProps wstrzykuje locale do bloków,
|
||||
- [locale]/not-found.tsx z getNotFoundPage (pages.md).
|
||||
- [locale]/not-found.tsx z getNotFoundPage dla każdego języka + LocaleView, BEZ headers() (pages.md).
|
||||
Plan najpierw.
|
||||
```
|
||||
Sprawdź: `/` → `/<domyślny język>`; `pnpm build` pokazuje strony jako `●`;
|
||||
@@ -385,4 +385,4 @@ Potem jedna pozycja z listy = jedno polecenie:
|
||||
```
|
||||
Zrób pozycję <nr> z PROGRAMISTA.md §6 wg wskazanego pliku docs. Usuń lokalną
|
||||
wersję, którą zastępuje plugin. Plan najpierw, na końcu pnpm build.
|
||||
```
|
||||
```
|
||||
|
||||
+1
-1
@@ -176,4 +176,4 @@ mail przez AKTUALNY transport. Pokazuje wynik (✓/✗ z błędem). Endpoint
|
||||
czyta z bazy, nie z pola na ekranie.
|
||||
|
||||
> Bezcenne przy diagnozie Graph — od razu widzisz `ErrorSendAsDenied`,
|
||||
> `Insufficient privileges` itp. zamiast zgadywać.
|
||||
> `Insufficient privileges` itp. zamiast zgadywać.
|
||||
|
||||
+2
-2
@@ -4,7 +4,7 @@
|
||||
WSZYSTKIMI brakami naraz — zamiast kryptograficznego crashu gdzieś w połowie
|
||||
builda (`getaddrinfo ENOTFOUND`) albo runtime'u. Fail fast.
|
||||
|
||||
Powiązane: [PROGRAMISTA.md §3–4](./PROGRAMISTA.md), [storage.md](./storage.md),
|
||||
Powiązane: [PROGRAMISTA.md §3–4](./dev/PROGRAMISTA.md), [storage.md](./storage.md),
|
||||
[forms.md](./forms.md).
|
||||
|
||||
## Dlaczego bez zod
|
||||
@@ -116,4 +116,4 @@ redeployów.
|
||||
```ts
|
||||
import { assertEnv, ipalEnvRules } from '@intecion/ipal-kit'
|
||||
import type { EnvRule, EnvKind, AssertEnvOptions, IpalEnvFeatures } from '@intecion/ipal-kit'
|
||||
```
|
||||
```
|
||||
|
||||
+1
-1
@@ -413,4 +413,4 @@ const label = resolveLocalized(topic.label, locale)
|
||||
|
||||
Turnstile wstrzykuje ukryte pole `cf-turnstile-response`. Plugin je toleruje
|
||||
(nie odrzuca jako `unknown_fields`) — bo sam obsługuje Turnstile. Nie musisz go
|
||||
filtrować w kliencie.
|
||||
filtrować w kliencie.
|
||||
|
||||
+2
-2
@@ -3,7 +3,7 @@
|
||||
Plugin dostarcza hooki, które zdejmują z projektów powtarzalną robotę. Wpinasz je
|
||||
w kolekcje; działają automatycznie. Wszystkie gotowe do użycia (import z pluginu).
|
||||
|
||||
Powiązane: [pages.md](./pages.md), [seo.md](./seo.md), [PROGRAMISTA.md §5](./PROGRAMISTA.md).
|
||||
Powiązane: [pages.md](./pages.md), [seo.md](./seo.md), [PROGRAMISTA.md §5](./dev/PROGRAMISTA.md).
|
||||
|
||||
---
|
||||
|
||||
@@ -203,4 +203,4 @@ hooks: {
|
||||
```
|
||||
|
||||
Które hooki wpiąć zależy od kolekcji — nie każda potrzebuje wszystkich (blog:
|
||||
setPublishedAt; wszystkie z URL: revalidate + slugHistory; Pages: + preventDelete).
|
||||
setPublishedAt; wszystkie z URL: revalidate + slugHistory; Pages: + preventDelete).
|
||||
|
||||
+1
-1
@@ -319,4 +319,4 @@ export const config = { matcher: ['/((?!api|admin|_next|.*\\..*).*)'] }
|
||||
```
|
||||
|
||||
`DEFAULT_PROXY_MATCHER` używaj jako referencji wartości, ale jeśli Next narzeka
|
||||
na matcher — wklej go inline. To ograniczenie Next, nie pluginu.
|
||||
na matcher — wklej go inline. To ograniczenie Next, nie pluginu.
|
||||
|
||||
+1
-1
@@ -72,4 +72,4 @@ wykona `initialize` → `tools/list` → i będzie mógł wołać `search_conten
|
||||
Pojedynczy obiekt JSON-RPC albo batch (tablica). Notyfikacje (`notifications/*`,
|
||||
bez `id`) → HTTP 202 bez ciała. Żądania → `{ jsonrpc:'2.0', id, result }` albo
|
||||
`error` (`-32601` nieznana metoda, `-32700` parse error). `initialize` odbija
|
||||
`protocolVersion` klienta (fallback `2025-06-18`).
|
||||
`protocolVersion` klienta (fallback `2025-06-18`).
|
||||
|
||||
@@ -66,4 +66,4 @@ fallback. `getNotificationTexts` resolwuje, co istnieje.
|
||||
|
||||
Global ma `read: () => true` — teksty są publiczne (pokazywane użytkownikom
|
||||
końcowym), więc front czyta je bez sesji. Inaczej niż SiteIntegrations
|
||||
(`read: isAdmin` — tam sekrety).
|
||||
(`read: isAdmin` — tam sekrety).
|
||||
|
||||
+26
-12
@@ -54,7 +54,7 @@ import { ALL_SYSTEM_PAGE_ROLES } from '@intecion/ipal-kit'
|
||||
// ['homepage', 'notFound', 'privacyPolicy', 'cookiePolicy', 'termsOfService']
|
||||
```
|
||||
|
||||
## Strona 404 — wybierana w panelu (od 1.8.0)
|
||||
## Strona 404 — wybierana w panelu (od 1.7.12)
|
||||
|
||||
Site Settings → System Pages → **404 (Not Found)**. Edytor wybiera:
|
||||
|
||||
@@ -62,24 +62,38 @@ Site Settings → System Pages → **404 (Not Found)**. Edytor wybiera:
|
||||
- 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
|
||||
Projekt (`app/(frontend)/[locale]/not-found.tsx`) — pełny przykład w
|
||||
`frontend/[locale]/not-found.tsx`:
|
||||
|
||||
```tsx
|
||||
import { headers } from 'next/headers'
|
||||
import { getNotFoundPage } from '@/lib/content' // z createContentHelpers
|
||||
import { RenderBlocks } from '@intecion/ipal-kit/rsc'
|
||||
import { LocaleView } from '@intecion/ipal-kit/client'
|
||||
import { getConfiguredLocales, getNotFoundPage } from '@/lib/content'
|
||||
|
||||
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} />
|
||||
const locales = await getConfiguredLocales()
|
||||
const views = Object.fromEntries(await Promise.all(locales.map(async (locale) => {
|
||||
const page = await getNotFoundPage(locale) // null → brak przypisania
|
||||
return [locale, page?.layout?.length
|
||||
? <RenderBlocks blocks={page.layout} components={blockRegistry} enhanceProps={() => ({ locale })} />
|
||||
: null]
|
||||
})))
|
||||
return <LocaleView views={views} defaultLocale={i18nConfig.defaultLocale} />
|
||||
}
|
||||
```
|
||||
|
||||
`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.
|
||||
> **NIE czytaj `headers()` w `not-found.tsx`** (`LocaleView` od 1.7.13). `not-found.tsx` nie dostaje
|
||||
> `params`, ale `headers()` (np. `x-locale` z proxy) zamienia stronę SSG/ISR w
|
||||
> dynamiczną — Next 16 rzuca `Page changed from static to dynamic at runtime`
|
||||
> (AGENT.md §4.6). Dlatego serwer renderuje stronę 404 **dla każdego języka**
|
||||
> (same odczyty z bazy — trasa zostaje statyczna), a `<LocaleView>` (komponent
|
||||
> kliencki pluginu) wybiera wersję po pierwszym segmencie URL (`usePathname`).
|
||||
> Działa też przy SSR — HTML ma od razu właściwy język. Layout `[locale]`
|
||||
> (nagłówek, menu, stopka) i tak dostaje `params.locale` z URL.
|
||||
|
||||
Status HTTP zostaje **404** (renderuje go Next po `notFound()`), treść jest z
|
||||
panelu we właściwym języku. Koszt: w payloadzie RSC strony 404 są wersje dla
|
||||
wszystkich języków — przy stronie 404 to pomijalne.
|
||||
|
||||
Co plugin robi automatycznie z przypisaną stroną 404:
|
||||
|
||||
@@ -158,4 +172,4 @@ tego requestu (traci cały zysk SSG/ISR + wraca problem metadata w body).
|
||||
strony zostały SSG.
|
||||
|
||||
Reguła: `searchParams` tylko tam, gdzie NAPRAWDĘ potrzebujesz (paginacja). Wszędzie
|
||||
indziej pomiń — inaczej tracisz SSG i SEO.
|
||||
indziej pomiń — inaczej tracisz SSG i SEO.
|
||||
|
||||
@@ -51,4 +51,4 @@ return <Form siteKey={turnstileSiteKey} />
|
||||
```ts
|
||||
import { getGlobal } from '@intecion/ipal-kit'
|
||||
const data = await getGlobal<MyType>(payload, 'moj-global', { locale: 'pl', depth: 1 })
|
||||
```
|
||||
```
|
||||
|
||||
+1
-1
@@ -85,4 +85,4 @@ Payload już ma (to edytor). Zero dodatkowych zależności.
|
||||
- **Brakujące węzły** — oficjalny konwerter obsługuje wszystkie (zagnieżdżone
|
||||
listy, upload, relacje, horizontal rule…)
|
||||
- **Rozjazd przy aktualizacji** — Payload utrzymuje konwerter, nie Ty
|
||||
- **`any`** — typowane (SerializedEditorState)
|
||||
- **`any`** — typowane (SerializedEditorState)
|
||||
|
||||
+1
-1
@@ -319,4 +319,4 @@ Admin może zresetować 2FA innego użytkownika (gdy zgubi telefon) — przez
|
||||
Wybrany, bo wrapuje ACCESS CONTROL (TOTP przed dostępem do danych) + forceSetup
|
||||
(wymuszenie dla wszystkich). Inne pluginy 2FA dla Payload gatują tylko nawigację
|
||||
/admin — user z hasłem może omijać przez REST/GraphQL/Bearer. @clocklimited chroni
|
||||
dostęp do danych, nie tylko UI.
|
||||
dostęp do danych, nie tylko UI.
|
||||
|
||||
+18
-6
@@ -385,7 +385,7 @@ poprawnie: czytając z panelu/env, nie zaszywając wartości klienta.
|
||||
|
||||
> **Zasada:** nawet gdy coś robisz ręcznie w projekcie, dane (nazwa, kolory,
|
||||
> opis, logo) czytaj z panelu (SiteSettings) albo env. Zaszyta nazwa/kolor
|
||||
> klienta = antywzorzec (patrz standardy-kodu.md). Manifest „R Custom Cars" z
|
||||
> klienta = antywzorzec (patrz AGENT.md §2). Manifest „R Custom Cars" z
|
||||
> hardkodem zadziała tylko dla jednego klienta.
|
||||
|
||||
### Web App Manifest (PWA) — jak zrobić DOBRZE
|
||||
@@ -394,6 +394,18 @@ Zasada nadrzędna: **brak danych → POMIŃ pole, NIE zaszywaj wartości.** Mani
|
||||
jest ważny bez `name`? Nie — ale lepszy manifest bez nazwy niż z cudzą nazwą
|
||||
klienta w fallbacku. Fallback z nazwą/kolorem klienta to ukryty hardkod.
|
||||
|
||||
> **Zalecane (aktualne): `createManifestHandler`** — to samo bez ręcznego kodu,
|
||||
> z try/catch na brak bazy w buildzie:
|
||||
> ```ts
|
||||
> // app/manifest.ts
|
||||
> import { createManifestHandler } from '@intecion/ipal-kit'
|
||||
> import { getCachedPayload } from '@/lib/content'
|
||||
> import { i18nConfig } from '@/i18n.config'
|
||||
> export const dynamic = 'force-dynamic'
|
||||
> export default createManifestHandler({ getCachedPayload, config: i18nConfig })
|
||||
> ```
|
||||
> Ręczny wariant poniżej — gdy manifest potrzebuje pól spoza panelu.
|
||||
|
||||
```ts
|
||||
// app/manifest.ts
|
||||
import type { MetadataRoute } from 'next'
|
||||
@@ -480,7 +492,7 @@ typu, itp.):
|
||||
- dane z panelu (SiteSettings / pola strony) albo env
|
||||
- nic zaszytego per klient (nazwa, kolor, adres, domena)
|
||||
- jeśli to uniwersalne i powtarzalne → rozważ zgłoszenie do pluginu zamiast
|
||||
ręcznie (patrz antigravity_zasady_agent.md A0)
|
||||
ręcznie (patrz AGENT.md §2)
|
||||
|
||||
## KRYTYCZNE: metadata w <head> dla Google
|
||||
|
||||
@@ -637,7 +649,7 @@ zwiększają szansę — nie gwarancję.
|
||||
1. **Ranking na 1. stronie Google** — bez tego sitelinków nie ma. To robota SEO
|
||||
(treść, linki), nie kodu.
|
||||
2. **Czysta struktura + jasne tytuły** — logiczna hierarchia stron, opisowe title
|
||||
(nie „Strona 1"). Patrz fundamenty-projektu.md.
|
||||
(nie „Strona 1"). Patrz AGENT.md §3.
|
||||
3. **Linkowanie wewnętrzne** — ważne strony podlinkowane z głównej.
|
||||
4. **Structured data** (poniżej) — sygnał pomocniczy, nie przełącznik.
|
||||
5. **Sitemap + robots** — żeby Google w ogóle widział wszystkie strony (patrz
|
||||
@@ -703,7 +715,7 @@ Plugin dostarcza helpery — projekt MUSI je wpiąć i podać dane z panelu:
|
||||
- [ ] `buildBreadcrumbJsonLd` na podstronach (z realnej ścieżki)
|
||||
- [ ] `buildSiteNavigationJsonLd` z pozycji menu (jeśli jest header nav)
|
||||
- [ ] `app/robots.ts` i `app/sitemap.ts` wystawione (patrz niżej — bez tego
|
||||
Google nie widzi stron!)
|
||||
Google nie widzi stron!)
|
||||
- [ ] Jasne, opisowe tytuły stron (nie generyczne)
|
||||
- [ ] Logiczna hierarchia + linkowanie wewnętrzne z głównej
|
||||
|
||||
@@ -1115,7 +1127,7 @@ Sztywny `buildCompanyGlobal()` w pluginie byłby **leaky abstraction** — austr
|
||||
projekt miałby martwe pole NIP i brakujący ABN. Dlatego:
|
||||
|
||||
- **Plugin:** klocki Schema (Organization, LocalBusiness, WebSite, SiteNavigation)
|
||||
+ JsonLdGraph (opakowanie + bezpieczny render)
|
||||
+ JsonLdGraph (opakowanie + bezpieczny render)
|
||||
- **Projekt:** własny `src/globals/Company.ts` pod kraj/branżę + mapowanie swoich
|
||||
danych na właściwy `@type` (LegalService w PL, HVACBusiness w AU)
|
||||
|
||||
@@ -1141,4 +1153,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.
|
||||
|
||||
+1
-1
@@ -63,4 +63,4 @@ buildSlugField({
|
||||
import { toSlug } from '@intecion/ipal-kit'
|
||||
|
||||
toSlug('Strona główna') // 'strona-glowna'
|
||||
```
|
||||
```
|
||||
|
||||
+12
-5
@@ -16,7 +16,7 @@ pnpm add @payloadcms/storage-s3
|
||||
|
||||
## Zmienne .env
|
||||
|
||||
Patrz [R2-ENV-przyklad](../R2-ENV-przyklad.md) po pełną instrukcję skąd wziąć wartości.
|
||||
Skąd wziąć wartości: Cloudflare → R2 → bucket (nazwa), Overview → S3 API (endpoint `https://<ACCOUNT_ID>.r2.cloudflarestorage.com`), Manage R2 API Tokens → „Object Read & Write” (para kluczy; secret widać raz). Wszystkie 4 zmienne → R2; brak którejś → dysk lokalny (częściowa konfiguracja = ostrzeżenie w logu).
|
||||
|
||||
```bash
|
||||
R2_BUCKET=nazwa-bucketa
|
||||
@@ -214,14 +214,21 @@ z CDN zawczasu, zanim napotka pierwszy `<img>`. Zysk ~150–300 ms na pierwszym
|
||||
obrazie.
|
||||
|
||||
```tsx
|
||||
// layout.tsx — w <head> (albo górze <body>, Next hoistuje link tagi)
|
||||
// layout.tsx — na GÓRZE <body>, NIE w jawnym <head>
|
||||
import { MediaPreconnect } from '@intecion/ipal-kit/rsc'
|
||||
|
||||
<head>
|
||||
<body className={...}>
|
||||
<MediaPreconnect />
|
||||
</head>
|
||||
{children}
|
||||
</body>
|
||||
```
|
||||
|
||||
> **NIE umieszczaj w jawnym `<head>`!** Sztywny `<head><MediaPreconnect/></head>`
|
||||
> w layoutcie App Router wymusza przedwczesne zamknięcie head — zanim strona
|
||||
> wygeneruje metadane — przez co title/canonical/hreflang lądują w `<body>`
|
||||
> (crawlery ich nie widzą). React 19 sam hoistuje `<link rel="preconnect">` do
|
||||
> `<head>`, więc renderowanie w `<body>` jest poprawne. Patrz seo.md (metadata w head).
|
||||
|
||||
Czyta domenę z **R2_PUBLIC_URL** (to samo źródło co buildR2Storage) — zero
|
||||
hardkodu, jedno źródło prawdy. Gdy R2_PUBLIC_URL nie ustawione (lokalny dysk,
|
||||
brak CDN) → nie renderuje nic. Zmiana domeny mediów = zmiana jednej zmiennej
|
||||
@@ -229,4 +236,4 @@ env, komponent podąża automatycznie.
|
||||
|
||||
> NIE hardkoduj `<link rel="preconnect" href="https://media.klient.pl">` ręcznie
|
||||
> w layoutcie — to zaszywa domenę klienta w kodzie. Użyj MediaPreconnect, który
|
||||
> bierze ją z env.
|
||||
> bierze ją z env.
|
||||
|
||||
+1
-1
@@ -127,4 +127,4 @@ w submitForm automatycznie.
|
||||
### Stary sposób (nadal działa)
|
||||
|
||||
`<Turnstile siteKey={...} onToken={...} />` bezpośrednio — jeśli potrzebujesz
|
||||
pełnej kontroli albo masz nietypowy przypadek. Provider to warstwa wygody nad tym.
|
||||
pełnej kontroli albo masz nietypowy przypadek. Provider to warstwa wygody nad tym.
|
||||
|
||||
+1
-1
@@ -88,4 +88,4 @@ przez `AdminIcon`.
|
||||
- [ ] `ipalKit({ whiteLabel: true })`
|
||||
- [ ] Redaktor wgrał `logo` i `favicon` w SiteSettings (+ `siteName`)
|
||||
- [ ] `pnpm generate:importmap`
|
||||
- [ ] Restart dev / rebuild → panel pokazuje markę klienta na loginie i w nav
|
||||
- [ ] Restart dev / rebuild → panel pokazuje markę klienta na loginie i w nav
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
import React from 'react'
|
||||
|
||||
import { RenderBlocks } from 'ipal-kit/rsc'
|
||||
import { LocaleView } from 'ipal-kit/client'
|
||||
|
||||
import { i18nConfig } from '@/i18n.config'
|
||||
import { blockRegistry } from '@/blocks/registry'
|
||||
import { getConfiguredLocales, getNotFoundPage } from '@/lib/content'
|
||||
|
||||
/**
|
||||
* 404 view. The editor picks which page plays the 404 role in
|
||||
* Site Settings → System Pages → "404 (Not Found)" — a dedicated page or the
|
||||
* homepage — or leaves it empty → the fallback below.
|
||||
*
|
||||
* not-found.tsx receives no params, and reading headers() here would turn the
|
||||
* SSG/ISR site dynamic ("Page changed from static to dynamic at runtime").
|
||||
* So: render the 404 page for EVERY locale on the server (DB reads only — stays
|
||||
* static) and let <LocaleView> pick the one from the URL (/en/... → en).
|
||||
* Next still answers HTTP 404.
|
||||
*/
|
||||
export default async function NotFound() {
|
||||
const locales = await getConfiguredLocales()
|
||||
|
||||
const views = Object.fromEntries(
|
||||
await Promise.all(
|
||||
locales.map(async (locale) => {
|
||||
const page = (await getNotFoundPage(locale)) as { layout?: unknown[] } | null
|
||||
const view = page?.layout?.length ? (
|
||||
<RenderBlocks
|
||||
blocks={page.layout as never}
|
||||
components={blockRegistry}
|
||||
enhanceProps={() => ({ locale })}
|
||||
/>
|
||||
) : null
|
||||
return [locale, view] as const
|
||||
}),
|
||||
),
|
||||
)
|
||||
|
||||
// No 404 page assigned in any locale (or DB unreachable during build):
|
||||
// the project's own minimal view — style it, keep it text-free or panel-driven.
|
||||
if (Object.values(views).every((v) => v === null)) {
|
||||
return (
|
||||
<main className="container py-24 text-center">
|
||||
<h1 className="text-6xl font-bold">404</h1>
|
||||
</main>
|
||||
)
|
||||
}
|
||||
|
||||
return <LocaleView views={views} defaultLocale={i18nConfig.defaultLocale} />
|
||||
}
|
||||
+9
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@intecion/ipal-kit",
|
||||
"version": "1.7.12",
|
||||
"version": "1.8.2",
|
||||
"description": "Intecion Payload Advanced Library — a Payload CMS 3 plugin: i18n, SEO, forms, consent, analytics, blog/archives.",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
@@ -73,6 +73,9 @@
|
||||
"peerDependencies": {
|
||||
"@payloadcms/plugin-form-builder": "^3.90.2",
|
||||
"@payloadcms/plugin-seo": "^3.90.2",
|
||||
"@payloadcms/richtext-lexical": "^3.90.2",
|
||||
"@payloadcms/storage-s3": "^3.90.2",
|
||||
"@payloadcms/ui": "^3.90.2",
|
||||
"next": ">=15",
|
||||
"payload": "^3.90.2",
|
||||
"react": "^19.0.0"
|
||||
@@ -127,5 +130,10 @@
|
||||
"esbuild",
|
||||
"unrs-resolver"
|
||||
]
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@payloadcms/storage-s3": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Generated
+1161
-1458
File diff suppressed because it is too large
Load Diff
+4
-16
@@ -1,22 +1,13 @@
|
||||
'use client'
|
||||
export { MaskedField } from '../globals/SiteIntegrations/components/MaskedField.js'
|
||||
export { TestEmailButton } from '../globals/SiteIntegrations/components/TestEmailButton.js'
|
||||
export {
|
||||
AccessibilityProvider,
|
||||
AccessibilityWidget,
|
||||
useAccessibility,
|
||||
} from '../modules/accessibility/client.js'
|
||||
export { AccessibilityProvider, AccessibilityWidget, useAccessibility } from '../modules/accessibility/client.js'
|
||||
export type { A11yClassNames, A11yState, A11yTexts } from '../modules/accessibility/client.js'
|
||||
export { 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'
|
||||
export { loadClarity, loadLinkedIn, loadMetaPixel, loadTikTok } from '../modules/analytics/client.js'
|
||||
/**
|
||||
* Entry point: ipal-kit/client
|
||||
*
|
||||
@@ -37,11 +28,7 @@ export { formAnalyticsOnSuccess } from '../modules/forms/formAnalytics.js'
|
||||
export type { FormAnalyticsConfig } from '../modules/forms/formAnalytics.js'
|
||||
export { HONEYPOT_FIELD, honeypotInputProps, isHoneypotTripped } from '../modules/forms/honeypot.js'
|
||||
export { useContactForm } from '../modules/forms/useContactForm.js'
|
||||
export type {
|
||||
ContactFormErrors,
|
||||
ContactFormValues,
|
||||
SubmitAction,
|
||||
} from '../modules/forms/useContactForm.js'
|
||||
export type { ContactFormErrors, ContactFormValues, SubmitAction } from '../modules/forms/useContactForm.js'
|
||||
export { useForm } from '../modules/forms/useForm.js'
|
||||
export type { FormErrors, FormSubmitAction, Validator } from '../modules/forms/useForm.js'
|
||||
export {
|
||||
@@ -73,6 +60,7 @@ export {
|
||||
useSetAlternateLinks,
|
||||
} from '../modules/i18n/index.js'
|
||||
export type { AlternateLinks, LanguageSwitcherClassNames } from '../modules/i18n/index.js'
|
||||
export { LocaleView } from '../modules/pages/LocaleView.js'
|
||||
export { Turnstile } from '../modules/turnstile/client.js'
|
||||
export { TurnstileProvider, useTurnstile } from '../modules/turnstile/client.js'
|
||||
export type { TurnstileProps } from '../modules/turnstile/client.js'
|
||||
|
||||
@@ -74,8 +74,8 @@ export function createContentHelpers({
|
||||
settingsSlug = 'site-settings',
|
||||
}: CreateContentHelpersArgs) {
|
||||
const origin = baseUrl ?? process.env.NEXT_PUBLIC_SERVER_URL ?? ''
|
||||
const getCachedPayload = cache(async (): Promise<BasePayload> =>
|
||||
getPayload({ config: await config }),
|
||||
const getCachedPayload = cache(
|
||||
async (): Promise<BasePayload> => getPayload({ config: await config }),
|
||||
)
|
||||
|
||||
const getConfiguredLocales = cache(async (): Promise<string[]> => {
|
||||
@@ -102,8 +102,9 @@ 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).
|
||||
* For app/not-found.tsx; never throws. not-found.tsx receives no params and
|
||||
* must NOT read headers() (breaks SSG/ISR) — call this for every configured
|
||||
* locale and let <LocaleView> (client) pick the one from the URL. See pages.md.
|
||||
*/
|
||||
const getNotFoundPage = cache(async (locale: string) => {
|
||||
try {
|
||||
@@ -150,7 +151,9 @@ export function createContentHelpers({
|
||||
*/
|
||||
const sitemap = cache(async (): Promise<SitemapEntry[]> => {
|
||||
if (!i18n) {
|
||||
throw new Error('[ipal] createContentHelpers: pass `i18n` to use the sitemap handler.')
|
||||
throw new Error(
|
||||
'[ipal] createContentHelpers: pass `i18n` to use the sitemap handler.',
|
||||
)
|
||||
}
|
||||
try {
|
||||
return await buildSitemapEntries({
|
||||
@@ -235,62 +238,60 @@ export function createContentHelpers({
|
||||
const params: Array<{ locale: string; slug: string[] } | { slug: string[] }> = []
|
||||
|
||||
for (const locale of locales) {
|
||||
// NO where:{_status} filter — collections without drafts enabled don't
|
||||
// register the _status field, and querying it throws
|
||||
// "path cannot be queried: _status". We filter drafts in memory below,
|
||||
// which is safe for every collection (with or without drafts).
|
||||
const result = await payload.find({
|
||||
collection: pagesSlug as never,
|
||||
depth: 0,
|
||||
limit: 1000,
|
||||
locale: (locale ?? 'all') as never,
|
||||
})
|
||||
// NO where:{_status} filter — collections without drafts enabled don't
|
||||
// register the _status field, and querying it throws
|
||||
// "path cannot be queried: _status". We filter drafts in memory below,
|
||||
// which is safe for every collection (with or without drafts).
|
||||
const result = await payload.find({
|
||||
collection: pagesSlug as never,
|
||||
depth: 0,
|
||||
limit: 1000,
|
||||
locale: (locale ?? 'all') as never,
|
||||
})
|
||||
|
||||
for (const raw of result.docs as Array<{
|
||||
_status?: string
|
||||
id: number | string
|
||||
meta?: { noindex?: boolean } | null
|
||||
slug?: unknown
|
||||
}>) {
|
||||
// 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}
|
||||
for (const raw of result.docs as Array<{
|
||||
_status?: string
|
||||
id: number | string
|
||||
meta?: { noindex?: boolean } | null
|
||||
slug?: unknown
|
||||
}>) {
|
||||
// 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
|
||||
// from the footer and crawlers read its <meta robots=noindex>. Pre-render
|
||||
// it as SSG so it's fast and its <head> is complete; noindex controls
|
||||
// INDEXING, not whether the page exists. Skipping it would force dynamic
|
||||
// rendering (the very streaming problem we're avoiding).
|
||||
// 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
|
||||
// it as SSG so it's fast and its <head> is complete; noindex controls
|
||||
// INDEXING, not whether the page exists. Skipping it would force dynamic
|
||||
// rendering (the very streaming problem we're avoiding).
|
||||
|
||||
if (homeId && raw.id === homeId) {
|
||||
// Homepage → root. Emit an empty-slug param so '/' (or '/pl') builds.
|
||||
const empty = singleLocale ? { slug: [] } : { slug: [], locale: locale as string }
|
||||
if (!params.some((p) => JSON.stringify(p) === JSON.stringify(empty))) {params.push(empty)}
|
||||
continue
|
||||
}
|
||||
|
||||
// Slug may be a plain string OR a localized map ({ pl: 'kontakt' }) when
|
||||
// read with locale:'all' or left unflattened. Handle both, or localized
|
||||
// pages get silently dropped.
|
||||
const rawSlug = raw.slug
|
||||
const slug =
|
||||
typeof rawSlug === 'string'
|
||||
? rawSlug
|
||||
: rawSlug && typeof rawSlug === 'object'
|
||||
? (((rawSlug as Record<string, unknown>)[locale ?? ''] as string | undefined) ??
|
||||
(Object.values(rawSlug as Record<string, unknown>)[0] as string | undefined))
|
||||
: undefined
|
||||
|
||||
if (!slug || EXCLUDED.has(slug)) {continue}
|
||||
|
||||
// Multi-level slugs ('atrakcje/telefon') → array segments.
|
||||
const segments = String(slug).split('/').filter(Boolean)
|
||||
params.push(
|
||||
singleLocale ? { slug: segments } : { slug: segments, locale: locale as string },
|
||||
)
|
||||
if (homeId && raw.id === homeId) {
|
||||
// Homepage → root. Emit an empty-slug param so '/' (or '/pl') builds.
|
||||
const empty = singleLocale ? { slug: [] } : { slug: [], locale: locale as string }
|
||||
if (!params.some((p) => JSON.stringify(p) === JSON.stringify(empty))) {params.push(empty)}
|
||||
continue
|
||||
}
|
||||
|
||||
// Slug may be a plain string OR a localized map ({ pl: 'kontakt' }) when
|
||||
// read with locale:'all' or left unflattened. Handle both, or localized
|
||||
// pages get silently dropped.
|
||||
const rawSlug = raw.slug
|
||||
const slug =
|
||||
typeof rawSlug === 'string'
|
||||
? rawSlug
|
||||
: rawSlug && typeof rawSlug === 'object'
|
||||
? ((rawSlug as Record<string, unknown>)[locale ?? ''] as string | undefined) ??
|
||||
(Object.values(rawSlug as Record<string, unknown>)[0] as string | undefined)
|
||||
: undefined
|
||||
|
||||
if (!slug || EXCLUDED.has(slug)) {continue}
|
||||
|
||||
// Multi-level slugs ('atrakcje/telefon') → array segments.
|
||||
const segments = String(slug).split('/').filter(Boolean)
|
||||
params.push(singleLocale ? { slug: segments } : { slug: segments, locale: locale as string })
|
||||
}
|
||||
}
|
||||
|
||||
return params
|
||||
} catch (err) {
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
'use client'
|
||||
import type { ReactNode } from 'react'
|
||||
// '.js' is required: `next` has no package.json "exports", so NodeNext resolution
|
||||
// (this plugin's tsconfig) can't find 'next/navigation' without the extension.
|
||||
// Bundlers in the project resolve the same file either way.
|
||||
import { usePathname } from 'next/navigation.js'
|
||||
|
||||
type LocaleViewProps = {
|
||||
/** Used when the URL has no locale segment (single-locale site) or an unknown one. */
|
||||
defaultLocale: string
|
||||
/**
|
||||
* One pre-rendered view per locale, e.g. { pl: <RenderBlocks …/>, en: … }.
|
||||
* Rendered on the SERVER (RSC) and passed in as props — this component only
|
||||
* picks one, so the content can come from the panel and the route stays static.
|
||||
*/
|
||||
views: Record<string, ReactNode>
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the view matching the locale in the current URL (`/en/...` → `en`).
|
||||
*
|
||||
* Made for `not-found.tsx`, which receives no `params`: reading the locale with
|
||||
* `headers()` there turns an SSG/ISR route dynamic ("Page changed from static
|
||||
* to dynamic at runtime"). `usePathname()` is client-side and static-safe, and
|
||||
* it also runs during SSR, so the HTML already contains the right language.
|
||||
*/
|
||||
export function LocaleView({ defaultLocale, views }: LocaleViewProps) {
|
||||
const pathname = usePathname() ?? ''
|
||||
const segment = pathname.split('/').filter(Boolean)[0] ?? ''
|
||||
const locale = segment in views ? segment : defaultLocale
|
||||
return <>{views[locale] ?? views[defaultLocale] ?? null}</>
|
||||
}
|
||||
@@ -1,6 +1,27 @@
|
||||
import type { Plugin } from 'payload'
|
||||
|
||||
import { s3Storage } from '@payloadcms/storage-s3'
|
||||
type GenerateFileURL = (args: { filename: string; prefix?: string }) => string
|
||||
|
||||
/**
|
||||
* Minimal shape of `s3Storage` from @payloadcms/storage-s3 — the plugin never
|
||||
* imports that package (it's optional: projects on local disk don't install it).
|
||||
* The project injects the real function; TypeScript checks it fits this shape.
|
||||
*/
|
||||
export type S3StorageFactory = (options: {
|
||||
bucket: string
|
||||
collections: Record<string, { generateFileURL: GenerateFileURL } | true>
|
||||
config: {
|
||||
credentials: { accessKeyId: string; secretAccessKey: string }
|
||||
endpoint: string
|
||||
forcePathStyle: boolean
|
||||
region: string
|
||||
}
|
||||
}) => Plugin
|
||||
|
||||
export type BuildR2StorageDeps = {
|
||||
/** `import { s3Storage } from '@payloadcms/storage-s3'` — required when R2 env is set. */
|
||||
s3Storage?: S3StorageFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* Cloudflare R2 media storage — configured from environment variables (agency
|
||||
@@ -16,9 +37,22 @@ import { s3Storage } from '@payloadcms/storage-s3'
|
||||
* storage (useful in dev without R2). This mirrors how mailAdapter degrades
|
||||
* gracefully when a transport isn't configured.
|
||||
*
|
||||
* The S3 adapter is INJECTED by the project (same pattern as 2FA / NextResponse):
|
||||
*
|
||||
* import { s3Storage } from '@payloadcms/storage-s3'
|
||||
* plugins: [buildR2Storage(['media'], { s3Storage })]
|
||||
*
|
||||
* A static import here would make @payloadcms/storage-s3 mandatory for every
|
||||
* project — including ones on local disk — because this module is exported
|
||||
* from the package's main entry.
|
||||
*
|
||||
* @param collections - slugs of upload collections to offload to R2 (e.g. ['media'])
|
||||
* @param deps - `{ s3Storage }` from @payloadcms/storage-s3 (needed only when R2 env is set)
|
||||
*/
|
||||
export const buildR2Storage = (collections: string[] = ['media']): Plugin => {
|
||||
export const buildR2Storage = (
|
||||
collections: string[] = ['media'],
|
||||
deps: BuildR2StorageDeps = {},
|
||||
): Plugin => {
|
||||
const bucket = process.env.R2_BUCKET
|
||||
const endpoint = process.env.R2_ENDPOINT
|
||||
const accessKeyId = process.env.R2_ACCESS_KEY_ID
|
||||
@@ -54,7 +88,18 @@ export const buildR2Storage = (collections: string[] = ['media']): Plugin => {
|
||||
[publicUrl, prefix, filename].filter(Boolean).join('/')
|
||||
: undefined
|
||||
|
||||
const collectionsConfig: Record<string, { generateFileURL: typeof generateFileURL } | true> = {}
|
||||
// R2 env is complete → the adapter is required. Fail loudly at boot rather
|
||||
// than silently storing media on the container disk (lost on redeploy).
|
||||
const { s3Storage } = deps
|
||||
if (!s3Storage) {
|
||||
throw new Error(
|
||||
'[ipal] R2 storage: R2_* env is set but the S3 adapter was not injected. ' +
|
||||
"Install @payloadcms/storage-s3 and pass it: buildR2Storage(['media'], { s3Storage }) " +
|
||||
"with `import { s3Storage } from '@payloadcms/storage-s3'`. See docs/storage.md.",
|
||||
)
|
||||
}
|
||||
|
||||
const collectionsConfig: Record<string, { generateFileURL: GenerateFileURL } | true> = {}
|
||||
for (const slug of collections) {
|
||||
collectionsConfig[slug] = generateFileURL ? { generateFileURL } : true
|
||||
}
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
export { buildR2Storage } from './buildR2Storage.js'
|
||||
export type { BuildR2StorageDeps, S3StorageFactory } from './buildR2Storage.js'
|
||||
|
||||
Reference in New Issue
Block a user