diff --git a/bin/ipal-skills.mjs b/bin/ipal-skills.mjs
new file mode 100644
index 0000000..9b50f35
--- /dev/null
+++ b/bin/ipal-skills.mjs
@@ -0,0 +1,47 @@
+#!/usr/bin/env node
+// ipal-skills — copies the ipal-kit agent skills into the project.
+// pnpm ipal-skills → ./.agents/skills/ipal-*
+// pnpm ipal-skills --dry-run → show what would change
+// pnpm ipal-skills --dest .claude/skills
+// Only folders named ipal-* are touched; the project's own skills stay as they are.
+// ipal-* folders that no longer exist in the package are removed (renamed/retired skills).
+
+import { cpSync, existsSync, mkdirSync, readdirSync, rmSync, statSync } from 'node:fs'
+import { dirname, join, resolve } from 'node:path'
+import { fileURLToPath } from 'node:url'
+
+const args = process.argv.slice(2)
+if (args.includes('--help') || args.includes('-h')) {
+ console.log('Usage: ipal-skills [--dest
] [--dry-run]\nDefault dest: .agents/skills')
+ process.exit(0)
+}
+const dryRun = args.includes('--dry-run')
+const destArg = args.indexOf('--dest')
+const dest = resolve(process.cwd(), destArg >= 0 ? args[destArg + 1] ?? '' : '.agents/skills')
+
+const pkgRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..')
+const src = join(pkgRoot, 'docs', 'agent', 'skills')
+if (!existsSync(src)) {
+ console.error(`ipal-skills: no skills found in ${src} — is @intecion/ipal-kit installed with docs?`)
+ process.exit(1)
+}
+
+const isSkillDir = (base, name) => name.startsWith('ipal-') && statSync(join(base, name)).isDirectory()
+const shipped = readdirSync(src).filter((n) => isSkillDir(src, n))
+const existing = existsSync(dest) ? readdirSync(dest).filter((n) => isSkillDir(dest, n)) : []
+const retired = existing.filter((n) => !shipped.includes(n))
+
+if (!dryRun) mkdirSync(dest, { recursive: true })
+for (const name of shipped) {
+ const action = existing.includes(name) ? 'update' : 'add '
+ console.log(`${action} ${name}`)
+ if (!dryRun) {
+ rmSync(join(dest, name), { recursive: true, force: true }) // drop files removed upstream
+ cpSync(join(src, name), join(dest, name), { recursive: true })
+ }
+}
+for (const name of retired) {
+ console.log(`remove ${name} (no longer in ipal-kit)`)
+ if (!dryRun) rmSync(join(dest, name), { recursive: true, force: true })
+}
+console.log(`${dryRun ? '[dry-run] ' : ''}${shipped.length} skill(s) → ${dest}`)
diff --git a/dist/index.d.ts b/dist/index.d.ts
index c3e3b9c..ac8021c 100644
--- a/dist/index.d.ts
+++ b/dist/index.d.ts
@@ -34,6 +34,8 @@ export type { LocaleMiddlewareResult } from './modules/i18n/index.js';
export { createLocaleMiddleware, DEFAULT_MIDDLEWARE_MATCHER } from './modules/i18n/index.js';
export { createProxy, DEFAULT_PROXY_MATCHER } from './modules/i18n/index.js';
export { resolveLocalized } from './modules/i18n/index.js';
+export { buildLinkField, buildLinksField, resolveLinkHref } from './modules/links/index.js';
+export type { BuildLinkFieldOptions, BuildLinksFieldOptions, LinkAppearance, LinkValue, ResolveLinkHrefOptions, } from './modules/links/index.js';
export { createMcpRoute } from './modules/mcp/index.js';
export { normalizeFilename, normalizeFilenameHook } from './modules/media/index.js';
export { getNotificationTexts, NOTIFICATION_FALLBACK, resolveFormMessage, } from './modules/notifications/index.js';
@@ -48,8 +50,9 @@ export { buildCsp } from './modules/security/index.js';
export type { BuildCspArgs } from './modules/security/index.js';
export type { BuildSecurityHeadersArgs, SecurityHeader } from './modules/security/index.js';
export type { PageMetadata, SeoMeta, SeoOption } from './modules/seo/index.js';
-export { buildHreflangAlternates, buildMetadata, composeTitle } from './modules/seo/index.js';
-export type { AutoFillMapping, RobotsRules, SitemapEntry } from './modules/seo/index.js';
+export { buildHreflangAlternates, buildMetadata, composeTitle, readSiteMetaConfig, slugsAcrossLocales, } from './modules/seo/index.js';
+export type { SiteMetaConfig } from './modules/seo/index.js';
+export type { AutoFillMapping, RobotsOptions, RobotsRules, SitemapEntry, } from './modules/seo/index.js';
export { AI_ASSISTANT_BOTS, AI_TRAINING_BOTS, buildAutoFillMetaHook, buildRobots, buildSitemapEntries, createMetadataGenerator, createPageMetadata, injectAutoFillMeta, } from './modules/seo/index.js';
export { createLlmsTxtRoute, createManifestHandler, createSitemapRouteHandler, } from './modules/seo/index.js';
export { buildIconsMetadata, buildOrganizationJsonLd, validateFaviconField, } from './modules/seo/index.js';
diff --git a/dist/index.js b/dist/index.js
index 5eb1923..b673fcb 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -27,6 +27,7 @@ export { buildLocalizedPath, getDefaultLocale, getLocaleCodes, getLocaleDefiniti
export { createLocaleMiddleware, DEFAULT_MIDDLEWARE_MATCHER } from './modules/i18n/index.js';
export { createProxy, DEFAULT_PROXY_MATCHER } from './modules/i18n/index.js';
export { resolveLocalized } from './modules/i18n/index.js';
+export { buildLinkField, buildLinksField, resolveLinkHref } from './modules/links/index.js';
// Read-only MCP server (Claude/agents connect to the site and query it).
export { createMcpRoute } from './modules/mcp/index.js';
export { normalizeFilename, normalizeFilenameHook } from './modules/media/index.js';
@@ -37,7 +38,7 @@ export { getGlobal, getSiteIntegrations, getSiteSettings, SITE_INTEGRATIONS_SLUG
export { lexicalToMarkdown } from './modules/richtext/index.js';
export { buildSecurityHeaders } from './modules/security/index.js';
export { buildCsp } from './modules/security/index.js';
-export { buildHreflangAlternates, buildMetadata, composeTitle } from './modules/seo/index.js';
+export { buildHreflangAlternates, buildMetadata, composeTitle, readSiteMetaConfig, slugsAcrossLocales } from './modules/seo/index.js';
export { AI_ASSISTANT_BOTS, AI_TRAINING_BOTS, buildAutoFillMetaHook, buildRobots, buildSitemapEntries, createMetadataGenerator, createPageMetadata, injectAutoFillMeta } from './modules/seo/index.js';
export { createLlmsTxtRoute, createManifestHandler, createSitemapRouteHandler } from './modules/seo/index.js';
export { buildIconsMetadata, buildOrganizationJsonLd, validateFaviconField } from './modules/seo/index.js';
diff --git a/dist/index.js.map b/dist/index.js.map
index 6f5a1c5..d740178 100644
--- a/dist/index.js.map
+++ b/dist/index.js.map
@@ -1 +1 @@
-{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export type { AccessOption, Role } from './modules/access/index.js'\nexport {\n adminOnly,\n adminOnlyField,\n adminOrEditor,\n adminOrEditorField,\n adminOrSelf,\n authenticated,\n hasMinimumRole,\n isAdmin,\n isEditor,\n requireRole,\n requireRoleField,\n ROLE_HIERARCHY,\n} from './modules/access/index.js'\nexport {\n A11Y_COOKIE,\n A11Y_DEFAULT,\n a11yAttributes,\n parseA11y,\n serializeA11y,\n} from './modules/accessibility/index.js'\nexport type { A11yState } from './modules/accessibility/index.js'\nexport type { AnalyticsConfig } from './modules/analytics/index.js'\nexport { getAnalyticsConfig } from './modules/analytics/index.js'\nexport {\n ACCEPT_ALL_CONSENT,\n CONSENT_CATEGORIES,\n CONSENT_COOKIE,\n CONSENT_MAX_AGE,\n CONSENT_VERSION,\n DEFAULT_CONSENT,\n getConsentTexts,\n parseConsent,\n REJECT_ALL_CONSENT,\n serializeConsent,\n setDefaultConsent,\n updateConsent,\n} from './modules/consent/index.js'\nexport type { ConsentCategory, ConsentState, ConsentTexts } from './modules/consent/index.js'\nexport type {\n ContentCollectionOption,\n ContentOption,\n ResolvedRoute,\n} from './modules/content/index.js'\nexport {\n archiveFieldName,\n blocksToMarkdown,\n buildArchivePath,\n buildEntryPath,\n createMarkdownRenderer,\n createSearchRoute,\n getArchiveEntries,\n MARKDOWN_PREFIX,\n markdownHref,\n markdownResponse,\n parsePageParam,\n prefersMarkdown,\n resolveNotFoundPage,\n resolveRedirect,\n resolveRoute,\n searchContent,\n} from './modules/content/index.js'\nexport type { ArchiveEntries } from './modules/content/index.js'\nexport type { SearchResult } from './modules/content/index.js'\nexport { graphAdapter } from './modules/email/graphAdapter.js'\nexport type { GraphAdapterArgs } from './modules/email/graphAdapter.js'\nexport { mailAdapter } from './modules/email/mailAdapter.js'\nexport type { MailAdapterArgs } from './modules/email/mailAdapter.js'\n// Imported straight from the file, NOT from ./modules/email/index.js — that\n// barrel re-exports sendEmail, which imports 'server-only' and would crash when\n// Payload loads the config (or runs generate:importmap) as a plain Node script.\nexport { panelSmtpAdapter } from './modules/email/panelSmtpAdapter.js'\nexport type { PanelSmtpAdapterArgs } from './modules/email/panelSmtpAdapter.js'\n// Boot-time environment validation (fail fast on misconfigured deploys).\nexport { assertEnv, ipalEnvRules } from './modules/env/index.js'\nexport type { AssertEnvOptions, EnvKind, EnvRule, IpalEnvFeatures } from './modules/env/index.js'\n// Panel-managed form analytics (config-time field builder).\nexport { buildFormAnalyticsFields } from './modules/forms/formAnalyticsFields.js'\nexport { buildFormsPlugin } from './modules/forms/formsPluginConfig.js'\nexport { HONEYPOT_FIELD, honeypotInputProps, isHoneypotTripped } from './modules/forms/honeypot.js'\nexport type {\n FormsCollectionOverrides,\n FormsFieldsOverride,\n FormsOption,\n} from './modules/forms/types.js'\nexport type { FormErrors, FormSubmitAction, Validator } from './modules/forms/useForm.js'\n// Validation rules are pure — exported server-side too, for re-validating a\n// submission inside a server action. (useForm/useContactForm are client-only →\n// '@intecion/ipal-kit/client'.)\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'\nexport { createContentHelpers } from './modules/frontend/index.js'\n// Healthcheck route (Coolify/Docker liveness with a real DB round-trip).\nexport { createHealthRoute } from './modules/health/index.js'\nexport {\n buildCrossLocaleFieldSync,\n buildPreventDeleteSystemPage,\n buildRevalidateHook,\n buildValidateUniqueRole,\n setPublishedAtHook,\n trackSlugHistoryHook,\n} from './modules/hooks/index.js'\nexport type { I18nConfig, LocaleDefinition, LocalizedSlugs } from './modules/i18n/index.js'\nexport {\n buildLocalizedPath,\n getDefaultLocale,\n getLocaleCodes,\n getLocaleDefinition,\n getLocalizedSlugs,\n isValidLocale,\n LOCALE_COOKIE_NAME,\n matchAcceptLanguage,\n negotiateLocale,\n switchLocalePath,\n} from './modules/i18n/index.js'\nexport type { LocaleMiddlewareResult } from './modules/i18n/index.js'\nexport { createLocaleMiddleware, DEFAULT_MIDDLEWARE_MATCHER } from './modules/i18n/index.js'\nexport { createProxy, DEFAULT_PROXY_MATCHER } from './modules/i18n/index.js'\nexport { resolveLocalized } from './modules/i18n/index.js'\n// Read-only MCP server (Claude/agents connect to the site and query it).\nexport { createMcpRoute } from './modules/mcp/index.js'\nexport { normalizeFilename, normalizeFilenameHook } from './modules/media/index.js'\nexport {\n getNotificationTexts,\n NOTIFICATION_FALLBACK,\n resolveFormMessage,\n} from './modules/notifications/index.js'\nexport type { FormNotificationTexts, NotificationTexts } from './modules/notifications/index.js'\nexport type { PagesOption, SystemPageRole } from './modules/pages/index.js'\nexport { ALL_SYSTEM_PAGE_ROLES, getSystemPagePath } from './modules/pages/index.js'\nexport type { GlobalQueryOptions } from './modules/payload/index.js'\nexport {\n getGlobal,\n getSiteIntegrations,\n getSiteSettings,\n SITE_INTEGRATIONS_SLUG,\n SITE_SETTINGS_SLUG,\n} from './modules/payload/index.js'\n// Lexical → Markdown (pure, no React) — for AI-readable output.\nexport { lexicalToMarkdown } from './modules/richtext/index.js'\nexport { buildSecurityHeaders } from './modules/security/index.js'\nexport { buildCsp } from './modules/security/index.js'\n\nexport type { BuildCspArgs } from './modules/security/index.js'\nexport type { BuildSecurityHeadersArgs, SecurityHeader } from './modules/security/index.js'\nexport type { PageMetadata, SeoMeta, SeoOption } from './modules/seo/index.js'\nexport { buildHreflangAlternates, buildMetadata, composeTitle } from './modules/seo/index.js'\nexport type { AutoFillMapping, RobotsRules, SitemapEntry } from './modules/seo/index.js'\nexport {\n AI_ASSISTANT_BOTS,\n AI_TRAINING_BOTS,\n buildAutoFillMetaHook,\n buildRobots,\n buildSitemapEntries,\n createMetadataGenerator,\n createPageMetadata,\n injectAutoFillMeta,\n} from './modules/seo/index.js'\nexport {\n createLlmsTxtRoute,\n createManifestHandler,\n createSitemapRouteHandler,\n} from './modules/seo/index.js'\nexport {\n buildIconsMetadata,\n buildOrganizationJsonLd,\n validateFaviconField,\n} from './modules/seo/index.js'\nexport { buildNoindexField } from './modules/seo/index.js'\nexport { buildSpeakableJsonLd } from './modules/seo/index.js'\nexport { buildSummaryField } from './modules/seo/index.js'\nexport {\n buildBreadcrumbJsonLd,\n buildSiteNavigationJsonLd,\n buildWebSiteJsonLd,\n} from './modules/seo/index.js'\n// Local SEO structured data — LocalBusiness (map pack), Service (offering), FAQPage.\nexport {\n buildFaqJsonLd,\n buildLocalBusinessJsonLd,\n buildServiceJsonLd,\n} from './modules/seo/index.js'\nexport { buildArticleJsonLd } from './modules/seo/index.js'\nexport { buildLlmsTxt } from './modules/seo/index.js'\nexport { buildSitemapXml } from './modules/seo/index.js'\nexport { buildSlugField, toSlug } from './modules/slug/index.js'\nexport { buildR2Storage } from './modules/storage/index.js'\nexport { ipalKit } from './plugin.js'\nexport type { IpalOptions } from './types.js'\n"],"names":["adminOnly","adminOnlyField","adminOrEditor","adminOrEditorField","adminOrSelf","authenticated","hasMinimumRole","isAdmin","isEditor","requireRole","requireRoleField","ROLE_HIERARCHY","A11Y_COOKIE","A11Y_DEFAULT","a11yAttributes","parseA11y","serializeA11y","getAnalyticsConfig","ACCEPT_ALL_CONSENT","CONSENT_CATEGORIES","CONSENT_COOKIE","CONSENT_MAX_AGE","CONSENT_VERSION","DEFAULT_CONSENT","getConsentTexts","parseConsent","REJECT_ALL_CONSENT","serializeConsent","setDefaultConsent","updateConsent","archiveFieldName","blocksToMarkdown","buildArchivePath","buildEntryPath","createMarkdownRenderer","createSearchRoute","getArchiveEntries","MARKDOWN_PREFIX","markdownHref","markdownResponse","parsePageParam","prefersMarkdown","resolveNotFoundPage","resolveRedirect","resolveRoute","searchContent","graphAdapter","mailAdapter","panelSmtpAdapter","assertEnv","ipalEnvRules","buildFormAnalyticsFields","buildFormsPlugin","HONEYPOT_FIELD","honeypotInputProps","isHoneypotTripped","buildValidator","checked","custom","email","isEmail","maxLength","minLength","pattern","required","createContentHelpers","createHealthRoute","buildCrossLocaleFieldSync","buildPreventDeleteSystemPage","buildRevalidateHook","buildValidateUniqueRole","setPublishedAtHook","trackSlugHistoryHook","buildLocalizedPath","getDefaultLocale","getLocaleCodes","getLocaleDefinition","getLocalizedSlugs","isValidLocale","LOCALE_COOKIE_NAME","matchAcceptLanguage","negotiateLocale","switchLocalePath","createLocaleMiddleware","DEFAULT_MIDDLEWARE_MATCHER","createProxy","DEFAULT_PROXY_MATCHER","resolveLocalized","createMcpRoute","normalizeFilename","normalizeFilenameHook","getNotificationTexts","NOTIFICATION_FALLBACK","resolveFormMessage","ALL_SYSTEM_PAGE_ROLES","getSystemPagePath","getGlobal","getSiteIntegrations","getSiteSettings","SITE_INTEGRATIONS_SLUG","SITE_SETTINGS_SLUG","lexicalToMarkdown","buildSecurityHeaders","buildCsp","buildHreflangAlternates","buildMetadata","composeTitle","AI_ASSISTANT_BOTS","AI_TRAINING_BOTS","buildAutoFillMetaHook","buildRobots","buildSitemapEntries","createMetadataGenerator","createPageMetadata","injectAutoFillMeta","createLlmsTxtRoute","createManifestHandler","createSitemapRouteHandler","buildIconsMetadata","buildOrganizationJsonLd","validateFaviconField","buildNoindexField","buildSpeakableJsonLd","buildSummaryField","buildBreadcrumbJsonLd","buildSiteNavigationJsonLd","buildWebSiteJsonLd","buildFaqJsonLd","buildLocalBusinessJsonLd","buildServiceJsonLd","buildArticleJsonLd","buildLlmsTxt","buildSitemapXml","buildSlugField","toSlug","buildR2Storage","ipalKit"],"mappings":"AACA,SACEA,SAAS,EACTC,cAAc,EACdC,aAAa,EACbC,kBAAkB,EAClBC,WAAW,EACXC,aAAa,EACbC,cAAc,EACdC,OAAO,EACPC,QAAQ,EACRC,WAAW,EACXC,gBAAgB,EAChBC,cAAc,QACT,4BAA2B;AAClC,SACEC,WAAW,EACXC,YAAY,EACZC,cAAc,EACdC,SAAS,EACTC,aAAa,QACR,mCAAkC;AAGzC,SAASC,kBAAkB,QAAQ,+BAA8B;AACjE,SACEC,kBAAkB,EAClBC,kBAAkB,EAClBC,cAAc,EACdC,eAAe,EACfC,eAAe,EACfC,eAAe,EACfC,eAAe,EACfC,YAAY,EACZC,kBAAkB,EAClBC,gBAAgB,EAChBC,iB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AASC,cAAc,EAAEC,MAAM,QAAQ,0BAAyB;AAChE,SAASC,cAAc,QAAQ,6BAA4B;AAC3D,SAASC,OAAO,QAAQ,cAAa"}
\ No newline at end of file
+{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export type { AccessOption, Role } from './modules/access/index.js'\nexport {\n adminOnly,\n adminOnlyField,\n adminOrEditor,\n adminOrEditorField,\n adminOrSelf,\n authenticated,\n hasMinimumRole,\n isAdmin,\n isEditor,\n requireRole,\n requireRoleField,\n ROLE_HIERARCHY,\n} from './modules/access/index.js'\nexport {\n A11Y_COOKIE,\n A11Y_DEFAULT,\n a11yAttributes,\n parseA11y,\n serializeA11y,\n} from './modules/accessibility/index.js'\nexport type { A11yState } from './modules/accessibility/index.js'\nexport type { AnalyticsConfig } from './modules/analytics/index.js'\nexport { getAnalyticsConfig } from './modules/analytics/index.js'\nexport {\n ACCEPT_ALL_CONSENT,\n CONSENT_CATEGORIES,\n CONSENT_COOKIE,\n CONSENT_MAX_AGE,\n CONSENT_VERSION,\n DEFAULT_CONSENT,\n getConsentTexts,\n parseConsent,\n REJECT_ALL_CONSENT,\n serializeConsent,\n setDefaultConsent,\n updateConsent,\n} from './modules/consent/index.js'\nexport type { ConsentCategory, ConsentState, ConsentTexts } from './modules/consent/index.js'\nexport type {\n ContentCollectionOption,\n ContentOption,\n ResolvedRoute,\n} from './modules/content/index.js'\nexport {\n archiveFieldName,\n blocksToMarkdown,\n buildArchivePath,\n buildEntryPath,\n createMarkdownRenderer,\n createSearchRoute,\n getArchiveEntries,\n MARKDOWN_PREFIX,\n markdownHref,\n markdownResponse,\n parsePageParam,\n prefersMarkdown,\n resolveNotFoundPage,\n resolveRedirect,\n resolveRoute,\n searchContent,\n} from './modules/content/index.js'\nexport type { ArchiveEntries } from './modules/content/index.js'\nexport type { SearchResult } from './modules/content/index.js'\nexport { graphAdapter } from './modules/email/graphAdapter.js'\nexport type { GraphAdapterArgs } from './modules/email/graphAdapter.js'\nexport { mailAdapter } from './modules/email/mailAdapter.js'\nexport type { MailAdapterArgs } from './modules/email/mailAdapter.js'\n// Imported straight from the file, NOT from ./modules/email/index.js — that\n// barrel re-exports sendEmail, which imports 'server-only' and would crash when\n// Payload loads the config (or runs generate:importmap) as a plain Node script.\nexport { panelSmtpAdapter } from './modules/email/panelSmtpAdapter.js'\nexport type { PanelSmtpAdapterArgs } from './modules/email/panelSmtpAdapter.js'\n// Boot-time environment validation (fail fast on misconfigured deploys).\nexport { assertEnv, ipalEnvRules } from './modules/env/index.js'\nexport type { AssertEnvOptions, EnvKind, EnvRule, IpalEnvFeatures } from './modules/env/index.js'\n// Panel-managed form analytics (config-time field builder).\nexport { buildFormAnalyticsFields } from './modules/forms/formAnalyticsFields.js'\nexport { buildFormsPlugin } from './modules/forms/formsPluginConfig.js'\nexport { HONEYPOT_FIELD, honeypotInputProps, isHoneypotTripped } from './modules/forms/honeypot.js'\nexport type {\n FormsCollectionOverrides,\n FormsFieldsOverride,\n FormsOption,\n} from './modules/forms/types.js'\nexport type { FormErrors, FormSubmitAction, Validator } from './modules/forms/useForm.js'\n// Validation rules are pure — exported server-side too, for re-validating a\n// submission inside a server action. (useForm/useContactForm are client-only →\n// '@intecion/ipal-kit/client'.)\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'\nexport { createContentHelpers } from './modules/frontend/index.js'\n// Healthcheck route (Coolify/Docker liveness with a real DB round-trip).\nexport { createHealthRoute } from './modules/health/index.js'\nexport {\n buildCrossLocaleFieldSync,\n buildPreventDeleteSystemPage,\n buildRevalidateHook,\n buildValidateUniqueRole,\n setPublishedAtHook,\n trackSlugHistoryHook,\n} from './modules/hooks/index.js'\nexport type { I18nConfig, LocaleDefinition, LocalizedSlugs } from './modules/i18n/index.js'\nexport {\n buildLocalizedPath,\n getDefaultLocale,\n getLocaleCodes,\n getLocaleDefinition,\n getLocalizedSlugs,\n isValidLocale,\n LOCALE_COOKIE_NAME,\n matchAcceptLanguage,\n negotiateLocale,\n switchLocalePath,\n} from './modules/i18n/index.js'\nexport type { LocaleMiddlewareResult } from './modules/i18n/index.js'\nexport { createLocaleMiddleware, DEFAULT_MIDDLEWARE_MATCHER } from './modules/i18n/index.js'\nexport { createProxy, DEFAULT_PROXY_MATCHER } from './modules/i18n/index.js'\nexport { resolveLocalized } from './modules/i18n/index.js'\nexport { buildLinkField, buildLinksField, resolveLinkHref } from './modules/links/index.js'\nexport type {\n BuildLinkFieldOptions,\n BuildLinksFieldOptions,\n LinkAppearance,\n LinkValue,\n ResolveLinkHrefOptions,\n} from './modules/links/index.js'\n// Read-only MCP server (Claude/agents connect to the site and query it).\nexport { createMcpRoute } from './modules/mcp/index.js'\nexport { normalizeFilename, normalizeFilenameHook } from './modules/media/index.js'\nexport {\n getNotificationTexts,\n NOTIFICATION_FALLBACK,\n resolveFormMessage,\n} from './modules/notifications/index.js'\nexport type { FormNotificationTexts, NotificationTexts } from './modules/notifications/index.js'\nexport type { PagesOption, SystemPageRole } from './modules/pages/index.js'\nexport { ALL_SYSTEM_PAGE_ROLES, getSystemPagePath } from './modules/pages/index.js'\nexport type { GlobalQueryOptions } from './modules/payload/index.js'\nexport {\n getGlobal,\n getSiteIntegrations,\n getSiteSettings,\n SITE_INTEGRATIONS_SLUG,\n SITE_SETTINGS_SLUG,\n} from './modules/payload/index.js'\n// Lexical → Markdown (pure, no React) — for AI-readable output.\nexport { lexicalToMarkdown } from './modules/richtext/index.js'\nexport { buildSecurityHeaders } from './modules/security/index.js'\n\nexport { buildCsp } from './modules/security/index.js'\nexport type { BuildCspArgs } from './modules/security/index.js'\nexport type { BuildSecurityHeadersArgs, SecurityHeader } from './modules/security/index.js'\nexport type { PageMetadata, SeoMeta, SeoOption } from './modules/seo/index.js'\nexport {\n buildHreflangAlternates,\n buildMetadata,\n composeTitle,\n readSiteMetaConfig,\n slugsAcrossLocales,\n} from './modules/seo/index.js'\nexport type { SiteMetaConfig } from './modules/seo/index.js'\nexport type {\n AutoFillMapping,\n RobotsOptions,\n RobotsRules,\n SitemapEntry,\n} from './modules/seo/index.js'\nexport {\n AI_ASSISTANT_BOTS,\n AI_TRAINING_BOTS,\n buildAutoFillMetaHook,\n buildRobots,\n buildSitemapEntries,\n createMetadataGenerator,\n createPageMetadata,\n injectAutoFillMeta,\n} from './modules/seo/index.js'\nexport {\n createLlmsTxtRoute,\n createManifestHandler,\n createSitemapRouteHandler,\n} from './modules/seo/index.js'\nexport {\n buildIconsMetadata,\n buildOrganizationJsonLd,\n validateFaviconField,\n} from './modules/seo/index.js'\nexport { buildNoindexField } from './modules/seo/index.js'\nexport { buildSpeakableJsonLd } from './modules/seo/index.js'\nexport { buildSummaryField } from './modules/seo/index.js'\nexport {\n buildBreadcrumbJsonLd,\n buildSiteNavigationJsonLd,\n buildWebSiteJsonLd,\n} from './modules/seo/index.js'\n// Local SEO structured data — LocalBusiness (map pack), Service (offering), FAQPage.\nexport {\n buildFaqJsonLd,\n buildLocalBusinessJsonLd,\n buildServiceJsonLd,\n} from './modules/seo/index.js'\nexport { buildArticleJsonLd } from './modules/seo/index.js'\nexport { buildLlmsTxt } from './modules/seo/index.js'\nexport { buildSitemapXml } from './modules/seo/index.js'\nexport { buildSlugField, toSlug } from './modules/slug/index.js'\nexport { buildR2Storage } from './modules/storage/index.js'\nexport { ipalKit } from './plugin.js'\nexport type { IpalOptions } from './types.js'\n"],"names":["adminOnly","adminOnlyField","adminOrEditor","adminOrEditorField","adminOrSelf","authenticated","hasMinimumRole","isAdmin","isEditor","requireRole","requireRoleField","ROLE_HIERARCHY","A11Y_COOKIE","A11Y_DEFAULT","a11yAttributes","parseA11y","serializeA11y","getAnalyticsConfig","ACCEPT_ALL_CONSENT","CONSENT_CATEGORIES","CONSENT_COOKIE","CONSENT_MAX_AGE","CONSENT_VERSION","DEFAULT_CONSENT","getConsentTexts","parseConsent","REJECT_ALL_CONSENT","serializeConsent","setDefaultConsent","updateConsent","archiveFieldName","blocksToMarkdown","buildArchivePath","buildEntryPath","createMarkdownRenderer","createSearchRoute","getArchiveEntries","MARKDOWN_PREFIX","markdownHref","markdownResponse","parsePageParam","prefersMarkdown","resolveNotFoundPage","resolveRedirect","resolveRoute","searchContent","graphAdapter","mailAdapter","panelSmtpAdapter","assertEnv","ipalEnvRules","buildFormAnalyticsFields","buildFormsPlugin","HONEYPOT_FIELD","honeypotInputProps","isHoneypotTripped","buildValidator","checked","custom","email","isEmail","maxLength","minLength","pattern","required","createContentHelpers","createHealthRoute","buildCrossLocaleFieldSync","buildPreventDeleteSystemPage","buildRevalidateHook","buildValidateUniqueRole","setPublishedAtHook","trackSlugHistoryHook","buildLocalizedPath","getDefaultLocale","getLocaleCodes","getLocaleDefinition","getLocalizedSlugs","isValidLocale","LOCALE_COOKIE_NAME","matchAcceptLanguage","negotiateLocale","switchLocalePath","createLocaleMiddleware","DEFAULT_MIDDLEWARE_MATCHER","createProxy","DEFAULT_PROXY_MATCHER","resolveLocalized","buildLinkField","buildLinksField","resolveLinkHref","createMcpRoute","normalizeFilename","normalizeFilenameHook","getNotificationTexts","NOTIFICATION_FALLBACK","resolveFormMessage","ALL_SYSTEM_PAGE_ROLES","getSystemPagePath","getGlobal","getSiteIntegrations","getSiteSettings","SITE_INTEGRATIONS_SLUG","SITE_SETTINGS_SLUG","lexicalToMarkdown","buildSecurityHeaders","buildCsp","buildHreflangAlternates","buildMetadata","composeTitle","readSiteMetaConfig","slugsAcrossLocales","AI_ASSISTANT_BOTS","AI_TRAINING_BOTS","buildAutoFillMetaHook","buildRobots","buildSitemapEntries","createMetadataGenerator","createPageMetadata","injectAutoFillMeta","createLlmsTxtRoute","createManifestHandler","createSitemapRouteHandler","buildIconsMetadata","buildOrganizationJsonLd","validateFaviconField","buildNoindexField","buildSpeakableJsonLd","buildSummaryField","buildBreadcrumbJsonLd","buildSiteNavigationJsonLd","buildWebSiteJsonLd","buildFaqJsonLd","buildLocalBusinessJsonLd","buildServiceJsonLd","buildArticleJsonLd","buildLlmsTxt","buildSitemapXml","buildSlugField","toSlug","buildR2Storage","ipalKit"],"mappings":"AACA,SACEA,SAAS,EACTC,cAAc,EACdC,aAAa,EACbC,kBAAkB,EAClBC,WAAW,EACXC,aAAa,EACbC,cAAc,EACdC,OAAO,EACPC,QAAQ,EACRC,WAAW,EACXC,gBAAgB,EAChBC,cAAc,QACT,4BAA2B;AAClC,SACEC,WAAW,EACXC,YAAY,EACZC,cAAc,EACdC,SAAS,EACTC,aAAa,QACR,mCAAkC;AAGzC,SAASC,kBAAkB,QAAQ,+BAA8B;AACjE,SACEC,kBAAkB,EAClBC,kBAAkB,EAClBC,cAAc,EACdC,eAAe,EACfC,eAAe,EACfC,eAAe,EACfC,eAAe,EACfC,YAAY,EACZC,kBAAkB,EAClBC,gBAAgB,EAChBC,iBAAiB,EACjBC,aAAa,QACR,6BAA4B;AAOnC,SACEC,gBAAgB,EAChBC,gBAAgB,EAChBC,gBAAgB,EAChBC,cAAc,EACdC,sBAAsB,EACtBC,iBAAiB,EACjBC,iBAAiB,EACjBC,eAAe,EACfC,YAAY,EACZC,gBAAgB,EAChBC,cAAc,EACdC,eAAe,EACfC,mBAAmB,EACnBC,eAAe,EACfC,YAAY,EACZC,aAAa,QACR,6BAA4B;AAGnC,SAASC,YAAY,QAAQ,kCAAiC;AAE9D,SAASC,WAAW,QAAQ,iCAAgC;AAE5D,4EAA4E;AAC5E,gFAAgF;AAChF,gFAAgF;AAChF,SAASC,gBAAgB,QAAQ,sCAAqC;AAEtE,yEAAyE;AACzE,SAASC,SAAS,EAAEC,YAAY,QAAQ,yBAAwB;AAEhE,4DAA4D;AAC5D,SAASC,wBAAwB,QAAQ,yCAAwC;AACjF,SAASC,gBAAgB,QAAQ,uCAAsC;AACvE,SAASC,cAAc,EAAEC,kBAAkB,EAAEC,iBAAiB,QAAQ,8BAA6B;AAOnG,4EAA4E;AAC5E,+EAA+E;AAC/E,gCAAgC;AAChC,SACEC,cAAc,EACdC,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B,EAChBC,qBAAqB,EACrBC,WAAW,EACXC,mBAAmB,EACnBC,uBAAuB,EACvBC,kBAAkB,EAClBC,kBAAkB,QACb,yBAAwB;AAC/B,SACEC,kBAAkB,EAClBC,qBAAqB,EACrBC,yBAAyB,QACpB,yBAAwB;AAC/B,SACEC,kBAAkB,EAClBC,uBAAuB,EACvBC,oBAAoB,QACf,yBAAwB;AAC/B,SAASC,iBAAiB,QAAQ,yBAAwB;AAC1D,SAASC,oBAAoB,QAAQ,yBAAwB;AAC7D,SAASC,iBAAiB,QAAQ,yBAAwB;AAC1D,SACEC,qBAAqB,EACrBC,yBAAyB,EACzBC,kBAAkB,QACb,yBAAwB;AAC/B,qFAAqF;AACrF,SACEC,cAAc,EACdC,wBAAwB,EACxBC,kBAAkB,QACb,yBAAwB;AAC/B,SAASC,kBAAkB,QAAQ,yBAAwB;AAC3D,SAASC,YAAY,QAAQ,yBAAwB;AACrD,SAASC,eAAe,QAAQ,yBAAwB;AACxD,SAASC,cAAc,EAAEC,MAAM,QAAQ,0BAAyB;AAChE,SAASC,cAAc,QAAQ,6BAA4B;AAC3D,SAASC,OAAO,QAAQ,cAAa"}
\ No newline at end of file
diff --git a/dist/modules/content/resolveRoute.d.ts b/dist/modules/content/resolveRoute.d.ts
index 9570715..b3904a7 100644
--- a/dist/modules/content/resolveRoute.d.ts
+++ b/dist/modules/content/resolveRoute.d.ts
@@ -38,6 +38,12 @@ type ResolveRouteArgs = {
payload: BasePayload;
/** Route segments after the locale, e.g. ['artykuly', 'moj-post']. */
segments?: string[];
+ /**
+ * SiteSettings already read for this locale (depth ≥ 1). Pass it to skip the
+ * read — createContentHelpers does, so layout, metadata and page share ONE
+ * settings query per request.
+ */
+ settings?: null | Record;
/** SiteSettings global slug. Defaults to 'site-settings'. */
settingsSlug?: string;
};
@@ -64,5 +70,5 @@ type ResolveRouteArgs = {
* make canonical and hreflang ambiguous (the same entry reachable under several
* URLs).
*/
-export declare function resolveRoute({ content, locale, page, pagesSlug, payload, segments, settingsSlug, }: ResolveRouteArgs): Promise;
+export declare function resolveRoute({ content, locale, page, pagesSlug, payload, segments, settings: preloaded, settingsSlug, }: ResolveRouteArgs): Promise;
export {};
diff --git a/dist/modules/content/resolveRoute.js b/dist/modules/content/resolveRoute.js
index 4926433..02277e3 100644
--- a/dist/modules/content/resolveRoute.js
+++ b/dist/modules/content/resolveRoute.js
@@ -21,8 +21,8 @@ import { archiveFieldName } from './types.js';
* Depth beyond {archive}/{entry} isn't supported — categories in the path would
* make canonical and hreflang ambiguous (the same entry reachable under several
* URLs).
- */ export async function resolveRoute({ content, locale, page = 1, pagesSlug = 'pages', payload, segments, settingsSlug = 'site-settings' }) {
- const settings = await payload.findGlobal({
+ */ export async function resolveRoute({ content, locale, page = 1, pagesSlug = 'pages', payload, segments, settings: preloaded, settingsSlug = 'site-settings' }) {
+ const settings = preloaded ?? await payload.findGlobal({
slug: settingsSlug,
depth: 1,
locale: locale
diff --git a/dist/modules/content/resolveRoute.js.map b/dist/modules/content/resolveRoute.js.map
index 153c09a..e0e1373 100644
--- a/dist/modules/content/resolveRoute.js.map
+++ b/dist/modules/content/resolveRoute.js.map
@@ -1 +1 @@
-{"version":3,"sources":["../../../src/modules/content/resolveRoute.ts"],"sourcesContent":["import type { BasePayload } from 'payload'\n\nimport type { ContentOption } from './types.js'\n\nimport { archiveFieldName } from './types.js'\n\ntype ArchivePage = { id: number | string; slug?: unknown }\n\nexport type ResolvedRoute =\n /** Locale root — the page assigned as Homepage in System Pages. */\n | {\n /** The archive page this entry lives under — its slug is the URL prefix. */\n archive: Record\n collection: string\n doc: Record\n type: 'entry'\n }\n /** An ordinary page. */\n | {\n collection: string\n doc: Record\n /** 1-based, from ?page=. */\n page: number\n perPage: number\n type: 'archive'\n }\n /** A collection's archive page, e.g. /pl/artykuly. */\n | { doc: Record; type: 'home' }\n /** A single entry, e.g. /pl/artykuly/moj-post. */\n | { doc: Record; type: 'page' }\n\ntype ResolveRouteArgs = {\n content?: ContentOption\n locale: string\n /** Page number from the query string (?page=2). Defaults to 1. */\n page?: number\n /** Client's Pages collection slug. Defaults to 'pages'. */\n pagesSlug?: string\n payload: BasePayload\n /** Route segments after the locale, e.g. ['artykuly', 'moj-post']. */\n segments?: string[]\n /** SiteSettings global slug. Defaults to 'site-settings'. */\n settingsSlug?: string\n}\n\n/**\n * Works out what a URL points at: the home page, an ordinary page, a\n * collection's archive, or a single entry.\n *\n * Routing only. An archive result says which collection to list and on which\n * page, but doesn't fetch the entries — that's `getArchiveEntries`, called by\n * whoever actually needs them. Keeping the two apart means listing changes\n * (sorting, filtering, pagination) never touch routing rules, and metadata\n * generation doesn't pay for a query it would discard.\n *\n * The trick is that archive prefixes aren't configured anywhere — they're the\n * slug of whichever page an editor assigned as that collection's archive. So\n * /pl/artykuly and /en/articles come from one assignment, and renaming the page\n * moves the whole section.\n *\n * Resolution order matters: a first segment matching an archive's slug wins\n * over an ordinary page of the same name, because an archive *is* a page and\n * would otherwise shadow its own entries.\n *\n * Depth beyond {archive}/{entry} isn't supported — categories in the path would\n * make canonical and hreflang ambiguous (the same entry reachable under several\n * URLs).\n */\nexport async function resolveRoute({\n content,\n locale,\n page = 1,\n pagesSlug = 'pages',\n payload,\n segments,\n settingsSlug = 'site-settings',\n}: ResolveRouteArgs): Promise {\n const settings = (await payload.findGlobal({\n slug: settingsSlug,\n depth: 1,\n locale: locale as never,\n })) as Record\n\n // Locale root → Homepage from System Pages.\n // settings.homepage is a shallow relation (depth: 1 above) — it identifies\n // WHICH page is the homepage, but its nested block relations (e.g. Hero\n // images) aren't populated. Re-fetch that page from the pages collection at\n // the same depth as every other page, so the frontend gets one consistent\n // shape. Uses pagesSlug/locale from args — no hard-coded collection or locale.\n if (!segments?.length) {\n const homepage = settings.homepage\n if (!homepage || typeof homepage !== 'object') {\n return null\n }\n\n const homepageId = (homepage as { id: number | string }).id\n const doc = await payload.findByID({\n id: homepageId,\n collection: pagesSlug,\n depth: 2,\n locale: locale as never,\n })\n\n return doc ? { type: 'home', doc: doc as Record } : null\n }\n\n const [first, ...rest] = segments\n\n // Does the first segment name an archive page?\n for (const collection of content?.collections ?? []) {\n const archive = settings[archiveFieldName(collection.slug)]\n if (!archive || typeof archive !== 'object') {continue}\n\n const archiveDoc = archive as ArchivePage\n if (archiveDoc.slug !== first) {continue}\n\n // /pl/artykuly → the archive page itself.\n if (rest.length === 0) {\n return {\n type: 'archive',\n collection: collection.slug,\n doc: archiveDoc as Record,\n page,\n perPage: collection.perPage ?? 10,\n }\n }\n\n // /pl/artykuly/moj-post → an entry.\n if (rest.length === 1) {\n const found = await payload.find({\n collection: collection.slug as never,\n depth: 2,\n limit: 1,\n locale: locale as never,\n where: { slug: { equals: rest[0] } },\n })\n const entry = found.docs[0]\n if (!entry) {return null}\n\n return {\n type: 'entry',\n archive: archiveDoc as Record,\n collection: collection.slug,\n doc: entry as Record,\n }\n }\n\n // Deeper than {archive}/{entry}.\n return null\n }\n\n // An ordinary page. Joined, so nested slugs ('a/b') keep working.\n const found = await payload.find({\n collection: pagesSlug as never,\n depth: 2,\n limit: 1,\n locale: locale as never,\n where: { slug: { equals: segments.join('/') } },\n })\n const doc = found.docs[0]\n if (!doc) {return null}\n\n // The page assigned as 404 in System Pages must not be reachable as a normal\n // 200 URL (/pl/strona-nie-znaleziona) — that's a soft-404 / duplicate. Treat\n // it as not found, so the route calls notFound() and not-found.tsx renders\n // that same page with a real 404 status. (If 404 = homepage, the homepage is\n // served from the root branch above and never reaches here by its own slug\n // in a way that matters — but guard anyway so we never hide the homepage.)\n const notFound = settings.notFound\n const homepage = settings.homepage\n const notFoundId =\n notFound && typeof notFound === 'object' ? (notFound as { id?: unknown }).id : notFound\n const homepageId =\n homepage && typeof homepage === 'object' ? (homepage as { id?: unknown }).id : homepage\n const docId = (doc as { id?: unknown }).id\n if (notFoundId != null && notFoundId === docId && notFoundId !== homepageId) {\n return null\n }\n\n return { type: 'page', doc: doc as Record }\n}\n"],"names":["archiveFieldName","resolveRoute","content","locale","page","pagesSlug","payload","segments","settingsSlug","settings","findGlobal","slug","depth","length","homepage","homepageId","id","doc","findByID","collection","type","first","rest","collections","archive","archiveDoc","perPage","found","find","limit","where","equals","entry","docs","join","notFound","notFoundId","docId"],"mappings":"AAIA,SAASA,gBAAgB,QAAQ,aAAY;AAyC7C;;;;;;;;;;;;;;;;;;;;;;CAsBC,GACD,OAAO,eAAeC,aAAa,EACjCC,OAAO,EACPC,MAAM,EACNC,OAAO,CAAC,EACRC,YAAY,OAAO,EACnBC,OAAO,EACPC,QAAQ,EACRC,eAAe,eAAe,EACb;IACjB,MAAMC,WAAY,MAAMH,QAAQI,UAAU,CAAC;QACzCC,MAAMH;QACNI,OAAO;QACPT,QAAQA;IACV;IAEA,4CAA4C;IAC5C,2EAA2E;IAC3E,wEAAwE;IACxE,4EAA4E;IAC5E,0EAA0E;IAC1E,+EAA+E;IAC/E,IAAI,CAACI,UAAUM,QAAQ;QACrB,MAAMC,WAAWL,SAASK,QAAQ;QAClC,IAAI,CAACA,YAAY,OAAOA,aAAa,UAAU;YAC7C,OAAO;QACT;QAEA,MAAMC,aAAa,AAACD,SAAqCE,EAAE;QAC3D,MAAMC,MAAM,MAAMX,QAAQY,QAAQ,CAAC;YACjCF,IAAID;YACJI,YAAYd;YACZO,OAAO;YACPT,QAAQA;QACV;QAEA,OAAOc,MAAM;YAAEG,MAAM;YAAQH,KAAKA;QAA+B,IAAI;IACvE;IAEA,MAAM,CAACI,OAAO,GAAGC,KAAK,GAAGf;IAEzB,+CAA+C;IAC/C,KAAK,MAAMY,cAAcjB,SAASqB,eAAe,EAAE,CAAE;QACnD,MAAMC,UAAUf,QAAQ,CAACT,iBAAiBmB,WAAWR,IAAI,EAAE;QAC3D,IAAI,CAACa,WAAW,OAAOA,YAAY,UAAU;YAAC;QAAQ;QAEtD,MAAMC,aAAaD;QACnB,IAAIC,WAAWd,IAAI,KAAKU,OAAO;YAAC;QAAQ;QAExC,0CAA0C;QAC1C,IAAIC,KAAKT,MAAM,KAAK,GAA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,AAACpB,IAAyBD,EAAE;IAC1C,IAAIoB,cAAc,QAAQA,eAAeC,SAASD,eAAerB,YAAY;QAC3E,OAAO;IACT;IAEA,OAAO;QAAEK,MAAM;QAAQH,KAAKA;IAA+B;AAC7D"}
\ No newline at end of file
+{"version":3,"sources":["../../../src/modules/content/resolveRoute.ts"],"sourcesContent":["import type { BasePayload } from 'payload'\n\nimport type { ContentOption } from './types.js'\n\nimport { archiveFieldName } from './types.js'\n\ntype ArchivePage = { id: number | string; slug?: unknown }\n\nexport type ResolvedRoute =\n /** Locale root — the page assigned as Homepage in System Pages. */\n | {\n /** The archive page this entry lives under — its slug is the URL prefix. */\n archive: Record\n collection: string\n doc: Record\n type: 'entry'\n }\n /** An ordinary page. */\n | {\n collection: string\n doc: Record\n /** 1-based, from ?page=. */\n page: number\n perPage: number\n type: 'archive'\n }\n /** A collection's archive page, e.g. /pl/artykuly. */\n | { doc: Record; type: 'home' }\n /** A single entry, e.g. /pl/artykuly/moj-post. */\n | { doc: Record; type: 'page' }\n\ntype ResolveRouteArgs = {\n content?: ContentOption\n locale: string\n /** Page number from the query string (?page=2). Defaults to 1. */\n page?: number\n /** Client's Pages collection slug. Defaults to 'pages'. */\n pagesSlug?: string\n payload: BasePayload\n /** Route segments after the locale, e.g. ['artykuly', 'moj-post']. */\n segments?: string[]\n /**\n * SiteSettings already read for this locale (depth ≥ 1). Pass it to skip the\n * read — createContentHelpers does, so layout, metadata and page share ONE\n * settings query per request.\n */\n settings?: null | Record\n /** SiteSettings global slug. Defaults to 'site-settings'. */\n settingsSlug?: string\n}\n\n/**\n * Works out what a URL points at: the home page, an ordinary page, a\n * collection's archive, or a single entry.\n *\n * Routing only. An archive result says which collection to list and on which\n * page, but doesn't fetch the entries — that's `getArchiveEntries`, called by\n * whoever actually needs them. Keeping the two apart means listing changes\n * (sorting, filtering, pagination) never touch routing rules, and metadata\n * generation doesn't pay for a query it would discard.\n *\n * The trick is that archive prefixes aren't configured anywhere — they're the\n * slug of whichever page an editor assigned as that collection's archive. So\n * /pl/artykuly and /en/articles come from one assignment, and renaming the page\n * moves the whole section.\n *\n * Resolution order matters: a first segment matching an archive's slug wins\n * over an ordinary page of the same name, because an archive *is* a page and\n * would otherwise shadow its own entries.\n *\n * Depth beyond {archive}/{entry} isn't supported — categories in the path would\n * make canonical and hreflang ambiguous (the same entry reachable under several\n * URLs).\n */\nexport async function resolveRoute({\n content,\n locale,\n page = 1,\n pagesSlug = 'pages',\n payload,\n segments,\n settings: preloaded,\n settingsSlug = 'site-settings',\n}: ResolveRouteArgs): Promise {\n const settings =\n preloaded ??\n ((await payload.findGlobal({\n slug: settingsSlug,\n depth: 1,\n locale: locale as never,\n })) as Record)\n\n // Locale root → Homepage from System Pages.\n // settings.homepage is a shallow relation (depth: 1 above) — it identifies\n // WHICH page is the homepage, but its nested block relations (e.g. Hero\n // images) aren't populated. Re-fetch that page from the pages collection at\n // the same depth as every other page, so the frontend gets one consistent\n // shape. Uses pagesSlug/locale from args — no hard-coded collection or locale.\n if (!segments?.length) {\n const homepage = settings.homepage\n if (!homepage || typeof homepage !== 'object') {\n return null\n }\n\n const homepageId = (homepage as { id: number | string }).id\n const doc = await payload.findByID({\n id: homepageId,\n collection: pagesSlug,\n depth: 2,\n locale: locale as never,\n })\n\n return doc ? { type: 'home', doc: doc as Record } : null\n }\n\n const [first, ...rest] = segments\n\n // Does the first segment name an archive page?\n for (const collection of content?.collections ?? []) {\n const archive = settings[archiveFieldName(collection.slug)]\n if (!archive || typeof archive !== 'object') {continue}\n\n const archiveDoc = archive as ArchivePage\n if (archiveDoc.slug !== first) {continue}\n\n // /pl/artykuly → the archive page itself.\n if (rest.length === 0) {\n return {\n type: 'archive',\n collection: collection.slug,\n doc: archiveDoc as Record,\n page,\n perPage: collection.perPage ?? 10,\n }\n }\n\n // /pl/artykuly/moj-post → an entry.\n if (rest.length === 1) {\n const found = await payload.find({\n collection: collection.slug as never,\n depth: 2,\n limit: 1,\n locale: locale as never,\n where: { slug: { equals: rest[0] } },\n })\n const entry = found.docs[0]\n if (!entry) {return null}\n\n return {\n type: 'entry',\n archive: archiveDoc as Record,\n collection: collection.slug,\n doc: entry as Record,\n }\n }\n\n // Deeper than {archive}/{entry}.\n return null\n }\n\n // An ordinary page. Joined, so nested slugs ('a/b') keep working.\n const found = await payload.find({\n collection: pagesSlug as never,\n depth: 2,\n limit: 1,\n locale: locale as never,\n where: { slug: { equals: segments.join('/') } },\n })\n const doc = found.docs[0]\n if (!doc) {return null}\n\n // The page assigned as 404 in System Pages must not be reachable as a normal\n // 200 URL (/pl/strona-nie-znaleziona) — that's a soft-404 / duplicate. Treat\n // it as not found, so the route calls notFound() and not-found.tsx renders\n // that same page with a real 404 status. (If 404 = homepage, the homepage is\n // served from the root branch above and never reaches here by its own slug\n // in a way that matters — but guard anyway so we never hide the homepage.)\n const notFound = settings.notFound\n const homepage = settings.homepage\n const notFoundId =\n notFound && typeof notFound === 'object' ? (notFound as { id?: unknown }).id : notFound\n const homepageId =\n homepage && typeof homepage === 'object' ? (homepage as { id?: unknown }).id : homepage\n const docId = (doc as { id?: unknown }).id\n if (notFoundId != null && notFoundId === docId && notFoundId !== homepageId) {\n return null\n }\n\n return { type: 'page', doc: doc as Record }\n}\n"],"names":["archiveFieldName","resolveRoute","content","locale","page","pagesSlug","payload","segments","settings","preloaded","settingsSlug","findGlobal","slug","depth","length","homepage","homepageId","id","doc","findByID","collection","type","first","rest","collections","archive","archiveDoc","perPage","found","find","limit","where","equals","entry","docs","join","notFound","notFoundId","docId"],"mappings":"AAIA,SAASA,gBAAgB,QAAQ,aAAY;AA+C7C;;;;;;;;;;;;;;;;;;;;;;CAsBC,GACD,OAAO,eAAeC,aAAa,EACjCC,OAAO,EACPC,MAAM,EACNC,OAAO,CAAC,EACRC,YAAY,OAAO,EACnBC,OAAO,EACPC,QAAQ,EACRC,UAAUC,SAAS,EACnBC,eAAe,eAAe,EACb;IACjB,MAAMF,WACJC,aACE,MAAMH,QAAQK,UAAU,CAAC;QACz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MAAMU,QAAQL,MAAMM,IAAI,CAAC,EAAE;YAC3B,IAAI,CAACD,OAAO;gBAAC,OAAO;YAAI;YAExB,OAAO;gBACLZ,MAAM;gBACNI,SAASC;gBACTN,YAAYA,WAAWR,IAAI;gBAC3BM,KAAKe;YACP;QACF;QAEA,iCAAiC;QACjC,OAAO;IACT;IAEA,kEAAkE;IAClE,MAAML,QAAQ,MAAMtB,QAAQuB,IAAI,CAAC;QAC/BT,YAAYf;QACZQ,OAAO;QACPiB,OAAO;QACP3B,QAAQA;QACR4B,OAAO;YAAEnB,MAAM;gBAAEoB,QAAQzB,SAAS4B,IAAI,CAAC;YAAK;QAAE;IAChD;IACA,MAAMjB,MAAMU,MAAMM,IAAI,CAAC,EAAE;IACzB,IAAI,CAAChB,KAAK;QAAC,OAAO;IAAI;IAEtB,6EAA6E;IAC7E,6EAA6E;IAC7E,2EAA2E;IAC3E,6EAA6E;IAC7E,2EAA2E;IAC3E,2EAA2E;IAC3E,MAAMkB,WAAW5B,SAAS4B,QAAQ;IAClC,MAAMrB,WAAWP,SAASO,QAAQ;IAClC,MAAMsB,aACJD,YAAY,OAAOA,aAAa,WAAW,AAACA,SAA8BnB,EAAE,GAAGmB;IACjF,MAAMpB,aACJD,YAAY,OAAOA,aAAa,WAAW,AAACA,SAA8BE,EAAE,GAAGF;IACjF,MAAMuB,QAAQ,AAACpB,IAAyBD,EAAE;IAC1C,IAAIoB,cAAc,QAAQA,eAAeC,SAASD,eAAerB,YAAY;QAC3E,OAAO;IACT;IAEA,OAAO;QAAEK,MAAM;QAAQH,KAAKA;IAA+B;AAC7D"}
\ No newline at end of file
diff --git a/dist/modules/frontend/createContentHelpers.d.ts b/dist/modules/frontend/createContentHelpers.d.ts
index cb6234a..3646752 100644
--- a/dist/modules/frontend/createContentHelpers.d.ts
+++ b/dist/modules/frontend/createContentHelpers.d.ts
@@ -1,7 +1,7 @@
import type { BasePayload, SanitizedConfig } from 'payload';
import type { ArchiveEntries, ContentOption, ResolvedRoute } from '../content/index.js';
import type { I18nConfig } from '../i18n/index.js';
-import type { RobotsRules, SitemapEntry } from '../seo/index.js';
+import type { PageMetadata, RobotsOptions, RobotsRules, SitemapEntry } from '../seo/index.js';
type CreateContentHelpersArgs = {
/**
* Absolute site origin for sitemap/robots URLs. Falls back to
@@ -23,6 +23,12 @@ type CreateContentHelpersArgs = {
i18n?: I18nConfig;
/** Pages collection slug. Defaults to 'pages'. */
pagesSlug?: string;
+ /**
+ * Options for the ready-made `robots` handler, e.g.
+ * `{ disallowParams: ['s', 'meter'], aiBots: 'block-training' }`, or
+ * `{ adminRoute: false }` when the admin path is hidden (ipalKit adminRoute).
+ */
+ robots?: RobotsOptions;
/** SiteSettings global slug. Defaults to 'site-settings'. */
settingsSlug?: string;
};
@@ -52,7 +58,8 @@ type CreateContentHelpersArgs = {
* a URL is, fetching gets the listing. Metadata generation needs the first and
* not the second, and a page component composes them in two obvious lines.
*/
-export declare function createContentHelpers({ baseUrl, config, content, i18n, pagesSlug, settingsSlug, }: CreateContentHelpersArgs): {
+export declare function createContentHelpers({ baseUrl, config, content, i18n, pagesSlug, robots: robotsOptions, settingsSlug, }: CreateContentHelpersArgs): {
+ generatePageMetadata: (locale: string, segments: string[] | undefined, page?: number) => Promise;
generateStaticParams: () => PromisegetPayload({
config: await config
@@ -36,7 +36,10 @@ import { buildRobots, buildSitemapEntries } from '../seo/index.js';
const c = await config;
return c.localization ? c.localization.locales.map((l)=>l.code) : [];
});
- const getSettings = cache(async (locale)=>{
+ /**
+ * SiteSettings for a locale — ONE query per locale per request, shared by the
+ * layout, generatePageMetadata, resolveRoute and anything else that asks.
+ */ const getSettings = cache(async (locale)=>{
const payload = await getCachedPayload();
return payload.findGlobal({
slug: settingsSlug,
@@ -46,6 +49,7 @@ import { buildRobots, buildSitemapEntries } from '../seo/index.js';
});
/** What does this URL point at? Routing only — no listing data. */ const resolveRoute = cache(async (locale, segments, page)=>{
const payload = await getCachedPayload();
+ const settings = await getSettings(locale);
return resolveRouteRaw({
content,
locale,
@@ -53,25 +57,82 @@ import { buildRobots, buildSitemapEntries } from '../seo/index.js';
pagesSlug,
payload,
segments,
+ settings,
settingsSlug
});
});
/**
+ * generateMetadata for the catch-all page, sharing the request cache with
+ * the page component: the same settings read and the same resolveRoute call
+ * (React cache spans generateMetadata and the page within one request), so
+ * metadata costs no extra route/settings queries.
+ *
+ * export async function generateMetadata({ params }) {
+ * const { locale, slug } = await params
+ * return generatePageMetadata(locale, slug)
+ * }
+ */ let pageMetadata;
+ const generatePageMetadata = async (locale, segments, page = 1)=>{
+ if (!i18n) {
+ throw new Error('[ipal] createContentHelpers: pass `i18n` to use generatePageMetadata.');
+ }
+ pageMetadata ??= createPageMetadata({
+ baseUrl: origin || undefined,
+ collection: pagesSlug,
+ config: i18n,
+ content,
+ loaders: {
+ getSettings: async (l)=>await getSettings(l),
+ resolveRoute
+ },
+ settingsSlug
+ });
+ return pageMetadata({
+ slug: segments,
+ locale,
+ page,
+ payload: await getCachedPayload()
+ });
+ };
+ /** ID of the page assigned as 404 — the relation isn't localized, so one read serves every locale. */ const getNotFoundPageId = cache(async ()=>{
+ const payload = await getCachedPayload();
+ const settings = await payload.findGlobal({
+ slug: settingsSlug,
+ depth: 0
+ });
+ const rel = settings.notFound;
+ if (typeof rel === 'string' || typeof rel === 'number') {
+ return rel;
+ }
+ if (rel && typeof rel === 'object') {
+ const id = rel.id;
+ if (typeof id === 'string' || typeof id === 'number') {
+ return id;
+ }
+ }
+ return null;
+ });
+ /**
* The page assigned as 404 in System Pages (or null → built-in fallback).
* 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 (client) pick the one from the URL. See pages.md.
*/ const getNotFoundPage = cache(async (locale)=>{
try {
+ const id = await getNotFoundPageId();
+ if (id === null) {
+ return null;
+ }
const payload = await getCachedPayload();
- return await resolveNotFoundPage({
- locale,
- pagesSlug,
- payload,
- settingsSlug
+ const doc = await payload.findByID({
+ id,
+ collection: pagesSlug,
+ depth: 2,
+ locale: locale
});
+ return doc ?? null;
} catch {
- return null // DB unreachable (container build) — fallback view
+ return null // DB unreachable (container build) or page deleted — fallback view
;
}
});
@@ -134,6 +195,7 @@ import { buildRobots, buildSitemapEntries } from '../seo/index.js';
* export { robots as default } from '@/lib/content'
* ```
*/ const robots = ()=>buildRobots({
+ ...robotsOptions,
baseUrl: origin
});
/**
@@ -250,6 +312,7 @@ import { buildRobots, buildSitemapEntries } from '../seo/index.js';
}
};
return {
+ generatePageMetadata,
generateStaticParams,
getCachedPayload,
getConfiguredLocales,
diff --git a/dist/modules/frontend/createContentHelpers.js.map b/dist/modules/frontend/createContentHelpers.js.map
index d7376e6..d433e72 100644
--- a/dist/modules/frontend/createContentHelpers.js.map
+++ b/dist/modules/frontend/createContentHelpers.js.map
@@ -1 +1 @@
-{"version":3,"sources":["../../../src/modules/frontend/createContentHelpers.ts"],"sourcesContent":["import type { BasePayload, SanitizedConfig } from 'payload'\n\nimport { getPayload } from 'payload'\nimport { cache } from 'react'\n\nimport type { ArchiveEntries, ContentOption, ResolvedRoute } from '../content/index.js'\nimport type { I18nConfig } from '../i18n/index.js'\nimport type { RobotsRules, SitemapEntry } from '../seo/index.js'\n\nimport {\n getArchiveEntries,\n resolveNotFoundPage,\n resolveRoute as resolveRouteRaw,\n} from '../content/index.js'\nimport { buildRobots, buildSitemapEntries } from '../seo/index.js'\n\ntype CreateContentHelpersArgs = {\n /**\n * Absolute site origin for sitemap/robots URLs. Falls back to\n * NEXT_PUBLIC_SERVER_URL, then to a relative origin (which most crawlers\n * reject, so set one in production).\n */\n baseUrl?: string\n /**\n * The client's payload config promise (the default export of payload.config).\n * Passed in because the plugin never imports the client's config directly.\n */\n config: Promise | SanitizedConfig\n /** Archive-backed collections, same value as the plugin option. */\n content?: ContentOption\n /**\n * i18n config. Required only if you want the ready-made `sitemap` / `robots`\n * handlers — they need the locale list to emit hreflang.\n */\n i18n?: I18nConfig\n /** Pages collection slug. Defaults to 'pages'. */\n pagesSlug?: string\n /** SiteSettings global slug. Defaults to 'site-settings'. */\n settingsSlug?: string\n}\n\n/**\n * Bundles the per-request data helpers a frontend needs — the same cached\n * wrappers every project was writing by hand (getPayload, settings, locale\n * list, route resolution, archive entries).\n *\n * Everything is wrapped in React `cache()`, so within one request a value is\n * fetched once no matter how many times it's asked for — which matters because\n * Next runs generateMetadata and the page component separately, and both hit\n * these. Crucially the Payload instance is cached *here*, once, so every helper\n * shares it; that's why this is a factory and not loose functions importing a\n * shared module.\n *\n * ```ts\n * // src/lib/content.ts\n * import { createContentHelpers } from 'ipal-kit'\n * import config from '@/payload.config'\n * import { contentConfig } from '@/content.config'\n *\n * export const { getCachedPayload, getSettings, getConfiguredLocales, resolveRoute, getEntries } =\n * createContentHelpers({ config, content: contentConfig })\n * ```\n *\n * `resolveRoute` and `getEntries` are separate on purpose: routing decides what\n * a URL is, fetching gets the listing. Metadata generation needs the first and\n * not the second, and a page component composes them in two obvious lines.\n */\nexport function createContentHelpers({\n baseUrl,\n config,\n content,\n i18n,\n pagesSlug = 'pages',\n settingsSlug = 'site-settings',\n}: CreateContentHelpersArgs) {\n const origin = baseUrl ?? process.env.NEXT_PUBLIC_SERVER_URL ?? ''\n const getCachedPayload = cache(\n async (): Promise => getPayload({ config: await config }),\n )\n\n const getConfiguredLocales = cache(async (): Promise => {\n const c = await config\n return c.localization ? c.localization.locales.map((l) => l.code) : []\n })\n\n const getSettings = cache(async (locale: string) => {\n const payload = await getCachedPayload()\n return payload.findGlobal({ slug: settingsSlug as never, depth: 2, locale: locale as never })\n })\n\n /** What does this URL point at? Routing only — no listing data. */\n const resolveRoute = cache(\n async (\n locale: string,\n segments: string[] | undefined,\n page: number,\n ): Promise => {\n const payload = await getCachedPayload()\n return resolveRouteRaw({ content, locale, page, pagesSlug, payload, segments, settingsSlug })\n },\n )\n\n /**\n * The page assigned as 404 in System Pages (or null → built-in fallback).\n * For app/not-found.tsx; never throws. not-found.tsx receives no params and\n * must NOT read headers() (breaks SSG/ISR) — call this for every configured\n * locale and let (client) pick the one from the URL. See pages.md.\n */\n const getNotFoundPage = cache(async (locale: string) => {\n try {\n const payload = await getCachedPayload()\n return await resolveNotFoundPage({ locale, pagesSlug, payload, settingsSlug })\n } catch {\n return null // DB unreachable (container build) — fallback view\n }\n })\n\n /** One page of a collection's entries, for an archive listing. */\n const getEntries = cache(\n async (\n collection: string,\n locale: string,\n page: number,\n perPage: number,\n ): Promise => {\n const payload = await getCachedPayload()\n return getArchiveEntries({ collection, locale, page, payload, perPage })\n },\n )\n\n /**\n * Ready-made handler for Next's `app/sitemap.ts` — every page and entry with\n * per-URL hreflang and lastmod. Re-export it directly:\n *\n * ```ts\n * // app/sitemap.ts\n * export { sitemap as default } from '@/lib/content'\n * export const dynamic = 'force-dynamic' // generate at runtime, not build\n * ```\n *\n * IMPORTANT — container deploys (Coolify/Docker/Railway/CI): Next treats\n * sitemap.ts as STATIC by default and prerenders it during `next build`, which\n * calls into Payload → the database. The build container usually has no access\n * to the internal Docker network, so the DB connection fails (ENOTFOUND) and\n * the build dies. Two defenses:\n * 1. `export const dynamic = 'force-dynamic'` in app/sitemap.ts — skips build\n * prerender, generates at runtime when the DB is reachable (recommended).\n * 2. This handler also catches DB errors and returns [] so that even without\n * (1) the build won't crash — it just ships an empty sitemap until the\n * next runtime regeneration. (1) is still preferred; (2) is a safety net.\n */\n const sitemap = cache(async (): Promise => {\n if (!i18n) {\n throw new Error(\n '[ipal] createContentHelpers: pass `i18n` to use the sitemap handler.',\n )\n }\n try {\n return await buildSitemapEntries({\n baseUrl: origin,\n config: i18n,\n content,\n pagesSlug,\n payload: await getCachedPayload(),\n settingsSlug,\n })\n } catch (error) {\n // DB unreachable (typically a container build with no DB network) — return\n // an empty sitemap instead of failing the build. Runtime regeneration will\n // produce the real one once the DB is reachable. See dynamic='force-dynamic'.\n console.warn(\n '[ipal] sitemap: could not reach the database, returning empty entries ' +\n \"(add `export const dynamic = 'force-dynamic'` to app/sitemap.ts to \" +\n 'generate at runtime and avoid build-time DB access):',\n error,\n )\n return []\n }\n })\n\n /**\n * Ready-made handler for Next's `app/robots.ts`. Re-export directly:\n *\n * ```ts\n * // app/robots.ts\n * export { robots as default } from '@/lib/content'\n * ```\n */\n const robots = (): RobotsRules => buildRobots({ baseUrl: origin })\n\n /**\n * Next.js generateStaticParams for the [[...slug]] route (or\n * [locale]/[[...slug]]). Returns every routable page as a params object, so\n * Next PRE-RENDERS them as static (SSG) instead of dynamic.\n *\n * Why this matters beyond convenience: an optional catch-all with no\n * generateStaticParams is treated as a DYNAMIC route (ƒ), which streams\n * metadata into (crawlers miss it). Providing generateStaticParams\n * compiles routes as SSG (●) — the is synchronous and complete. This is\n * the strongest fix for the metadata-in-head problem (stronger than ISR alone).\n *\n * Handles automatically:\n * - pages collection + content collections (with their archive prefix)\n * - excludes the homepage (maps to { slug: [] } — the root)\n * - excludes drafts and 404/500/system slugs\n * - KEEPS noindex pages (they must still render — noindex controls indexing,\n * not existence; skipping them would force dynamic rendering)\n * - localized slugs (string or per-locale map) both handled\n * - single-locale → { slug }[]; multi-locale → { locale, slug }[]\n *\n * Wire it in the project:\n * // app/(frontend)/[[...slug]]/page.tsx (or [locale]/[[...slug]])\n * export { generateStaticParams } from '@/lib/content'\n */\n const generateStaticParams = async (): Promise<\n Array<{ locale: string; slug: string[] } | { slug: string[] }>\n > => {\n try {\n const payload = await getCachedPayload()\n const locales = i18n ? i18n.locales.map((l) => l.code) : [undefined]\n const singleLocale = !i18n || i18n.locales.length === 1\n\n // Home slug per locale, to exclude the homepage (it's the root, slug []).\n const settings = (await payload\n .findGlobal({ slug: settingsSlug as never, depth: 1, locale: 'all' as never })\n .catch(() => null)) as {\n homepage?: { id?: number | string; slug?: unknown }\n notFound?: { id?: number | string } | null\n } | null\n const homeId = settings?.homepage?.id\n // The assigned 404 page renders via not-found.tsx, never as its own URL.\n const notFoundId =\n settings?.notFound?.id !== undefined && settings.notFound.id !== homeId\n ? settings.notFound.id\n : undefined\n\n const EXCLUDED = new Set(['404', '500', 'error', 'not-found'])\n const params: Array<{ locale: string; slug: string[] } | { slug: string[] }> = []\n\n for (const locale of locales) {\n // NO where:{_status} filter — collections without drafts enabled don't\n // register the _status field, and querying it throws\n // \"path cannot be queried: _status\". We filter drafts in memory below,\n // which is safe for every collection (with or without drafts).\n const result = await payload.find({\n collection: pagesSlug as never,\n depth: 0,\n limit: 1000,\n locale: (locale ?? 'all') as never,\n })\n\n for (const raw of result.docs as Array<{\n _status?: string\n id: number | string\n meta?: { noindex?: boolean } | null\n slug?: unknown\n }>) {\n // Draft filter in memory (safe whether or not the collection has drafts).\n if (raw._status && raw._status !== 'published') {continue}\n if (notFoundId !== undefined && raw.id === notFoundId) {continue}\n\n // NOTE: unlike the sitemap, we do NOT skip meta.noindex here. A noindex\n // page (privacy, cookies, terms) still needs to render — users reach it\n // from the footer and crawlers read its . Pre-render\n // it as SSG so it's fast and its is complete; noindex controls\n // INDEXING, not whether the page exists. Skipping it would force dynamic\n // rendering (the very streaming problem we're avoiding).\n\n if (homeId && raw.id === homeId) {\n // Homepage → root. Emit an empty-slug param so '/' (or '/pl') builds.\n const empty = singleLocale ? { slug: [] } : { slug: [], locale: locale as string }\n if (!params.some((p) => JSON.stringify(p) === JSON.stringify(empty))) {params.push(empty)}\n continue\n }\n\n // Slug may be a plain string OR a localized map ({ pl: 'kontakt' }) when\n // read with locale:'all' or left unflattened. Handle both, or localized\n // pages get silently dropped.\n const rawSlug = raw.slug\n const slug =\n typeof rawSlug === 'string'\n ? rawSlug\n : rawSlug && typeof rawSlug === 'object'\n ? ((rawSlug as Record)[locale ?? ''] as string | undefined) ??\n (Object.values(rawSlug as Record)[0] as string | undefined)\n : undefined\n\n if (!slug || EXCLUDED.has(slug)) {continue}\n\n // Multi-level slugs ('atrakcje/telefon') → array segments.\n const segments = String(slug).split('/').filter(Boolean)\n params.push(singleLocale ? { slug: segments } : { slug: segments, locale: locale as string })\n }\n }\n\n return params\n } catch (err) {\n // DB unreachable — typically a container build (Docker/Coolify/CI) with no\n // database network. Return [] so the build doesn't crash: Next falls back\n // to on-demand rendering for the routes, which fill in once the DB is\n // reachable at runtime. Without this every project would need its own\n // try/catch here. (Same graceful-degradation as the sitemap handler.)\n console.warn(\n '[ipal] generateStaticParams: database not reachable during build ' +\n '(Docker/CI) — returning empty params; routes render on-demand at runtime:',\n err,\n )\n return []\n }\n }\n\n return {\n generateStaticParams,\n getCachedPayload,\n getConfiguredLocales,\n getEntries,\n getNotFoundPage,\n getSettings,\n resolveRoute,\n robots,\n sitemap,\n }\n}\n"],"names":["getPayload","cache","getArchiveEntries","resolveNotFoundPage","resolveRoute","resolveRouteRaw","buildRobots","buildSitemapEntries","createContentHelpers","baseUrl","config","content","i18n","pagesSlug","settingsSlug","origin","process","env","NEXT_PUBLIC_SERVER_URL","getCachedPayload","getConfiguredLocales","c","localization","locales","map","l","code","getSettings","locale","payload","findGlobal","slug","depth","segments","page","getNotFoundPage","getEntries","collection","perPage","sitemap","Error","error","console","warn","robots","generateStaticParams","undefined","singleLocale","length","settings","catch","homeId","homepage","id","notFoundId","notFound","EXCLUDED","Set","params","result","find","limit","raw","docs","_status","empty","some","p","JSON","stringify","push","rawSlug","Object","values","has","String","split","filter","Boolean","err"],"mappings":"AAEA,SAASA,UAAU,QAAQ,UAAS;AACpC,SAASC,KAAK,QAAQ,QAAO;AAM7B,SACEC,iBAAiB,EACjBC,mBAAmB,EACnBC,gBAAgBC,eAAe,QAC1B,sBAAqB;AAC5B,SAASC,WAAW,EAAEC,mBAAmB,QAAQ,kBAAiB;AA2BlE;;;;;;;;;;;;;;;;;;;;;;;;;CAyBC,GACD,OAAO,SAASC,qBAAqB,EACnCC,OAAO,EACPC,MAAM,EACNC,OAAO,EACPC,IAAI,EACJC,YAAY,OAAO,EACnBC,eAAe,eAAe,EACL;IACzB,MAAMC,SAASN,WAAWO,QAAQC,GAAG,CAACC,sBAAsB,IAAI;IAChE,MAAMC,mBAAmBlB,MACvB,UAAkCD,WAAW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AwC;QACAL;IACF;AACF"}
\ No newline at end of file
+{"version":3,"sources":["../../../src/modules/frontend/createContentHelpers.ts"],"sourcesContent":["import type { BasePayload, SanitizedConfig } from 'payload'\n\nimport { getPayload } from 'payload'\nimport { cache } from 'react'\n\nimport type { ArchiveEntries, ContentOption, ResolvedRoute } from '../content/index.js'\nimport type { I18nConfig } from '../i18n/index.js'\nimport type { PageMetadata, RobotsOptions, RobotsRules, SitemapEntry } from '../seo/index.js'\n\nimport { getArchiveEntries, resolveRoute as resolveRouteRaw } from '../content/index.js'\nimport { buildRobots, buildSitemapEntries, createPageMetadata } from '../seo/index.js'\n\ntype CreateContentHelpersArgs = {\n /**\n * Absolute site origin for sitemap/robots URLs. Falls back to\n * NEXT_PUBLIC_SERVER_URL, then to a relative origin (which most crawlers\n * reject, so set one in production).\n */\n baseUrl?: string\n /**\n * The client's payload config promise (the default export of payload.config).\n * Passed in because the plugin never imports the client's config directly.\n */\n config: Promise | SanitizedConfig\n /** Archive-backed collections, same value as the plugin option. */\n content?: ContentOption\n /**\n * i18n config. Required only if you want the ready-made `sitemap` / `robots`\n * handlers — they need the locale list to emit hreflang.\n */\n i18n?: I18nConfig\n /** Pages collection slug. Defaults to 'pages'. */\n pagesSlug?: string\n /**\n * Options for the ready-made `robots` handler, e.g.\n * `{ disallowParams: ['s', 'meter'], aiBots: 'block-training' }`, or\n * `{ adminRoute: false }` when the admin path is hidden (ipalKit adminRoute).\n */\n robots?: RobotsOptions\n /** SiteSettings global slug. Defaults to 'site-settings'. */\n settingsSlug?: string\n}\n\n/**\n * Bundles the per-request data helpers a frontend needs — the same cached\n * wrappers every project was writing by hand (getPayload, settings, locale\n * list, route resolution, archive entries).\n *\n * Everything is wrapped in React `cache()`, so within one request a value is\n * fetched once no matter how many times it's asked for — which matters because\n * Next runs generateMetadata and the page component separately, and both hit\n * these. Crucially the Payload instance is cached *here*, once, so every helper\n * shares it; that's why this is a factory and not loose functions importing a\n * shared module.\n *\n * ```ts\n * // src/lib/content.ts\n * import { createContentHelpers } from 'ipal-kit'\n * import config from '@/payload.config'\n * import { contentConfig } from '@/content.config'\n *\n * export const { getCachedPayload, getSettings, getConfiguredLocales, resolveRoute, getEntries } =\n * createContentHelpers({ config, content: contentConfig })\n * ```\n *\n * `resolveRoute` and `getEntries` are separate on purpose: routing decides what\n * a URL is, fetching gets the listing. Metadata generation needs the first and\n * not the second, and a page component composes them in two obvious lines.\n */\nexport function createContentHelpers({\n baseUrl,\n config,\n content,\n i18n,\n pagesSlug = 'pages',\n robots: robotsOptions,\n settingsSlug = 'site-settings',\n}: CreateContentHelpersArgs) {\n const origin = baseUrl ?? process.env.NEXT_PUBLIC_SERVER_URL ?? ''\n const getCachedPayload = cache(\n async (): Promise => getPayload({ config: await config }),\n )\n\n const getConfiguredLocales = cache(async (): Promise => {\n const c = await config\n return c.localization ? c.localization.locales.map((l) => l.code) : []\n })\n\n /**\n * SiteSettings for a locale — ONE query per locale per request, shared by the\n * layout, generatePageMetadata, resolveRoute and anything else that asks.\n */\n const getSettings = cache(async (locale: string) => {\n const payload = await getCachedPayload()\n return payload.findGlobal({ slug: settingsSlug as never, depth: 2, locale: locale as never })\n })\n\n /** What does this URL point at? Routing only — no listing data. */\n const resolveRoute = cache(\n async (\n locale: string,\n segments: string[] | undefined,\n page: number,\n ): Promise => {\n const payload = await getCachedPayload()\n const settings = (await getSettings(locale)) as Record\n return resolveRouteRaw({\n content,\n locale,\n page,\n pagesSlug,\n payload,\n segments,\n settings,\n settingsSlug,\n })\n },\n )\n\n /**\n * generateMetadata for the catch-all page, sharing the request cache with\n * the page component: the same settings read and the same resolveRoute call\n * (React cache spans generateMetadata and the page within one request), so\n * metadata costs no extra route/settings queries.\n *\n * export async function generateMetadata({ params }) {\n * const { locale, slug } = await params\n * return generatePageMetadata(locale, slug)\n * }\n */\n let pageMetadata: ReturnType | undefined\n const generatePageMetadata = async (\n locale: string,\n segments: string[] | undefined,\n page = 1,\n ): Promise => {\n if (!i18n) {\n throw new Error('[ipal] createContentHelpers: pass `i18n` to use generatePageMetadata.')\n }\n pageMetadata ??= createPageMetadata({\n baseUrl: origin || undefined,\n collection: pagesSlug,\n config: i18n,\n content,\n loaders: {\n getSettings: async (l) => (await getSettings(l)) as Record,\n resolveRoute,\n },\n settingsSlug,\n })\n return pageMetadata({ slug: segments, locale, page, payload: await getCachedPayload() })\n }\n\n /** ID of the page assigned as 404 — the relation isn't localized, so one read serves every locale. */\n const getNotFoundPageId = cache(async (): Promise => {\n const payload = await getCachedPayload()\n const settings = (await payload.findGlobal({\n slug: settingsSlug as never,\n depth: 0,\n })) as { notFound?: unknown }\n const rel = settings.notFound\n if (typeof rel === 'string' || typeof rel === 'number') {return rel}\n if (rel && typeof rel === 'object') {\n const id = (rel as { id?: unknown }).id\n if (typeof id === 'string' || typeof id === 'number') {return id}\n }\n return null\n })\n\n /**\n * The page assigned as 404 in System Pages (or null → built-in fallback).\n * For app/not-found.tsx; never throws. not-found.tsx receives no params and\n * must NOT read headers() (breaks SSG/ISR) — call this for every configured\n * locale and let (client) pick the one from the URL. See pages.md.\n */\n const getNotFoundPage = cache(async (locale: string) => {\n try {\n const id = await getNotFoundPageId()\n if (id === null) {return null}\n const payload = await getCachedPayload()\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) ?? null\n } catch {\n return null // DB unreachable (container build) or page deleted — fallback view\n }\n })\n\n /** One page of a collection's entries, for an archive listing. */\n const getEntries = cache(\n async (\n collection: string,\n locale: string,\n page: number,\n perPage: number,\n ): Promise => {\n const payload = await getCachedPayload()\n return getArchiveEntries({ collection, locale, page, payload, perPage })\n },\n )\n\n /**\n * Ready-made handler for Next's `app/sitemap.ts` — every page and entry with\n * per-URL hreflang and lastmod. Re-export it directly:\n *\n * ```ts\n * // app/sitemap.ts\n * export { sitemap as default } from '@/lib/content'\n * export const dynamic = 'force-dynamic' // generate at runtime, not build\n * ```\n *\n * IMPORTANT — container deploys (Coolify/Docker/Railway/CI): Next treats\n * sitemap.ts as STATIC by default and prerenders it during `next build`, which\n * calls into Payload → the database. The build container usually has no access\n * to the internal Docker network, so the DB connection fails (ENOTFOUND) and\n * the build dies. Two defenses:\n * 1. `export const dynamic = 'force-dynamic'` in app/sitemap.ts — skips build\n * prerender, generates at runtime when the DB is reachable (recommended).\n * 2. This handler also catches DB errors and returns [] so that even without\n * (1) the build won't crash — it just ships an empty sitemap until the\n * next runtime regeneration. (1) is still preferred; (2) is a safety net.\n */\n const sitemap = cache(async (): Promise => {\n if (!i18n) {\n throw new Error(\n '[ipal] createContentHelpers: pass `i18n` to use the sitemap handler.',\n )\n }\n try {\n return await buildSitemapEntries({\n baseUrl: origin,\n config: i18n,\n content,\n pagesSlug,\n payload: await getCachedPayload(),\n settingsSlug,\n })\n } catch (error) {\n // DB unreachable (typically a container build with no DB network) — return\n // an empty sitemap instead of failing the build. Runtime regeneration will\n // produce the real one once the DB is reachable. See dynamic='force-dynamic'.\n console.warn(\n '[ipal] sitemap: could not reach the database, returning empty entries ' +\n \"(add `export const dynamic = 'force-dynamic'` to app/sitemap.ts to \" +\n 'generate at runtime and avoid build-time DB access):',\n error,\n )\n return []\n }\n })\n\n /**\n * Ready-made handler for Next's `app/robots.ts`. Re-export directly:\n *\n * ```ts\n * // app/robots.ts\n * export { robots as default } from '@/lib/content'\n * ```\n */\n const robots = (): RobotsRules => buildRobots({ ...robotsOptions, baseUrl: origin })\n\n /**\n * Next.js generateStaticParams for the [[...slug]] route (or\n * [locale]/[[...slug]]). Returns every routable page as a params object, so\n * Next PRE-RENDERS them as static (SSG) instead of dynamic.\n *\n * Why this matters beyond convenience: an optional catch-all with no\n * generateStaticParams is treated as a DYNAMIC route (ƒ), which streams\n * metadata into (crawlers miss it). Providing generateStaticParams\n * compiles routes as SSG (●) — the is synchronous and complete. This is\n * the strongest fix for the metadata-in-head problem (stronger than ISR alone).\n *\n * Handles automatically:\n * - pages collection + content collections (with their archive prefix)\n * - excludes the homepage (maps to { slug: [] } — the root)\n * - excludes drafts and 404/500/system slugs\n * - KEEPS noindex pages (they must still render — noindex controls indexing,\n * not existence; skipping them would force dynamic rendering)\n * - localized slugs (string or per-locale map) both handled\n * - single-locale → { slug }[]; multi-locale → { locale, slug }[]\n *\n * Wire it in the project:\n * // app/(frontend)/[[...slug]]/page.tsx (or [locale]/[[...slug]])\n * export { generateStaticParams } from '@/lib/content'\n */\n const generateStaticParams = async (): Promise<\n Array<{ locale: string; slug: string[] } | { slug: string[] }>\n > => {\n try {\n const payload = await getCachedPayload()\n const locales = i18n ? i18n.locales.map((l) => l.code) : [undefined]\n const singleLocale = !i18n || i18n.locales.length === 1\n\n // Home slug per locale, to exclude the homepage (it's the root, slug []).\n const settings = (await payload\n .findGlobal({ slug: settingsSlug as never, depth: 1, locale: 'all' as never })\n .catch(() => null)) as {\n homepage?: { id?: number | string; slug?: unknown }\n notFound?: { id?: number | string } | null\n } | null\n const homeId = settings?.homepage?.id\n // The assigned 404 page renders via not-found.tsx, never as its own URL.\n const notFoundId =\n settings?.notFound?.id !== undefined && settings.notFound.id !== homeId\n ? settings.notFound.id\n : undefined\n\n const EXCLUDED = new Set(['404', '500', 'error', 'not-found'])\n const params: Array<{ locale: string; slug: string[] } | { slug: string[] }> = []\n\n for (const locale of locales) {\n // NO where:{_status} filter — collections without drafts enabled don't\n // register the _status field, and querying it throws\n // \"path cannot be queried: _status\". We filter drafts in memory below,\n // which is safe for every collection (with or without drafts).\n const result = await payload.find({\n collection: pagesSlug as never,\n depth: 0,\n limit: 1000,\n locale: (locale ?? 'all') as never,\n })\n\n for (const raw of result.docs as Array<{\n _status?: string\n id: number | string\n meta?: { noindex?: boolean } | null\n slug?: unknown\n }>) {\n // Draft filter in memory (safe whether or not the collection has drafts).\n if (raw._status && raw._status !== 'published') {continue}\n if (notFoundId !== undefined && raw.id === notFoundId) {continue}\n\n // NOTE: unlike the sitemap, we do NOT skip meta.noindex here. A noindex\n // page (privacy, cookies, terms) still needs to render — users reach it\n // from the footer and crawlers read its . Pre-render\n // it as SSG so it's fast and its is complete; noindex controls\n // INDEXING, not whether the page exists. Skipping it would force dynamic\n // rendering (the very streaming problem we're avoiding).\n\n if (homeId && raw.id === homeId) {\n // Homepage → root. Emit an empty-slug param so '/' (or '/pl') builds.\n const empty = singleLocale ? { slug: [] } : { slug: [], locale: locale as string }\n if (!params.some((p) => JSON.stringify(p) === JSON.stringify(empty))) {params.push(empty)}\n continue\n }\n\n // Slug may be a plain string OR a localized map ({ pl: 'kontakt' }) when\n // read with locale:'all' or left unflattened. Handle both, or localized\n // pages get silently dropped.\n const rawSlug = raw.slug\n const slug =\n typeof rawSlug === 'string'\n ? rawSlug\n : rawSlug && typeof rawSlug === 'object'\n ? ((rawSlug as Record)[locale ?? ''] as string | undefined) ??\n (Object.values(rawSlug as Record)[0] as string | undefined)\n : undefined\n\n if (!slug || EXCLUDED.has(slug)) {continue}\n\n // Multi-level slugs ('atrakcje/telefon') → array segments.\n const segments = String(slug).split('/').filter(Boolean)\n params.push(singleLocale ? { slug: segments } : { slug: segments, locale: locale as string })\n }\n }\n\n return params\n } catch (err) {\n // DB unreachable — typically a container build (Docker/Coolify/CI) with no\n // database network. Return [] so the build doesn't crash: Next falls back\n // to on-demand rendering for the routes, which fill in once the DB is\n // reachable at runtime. Without this every project would need its own\n // try/catch here. (Same graceful-degradation as the sitemap handler.)\n console.warn(\n '[ipal] generateStaticParams: database not reachable during build ' +\n '(Docker/CI) — returning empty params; routes render on-demand at runtime:',\n err,\n )\n return []\n }\n }\n\n return {\n generatePageMetadata,\n generateStaticParams,\n getCachedPayload,\n getConfiguredLocales,\n getEntries,\n getNotFoundPage,\n getSettings,\n resolveRoute,\n robots,\n sitemap,\n }\n}\n"],"names":["getPayload","cache","getArchiveEntries","resolveRoute","resolveRouteRaw","buildRobots","buildSitemapEntries","createPageMetadata","createContentHelpers","baseUrl","config","content","i18n","pagesSlug","robots","robotsOptions","settingsSlug","origin","process","env","NEXT_PUBLIC_SERVER_URL","getCachedPayload","getConfiguredLocales","c","localization","locales","map","l","code","getSettings","locale","payload","findGlobal","slug","depth","segments","page","settings","pageMetadata","generatePageMetadata","Error","undefined","collection","loaders","getNotFoundPageId","rel","notFound","id","getNotFoundPage","doc","findByID","getEntries","perPage","sitemap","error","console","warn","generateStaticParams","singleLocale","length","catch","homeId","homepage","notFoundId","EXCLUDED","Set","params","result","find","limit","raw","docs","_status","empty","some","p","JSON","stringify","push","rawSlug","Object","values","has","String","split","filter","Boolean","err"],"mappings":"AAEA,SAASA,UAAU,QAAQ,UAAS;AACpC,SAASC,KAAK,QAAQ,QAAO;AAM7B,SAASC,iBAAiB,EAAEC,gBAAgBC,eAAe,QAAQ,sBAAqB;AACxF,SAASC,WAAW,EAAEC,mBAAmB,EAAEC,kBAAkB,QAAQ,kBAAiB;AAiCtF;;;;;;;;;;;;;;;;;;;;;;;;;CAyBC,GACD,OAAO,SAASC,qBAAqB,EACnCC,OAAO,EACPC,MAAM,EACNC,OAAO,EACPC,IAAI,EACJC,YAAY,OAAO,EACnBC,QAAQC,aAAa,EACrBC,eAAe,eAAe,EACL;IACzB,MAAMC,SAASR,WAAWS,QAAQC,GAAG,CAACC,sBAAsB,IAAI;IAChE,MAAMC,mBAAmBpB,MACvB,UAAkCD,WAAW;YAAEU,QAAQ,MAAMA;QAAO;IAGtE,MAAMY,uBAAuBrB,MAAM;QACjC,MAAMsB,IAAI,MAAMb;QAChB,OAAOa,EAAEC,YAAY,GAAGD,EAAEC,YAAY,CAACC,OAAO,CAACC,GAAG,CAAC,CAACC,IAAMA,EAAEC,IAAI,IAAI,EAAE;IACxE;IAEA;;;GAGC,GACD,MAAMC,cAAc5B,MAAM,OAAO6B;QAC/B,MAAMC,UAAU,MAAMV;QACtB,OAAOU,QAAQC,UAAU,CAAC;YAAEC,MAAMjB;YAAuBkB,OAAO;YAAGJ,QAAQA;QAAgB;IAC7F;IAEA,iEAAiE,GACjE,MAAM3B,eAAeF,MACnB,OACE6B,QACAK,UACAC;QA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CAACjD,UAAU,GAAG,IAClDkD,OAAOC,MAAM,CAACF,QAAmC,CAAC,EAAE,GACrDtC;oBAER,IAAI,CAACR,QAAQ+B,SAASkB,GAAG,CAACjD,OAAO;wBAAC;oBAAQ;oBAE1C,2DAA2D;oBAC3D,MAAME,WAAWgD,OAAOlD,MAAMmD,KAAK,CAAC,KAAKC,MAAM,CAACC;oBAChDpB,OAAOY,IAAI,CAACpB,eAAe;wBAAEzB,MAAME;oBAAS,IAAI;wBAAEF,MAAME;wBAAUL,QAAQA;oBAAiB;gBAC7F;YACF;YAEE,OAAOoC;QACT,EAAE,OAAOqB,KAAK;YACZ,2EAA2E;YAC3E,0EAA0E;YAC1E,sEAAsE;YACtE,sEAAsE;YACtE,sEAAsE;YACtEhC,QAAQC,IAAI,CACV,sEACE,6EACF+B;YAEF,OAAO,EAAE;QACX;IACF;IAEA,OAAO;QACLhD;QACAkB;QACApC;QACAC;QACA6B;QACAH;QACAnB;QACA1B;QACAW;QACAuC;IACF;AACF"}
\ No newline at end of file
diff --git a/dist/modules/links/buildLinkField.d.ts b/dist/modules/links/buildLinkField.d.ts
new file mode 100644
index 0000000..8437b50
--- /dev/null
+++ b/dist/modules/links/buildLinkField.d.ts
@@ -0,0 +1,39 @@
+import type { ArrayField, GroupField } from 'payload';
+export type LinkAppearance = 'link' | 'primary' | 'secondary';
+export type BuildLinkFieldOptions = {
+ /** Visual styles the editor may pick. `false` → no appearance select. Default all three. */
+ appearances?: false | LinkAppearance[];
+ /** Hide the label — for links that wrap something (a whole card, an image). */
+ disableLabel?: boolean;
+ /** Field name. Default 'link'. */
+ name?: string;
+ /** Collection the "Page" option points at. Default 'pages'. */
+ relationTo?: string;
+ required?: boolean;
+ /** Upload collection for "File" links (PDF, documents). Default 'media'. */
+ uploadTo?: string;
+};
+/**
+ * The ONE link shape for a project: a page, an external URL (also mailto:,
+ * tel:, #anchor) or an uploaded file — plus label, new-tab flag and visual
+ * style. Every CTA, card link and download in every block uses this field, so
+ * there is no zoo of ctaLabel / buttonUrl / pdfUrl fields and one renderer
+ * (resolveLinkHref + the project's CMSLink) handles them all.
+ *
+ * Generates a named TypeScript type `CmsLink` in payload-types.ts.
+ *
+ * fields: [buildLinkField()] // single link
+ * fields: [buildLinkField({ disableLabel: true, appearances: false })] // clickable card
+ */
+export declare function buildLinkField({ name, appearances, disableLabel, relationTo, required, uploadTo, }?: BuildLinkFieldOptions): GroupField;
+export type BuildLinksFieldOptions = {
+ /** Max number of buttons. Default 2. */
+ maxRows?: number;
+ /** Field name. Default 'links'. */
+ name?: string;
+} & Omit;
+/**
+ * 0..N buttons — use for every "CTA(s)" of a section. Each row holds one
+ * `link` (buildLinkField). Render: `links.map(({ id, link }) => )`.
+ */
+export declare function buildLinksField({ name, maxRows, ...linkOptions }?: BuildLinksFieldOptions): ArrayField;
diff --git a/dist/modules/links/buildLinkField.js b/dist/modules/links/buildLinkField.js
new file mode 100644
index 0000000..ecb08dc
--- /dev/null
+++ b/dist/modules/links/buildLinkField.js
@@ -0,0 +1,134 @@
+const URL_PATTERN = /^(https?:\/\/|mailto:|tel:|#)/;
+/**
+ * The ONE link shape for a project: a page, an external URL (also mailto:,
+ * tel:, #anchor) or an uploaded file — plus label, new-tab flag and visual
+ * style. Every CTA, card link and download in every block uses this field, so
+ * there is no zoo of ctaLabel / buttonUrl / pdfUrl fields and one renderer
+ * (resolveLinkHref + the project's CMSLink) handles them all.
+ *
+ * Generates a named TypeScript type `CmsLink` in payload-types.ts.
+ *
+ * fields: [buildLinkField()] // single link
+ * fields: [buildLinkField({ disableLabel: true, appearances: false })] // clickable card
+ */ export function buildLinkField({ name = 'link', appearances = [
+ 'primary',
+ 'secondary',
+ 'link'
+], disableLabel = false, relationTo = 'pages', required = false, uploadTo = 'media' } = {}) {
+ const fields = [
+ {
+ type: 'row',
+ fields: [
+ {
+ name: 'type',
+ type: 'radio',
+ admin: {
+ layout: 'horizontal',
+ width: '50%'
+ },
+ defaultValue: 'internal',
+ options: [
+ {
+ label: 'Page',
+ value: 'internal'
+ },
+ {
+ label: 'URL',
+ value: 'external'
+ },
+ {
+ label: 'File',
+ value: 'file'
+ }
+ ]
+ },
+ {
+ name: 'newTab',
+ type: 'checkbox',
+ admin: {
+ style: {
+ alignSelf: 'flex-end'
+ },
+ width: '50%'
+ },
+ label: 'Open in new tab'
+ }
+ ]
+ },
+ {
+ name: 'page',
+ type: 'relationship',
+ admin: {
+ condition: (_, s)=>s?.type === 'internal'
+ },
+ relationTo,
+ required
+ },
+ {
+ name: 'url',
+ type: 'text',
+ admin: {
+ condition: (_, s)=>s?.type === 'external',
+ description: 'Full URL (https://…), mailto:, tel: or #section-anchor.'
+ },
+ required,
+ validate: (v)=>!v || URL_PATTERN.test(v) || 'Use https://…, mailto:, tel: or #anchor'
+ },
+ {
+ name: 'file',
+ type: 'upload',
+ admin: {
+ condition: (_, s)=>s?.type === 'file',
+ description: 'Upload a PDF / document / image. Never paste a file URL.'
+ },
+ relationTo: uploadTo,
+ required
+ }
+ ];
+ if (!disableLabel) {
+ fields.push({
+ name: 'label',
+ type: 'text',
+ localized: true,
+ required
+ });
+ }
+ if (appearances && appearances.length) {
+ fields.push({
+ name: 'appearance',
+ type: 'select',
+ defaultValue: appearances[0],
+ options: appearances.map((a)=>({
+ label: a,
+ value: a
+ }))
+ });
+ }
+ return {
+ name,
+ type: 'group',
+ admin: {
+ hideGutter: true
+ },
+ fields,
+ interfaceName: 'CmsLink'
+ };
+}
+/**
+ * 0..N buttons — use for every "CTA(s)" of a section. Each row holds one
+ * `link` (buildLinkField). Render: `links.map(({ id, link }) => )`.
+ */ export function buildLinksField({ name = 'links', maxRows = 2, ...linkOptions } = {}) {
+ return {
+ name,
+ type: 'array',
+ admin: {
+ initCollapsed: true
+ },
+ fields: [
+ buildLinkField(linkOptions)
+ ],
+ maxRows
+ };
+}
+
+//# sourceMappingURL=buildLinkField.js.map
\ No newline at end of file
diff --git a/dist/modules/links/buildLinkField.js.map b/dist/modules/links/buildLinkField.js.map
new file mode 100644
index 0000000..69b623e
--- /dev/null
+++ b/dist/modules/links/buildLinkField.js.map
@@ -0,0 +1 @@
+{"version":3,"sources":["../../../src/modules/links/buildLinkField.ts"],"sourcesContent":["import type { ArrayField, Field, GroupField } from 'payload'\n\nexport type LinkAppearance = 'link' | 'primary' | 'secondary'\n\nexport type BuildLinkFieldOptions = {\n /** Visual styles the editor may pick. `false` → no appearance select. Default all three. */\n appearances?: false | LinkAppearance[]\n /** Hide the label — for links that wrap something (a whole card, an image). */\n disableLabel?: boolean\n /** Field name. Default 'link'. */\n name?: string\n /** Collection the \"Page\" option points at. Default 'pages'. */\n relationTo?: string\n required?: boolean\n /** Upload collection for \"File\" links (PDF, documents). Default 'media'. */\n uploadTo?: string\n}\n\nconst URL_PATTERN = /^(https?:\\/\\/|mailto:|tel:|#)/\n\ntype SiblingWithType = { type?: string } | undefined\n\n/**\n * The ONE link shape for a project: a page, an external URL (also mailto:,\n * tel:, #anchor) or an uploaded file — plus label, new-tab flag and visual\n * style. Every CTA, card link and download in every block uses this field, so\n * there is no zoo of ctaLabel / buttonUrl / pdfUrl fields and one renderer\n * (resolveLinkHref + the project's CMSLink) handles them all.\n *\n * Generates a named TypeScript type `CmsLink` in payload-types.ts.\n *\n * fields: [buildLinkField()] // single link\n * fields: [buildLinkField({ disableLabel: true, appearances: false })] // clickable card\n */\nexport function buildLinkField({\n name = 'link',\n appearances = ['primary', 'secondary', 'link'],\n disableLabel = false,\n relationTo = 'pages',\n required = false,\n uploadTo = 'media',\n}: BuildLinkFieldOptions = {}): GroupField {\n const fields: Field[] = [\n {\n type: 'row',\n fields: [\n {\n name: 'type',\n type: 'radio',\n admin: { layout: 'horizontal', width: '50%' },\n defaultValue: 'internal',\n options: [\n { label: 'Page', value: 'internal' },\n { label: 'URL', value: 'external' },\n { label: 'File', value: 'file' },\n ],\n },\n {\n name: 'newTab',\n type: 'checkbox',\n admin: { style: { alignSelf: 'flex-end' }, width: '50%' },\n label: 'Open in new tab',\n },\n ],\n },\n {\n name: 'page',\n type: 'relationship',\n admin: { condition: (_: unknown, s: SiblingWithType) => s?.type === 'internal' },\n relationTo,\n required,\n },\n {\n name: 'url',\n type: 'text',\n admin: {\n condition: (_: unknown, s: SiblingWithType) => s?.type === 'external',\n description: 'Full URL (https://…), mailto:, tel: or #section-anchor.',\n },\n required,\n validate: (v: null | string | undefined) =>\n !v || URL_PATTERN.test(v) || 'Use https://…, mailto:, tel: or #anchor',\n },\n {\n name: 'file',\n type: 'upload',\n admin: {\n condition: (_: unknown, s: SiblingWithType) => s?.type === 'file',\n description: 'Upload a PDF / document / image. Never paste a file URL.',\n },\n relationTo: uploadTo,\n required,\n },\n ]\n\n if (!disableLabel) {\n fields.push({ name: 'label', type: 'text', localized: true, required })\n }\n\n if (appearances && appearances.length) {\n fields.push({\n name: 'appearance',\n type: 'select',\n defaultValue: appearances[0],\n options: appearances.map((a) => ({ label: a, value: a })),\n })\n }\n\n return {\n name,\n type: 'group',\n admin: { hideGutter: true },\n fields,\n interfaceName: 'CmsLink',\n }\n}\n\nexport type BuildLinksFieldOptions = {\n /** Max number of buttons. Default 2. */\n maxRows?: number\n /** Field name. Default 'links'. */\n name?: string\n} & Omit\n\n/**\n * 0..N buttons — use for every \"CTA(s)\" of a section. Each row holds one\n * `link` (buildLinkField). Render: `links.map(({ id, link }) => )`.\n */\nexport function buildLinksField({\n name = 'links',\n maxRows = 2,\n ...linkOptions\n}: BuildLinksFieldOptions = {}): ArrayField {\n return {\n name,\n type: 'array',\n admin: { initCollapsed: true },\n fields: [buildLinkField(linkOptions)],\n maxRows,\n }\n}\n"],"names":["URL_PATTERN","buildLinkField","name","appearances","disableLabel","relationTo","required","uploadTo","fields","type","admin","layout","width","defaultValue","options","label","value","style","alignSelf","condition","_","s","description","validate","v","test","push","localized","length","map","a","hideGutter","interfaceName","buildLinksField","maxRows","linkOptions","initCollapsed"],"mappings":"AAkBA,MAAMA,cAAc;AAIpB;;;;;;;;;;;CAWC,GACD,OAAO,SAASC,eAAe,E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AM;YACNO,MAAM;YACNI,cAAcV,WAAW,CAAC,EAAE;YAC5BW,SAASX,YAAY0B,GAAG,CAAC,CAACC,IAAO,CAAA;oBAAEf,OAAOe;oBAAGd,OAAOc;gBAAE,CAAA;QACxD;IACF;IAEA,OAAO;QACL5B;QACAO,MAAM;QACNC,OAAO;YAAEqB,YAAY;QAAK;QAC1BvB;QACAwB,eAAe;IACjB;AACF;AASA;;;CAGC,GACD,OAAO,SAASC,gBAAgB,EAC9B/B,OAAO,OAAO,EACdgC,UAAU,CAAC,EACX,GAAGC,aACoB,GAAG,CAAC,CAAC;IAC5B,OAAO;QACLjC;QACAO,MAAM;QACNC,OAAO;YAAE0B,eAAe;QAAK;QAC7B5B,QAAQ;YAACP,eAAekC;SAAa;QACrCD;IACF;AACF"}
\ No newline at end of file
diff --git a/dist/modules/links/index.d.ts b/dist/modules/links/index.d.ts
new file mode 100644
index 0000000..e1a4b07
--- /dev/null
+++ b/dist/modules/links/index.d.ts
@@ -0,0 +1,4 @@
+export { buildLinkField, buildLinksField } from './buildLinkField.js';
+export type { BuildLinkFieldOptions, BuildLinksFieldOptions, LinkAppearance } from './buildLinkField.js';
+export { resolveLinkHref } from './resolveLinkHref.js';
+export type { LinkValue, ResolveLinkHrefOptions } from './resolveLinkHref.js';
diff --git a/dist/modules/links/index.js b/dist/modules/links/index.js
new file mode 100644
index 0000000..f1413cf
--- /dev/null
+++ b/dist/modules/links/index.js
@@ -0,0 +1,4 @@
+export { buildLinkField, buildLinksField } from './buildLinkField.js';
+export { resolveLinkHref } from './resolveLinkHref.js';
+
+//# sourceMappingURL=index.js.map
\ No newline at end of file
diff --git a/dist/modules/links/index.js.map b/dist/modules/links/index.js.map
new file mode 100644
index 0000000..94165c5
--- /dev/null
+++ b/dist/modules/links/index.js.map
@@ -0,0 +1 @@
+{"version":3,"sources":["../../../src/modules/links/index.ts"],"sourcesContent":["export { buildLinkField, buildLinksField } from './buildLinkField.js'\nexport type { BuildLinkFieldOptions, BuildLinksFieldOptions, LinkAppearance } from './buildLinkField.js'\nexport { resolveLinkHref } from './resolveLinkHref.js'\nexport type { LinkValue, ResolveLinkHrefOptions } from './resolveLinkHref.js'\n"],"names":["buildLinkField","buildLinksField","resolveLinkHref"],"mappings":"AAAA,SAASA,cAAc,EAAEC,eAAe,QAAQ,sBAAqB;AAErE,SAASC,eAAe,QAAQ,uBAAsB"}
\ No newline at end of file
diff --git a/dist/modules/links/resolveLinkHref.d.ts b/dist/modules/links/resolveLinkHref.d.ts
new file mode 100644
index 0000000..867fdf4
--- /dev/null
+++ b/dist/modules/links/resolveLinkHref.d.ts
@@ -0,0 +1,35 @@
+import type { I18nConfig } from '../i18n/index.js';
+/**
+ * Minimal shape of a link value (the project's generated `CmsLink` fits it).
+ * The plugin doesn't know the project's types — only this contract.
+ */
+export type LinkValue = {
+ appearance?: null | string;
+ file?: unknown;
+ label?: null | string;
+ newTab?: boolean | null;
+ page?: unknown;
+ type?: 'external' | 'file' | 'internal' | null;
+ url?: null | string;
+};
+export type ResolveLinkHrefOptions = {
+ config: I18nConfig;
+ /**
+ * Slug(s) of the homepage so it collapses to /{locale}. A per-locale map or a
+ * string. Usually from SiteSettings.homepage.
+ */
+ homeSlug?: Record | string;
+ locale: string;
+};
+/**
+ * Turns a link value (buildLinkField) into an href — the single place that
+ * knows the link types. Returns null when the link is empty or its target is
+ * missing in this locale (deleted page, page not populated, no file).
+ *
+ * Internal links need the related page POPULATED (block depth ≥ 2) — a bare ID
+ * resolves to null.
+ *
+ * resolveLinkHref(link, { locale, config: i18nConfig, homeSlug })
+ * // internal → '/en/about' · external → 'https://…' · file → media URL
+ */
+export declare function resolveLinkHref(link: LinkValue | null | undefined, { config, homeSlug, locale }: ResolveLinkHrefOptions): null | string;
diff --git a/dist/modules/links/resolveLinkHref.js b/dist/modules/links/resolveLinkHref.js
new file mode 100644
index 0000000..13a57de
--- /dev/null
+++ b/dist/modules/links/resolveLinkHref.js
@@ -0,0 +1,48 @@
+import { buildLocalizedPath } from '../i18n/index.js';
+/**
+ * Turns a link value (buildLinkField) into an href — the single place that
+ * knows the link types. Returns null when the link is empty or its target is
+ * missing in this locale (deleted page, page not populated, no file).
+ *
+ * Internal links need the related page POPULATED (block depth ≥ 2) — a bare ID
+ * resolves to null.
+ *
+ * resolveLinkHref(link, { locale, config: i18nConfig, homeSlug })
+ * // internal → '/en/about' · external → 'https://…' · file → media URL
+ */ export function resolveLinkHref(link, { config, homeSlug, locale }) {
+ if (!link) {
+ return null;
+ }
+ if (link.type === 'external') {
+ return link.url?.trim() || null;
+ }
+ if (link.type === 'file') {
+ const file = link.file;
+ if (file && typeof file === 'object' && 'url' in file) {
+ const url = file.url;
+ return typeof url === 'string' && url ? url : null;
+ }
+ return null;
+ }
+ // internal (default)
+ const page = link.page;
+ if (!page || typeof page !== 'object') {
+ return null;
+ }
+ const slug = page.slug;
+ if (typeof slug !== 'string' || !slug) {
+ return null;
+ }
+ return buildLocalizedPath({
+ config,
+ locale,
+ slugs: {
+ [locale]: slug
+ },
+ ...homeSlug ? {
+ homeSlug
+ } : {}
+ }) ?? null;
+}
+
+//# sourceMappingURL=resolveLinkHref.js.map
\ No newline at end of file
diff --git a/dist/modules/links/resolveLinkHref.js.map b/dist/modules/links/resolveLinkHref.js.map
new file mode 100644
index 0000000..e084811
--- /dev/null
+++ b/dist/modules/links/resolveLinkHref.js.map
@@ -0,0 +1 @@
+{"version":3,"sources":["../../../src/modules/links/resolveLinkHref.ts"],"sourcesContent":["import type { I18nConfig } from '../i18n/index.js'\n\nimport { buildLocalizedPath } from '../i18n/index.js'\n\n/**\n * Minimal shape of a link value (the project's generated `CmsLink` fits it).\n * The plugin doesn't know the project's types — only this contract.\n */\nexport type LinkValue = {\n appearance?: null | string\n file?: unknown\n label?: null | string\n newTab?: boolean | null\n page?: unknown\n type?: 'external' | 'file' | 'internal' | null\n url?: null | string\n}\n\nexport type ResolveLinkHrefOptions = {\n config: I18nConfig\n /**\n * Slug(s) of the homepage so it collapses to /{locale}. A per-locale map or a\n * string. Usually from SiteSettings.homepage.\n */\n homeSlug?: Record | string\n locale: string\n}\n\n/**\n * Turns a link value (buildLinkField) into an href — the single place that\n * knows the link types. Returns null when the link is empty or its target is\n * missing in this locale (deleted page, page not populated, no file).\n *\n * Internal links need the related page POPULATED (block depth ≥ 2) — a bare ID\n * resolves to null.\n *\n * resolveLinkHref(link, { locale, config: i18nConfig, homeSlug })\n * // internal → '/en/about' · external → 'https://…' · file → media URL\n */\nexport function resolveLinkHref(\n link: LinkValue | null | undefined,\n { config, homeSlug, locale }: ResolveLinkHrefOptions,\n): null | string {\n if (!link) {return null}\n\n if (link.type === 'external') {return link.url?.trim() || null}\n\n if (link.type === 'file') {\n const file = link.file\n if (file && typeof file === 'object' && 'url' in file) {\n const url = (file as { url?: unknown }).url\n return typeof url === 'string' && url ? url : null\n }\n return null\n }\n\n // internal (default)\n const page = link.page\n if (!page || typeof page !== 'object') {return null}\n const slug = (page as { slug?: unknown }).slug\n if (typeof slug !== 'string' || !slug) {return null}\n\n return (\n buildLocalizedPath({\n config,\n locale,\n slugs: { [locale]: slug },\n ...(homeSlug ? { homeSlug } : {}),\n }) ?? null\n )\n}\n"],"names":["buildLocalizedPath","resolveLinkHref","link","config","homeSlug","locale","type","url","trim","file","page","slug","slugs"],"mappings":"AAEA,SAASA,kBAAkB,QAAQ,mBAAkB;AA0BrD;;;;;;;;;;CAUC,GACD,OAAO,SAASC,gBACdC,IAAkC,EAClC,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,MAAM,EAA0B;IAEpD,IAAI,CAACH,MAAM;QAAC,OAAO;IAAI;IAEvB,IAAIA,KAAKI,IAAI,KAAK,YAAY;QAAC,OAAOJ,KAAKK,GAAG,EAAEC,UAAU;IAAI;IAE9D,IAAIN,KAAKI,IAAI,KAAK,QAAQ;QACxB,MAAMG,OAAOP,KAAKO,IAAI;QACtB,IAAIA,QAAQ,OAAOA,SAAS,YAAY,SAASA,MAAM;YACrD,MAAMF,MAAM,AAACE,KAA2BF,GAAG;YAC3C,OAAO,OAAOA,QAAQ,YAAYA,MAAMA,MAAM;QAChD;QACA,OAAO;IACT;IAEA,qBAAqB;IACrB,MAAMG,OAAOR,KAAKQ,IAAI;IACtB,IAAI,CAACA,QAAQ,OAAOA,SAAS,UAAU;QAAC,OAAO;IAAI;IACnD,MAAMC,OAAO,AAACD,KAA4BC,IAAI;IAC9C,IAAI,OAAOA,SAAS,YAAY,CAACA,MAAM;QAAC,OAAO;IAAI;IAEnD,OACEX,mBAAmB;QACjBG;QACAE;QACAO,OAAO;YAAE,CAACP,OAAO,EAAEM;QAAK;QACxB,GAAIP,WAAW;YAAEA;QAAS,IAAI,CAAC,CAAC;IAClC,MAAM;AAEV"}
\ No newline at end of file
diff --git a/dist/modules/seo/buildRobots.d.ts b/dist/modules/seo/buildRobots.d.ts
index f49f90b..81ee212 100644
--- a/dist/modules/seo/buildRobots.d.ts
+++ b/dist/modules/seo/buildRobots.d.ts
@@ -14,7 +14,13 @@ type RobotRule = {
export declare const AI_ASSISTANT_BOTS: readonly ["ClaudeBot", "Claude-Web", "Claude-SearchBot", "ChatGPT-User", "OAI-SearchBot", "PerplexityBot", "Perplexity-User"];
export declare const AI_TRAINING_BOTS: readonly ["GPTBot", "Google-Extended", "CCBot", "anthropic-ai", "Applebot-Extended", "Bytespider", "Meta-ExternalAgent"];
type AiBotsPolicy = 'allow' | 'block-training' | 'disallow' | false;
-type BuildRobotsArgs = {
+export type RobotsOptions = {
+ /**
+ * Admin path to disallow. Default '/admin'. With a hidden panel
+ * (ipalKit adminRoute) pass `false`: robots.txt is public, so listing the
+ * path would reveal it — the admin is noindex anyway.
+ */
+ adminRoute?: false | string;
/** Override the assistant/search bot list. */
aiAssistantAgents?: readonly string[];
/**
@@ -31,13 +37,27 @@ type BuildRobotsArgs = {
aiBots?: AiBotsPolicy;
/** Override the training crawler list. */
aiTrainingAgents?: readonly string[];
- /** Absolute origin, e.g. 'https://example.com'. */
- baseUrl: string;
- /** Paths to disallow. Defaults to Payload's admin and API. */
+ /**
+ * Full disallow list — REPLACES the defaults ([adminRoute, '/api']). Prefer
+ * `extraDisallow` / `disallowParams`, which add to the defaults instead.
+ */
disallow?: string[];
+ /**
+ * Query parameters whose URLs crawlers should skip (thin/duplicate pages that
+ * waste crawl budget), e.g. ['s', 'meter', 'utm_source']. Each becomes
+ * `/*?name=` and `/*&name=` (the parameter may not be first).
+ * Don't list `page` — paginated archives are real, canonical-to-self pages.
+ */
+ disallowParams?: string[];
+ /** Paths added to the default disallow list, e.g. ['/koszyk']. */
+ extraDisallow?: string[];
/** Whether to advertise the sitemap. Defaults to true. */
sitemap?: boolean;
};
+type BuildRobotsArgs = {
+ /** Absolute origin, e.g. 'https://example.com'. */
+ baseUrl: string;
+} & RobotsOptions;
/**
* Shape for Next's `app/robots.ts`. `rules` may be a single rule or an array
* (Next accepts both) — it becomes an array when AI-bot rules are added.
@@ -68,10 +88,11 @@ export type RobotsRules = {
* PerplexityBot, Google-Extended and friends. To keep AI answers but opt out of
* model training, use `aiBots: 'block-training'`. To block them all, 'disallow'.
*
- * Pass custom disallow to block parametrized/thin URLs that waste crawl budget:
+ * Block parametrized/thin URLs that waste crawl budget — added to the defaults:
* ```ts
- * buildRobots({ baseUrl, disallow: ['/admin', '/api', '/*?meter=*', '/*?s=*'] })
+ * buildRobots({ baseUrl, disallowParams: ['s', 'meter'] })
+ * // Disallow: /admin, /api, /*?s=, /*&s=, /*?meter=, /*&meter=
* ```
*/
-export declare function buildRobots({ aiAssistantAgents, aiBots, aiTrainingAgents, baseUrl, disallow, sitemap, }: BuildRobotsArgs): RobotsRules;
+export declare function buildRobots({ adminRoute, aiAssistantAgents, aiBots, aiTrainingAgents, baseUrl, disallow: disallowOverride, disallowParams, extraDisallow, sitemap, }: BuildRobotsArgs): RobotsRules;
export {};
diff --git a/dist/modules/seo/buildRobots.js b/dist/modules/seo/buildRobots.js
index 08dc75f..3e897ee 100644
--- a/dist/modules/seo/buildRobots.js
+++ b/dist/modules/seo/buildRobots.js
@@ -44,15 +44,30 @@ export const AI_TRAINING_BOTS = [
* PerplexityBot, Google-Extended and friends. To keep AI answers but opt out of
* model training, use `aiBots: 'block-training'`. To block them all, 'disallow'.
*
- * Pass custom disallow to block parametrized/thin URLs that waste crawl budget:
+ * Block parametrized/thin URLs that waste crawl budget — added to the defaults:
* ```ts
- * buildRobots({ baseUrl, disallow: ['/admin', '/api', '/*?meter=*', '/*?s=*'] })
+ * buildRobots({ baseUrl, disallowParams: ['s', 'meter'] })
+ * // Disallow: /admin, /api, /*?s=, /*&s=, /*?meter=, /*&meter=
* ```
- */ export function buildRobots({ aiAssistantAgents = AI_ASSISTANT_BOTS, aiBots = 'allow', aiTrainingAgents = AI_TRAINING_BOTS, baseUrl, disallow = [
- '/admin',
- '/api'
-], sitemap = true }) {
+ */ export function buildRobots({ adminRoute = '/admin', aiAssistantAgents = AI_ASSISTANT_BOTS, aiBots = 'allow', aiTrainingAgents = AI_TRAINING_BOTS, baseUrl, disallow: disallowOverride, disallowParams = [], extraDisallow = [], sitemap = true }) {
const origin = baseUrl.replace(/\/$/, '');
+ const defaults = [
+ ...adminRoute ? [
+ adminRoute
+ ] : [],
+ '/api'
+ ];
+ const paramRules = disallowParams.map((p)=>p.trim()).filter(Boolean).flatMap((p)=>[
+ `/*?${p}=`,
+ `/*&${p}=`
+ ]);
+ const disallow = [
+ ...new Set([
+ ...disallowOverride ?? defaults,
+ ...extraDisallow,
+ ...paramRules
+ ])
+ ];
const baseRule = {
allow: '/',
disallow,
diff --git a/dist/modules/seo/buildRobots.js.map b/dist/modules/seo/buildRobots.js.map
index 6760039..9265c08 100644
--- a/dist/modules/seo/buildRobots.js.map
+++ b/dist/modules/seo/buildRobots.js.map
@@ -1 +1 @@
-{"version":3,"sources":["../../../src/modules/seo/buildRobots.ts"],"sourcesContent":["type RobotRule = { allow?: string; disallow?: string[]; userAgent: string | string[] }\n\n/**\n * Known AI user agents, split by purpose:\n * - assistant/search bots fetch a page to answer a user's question live or to\n * power an AI search index — the ones that make \"the chat reads your site\"\n * work, and that most businesses WANT.\n * - training crawlers collect pages to train models — some clients prefer to\n * opt out of these while keeping assistant/search visibility.\n */\nexport const AI_ASSISTANT_BOTS = [\n 'ClaudeBot',\n 'Claude-Web',\n 'Claude-SearchBot',\n 'ChatGPT-User',\n 'OAI-SearchBot',\n 'PerplexityBot',\n 'Perplexity-User',\n] as const\n\nexport const AI_TRAINING_BOTS = [\n 'GPTBot',\n 'Google-Extended',\n 'CCBot',\n 'anthropic-ai',\n 'Applebot-Extended',\n 'Bytespider',\n 'Meta-ExternalAgent',\n] as const\n\ntype AiBotsPolicy = 'allow' | 'block-training' | 'disallow' | false\n\ntype BuildRobotsArgs = {\n /** Override the assistant/search bot list. */\n aiAssistantAgents?: readonly string[]\n /**\n * How to treat AI crawlers (assistant/search + training). Default 'allow' —\n * explicitly welcome them so the site stays visible to Claude, ChatGPT,\n * Perplexity etc. and an accidental future '*' tightening doesn't lock them\n * out. Options:\n * - 'allow' (default): explicit allow for assistant AND training bots.\n * - 'block-training': allow assistant/search bots, disallow training crawlers\n * — keep AI answers/visibility, opt out of model training.\n * - 'disallow': block all known AI bots.\n * - false: emit no AI-specific rules (only the '*' rule).\n */\n aiBots?: AiBotsPolicy\n /** Override the training crawler list. */\n aiTrainingAgents?: readonly string[]\n /** Absolute origin, e.g. 'https://example.com'. */\n baseUrl: string\n /** Paths to disallow. Defaults to Payload's admin and API. */\n disallow?: string[]\n /** Whether to advertise the sitemap. Defaults to true. */\n sitemap?: boolean\n}\n\n/**\n * Shape for Next's `app/robots.ts`. `rules` may be a single rule or an array\n * (Next accepts both) — it becomes an array when AI-bot rules are added.\n */\nexport type RobotsRules = {\n host?: string\n rules: RobotRule | RobotRule[]\n sitemap?: string\n}\n\n/**\n * Builds robots rules that allow crawling everything except the admin panel and\n * API, point crawlers at the sitemap, and (by default) explicitly welcome AI\n * assistant/search/training bots.\n *\n * ```ts\n * // app/robots.ts\n * export default function robots() {\n * return buildRobots({ baseUrl: process.env.NEXT_PUBLIC_SERVER_URL! })\n * }\n * ```\n *\n * The admin and API are disallowed by default — no reason for them in the index,\n * and it keeps crawl budget on real content.\n *\n * AI visibility: the #1 reason \"the chat won't read the site\" is an AI user\n * agent being blocked (or not explicitly allowed under a tightened '*' rule).\n * `aiBots: 'allow'` (default) emits explicit allow rules for ClaudeBot, GPTBot,\n * PerplexityBot, Google-Extended and friends. To keep AI answers but opt out of\n * model training, use `aiBots: 'block-training'`. To block them all, 'disallow'.\n *\n * Pass custom disallow to block parametrized/thin URLs that waste crawl budget:\n * ```ts\n * buildRobots({ baseUrl, disallow: ['/admin', '/api', '/*?meter=*', '/*?s=*'] })\n * ```\n */\nexport function buildRobots({\n aiAssistantAgents = AI_ASSISTANT_BOTS,\n aiBots = 'allow',\n aiTrainingAgents = AI_TRAINING_BOTS,\n baseUrl,\n disallow = ['/admin', '/api'],\n sitemap = true,\n}: BuildRobotsArgs): RobotsRules {\n const origin = baseUrl.replace(/\\/$/, '')\n\n const baseRule: RobotRule = { allow: '/', disallow, userAgent: '*' }\n\n const aiRules: RobotRule[] = []\n if (aiBots === 'allow') {\n aiRules.push({ allow: '/', disallow, userAgent: [...aiAssistantAgents, ...aiTrainingAgents] })\n } else if (aiBots === 'block-training') {\n aiRules.push({ allow: '/', disallow, userAgent: [...aiAssistantAgents] })\n aiRules.push({ disallow: ['/'], userAgent: [...aiTrainingAgents] })\n } else if (aiBots === 'disallow') {\n aiRules.push({ disallow: ['/'], userAgent: [...aiAssistantAgents, ...aiTrainingAgents] })\n }\n\n return {\n rules: aiRules.length > 0 ? [baseRule, ...aiRules] : baseRule,\n ...(sitemap ? { sitemap: `${origin}/sitemap.xml` } : {}),\n host: origin,\n }\n}\n"],"names":["AI_ASSISTANT_BOTS","AI_TRAINING_BOTS","buildRobots","aiAssistantAgents","aiBots","aiTrainingAgents","baseUrl","disallow","sitemap","origin","replace","baseRule","allow","userAgent","aiRules","push","rules","length","host"],"mappings":"AAEA;;;;;;;CAOC,GACD,OAAO,MAAMA,oBAAoB;IAC/B;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAS;AAEV,OAAO,MAAMC,mBAAmB;IAC9B;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAS;AAuCV;;;;;;;;;;;;;;;;;;;;;;;;;CAyBC,GACD,OAAO,SAASC,YAAY,EAC1BC,oBAAoBH,iBAAiB,EACrCI,SAAS,OAAO,EAChBC,mBAAmBJ,gBAAgB,EACnCK,OAAO,EACPC,WAAW;IAAC;IAAU;CAAO,EAC7BC,UAAU,IAAI,EACE;IAChB,MAAMC,SAASH,QAAQI,OAAO,CAAC,OAAO;IAEtC,MAAMC,WAAsB;QAAEC,OAAO;QAAKL;QAAUM,WAAW;IAAI;IAEnE,MAAMC,UAAuB,EAAE;IAC/B,IAAIV,WAAW,SAAS;QACtBU,QAAQC,IAAI,CAAC;YAAEH,OAAO;YAAKL;YAAUM,WAAW;mBAAIV;mBAAsBE;aAAiB;QAAC;IAC9F,OAAO,IAAID,WAAW,kBAAkB;QACtCU,QAAQC,IAAI,CAAC;YAAEH,OAAO;YAAKL;YAAUM,WAAW;mBAAIV;aAAkB;QAAC;QACvEW,QAAQC,IAAI,CAAC;YAAER,UAAU;gBAAC;aAAI;YAAEM,WAAW;mBAAIR;aAAiB;QAAC;IACnE,OAAO,IAAID,WAAW,YAAY;QAChCU,QAAQC,IAAI,CAAC;YAAER,UAAU;gBAAC;aAAI;YAAEM,WAAW;mBAAIV;mBAAsBE;aAAiB;QAAC;IACzF;IAEA,OAAO;QACLW,OAAOF,QAAQG,MAAM,GAAG,IAAI;YAACN;eAAaG;SAAQ,GAAGH;QACrD,GAAIH,UAAU;YAAEA,SAAS,GAAGC,OAAO,YAAY,CAAC;QAAC,IAAI,CAAC,CAAC;QACvDS,MAAMT;IACR;AACF"}
\ No newline at end of file
+{"version":3,"sources":["../../../src/modules/seo/buildRobots.ts"],"sourcesContent":["type RobotRule = { allow?: string; disallow?: string[]; userAgent: string | string[] }\n\n/**\n * Known AI user agents, split by purpose:\n * - assistant/search bots fetch a page to answer a user's question live or to\n * power an AI search index — the ones that make \"the chat reads your site\"\n * work, and that most businesses WANT.\n * - training crawlers collect pages to train models — some clients prefer to\n * opt out of these while keeping assistant/search visibility.\n */\nexport const AI_ASSISTANT_BOTS = [\n 'ClaudeBot',\n 'Claude-Web',\n 'Claude-SearchBot',\n 'ChatGPT-User',\n 'OAI-SearchBot',\n 'PerplexityBot',\n 'Perplexity-User',\n] as const\n\nexport const AI_TRAINING_BOTS = [\n 'GPTBot',\n 'Google-Extended',\n 'CCBot',\n 'anthropic-ai',\n 'Applebot-Extended',\n 'Bytespider',\n 'Meta-ExternalAgent',\n] as const\n\ntype AiBotsPolicy = 'allow' | 'block-training' | 'disallow' | false\n\nexport type RobotsOptions = {\n /**\n * Admin path to disallow. Default '/admin'. With a hidden panel\n * (ipalKit adminRoute) pass `false`: robots.txt is public, so listing the\n * path would reveal it — the admin is noindex anyway.\n */\n adminRoute?: false | string\n /** Override the assistant/search bot list. */\n aiAssistantAgents?: readonly string[]\n /**\n * How to treat AI crawlers (assistant/search + training). Default 'allow' —\n * explicitly welcome them so the site stays visible to Claude, ChatGPT,\n * Perplexity etc. and an accidental future '*' tightening doesn't lock them\n * out. Options:\n * - 'allow' (default): explicit allow for assistant AND training bots.\n * - 'block-training': allow assistant/search bots, disallow training crawlers\n * — keep AI answers/visibility, opt out of model training.\n * - 'disallow': block all known AI bots.\n * - false: emit no AI-specific rules (only the '*' rule).\n */\n aiBots?: AiBotsPolicy\n /** Override the training crawler list. */\n aiTrainingAgents?: readonly string[]\n /**\n * Full disallow list — REPLACES the defaults ([adminRoute, '/api']). Prefer\n * `extraDisallow` / `disallowParams`, which add to the defaults instead.\n */\n disallow?: string[]\n /**\n * Query parameters whose URLs crawlers should skip (thin/duplicate pages that\n * waste crawl budget), e.g. ['s', 'meter', 'utm_source']. Each becomes\n * `/*?name=` and `/*&name=` (the parameter may not be first).\n * Don't list `page` — paginated archives are real, canonical-to-self pages.\n */\n disallowParams?: string[]\n /** Paths added to the default disallow list, e.g. ['/koszyk']. */\n extraDisallow?: string[]\n /** Whether to advertise the sitemap. Defaults to true. */\n sitemap?: boolean\n}\n\ntype BuildRobotsArgs = {\n /** Absolute origin, e.g. 'https://example.com'. */\n baseUrl: string\n} & RobotsOptions\n\n/**\n * Shape for Next's `app/robots.ts`. `rules` may be a single rule or an array\n * (Next accepts both) — it becomes an array when AI-bot rules are added.\n */\nexport type RobotsRules = {\n host?: string\n rules: RobotRule | RobotRule[]\n sitemap?: string\n}\n\n/**\n * Builds robots rules that allow crawling everything except the admin panel and\n * API, point crawlers at the sitemap, and (by default) explicitly welcome AI\n * assistant/search/training bots.\n *\n * ```ts\n * // app/robots.ts\n * export default function robots() {\n * return buildRobots({ baseUrl: process.env.NEXT_PUBLIC_SERVER_URL! })\n * }\n * ```\n *\n * The admin and API are disallowed by default — no reason for them in the index,\n * and it keeps crawl budget on real content.\n *\n * AI visibility: the #1 reason \"the chat won't read the site\" is an AI user\n * agent being blocked (or not explicitly allowed under a tightened '*' rule).\n * `aiBots: 'allow'` (default) emits explicit allow rules for ClaudeBot, GPTBot,\n * PerplexityBot, Google-Extended and friends. To keep AI answers but opt out of\n * model training, use `aiBots: 'block-training'`. To block them all, 'disallow'.\n *\n * Block parametrized/thin URLs that waste crawl budget — added to the defaults:\n * ```ts\n * buildRobots({ baseUrl, disallowParams: ['s', 'meter'] })\n * // Disallow: /admin, /api, /*?s=, /*&s=, /*?meter=, /*&meter=\n * ```\n */\nexport function buildRobots({\n adminRoute = '/admin',\n aiAssistantAgents = AI_ASSISTANT_BOTS,\n aiBots = 'allow',\n aiTrainingAgents = AI_TRAINING_BOTS,\n baseUrl,\n disallow: disallowOverride,\n disallowParams = [],\n extraDisallow = [],\n sitemap = true,\n}: BuildRobotsArgs): RobotsRules {\n const origin = baseUrl.replace(/\\/$/, '')\n\n const defaults = [...(adminRoute ? [adminRoute] : []), '/api']\n const paramRules = disallowParams\n .map((p) => p.trim())\n .filter(Boolean)\n .flatMap((p) => [`/*?${p}=`, `/*&${p}=`])\n const disallow = [...new Set([...(disallowOverride ?? defaults), ...extraDisallow, ...paramRules])]\n\n const baseRule: RobotRule = { allow: '/', disallow, userAgent: '*' }\n\n const aiRules: RobotRule[] = []\n if (aiBots === 'allow') {\n aiRules.push({ allow: '/', disallow, userAgent: [...aiAssistantAgents, ...aiTrainingAgents] })\n } else if (aiBots === 'block-training') {\n aiRules.push({ allow: '/', disallow, userAgent: [...aiAssistantAgents] })\n aiRules.push({ disallow: ['/'], userAgent: [...aiTrainingAgents] })\n } else if (aiBots === 'disallow') {\n aiRules.push({ disallow: ['/'], userAgent: [...aiAssistantAgents, ...aiTrainingAgents] })\n }\n\n return {\n rules: aiRules.length > 0 ? [baseRule, ...aiRules] : baseRule,\n ...(sitemap ? { sitemap: `${origin}/sitemap.xml` } : {}),\n host: origin,\n }\n}\n"],"names":["AI_ASSISTANT_BOTS","AI_TRAINING_BOTS","buildRobots","adminRoute","aiAssistantAgents","aiBots","aiTrainingAgents","baseUrl","disallow","disallowOverride","disallowParams","extraDisallow","sitemap","origin","replace","defaults","paramRules","map","p","trim","filter","Boolean","flatMap","Set","baseRule","allow","userAgent","aiRules","push","rules","length","host"],"mappings":"AAEA;;;;;;;CAOC,GACD,OAAO,MAAMA,oBAAoB;IAC/B;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAS;AAEV,OAAO,MAAMC,mBAAmB;IAC9B;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAS;AA4DV;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BC,GACD,OAAO,SAASC,YAAY,EAC1BC,aAAa,QAAQ,EACrBC,oBAAoBJ,iBAAiB,EACrCK,SAAS,OAAO,EAChBC,mBAAmBL,gBAAgB,EACnCM,OAAO,EACPC,UAAUC,gBAAgB,EAC1BC,iBAAiB,EAAE,EACnBC,gBAAgB,EAAE,EAClBC,UAAU,IAAI,EACE;IAChB,MAA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8bc8dbd..58cf9f8 100644
--- a/dist/modules/seo/createPageMetadata.d.ts
+++ b/dist/modules/seo/createPageMetadata.d.ts
@@ -1,5 +1,5 @@
import type { BasePayload } from 'payload';
-import type { ContentOption } from '../content/index.js';
+import type { ContentOption, ResolvedRoute } from '../content/index.js';
import type { I18nConfig } from '../i18n/index.js';
import type { PageMetadata } from './buildMetadata.js';
type CreatePageMetadataArgs = {
@@ -14,6 +14,15 @@ type CreatePageMetadataArgs = {
* omit it and only pages are handled.
*/
content?: ContentOption;
+ /**
+ * Request-cached loaders (createContentHelpers passes its own), so metadata
+ * reuses the SAME settings read and route resolution as the layout and the
+ * page component instead of querying again. Omit → plain queries.
+ */
+ loaders?: {
+ getSettings?: (locale: string) => Promise>;
+ resolveRoute?: (locale: string, segments: string[] | undefined, page: number) => Promise;
+ };
/** SiteSettings global slug. Defaults to 'site-settings'. */
settingsSlug?: string;
/** Field on SiteSettings holding the site name. Defaults to 'siteName'. */
diff --git a/dist/modules/seo/createPageMetadata.js b/dist/modules/seo/createPageMetadata.js
index 110de3c..f85c5b6 100644
--- a/dist/modules/seo/createPageMetadata.js
+++ b/dist/modules/seo/createPageMetadata.js
@@ -34,11 +34,14 @@ import { slugsAcrossLocales } from './slugsAcrossLocales.js';
* }
* ```
*/ export function createPageMetadata(args) {
- const { baseUrl, collection = 'pages', config, content, settingsSlug = 'site-settings', siteNameField = 'siteName' } = args;
+ const { baseUrl, collection = 'pages', config, content, loaders, settingsSlug = 'site-settings', siteNameField = 'siteName' } = args;
return async function pageMetadata({ slug, locale, page, payload }) {
+ const settings = loaders?.getSettings ? await loaders.getSettings(locale) : undefined;
const site = await readSiteMetaConfig({
locale,
+ pagesSlug: collection,
payload,
+ settings,
settingsSlug,
siteNameField
});
@@ -51,13 +54,14 @@ import { slugsAcrossLocales } from './slugsAcrossLocales.js';
separator: site.separator,
siteName: site.siteName
};
- const route = await resolveRoute({
+ const route = loaders?.resolveRoute ? await loaders.resolveRoute(locale, slug, page ?? 1) : await resolveRoute({
content,
locale,
page,
pagesSlug: collection,
payload,
segments: slug,
+ settings,
settingsSlug
});
// Unknown route (the page component will 404) — still return something
diff --git a/dist/modules/seo/createPageMetadata.js.map b/dist/modules/seo/createPageMetadata.js.map
index 56be01e..3cb7e6b 100644
--- a/dist/modules/seo/createPageMetadata.js.map
+++ b/dist/modules/seo/createPageMetadata.js.map
@@ -1 +1 @@
-{"version":3,"sources":["../../../src/modules/seo/createPageMetadata.ts"],"sourcesContent":["import type { BasePayload } from 'payload'\n\nimport type { ContentOption } from '../content/index.js'\nimport type { I18nConfig } from '../i18n/index.js'\nimport type { PageMetadata } from './buildMetadata.js'\nimport type { SeoMeta } from './types.js'\n\nimport { resolveRoute } from '../content/index.js'\nimport { buildMetadata } from './buildMetadata.js'\nimport { readSiteMetaConfig } from './readSiteMetaConfig.js'\nimport { slugsAcrossLocales } from './slugsAcrossLocales.js'\n\ntype CreatePageMetadataArgs = {\n /** Absolute site origin, e.g. 'https://example.com'. */\n baseUrl?: string\n /** Collection holding pages. Defaults to 'pages'. */\n collection?: string\n config: I18nConfig\n /**\n * Archive-backed collections, same value as the plugin option. Pass it and\n * entry URLs (/pl/artykuly/moj-post) get correct canonical and hreflang;\n * omit it and only pages are handled.\n */\n content?: ContentOption\n /** SiteSettings global slug. Defaults to 'site-settings'. */\n settingsSlug?: string\n /** Field on SiteSettings holding the site name. Defaults to 'siteName'. */\n siteNameField?: string\n}\n\ntype PageMetadataContext = {\n locale: string\n /**\n * Page number from ?page= on an archive listing. Pass it and page 2 gets a\n * canonical to itself; leave it out and every page claims to be page 1.\n */\n page?: number\n payload: BasePayload\n /** Route slug segments; empty/undefined means the locale root. */\n slug?: string[]\n}\n\ntype DocShape = {\n id: number | string\n meta?: null | SeoMeta\n /** Top-level noindex checkbox (buildNoindexField) — the field that persists. */\n noindex?: boolean | null\n /** The document's own title (page name), used as the fallback page title. */\n title?: null | string\n}\n\n/** plugin-seo stores the OG image as an upload relationship. */\nfunction resolveOgImage(doc: DocShape): null | string {\n const image = (doc.meta as { image?: unknown } | null | undefined)?.image\n if (image && typeof image === 'object' && 'url' in image) {\n return (image as { url: string }).url ?? null\n }\n return null\n}\n\n/**\n * Metadata for the page route, with every resolver already wired.\n *\n * `createMetadataGenerator` asks the client for resolvers because it can't know\n * their collections. But for the plugin's own conventions it does know: pages\n * live in one collection, the site name sits on SiteSettings, the OG image sits\n * on the plugin-seo `meta` group, the home page is whatever System Pages points\n * at, and — with `content` — entries live under their collection's archive page.\n * Re-declaring all that in every project is copy-paste, so this resolves it.\n *\n * Reach for `createMetadataGenerator` instead when a route doesn't follow those\n * conventions — custom image logic, a different global, hand-rolled paths.\n *\n * The plugin never calls getPayload, and Next calls generateMetadata without a\n * payload, so the client keeps a small wrapper:\n *\n * ```ts\n * const pageMetadata = createPageMetadata({ config: i18nConfig, baseUrl, content })\n *\n * export async function generateMetadata({ params }) {\n * const { locale, slug } = await params\n * return pageMetadata({ payload: await getPayload({ config }), locale, slug })\n * }\n * ```\n */\nexport function createPageMetadata(args: CreatePageMetadataArgs) {\n const {\n baseUrl,\n collection = 'pages',\n config,\n content,\n settingsSlug = 'site-settings',\n siteNameField = 'siteName',\n } = args\n\n return async function pageMetadata({\n slug,\n locale,\n page,\n payload,\n }: PageMetadataContext): Promise {\n const site = await readSiteMetaConfig({ locale, payload, settingsSlug, siteNameField })\n\n const base = {\n baseUrl,\n config,\n homeSlug: site.homeSlug,\n locale,\n order: site.order,\n separator: site.separator,\n siteName: site.siteName,\n }\n\n const route = await resolveRoute({\n content,\n locale,\n page,\n pagesSlug: collection,\n payload,\n segments: slug,\n settingsSlug,\n })\n\n // Unknown route (the page component will 404) — still return something\n // coherent rather than throwing during metadata generation.\n if (!route) {\n return buildMetadata({ ...base, meta: null, slugs: {} })\n }\n\n const doc = route.doc as DocShape\n\n // An entry sits under its archive, so its URLs need that segment — and the\n // segment differs per locale, since it's the archive page's own slug.\n const prefix =\n route.type === 'entry'\n ? await slugsAcrossLocales({\n id: (route.archive as DocShape).id,\n collection,\n config,\n payload,\n })\n : undefined\n\n const slugs = await slugsAcrossLocales({\n id: doc.id,\n collection: route.type === 'entry' ? route.collection : collection,\n config,\n payload,\n })\n\n // Page 2 of a listing is its own URL, not a variant of page 1.\n const query = route.type === 'archive' && route.page > 1 ? `?page=${route.page}` : undefined\n\n return buildMetadata({\n ...base,\n imageUrl: resolveOgImage(doc),\n meta: doc.meta,\n noindex: doc.noindex,\n pageTitle: doc.title,\n prefix,\n query,\n slugs,\n })\n }\n}\n"],"names":["resolveRoute","buildMetadata","readSiteMetaConfig","slugsAcrossLocales","resolveOgImage","doc","image","meta","url","createPageMetadata","args","baseUrl","collection","config","content","settingsSlug","siteNameField","pageMetadata","slug","locale","page","payload","site","base","homeSlug","order","separator","siteName","route","pagesSlug","segments","slugs","prefix","type","id","archive","undefined","query","imageUrl","noindex","pageTitle","title"],"mappings":"AAOA,SAASA,YAAY,QAAQ,sBAAqB;AAClD,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,kBAAkB,QAAQ,0BAAyB;AAyC5D,8DAA8D,GAC9D,SAASC,eAAeC,GAAa;IACnC,MAAMC,QAASD,IAAIE,IAAI,EAA6CD;IACpE,IAAIA,SAAS,OAAOA,UAAU,YAAY,SAASA,OAAO;QACxD,OAAO,AAACA,MAA0BE,GAAG,IAAI;IAC3C;IACA,OAAO;AACT;AAEA;;;;;;;;;;;;;;;;;;;;;;;;CAwBC,GACD,OAAO,SAASC,mBAAmBC,IAA4B;IAC7D,MAAM,EACJC,OAAO,EACPC,aAAa,OAAO,EACpBC,MAAM,EACNC,OAAO,EACPC,eAAe,eAAe,EAC9BC,gBAAgB,UAAU,EAC3B,GAAGN;IAEJ,OAAO,eAAeO,aAAa,EACjCC,IAAI,EACJC,MAAM,EACNC,IAAI,EACJC,OAAO,EACa;QACpB,MAAMC,OAAO,MAAMpB,mBAAmB;YAAEiB;YAAQE;YAASN;YAAcC;QAAc;QAErF,MAAMO,OAAO;YACXZ;YACAE;YACAW,UAAUF,KAAKE,QAAQ;YACvBL;YACAM,OAAOH,KAAKG,KAAK;YACjBC,WAAWJ,KAAKI,SAAS;YACzBC,UAAUL,KAAKK,QAAQ;QACzB;QAEA,MAAMC,QAAQ,MAAM5B,aAAa;YAC/Bc;YACAK;YACAC;YACAS,WAAWjB;YACXS;YACAS,UAAUZ;YACVH;QACF;QAEA,uEAAuE;QACvE,4DAA4D;QAC5D,IAAI,CAACa,OAAO;YACV,OAAO3B,cAAc;gBAAE,GAAGsB,IAAI;gBAAEhB,MAAM;gBAAMwB,OAAO,CAAC;YAAE;QACxD;QAEA,MAAM1B,MAAMuB,MAAMvB,GAAG;QAErB,2EAA2E;QAC3E,sEAAsE;QACtE,MAAM2B,SACJJ,MAAMK,IAAI,KAAK,UACX,MAAM9B,mBAAmB;YACvB+B,IAAI,AAACN,MAAMO,OAAO,CAAcD,EAAE;YAClCtB;YACAC;YACAQ;QACF,KACAe;QAEN,MAAML,QAAQ,MAAM5B,mBAAmB;YACrC+B,IAAI7B,IAAI6B,EAAE;YACVtB,YAAYgB,MAAMK,IAAI,KAAK,UAAUL,MAAMhB,UAAU,GAAGA;YACxDC;YACAQ;QACF;QAEA,+DAA+D;QAC/D,MAAMgB,QAAQT,MAAMK,IAAI,KAAK,aAAaL,MAAMR,IAAI,GAAG,IAAI,CAAC,MAAM,EAAEQ,MAAMR,IAAI,EAAE,GAAGgB;QAEnF,OAAOnC,cAAc;YACnB,GAAGsB,IAAI;YACPe,UAAUlC,eAAeC;YACzBE,MAAMF,IAAIE,IAAI;YACdgC,SAASlC,IAAIkC,OAAO;YACpBC,WAAWnC,IAAIoC,KAAK;YACpBT;YACAK;YACAN;QACF;IACF;AACF"}
\ No newline at end of file
+{"version":3,"sources":["../../../src/modules/seo/createPageMetadata.ts"],"sourcesContent":["import type { BasePayload } from 'payload'\n\nimport type { ContentOption, ResolvedRoute } from '../content/index.js'\nimport type { I18nConfig } from '../i18n/index.js'\nimport type { PageMetadata } from './buildMetadata.js'\nimport type { SeoMeta } from './types.js'\n\nimport { resolveRoute } from '../content/index.js'\nimport { buildMetadata } from './buildMetadata.js'\nimport { readSiteMetaConfig } from './readSiteMetaConfig.js'\nimport { slugsAcrossLocales } from './slugsAcrossLocales.js'\n\ntype CreatePageMetadataArgs = {\n /** Absolute site origin, e.g. 'https://example.com'. */\n baseUrl?: string\n /** Collection holding pages. Defaults to 'pages'. */\n collection?: string\n config: I18nConfig\n /**\n * Archive-backed collections, same value as the plugin option. Pass it and\n * entry URLs (/pl/artykuly/moj-post) get correct canonical and hreflang;\n * omit it and only pages are handled.\n */\n content?: ContentOption\n /**\n * Request-cached loaders (createContentHelpers passes its own), so metadata\n * reuses the SAME settings read and route resolution as the layout and the\n * page component instead of querying again. Omit → plain queries.\n */\n loaders?: {\n getSettings?: (locale: string) => Promise>\n resolveRoute?: (\n locale: string,\n segments: string[] | undefined,\n page: number,\n ) => Promise\n }\n /** SiteSettings global slug. Defaults to 'site-settings'. */\n settingsSlug?: string\n /** Field on SiteSettings holding the site name. Defaults to 'siteName'. */\n siteNameField?: string\n}\n\ntype PageMetadataContext = {\n locale: string\n /**\n * Page number from ?page= on an archive listing. Pass it and page 2 gets a\n * canonical to itself; leave it out and every page claims to be page 1.\n */\n page?: number\n payload: BasePayload\n /** Route slug segments; empty/undefined means the locale root. */\n slug?: string[]\n}\n\ntype DocShape = {\n id: number | string\n meta?: null | SeoMeta\n /** Top-level noindex checkbox (buildNoindexField) — the field that persists. */\n noindex?: boolean | null\n /** The document's own title (page name), used as the fallback page title. */\n title?: null | string\n}\n\n/** plugin-seo stores the OG image as an upload relationship. */\nfunction resolveOgImage(doc: DocShape): null | string {\n const image = (doc.meta as { image?: unknown } | null | undefined)?.image\n if (image && typeof image === 'object' && 'url' in image) {\n return (image as { url: string }).url ?? null\n }\n return null\n}\n\n/**\n * Metadata for the page route, with every resolver already wired.\n *\n * `createMetadataGenerator` asks the client for resolvers because it can't know\n * their collections. But for the plugin's own conventions it does know: pages\n * live in one collection, the site name sits on SiteSettings, the OG image sits\n * on the plugin-seo `meta` group, the home page is whatever System Pages points\n * at, and — with `content` — entries live under their collection's archive page.\n * Re-declaring all that in every project is copy-paste, so this resolves it.\n *\n * Reach for `createMetadataGenerator` instead when a route doesn't follow those\n * conventions — custom image logic, a different global, hand-rolled paths.\n *\n * The plugin never calls getPayload, and Next calls generateMetadata without a\n * payload, so the client keeps a small wrapper:\n *\n * ```ts\n * const pageMetadata = createPageMetadata({ config: i18nConfig, baseUrl, content })\n *\n * export async function generateMetadata({ params }) {\n * const { locale, slug } = await params\n * return pageMetadata({ payload: await getPayload({ config }), locale, slug })\n * }\n * ```\n */\nexport function createPageMetadata(args: CreatePageMetadataArgs) {\n const {\n baseUrl,\n collection = 'pages',\n config,\n content,\n loaders,\n settingsSlug = 'site-settings',\n siteNameField = 'siteName',\n } = args\n\n return async function pageMetadata({\n slug,\n locale,\n page,\n payload,\n }: PageMetadataContext): Promise {\n const settings = loaders?.getSettings ? await loaders.getSettings(locale) : undefined\n const site = await readSiteMetaConfig({\n locale,\n pagesSlug: collection,\n payload,\n settings,\n settingsSlug,\n siteNameField,\n })\n\n const base = {\n baseUrl,\n config,\n homeSlug: site.homeSlug,\n locale,\n order: site.order,\n separator: site.separator,\n siteName: site.siteName,\n }\n\n const route = loaders?.resolveRoute\n ? await loaders.resolveRoute(locale, slug, page ?? 1)\n : await resolveRoute({\n content,\n locale,\n page,\n pagesSlug: collection,\n payload,\n segments: slug,\n settings,\n settingsSlug,\n })\n\n // Unknown route (the page component will 404) — still return something\n // coherent rather than throwing during metadata generation.\n if (!route) {\n return buildMetadata({ ...base, meta: null, slugs: {} })\n }\n\n const doc = route.doc as DocShape\n\n // An entry sits under its archive, so its URLs need that segment — and the\n // segment differs per locale, since it's the archive page's own slug.\n const prefix =\n route.type === 'entry'\n ? await slugsAcrossLocales({\n id: (route.archive as DocShape).id,\n collection,\n config,\n payload,\n })\n : undefined\n\n const slugs = await slugsAcrossLocales({\n id: doc.id,\n collection: route.type === 'entry' ? route.collection : collection,\n config,\n payload,\n })\n\n // Page 2 of a listing is its own URL, not a variant of page 1.\n const query = route.type === 'archive' && route.page > 1 ? `?page=${route.page}` : undefined\n\n return buildMetadata({\n ...base,\n imageUrl: resolveOgImage(doc),\n meta: doc.meta,\n noindex: doc.noindex,\n pageTitle: doc.title,\n prefix,\n query,\n slugs,\n })\n }\n}\n"],"names":["resolveRoute","buildMetadata","readSiteMetaConfig","slugsAcrossLocales","resolveOgImage","doc","image","meta","url","createPageMetadata","args","baseUrl","collection","config","content","loaders","settingsSlug","siteNameField","pageMetadata","slug","locale","page","payload","settings","getSettings","undefined","site","pagesSlug","base","homeSlug","order","separator","siteName","route","segments","slugs","prefix","type","id","archive","query","imageUrl","noindex","pageTitle","title"],"mappings":"AAOA,SAASA,YAAY,QAAQ,sBAAqB;AAClD,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,kBAAkB,QAAQ,0BAAyB;AAsD5D,8DAA8D,GAC9D,SAASC,eAAeC,GAAa;IACnC,MAAMC,QAASD,IAAIE,IAAI,EAA6CD;IACpE,IAAIA,SAAS,OAAOA,UAAU,YAAY,SAASA,OAAO;QACxD,OAAO,AAACA,MAA0BE,GAAG,IAAI;IAC3C;IACA,OAAO;AACT;AAEA;;;;;;;;;;;;;;;;;;;;;;;;CAwBC,GACD,OAAO,SAASC,mBAAmBC,IAA4B;IAC7D,MAAM,EACJC,OAAO,EACPC,aAAa,OAAO,EACpBC,MAAM,EACNC,OAAO,EACPC,OAAO,EACPC,eAAe,eAAe,EAC9BC,gBAAgB,UAAU,EAC3B,GAAGP;IAEJ,OAAO,eAAeQ,aAAa,EACjCC,IAAI,EACJC,MAAM,EACNC,IAAI,EACJC,OAAO,EACa;QACpB,MAAMC,WAAWR,SAASS,cAAc,MAAMT,QAAQS,WAAW,CAACJ,UAAUK;QAC5E,M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ACF"}
\ No newline at end of file
diff --git a/dist/modules/seo/index.d.ts b/dist/modules/seo/index.d.ts
index 8c7e3c8..a4c91be 100644
--- a/dist/modules/seo/index.d.ts
+++ b/dist/modules/seo/index.d.ts
@@ -12,7 +12,7 @@ export type { PageMetadata } from './buildMetadata.js';
export { buildNoindexField } from './buildNoindexField.js';
export { buildOrganizationJsonLd } from './buildOrganizationJsonLd.js';
export { AI_ASSISTANT_BOTS, AI_TRAINING_BOTS, buildRobots } from './buildRobots.js';
-export type { RobotsRules } from './buildRobots.js';
+export type { RobotsOptions, RobotsRules } from './buildRobots.js';
export { buildServiceJsonLd } from './buildServiceJsonLd.js';
export { buildSitemapEntries } from './buildSitemapEntries.js';
export type { SitemapEntry } from './buildSitemapEntries.js';
diff --git a/dist/modules/seo/index.js.map b/dist/modules/seo/index.js.map
index e6bd885..8b0d56d 100644
--- a/dist/modules/seo/index.js.map
+++ b/dist/modules/seo/index.js.map
@@ -1 +1 @@
-{"version":3,"sources":["../../../src/modules/seo/index.ts"],"sourcesContent":["export { buildAutoFillMetaHook } from './autoFillMeta.js'\nexport type { AutoFillMapping } from './autoFillMeta.js'\nexport { buildArticleJsonLd } from './buildArticleJsonLd.js'\nexport { buildBreadcrumbJsonLd } from './buildBreadcrumbJsonLd.js'\nexport { buildFaqJsonLd } from './buildFaqJsonLd.js'\nexport { buildIconsMetadata } from './buildIconsMetadata.js'\nexport { buildLlmsTxt } from './buildLlmsTxt.js'\nexport { buildLocalBusinessJsonLd } from './buildLocalBusinessJsonLd.js'\nexport { createManifestHandler } from './buildManifest.js'\nexport { buildMetadata } from './buildMetadata.js'\nexport type { PageMetadata } from './buildMetadata.js'\nexport { buildNoindexField } from './buildNoindexField.js'\nexport { buildOrganizationJsonLd } from './buildOrganizationJsonLd.js'\nexport { AI_ASSISTANT_BOTS, AI_TRAINING_BOTS, buildRobots } from './buildRobots.js'\nexport type { RobotsRules } from './buildRobots.js'\nexport { buildServiceJsonLd } from './buildServiceJsonLd.js'\nexport { buildSitemapEntries } from './buildSitemapEntries.js'\nexport type { SitemapEntry } from './buildSitemapEntries.js'\nexport { buildSitemapXml } from './buildSitemapXml.js'\nexport { buildSiteNavigationJsonLd } from './buildSiteNavigationJsonLd.js'\nexport { buildSpeakableJsonLd } from './buildSpeakableJsonLd.js'\nexport { buildSummaryField } from './buildSummaryField.js'\nexport { buildWebSiteJsonLd } from './buildWebSiteJsonLd.js'\nexport { composeTitle } from './composeTitle.js'\nexport type { TitleOrder } from './composeTitle.js'\nexport { createMetadataGenerator } from './createMetadataGenerator.js'\nexport { createPageMetadata } from './createPageMetadata.js'\nexport { buildHreflangAlternates } from './hreflang.js'\nexport { injectAutoFillMeta } from './injectAutoFillMeta.js'\nexport { injectSeoTabs } from './injectSeoTabs.js'\nexport { JsonLdGraph } from './JsonLdGraph.js'\nexport { readSiteMetaConfig } from './readSiteMetaConfig.js'\nexport type { SiteMetaConfig } from './readSiteMetaConfig.js'\nexport { createLlmsTxtRoute, createSitemapRouteHandler } from './routeHandlers.js'\nexport { buildSeoPlugin } from './seoPluginConfig.js'\nexport { slugsAcrossLocales } from './slugsAcrossLocales.js'\nexport type { SeoMeta, SeoOption } from './types.js'\nexport { validateFaviconField } from './validateFavicon.js'\n"],"names":["buildAutoFillMetaHook","buildArticleJsonLd","buildBreadcrumbJsonLd","buildFaqJsonLd","buildIconsMetadata","buildLlmsTxt","buildLocalBusinessJsonLd","createManifestHandler","buildMetadata","buildNoindexField","buildOrganizationJsonLd","AI_ASSISTANT_BOTS","AI_TRAINING_BOTS","buildRobots","buildServiceJsonLd","buildSitemapEntries","buildSitemapXml","buildSiteNavigationJsonLd","buildSpeakableJsonLd","buildSummaryField","buildWebSiteJsonLd","composeTitle","createMetadataGenerator","createPageMetadata","buildHreflangAlternates","injectAutoFillMeta","injectSeoTabs","JsonLdGraph","readSiteMetaConfig","createLlmsTxtRoute","createSitemapRouteHandler","buildSeoPlugin","slugsAcrossLocales","validateFaviconField"],"mappings":"AAAA,SAASA,qB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FillMeta.js'\nexport type { AutoFillMapping } from './autoFillMeta.js'\nexport { buildArticleJsonLd } from './buildArticleJsonLd.js'\nexport { buildBreadcrumbJsonLd } from './buildBreadcrumbJsonLd.js'\nexport { buildFaqJsonLd } from './buildFaqJsonLd.js'\nexport { buildIconsMetadata } from './buildIconsMetadata.js'\nexport { buildLlmsTxt } from './buildLlmsTxt.js'\nexport { buildLocalBusinessJsonLd } from './buildLocalBusinessJsonLd.js'\nexport { createManifestHandler } from './buildManifest.js'\nexport { buildMetadata } from './buildMetadata.js'\nexport type { PageMetadata } from './buildMetadata.js'\nexport { buildNoindexField } from './buildNoindexField.js'\nexport { buildOrganizationJsonLd } from './buildOrganizationJsonLd.js'\nexport { AI_ASSISTANT_BOTS, AI_TRAINING_BOTS, buildRobots } from './buildRobots.js'\nexport type { RobotsOptions, RobotsRules } from './buildRobots.js'\nexport { buildServiceJsonLd } from './buildServiceJsonLd.js'\nexport { buildSitemapEntries } from './buildSitemapEntries.js'\nexport type { SitemapEntry } from './buildSitemapEntries.js'\nexport { buildSitemapXml } from './buildSitemapXml.js'\nexport { buildSiteNavigationJsonLd } from './buildSiteNavigationJsonLd.js'\nexport { buildSpeakableJsonLd } from './buildSpeakableJsonLd.js'\nexport { buildSummaryField } from './buildSummaryField.js'\nexport { buildWebSiteJsonLd } from './buildWebSiteJsonLd.js'\nexport { composeTitle } from './composeTitle.js'\nexport type { TitleOrder } from './composeTitle.js'\nexport { createMetadataGenerator } from './createMetadataGenerator.js'\nexport { createPageMetadata } from './createPageMetadata.js'\nexport { buildHreflangAlternates } from './hreflang.js'\nexport { injectAutoFillMeta } from './injectAutoFillMeta.js'\nexport { injectSeoTabs } from './injectSeoTabs.js'\nexport { JsonLdGraph } from './JsonLdGraph.js'\nexport { readSiteMetaConfig } from './readSiteMetaConfig.js'\nexport type { SiteMetaConfig } from './readSiteMetaConfig.js'\nexport { createLlmsTxtRoute, createSitemapRouteHandler } from './routeHandlers.js'\nexport { buildSeoPlugin } from './seoPluginConfig.js'\nexport { slugsAcrossLocales } from './slugsAcrossLocales.js'\nexport type { SeoMeta, SeoOption } from './types.js'\nexport { validateFaviconField } from './validateFavicon.js'\n"],"names":["buildAutoFillMetaHook","buildArticleJsonLd","buildBreadcrumbJsonLd","buildFaqJsonLd","buildIconsMetadata","buildLlmsTxt","buildLocalBusinessJsonLd","createManifestHandler","buildMetadata","buildNoindexField","buildOrganizationJsonLd","AI_ASSISTANT_BOTS","AI_TRAINING_BOTS","buildRobots","buildServiceJsonLd","buildSitemapEntries","buildSitemapXml","buildSiteNavigationJsonLd","buildSpeakableJsonLd","buildSummaryField","buildWebSiteJsonLd","composeTitle","createMetadataGenerator","createPageMetadata","buildHreflangAlternates","injectAutoFillMeta","injectSeoTabs","JsonLdGraph","readSiteMetaConfig","createLlmsTxtRoute","createSitemapRouteHandler","buildSeoPlugin","slugsAcrossLocales","validateFaviconField"],"mappings":"AAAA,SAASA,qBAAqB,QAAQ,oBAAmB;AAEzD,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,qBAAqB,QAAQ,6BAA4B;AAClE,SAASC,cAAc,QAAQ,sBAAqB;AACpD,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,wBAAwB,QAAQ,gCAA+B;AACxE,SAASC,qBAAqB,QAAQ,qBAAoB;AAC1D,SAASC,aAAa,QAAQ,qBAAoB;AAElD,SAASC,iBAAiB,QAAQ,yBAAwB;AAC1D,SAASC,uBAAuB,QAAQ,+BAA8B;AACtE,SAASC,iBAAiB,EAAEC,gBAAgB,EAAEC,WAAW,QAAQ,mBAAkB;AAEnF,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,mBAAmB,QAAQ,2BAA0B;AAE9D,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,yBAAyB,QAAQ,iCAAgC;AAC1E,SAASC,oBAAoB,QAAQ,4BAA2B;AAChE,SAASC,iBAAiB,QAAQ,yBAAwB;AAC1D,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,YAAY,QAAQ,oBAAmB;AAEhD,SAASC,uBAAuB,QAAQ,+BAA8B;AACtE,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,uBAAuB,QAAQ,gBAAe;AACvD,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,WAAW,QAAQ,mBAAkB;AAC9C,SAASC,kBAAkB,QAAQ,0BAAyB;AAE5D,SAASC,kBAAkB,EAAEC,yBAAyB,QAAQ,qBAAoB;AAClF,SAASC,cAAc,QAAQ,uBAAsB;AACrD,SAASC,kBAAkB,QAAQ,0BAAyB;AAE5D,SAASC,oBAAoB,QAAQ,uBAAsB"}
\ No newline at end of file
diff --git a/dist/modules/seo/readSiteMetaConfig.d.ts b/dist/modules/seo/readSiteMetaConfig.d.ts
index c7d12ac..57abff2 100644
--- a/dist/modules/seo/readSiteMetaConfig.d.ts
+++ b/dist/modules/seo/readSiteMetaConfig.d.ts
@@ -23,9 +23,13 @@ export type SiteMetaConfig = {
* that the separator arrives unpadded, or that the home slug hides inside a
* relationship — it should receive a resolved config.
*/
-export declare function readSiteMetaConfig({ locale, payload, settingsSlug, siteNameField, }: {
+export declare function readSiteMetaConfig({ locale, pagesSlug, payload, settings: preloaded, settingsSlug, siteNameField, }: {
locale: string;
+ /** Collection holding the homepage. Default 'pages'. */
+ pagesSlug?: string;
payload: BasePayload;
+ /** SiteSettings already read for this locale (depth ≥ 1) — skips the read. */
+ settings?: null | Record;
settingsSlug?: string;
siteNameField?: string;
}): Promise;
diff --git a/dist/modules/seo/readSiteMetaConfig.js b/dist/modules/seo/readSiteMetaConfig.js
index f35e0f1..d8cdd4a 100644
--- a/dist/modules/seo/readSiteMetaConfig.js
+++ b/dist/modules/seo/readSiteMetaConfig.js
@@ -5,10 +5,10 @@
* whatever an editor set in the panel. Metadata generation shouldn't also know
* that the separator arrives unpadded, or that the home slug hides inside a
* relationship — it should receive a resolved config.
- */ export async function readSiteMetaConfig({ locale, payload, settingsSlug = 'site-settings', siteNameField = 'siteName' }) {
+ */ export async function readSiteMetaConfig({ locale, pagesSlug = 'pages', payload, settings: preloaded, settingsSlug = 'site-settings', siteNameField = 'siteName' }) {
// depth 1 populates the homepage relationship, so its slug is available
// without a second query.
- const settings = await payload.findGlobal({
+ const settings = preloaded ?? await payload.findGlobal({
slug: settingsSlug,
depth: 1,
locale: locale
@@ -23,7 +23,7 @@
try {
const homeDoc = await payload.findByID({
id: homepage.id,
- collection: 'pages',
+ collection: pagesSlug,
depth: 0,
locale: 'all'
});
diff --git a/dist/modules/seo/readSiteMetaConfig.js.map b/dist/modules/seo/readSiteMetaConfig.js.map
index 375f0bb..6cbea7e 100644
--- a/dist/modules/seo/readSiteMetaConfig.js.map
+++ b/dist/modules/seo/readSiteMetaConfig.js.map
@@ -1 +1 @@
-{"version":3,"sources":["../../../src/modules/seo/readSiteMetaConfig.ts"],"sourcesContent":["import type { BasePayload } from 'payload'\n\nimport type { TitleOrder } from './composeTitle.js'\n\ntype SettingsShape = {\n [key: string]: unknown\n homepage?: { id: number | string; slug?: unknown } | null | number | string\n titleOrder?: null | TitleOrder\n titleSeparator?: null | string\n}\n\nexport type SiteMetaConfig = {\n /**\n * Home slug per locale, e.g. { pl: 'strona-glowna', de: 'startseite' }. A map\n * (not a single string) so multilingual homepages collapse to root in EVERY\n * language — otherwise hreflang points other languages at '/de/startseite'\n * instead of '/de', breaking return tags (a real GSC error).\n */\n homeSlug?: Record\n order?: TitleOrder\n /** Padded separator, e.g. ' | ' — the panel stores the bare character. */\n separator?: string\n /** Global fallback meta description. */\n siteDescription?: null | string\n siteName: null | string\n}\n\n/**\n * Reads the site-wide inputs to title and URL composition from SiteSettings.\n *\n * Split out of metadata assembly because these are one concern with one source:\n * whatever an editor set in the panel. Metadata generation shouldn't also know\n * that the separator arrives unpadded, or that the home slug hides inside a\n * relationship — it should receive a resolved config.\n */\nexport async function readSiteMetaConfig({\n locale,\n payload,\n settingsSlug = 'site-settings',\n siteNameField = 'siteName',\n}: {\n locale: string\n payload: BasePayload\n settingsSlug?: string\n siteNameField?: string\n}): Promise {\n // depth 1 populates the homepage relationship, so its slug is available\n // without a second query.\n const settings = (await payload.findGlobal({\n slug: settingsSlug as never,\n depth: 1,\n locale: locale as never,\n })) as SettingsShape\n\n const homepage =\n settings.homepage && typeof settings.homepage === 'object' ? settings.homepage : null\n\n // Build the per-locale home slug map. The homepage's slug is localized, so a\n // single-locale read only gives THIS language's slug. Re-read the homepage\n // with locale:'all' to get every language's slug — needed so hreflang can\n // collapse each language's home to its root.\n let homeSlug: Record | undefined\n if (homepage?.id) {\n try {\n const homeDoc = (await payload.findByID({\n id: homepage.id,\n collection: 'pages' as never,\n depth: 0,\n locale: 'all' as never,\n })) as { slug?: unknown }\n const slugField = homeDoc.slug\n if (slugField && typeof slugField === 'object') {\n const map: Record = {}\n for (const [loc, value] of Object.entries(slugField as Record)) {\n if (typeof value === 'string') {map[loc] = value}\n }\n if (Object.keys(map).length > 0) {homeSlug = map}\n } else if (typeof slugField === 'string') {\n // Non-localized slug (same in every language) — key it by current locale;\n // buildLocalizedPath tolerates a partial map. Non-localized homepage\n // slugs are rare, so this branch is a safety net, not the norm.\n homeSlug = { [locale]: slugField }\n }\n } catch {\n // Fall back to the single-locale slug below.\n }\n }\n\n // Fallback: if the 'all' read didn't yield a map, use the current locale's slug\n // for at least this locale (better than nothing).\n if (!homeSlug && typeof homepage?.slug === 'string') {\n homeSlug = { [locale]: homepage.slug }\n }\n\n return {\n siteDescription: (settings.siteDescription as string | undefined) ?? null,\n siteName: (settings[siteNameField] as string | undefined) ?? null,\n // The panel stores '|'; titles need it padded.\n homeSlug,\n order: settings.titleOrder ?? undefined,\n separator: settings.titleSeparator ? ` ${settings.titleSeparator} ` : undefined,\n }\n}\n"],"names":["readSiteMetaConfig","locale","payload","settingsSlug","siteNameField","settings","findGlobal","slug","depth","homepage","homeSlug","id","homeDoc","findByID","collection","slugField","map","loc","value","Object","entries","keys","length","siteDescription","siteName","order","titleOrder","undefined","separator","titleSeparator"],"mappings":"AA2BA;;;;;;;CAOC,GACD,OAAO,eAAeA,mBAAmB,EACvCC,MAAM,EACNC,OAAO,EACPC,eAAe,eAAe,EAC9BC,gBAAgB,UAAU,EAM3B;IACC,wEAAwE;IACxE,0BAA0B;IAC1B,MAAMC,WAAY,MAAMH,QAAQI,UAAU,CAAC;QACzCC,MAAMJ;QACNK,OAAO;QACPP,QAAQA;IACV;IAEA,MAAMQ,WACJJ,SAASI,QAAQ,IAAI,OAAOJ,SAASI,QAAQ,KAAK,WAAWJ,SAASI,QAAQ,GAAG;IAEnF,6EAA6E;IAC7E,2EAA2E;IAC3E,0EAA0E;IAC1E,6CAA6C;IAC7C,IAAIC;IACJ,IAAID,UAAUE,IAAI;QAChB,IAAI;YACF,MAAMC,UAAW,MAAMV,QAAQW,QAAQ,CAAC;gBACtCF,IAAIF,SAASE,EAAE;gBACfG,YAAY;gBACZN,OAAO;gBACPP,QAAQ;YACV;YACA,MAAMc,YAAYH,QAAQL,IAAI;YAC9B,IAAIQ,aAAa,OAAOA,cAAc,UAAU;gBAC9C,MAAMC,MAA8B,CAAC;gBACrC,KAAK,MAAM,CAACC,KAAKC,MAAM,IAAIC,OAAOC,OAAO,CAACL,WAAuC;oBAC/E,IAAI,OAAOG,UAAU,UAAU;wBAACF,GAAG,CAACC,IAAI,GAAGC;oBAAK;gBAClD;gBACA,IAAIC,OAAOE,IAAI,CAACL,KAAKM,MAAM,GAAG,GAAG;oBAACZ,WAAWM;gBAAG;YAClD,OAAO,IAAI,OAAOD,cAAc,UAAU;gBACxC,0EAA0E;gBAC1E,qEAAqE;gBACrE,gEAAgE;gBAChEL,WAAW;oBAAE,CAACT,OAAO,EAAEc;gBAAU;YACnC;QACF,EAAE,OAAM;QACN,6CAA6C;QAC/C;IACF;IAEA,gFAAgF;IAChF,kDAAkD;IAClD,IAAI,CAACL,YAAY,OAAOD,UAAUF,SAAS,UAAU;QACnDG,WAAW;YAAE,CAACT,OAAO,EAAEQ,SAASF,IAAI;QAAC;IACvC;IAEA,OAAO;QACLgB,iBAAiB,AAAClB,SAASkB,eAAe,IAA2B;QACrEC,UAAU,AAACnB,QAAQ,CAACD,cAAc,IAA2B;QAC7D,+CAA+C;QAC/CM;QACAe,OAAOpB,SAASqB,UAAU,IAAIC;QAC9BC,WAAWvB,SAASwB,cAAc,GAAG,CAAC,CAAC,EAAExB,SAASwB,cAAc,CAAC,CAAC,CAAC,GAAGF;IACxE;AACF"}
\ No newline at end of file
+{"version":3,"sources":["../../../src/modules/seo/readSiteMetaConfig.ts"],"sourcesContent":["import type { BasePayload } from 'payload'\n\nimport type { TitleOrder } from './composeTitle.js'\n\ntype SettingsShape = {\n [key: string]: unknown\n homepage?: { id: number | string; slug?: unknown } | null | number | string\n titleOrder?: null | TitleOrder\n titleSeparator?: null | string\n}\n\nexport type SiteMetaConfig = {\n /**\n * Home slug per locale, e.g. { pl: 'strona-glowna', de: 'startseite' }. A map\n * (not a single string) so multilingual homepages collapse to root in EVERY\n * language — otherwise hreflang points other languages at '/de/startseite'\n * instead of '/de', breaking return tags (a real GSC error).\n */\n homeSlug?: Record\n order?: TitleOrder\n /** Padded separator, e.g. ' | ' — the panel stores the bare character. */\n separator?: string\n /** Global fallback meta description. */\n siteDescription?: null | string\n siteName: null | string\n}\n\n/**\n * Reads the site-wide inputs to title and URL composition from SiteSettings.\n *\n * Split out of metadata assembly because these are one concern with one source:\n * whatever an editor set in the panel. Metadata generation shouldn't also know\n * that the separator arrives unpadded, or that the home slug hides inside a\n * relationship — it should receive a resolved config.\n */\nexport async function readSiteMetaConfig({\n locale,\n pagesSlug = 'pages',\n payload,\n settings: preloaded,\n settingsSlug = 'site-settings',\n siteNameField = 'siteName',\n}: {\n locale: string\n /** Collection holding the homepage. Default 'pages'. */\n pagesSlug?: string\n payload: BasePayload\n /** SiteSettings already read for this locale (depth ≥ 1) — skips the read. */\n settings?: null | Record\n settingsSlug?: string\n siteNameField?: string\n}): Promise {\n // depth 1 populates the homepage relationship, so its slug is available\n // without a second query.\n const settings = (preloaded ??\n (await payload.findGlobal({\n slug: settingsSlug as never,\n depth: 1,\n locale: locale as never,\n }))) as SettingsShape\n\n const homepage =\n settings.homepage && typeof settings.homepage === 'object' ? settings.homepage : null\n\n // Build the per-locale home slug map. The homepage's slug is localized, so a\n // single-locale read only gives THIS language's slug. Re-read the homepage\n // with locale:'all' to get every language's slug — needed so hreflang can\n // collapse each language's home to its root.\n let homeSlug: Record | undefined\n if (homepage?.id) {\n try {\n const homeDoc = (await payload.findByID({\n id: homepage.id,\n collection: pagesSlug as never,\n depth: 0,\n locale: 'all' as never,\n })) as { slug?: unknown }\n const slugField = homeDoc.slug\n if (slugField && typeof slugField === 'object') {\n const map: Record = {}\n for (const [loc, value] of Object.entries(slugField as Record)) {\n if (typeof value === 'string') {map[loc] = value}\n }\n if (Object.keys(map).length > 0) {homeSlug = map}\n } else if (typeof slugField === 'string') {\n // Non-localized slug (same in every language) — key it by current locale;\n // buildLocalizedPath tolerates a partial map. Non-localized homepage\n // slugs are rare, so this branch is a safety net, not the norm.\n homeSlug = { [locale]: slugField }\n }\n } catch {\n // Fall back to the single-locale slug below.\n }\n }\n\n // Fallback: if the 'all' read didn't yield a map, use the current locale's slug\n // for at least this locale (better than nothing).\n if (!homeSlug && typeof homepage?.slug === 'string') {\n homeSlug = { [locale]: homepage.slug }\n }\n\n return {\n siteDescription: (settings.siteDescription as string | undefined) ?? null,\n siteName: (settings[siteNameField] as string | undefined) ?? null,\n // The panel stores '|'; titles need it padded.\n homeSlug,\n order: settings.titleOrder ?? undefined,\n separator: settings.titleSeparator ? ` ${settings.titleSeparator} ` : undefined,\n }\n}\n"],"names":["readSiteMetaConfig","locale","pagesSlug","payload","settings","preloaded","settingsSlug","siteNameField","findGlobal","slug","depth","homepage","homeSlug","id","homeDoc","findByID","collection","slugField","map","loc","value","Object","entries","keys","length","siteDescription","siteName","order","titleOrder","undefined","separator","titleSeparator"],"mappings":"AA2BA;;;;;;;CAOC,GACD,OAAO,eAAeA,mBAAmB,EACvCC,MAAM,EACNC,YAAY,OAAO,EACnBC,OAAO,EACPC,UAAUC,SAAS,EACnBC,eAAe,eAAe,EAC9BC,gBAAgB,UAAU,EAU3B;IACC,wEAAwE;IACxE,0BAA0B;IAC1B,MAAMH,WAAYC,aACf,MAAMF,QAAQK,UAAU,CAAC;QACxBC,MAAMH;QACNI,OAAO;QACPT,QAAQA;IACV;IAEF,MAAMU,WACJP,SAASO,QAAQ,IAAI,OAAOP,SAASO,QAAQ,KAAK,WAAWP,SAASO,QAAQ,GAAG;IAEnF,6EAA6E;IAC7E,2EAA2E;IAC3E,0EAA0E;IAC1E,6CAA6C;IAC7C,IAAIC;IACJ,IAAID,UAAUE,IAAI;QAChB,IAAI;YACF,MAAMC,UAAW,MAAMX,QAAQY,QAAQ,CAAC;gBACtCF,IAAIF,SAASE,EAAE;gBACfG,YAAYd;gBACZQ,OAAO;gBACPT,QAAQ;YACV;YACA,MAAMgB,YAAYH,QAAQL,IAAI;YAC9B,IAAIQ,aAAa,OAAOA,cAAc,UAAU;gBAC9C,MAAMC,MAA8B,CAAC;gBACrC,KAAK,MAAM,CAACC,KAAKC,MAAM,IAAIC,OAAOC,OAAO,CAACL,WAAuC;oBAC/E,IAAI,OAAOG,UAAU,UAAU;wBAACF,GAAG,CAACC,IAAI,GAAGC;oBAAK;gBAClD;gBACA,IAAIC,OAAOE,IAAI,CAACL,KAAKM,MAAM,GAAG,GAAG;oBAACZ,WAAWM;gBAAG;YAClD,OAAO,IAAI,OAAOD,cAAc,UAAU;gBACxC,0EAA0E;gBAC1E,qEAAqE;gBACrE,gEAAgE;gBAChEL,WAAW;oBAAE,CAACX,OAAO,EAAEgB;gBAAU;YACnC;QACF,EAAE,OAAM;QACN,6CAA6C;QAC/C;IACF;IAEA,gFAAgF;IAChF,kDAAkD;IAClD,IAAI,CAACL,YAAY,OAAOD,UAAUF,SAAS,UAAU;QACnDG,WAAW;YAAE,CAACX,OAAO,EAAEU,SAASF,IAAI;QAAC;IACvC;IAEA,OAAO;QACLgB,iBAAiB,AAACrB,SAASqB,eAAe,IAA2B;QACrEC,UAAU,AAACtB,QAAQ,CAACG,cAAc,IAA2B;QAC7D,+CAA+C;QAC/CK;QACAe,OAAOvB,SAASwB,UAAU,IAAIC;QAC9BC,WAAW1B,SAAS2B,cAAc,GAAG,CAAC,CAAC,EAAE3B,SAAS2B,cAAc,CAAC,CAAC,CAAC,GAAGF;IACxE;AACF"}
\ No newline at end of file
diff --git a/docs/README.md b/docs/README.md
index d59d555..8fcccd2 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -22,6 +22,7 @@ Szczegóły API — jeden plik na moduł:
| Formularze, useForm, honeypot | [forms.md](./forms.md) |
| Hooki | [hooks.md](./hooks.md) |
| i18n, proxy, przełącznik języka | [i18n.md](./i18n.md) |
+| Linki / CTA: buildLinkField, buildLinksField, resolveLinkHref | [links.md](./links.md) |
| Serwer MCP strony | [mcp.md](./mcp.md) |
| Komunikaty formularzy | [notifications.md](./notifications.md) |
| Strony systemowe, 404, generateStaticParams | [pages.md](./pages.md) |
diff --git a/docs/agent/AGENT.md b/docs/agent/AGENT.md
index 593dd5f..0716165 100644
--- a/docs/agent/AGENT.md
+++ b/docs/agent/AGENT.md
@@ -25,7 +25,7 @@
ląduje w `` i SEO pada.
5. **Minimum kolekcji.** Users są wbudowane, dane firmy/nawigacja to globale,
FAQ/hero to bloki.
-6. **Sekcja = kompozycja prymitywów.** `linksField()` + ``, upload +
+6. **Sekcja = kompozycja prymitywów.** `buildLinksField()` + ``, upload +
``, `` + ``. Zero pól `ctaLabel`/`pdfUrl`.
7. **Renderery z pluginu:** `RenderBlocks` (nie `switch`), `RenderRichText` (nie
własny parser Lexical), `useForm` (nie ręczna hydraulika formularza).
@@ -74,7 +74,7 @@ gatingiem zgody (plugin ma opcję `defer`).
|---|---|---|
| Tekst | tekst w JSX, `if (locale === 'pl')`, tablice tekstów w kodzie | pole `localized: true` z panelu |
| Obraz / plik | `import x from '@/assets/…'`, `src="/images/…"`, URL pliku w polu `text` | `upload → media` + `` / link typu `file` |
-| Link | `href="/pl/kontakt"`, menu jako tablica, mapa `localizedRoutes` | `linkField()` + ``, `getLocalizedSlugs`, `getSystemPagePath`, nawigacja jako relationship → pages |
+| Link | `href="/pl/kontakt"`, menu jako tablica, mapa `localizedRoutes` | `buildLinkField()` + ``, `getLocalizedSlugs`, `getSystemPagePath`, nawigacja jako relationship → pages |
| Konfiguracja | `locale as 'pl' \| 'en'`, zaszyty slug kolekcji, lista języków `['pl','en']` | `i18n.config.ts`, `locale as never`, lista z configu |
| Dane firmy | NIP, adres, telefon, nazwa w kodzie | global (`siteSettings` / `company`) |
| Infrastruktura | domena, klucz, bucket w kodzie | `.env` |
@@ -105,7 +105,7 @@ src/
sitemap.ts, robots.ts # z lib/content (+ force-dynamic na sitemap)
api/health/route.ts # createHealthRoute
instrumentation.ts # assertEnv(ipalEnvRules({...}))
- fields/ # wspólne pola: link.ts, sectionHeader.ts, sectionSettings.ts
+ fields/ # sectionHeader.ts, sectionSettings.ts (linki: z pluginu)
components/
ui/ # prymitywy: CMSLink, Button, Media, Section, SectionHeader
layout/ # Header, Footer, MobileNav (§6.8)
@@ -115,7 +115,6 @@ src/
collections/ # Pages.ts, Media.ts (+ treść tylko gdy wymagana)
globals/ # Header.ts, Footer.ts, Company.ts
lib/content.ts # createContentHelpers — JEDYNY dostęp do Payloada
- lib/links.ts # resolveLinkHref
lib/navigation.ts # resolveNav → dane dla menu
i18n.config.ts # locale — jedno źródło
payload.config.ts
@@ -222,7 +221,8 @@ Trzy problemy, których nie wolno powtarzać: **zoo pól CTA** (`ctaLabel`,
### 6.1 Trzy warstwy
```
-src/fields/ WARSTWA 1 — wspólne pola schematu (link, header, settings)
+WARSTWA 1 — wspólne pola: linki z pluginu (buildLinkField, buildLinksField)
+ + src/fields/ projektu (sectionHeader, sectionSettings)
src/components/ui/ WARSTWA 2 — prymitywy UI (CMSLink, Button, Media, Section, SectionHeader)
src/blocks/X/ WARSTWA 3 — sekcja = kompozycja warstw 1 i 2
```
@@ -231,364 +231,51 @@ musisz zmieniać 12 bloków, architektura jest zła.
### 6.2 Warstwa 1 — wspólne pola
-`src/fields/link.ts` — **jedyny sposób na link/CTA**:
+**Link / CTA — z pluginu** ([links.md](../links.md)), nigdy kopia w projekcie:
```ts
-import type { ArrayField, Field, GroupField } from 'payload'
+import { buildLinkField, buildLinksField } from '@intecion/ipal-kit'
-export type LinkAppearance = 'primary' | 'secondary' | 'link'
-
-type LinkFieldOptions = {
- name?: string
- /** Which visual styles the editor may pick. false → no appearance select. */
- appearances?: LinkAppearance[] | false
- /** Label hidden for links that wrap something (a card, an image). */
- disableLabel?: boolean
- required?: boolean
-}
-
-const URL_PATTERN = /^(https?:\/\/|mailto:|tel:|#)/
-
-export function linkField({
- name = 'link',
- appearances = ['primary', 'secondary', 'link'],
- disableLabel = false,
- required = false,
-}: LinkFieldOptions = {}): GroupField {
- const fields: Field[] = [
- {
- type: 'row',
- fields: [
- {
- name: 'type',
- type: 'radio',
- defaultValue: 'internal',
- options: [
- { label: 'Page', value: 'internal' },
- { label: 'URL', value: 'external' },
- { label: 'File', value: 'file' },
- ],
- admin: { layout: 'horizontal', width: '50%' },
- },
- {
- name: 'newTab',
- type: 'checkbox',
- label: 'Open in new tab',
- admin: { width: '50%', style: { alignSelf: 'flex-end' } },
- },
- ],
- },
- {
- name: 'page',
- type: 'relationship',
- relationTo: 'pages',
- required,
- admin: { condition: (_, s) => s?.type === 'internal' },
- },
- {
- name: 'url',
- type: 'text',
- required,
- validate: (v: string | null | undefined) =>
- !v || URL_PATTERN.test(v) || 'Use https://…, mailto:, tel: or #anchor',
- admin: {
- condition: (_, s) => s?.type === 'external',
- description: 'Full URL (https://…), mailto:, tel: or #section-anchor.',
- },
- },
- {
- name: 'file',
- type: 'upload',
- relationTo: 'media',
- required,
- admin: {
- condition: (_, s) => s?.type === 'file',
- description: 'Upload a PDF / document / image. Never paste a file URL.',
- },
- },
- ]
-
- if (!disableLabel) {
- fields.push({ name: 'label', type: 'text', localized: true, required })
- }
-
- if (appearances && appearances.length) {
- fields.push({
- name: 'appearance',
- type: 'select',
- defaultValue: appearances[0],
- options: appearances.map((a) => ({ label: a, value: a })),
- })
- }
-
- return {
- name,
- type: 'group',
- interfaceName: 'CmsLink', // → `CmsLink` type in payload-types.ts
- admin: { hideGutter: true },
- fields,
- }
-}
-
-/** 0..N buttons. Use this for every "CTA(s)" in a section. */
-export function linksField({
- name = 'links',
- maxRows = 2,
- appearances,
-}: { name?: string; maxRows?: number; appearances?: LinkAppearance[] } = {}): ArrayField {
- return {
- name,
- type: 'array',
- maxRows,
- admin: { initCollapsed: true },
- fields: [linkField({ appearances })],
- }
-}
+buildLinksField() // pole `links`: 0–2 przyciski sekcji
+buildLinkField() // pole `link`: pojedynczy link
+buildLinkField({ disableLabel: true, appearances: false }) // klikalna cała karta
```
+Typ linku: strona / URL (też mailto, tel, #anchor) / **plik** (upload). Plik do
+pobrania = link typu `file`, nigdy pole `pdfUrl`. W `payload-types.ts`: `CmsLink`.
-Całe CTA w bloku to jedna linia: `linksField()`. Karta klikalna w całości:
-`linkField({ disableLabel: true, appearances: false })`.
+**Obraz / wideo:** `{ name: 'media', type: 'upload', relationTo: 'media' }`. Kolekcja
+`media` dopuszcza PDF, ma `alt` (required, localized) i `normalizeFilenameHook`.
-**Pliki i obrazy:** `{ name: 'media', type: 'upload', relationTo: 'media' }`.
-Kolekcja `media` dopuszcza PDF (`upload.mimeTypes: ['image/*', 'application/pdf',
-'video/mp4']`), ma `alt` (required, localized) i `normalizeFilenameHook`.
-„Pobierz cennik (PDF)” to **link typu `file`**, nie osobne pole `pdf`/`pdfUrl`.
-
-`src/fields/sectionHeader.ts` i `src/fields/sectionSettings.ts`:
-
-```ts
-import type { GroupField } from 'payload'
-
-export function sectionHeaderField(name = 'header'): GroupField {
- return {
- name,
- type: 'group',
- interfaceName: 'SectionHeaderData',
- fields: [
- { name: 'eyebrow', type: 'text', localized: true },
- { name: 'heading', type: 'text', localized: true },
- { name: 'intro', type: 'textarea', localized: true },
- ],
- }
-}
-
-export function sectionSettingsField(): GroupField {
- return {
- name: 'settings',
- type: 'group',
- interfaceName: 'SectionSettings',
- admin: { position: 'sidebar' },
- fields: [
- {
- name: 'anchor',
- type: 'text',
- admin: { description: 'Section id for #links and section nav, e.g. "pricing".' },
- },
- {
- name: 'background',
- type: 'select',
- defaultValue: 'default',
- options: ['default', 'muted', 'inverted'].map((v) => ({ label: v, value: v })),
- },
- ],
- }
-}
-```
-
-Każda sekcja ma `sectionSettingsField()` — żadnych `bgColor`, `darkMode`,
-`sectionId` w poszczególnych blokach. Etykiety pól po angielsku (panel jest EN).
+**W projekcie (`src/fields/`)** — dwa małe helpery, kod w [kod-sekcji.md](./skills/ipal-block/resources/kod-sekcji.md):
+- `sectionHeaderField()` → grupa `header`: `eyebrow`, `heading`, `intro` (localized),
+- `sectionSettingsField()` → grupa `settings` (sidebar): `anchor`, `background`.
+Każda sekcja ma `sectionSettingsField()` — żadnych `bgColor`, `sectionId` per blok.
+Etykiety pól po angielsku (panel jest EN).
### 6.3 Warstwa 2 — prymitywy UI
-`src/lib/links.ts` — jedyne miejsce, które zna typy linków:
+Kod 1:1: [kod-sekcji.md](./skills/ipal-block/resources/kod-sekcji.md). Każdy ma jedno zadanie:
-```ts
-import type { CmsLink } from '@/payload-types'
-import { buildLocalizedPath } from '@intecion/ipal-kit'
-import { i18nConfig } from '@/i18n.config'
-
-export function resolveLinkHref(
- link: CmsLink | null | undefined,
- locale: string,
- homeSlug?: string,
-): string | null {
- if (!link) return null
- if (link.type === 'external') return link.url || null
- if (link.type === 'file') {
- const file = link.file
- return file && typeof file === 'object' && file.url ? file.url : null
- }
- // internal — `page` must be populated (block depth ≥ 2), not a bare ID
- const page = link.page
- if (!page || typeof page !== 'object' || typeof page.slug !== 'string') return null
- return (
- buildLocalizedPath({
- slugs: { [locale]: page.slug },
- locale,
- config: i18nConfig,
- ...(homeSlug ? { homeSlug } : {}),
- }) ?? null
- )
-}
-```
-
-`src/components/ui/CMSLink.tsx` — **każdy** link/przycisk z panelu:
-
-```tsx
-import Link from 'next/link'
-import type { ReactNode } from 'react'
-import type { CmsLink } from '@/payload-types'
-import { resolveLinkHref } from '@/lib/links'
-import { getSettings } from '@/lib/content'
-import { buttonClass } from './Button'
-
-type Props = {
- link: CmsLink | null | undefined
- locale: string
- className?: string
- /** For wrapping links (cards): content instead of link.label. */
- children?: ReactNode
-}
-
-export async function CMSLink({ link, locale, className, children }: Props) {
- const settings = await getSettings(locale) // react cache → one query per request
- const home = settings?.homepage
- const homeSlug = home && typeof home === 'object' && typeof home.slug === 'string' ? home.slug : undefined
-
- const href = resolveLinkHref(link, locale, homeSlug)
- const content = children ?? link?.label
- if (!link || !href || !content) return null
-
- const cls = [link.appearance ? buttonClass(link.appearance) : '', className]
- .filter(Boolean)
- .join(' ')
- const newTab = link.newTab || link.type === 'file'
- const targetProps = newTab ? { target: '_blank', rel: 'noopener noreferrer' } : {}
-
- if (link.type === 'internal') {
- return {content}
- }
- return {content}
-}
-```
-
-`src/components/ui/Button.tsx` — warianty jako mapa, nie ternary:
-
-```ts
-import type { LinkAppearance } from '@/fields/link'
-
-const VARIANTS: Record = {
- primary: 'btn btn-primary',
- secondary: 'btn btn-secondary',
- link: 'link-arrow',
-}
-
-export function buttonClass(appearance: LinkAppearance): string {
- return VARIANTS[appearance]
-}
-```
-
-`src/components/ui/Media.tsx` — **każdy** obraz/wideo z panelu:
-
-```tsx
-import Image from 'next/image'
-import type { Media as MediaDoc } from '@/payload-types'
-
-type Props = {
- resource: MediaDoc | string | number | null | undefined
- sizes?: string
- priority?: boolean
- className?: string
-}
-
-export function Media({ resource, sizes = '100vw', priority = false, className }: Props) {
- if (!resource || typeof resource !== 'object' || !resource.url) return null
- const { url, alt, width, height, mimeType } = resource
-
- if (mimeType?.startsWith('video/')) {
- return
- }
- if (!width || !height) return null // non-image file (PDF) — use CMSLink type 'file'
-
- return (
-
- )
-}
-```
-
-`Section.tsx` i `SectionHeader.tsx`:
-
-```tsx
-// src/components/ui/Section.tsx
-import type { ReactNode } from 'react'
-import type { SectionSettings } from '@/payload-types'
-
-const BACKGROUNDS: Record, string> = {
- default: 'bg-background',
- muted: 'bg-muted',
- inverted: 'bg-foreground text-background',
-}
-
-export function Section({ settings, children }: { settings?: SectionSettings | null; children: ReactNode }) {
- return (
-
- )
-}
-```
-
-```tsx
-// src/components/ui/SectionHeader.tsx
-import type { SectionHeaderData } from '@/payload-types'
-
-export function SectionHeader({ header, as: H = 'h2' }: { header?: SectionHeaderData | null; as?: 'h1' | 'h2' }) {
- if (!header?.heading && !header?.eyebrow && !header?.intro) return null
- return (
-
- {header.eyebrow && {header.eyebrow}
}
- {header.heading && {header.heading} }
- {header.intro && {header.intro}
}
-
- )
-}
-```
-
-**`locale` dla każdego bloku — raz, w trasie strony:**
+| Prymityw | Robi | Zamiast |
+|---|---|---|
+| `CMSLink` (async, serwer) | każdy link z panelu: `resolveLinkHref` z pluginu + styl z `Button` + `newTab`/plik | ``, ` ` w sekcjach |
+| `Button.tsx` | `Record` z klasami wariantów | łańcuchy ternary, style przycisków w sekcjach |
+| `Media` | każdy obraz/wideo z panelu (`next/image`, alt z dokumentu) | ` ` |
+| `Section` | `id` z anchora, tło z mapy, kontener | ręczne `` |
+| `SectionHeader` | eyebrow + nagłówek (`h1`/`h2`) + intro | luźne nagłówki w każdej sekcji |
+**`locale` dla bloków — raz, w trasie strony** (nigdy `headers()` w komponentach):
```tsx
const enhanceProps = ({ block }: { block: { blockType: string } }) => ({
locale,
...(block.blockType === 'formBlock' ? { turnstileSiteKey } : {}),
})
-
```
### 6.4 Warstwa 3 — sekcja = kompozycja
-```ts
-// src/blocks/Hero/config.ts
-import type { Block } from 'payload'
-import { linksField } from '@/fields/link'
-import { sectionHeaderField } from '@/fields/sectionHeader'
-import { sectionSettingsField } from '@/fields/sectionSettings'
-
-export const HeroBlock: Block = {
- slug: 'hero',
- interfaceName: 'HeroBlock',
- labels: { singular: 'Hero', plural: 'Heroes' },
- fields: [
- sectionHeaderField(),
- { name: 'media', type: 'upload', relationTo: 'media' },
- linksField(),
- sectionSettingsField(),
- ],
-}
-```
+Wzorcowy kształt sekcji (cały komponent; schemat `config.ts` i przykład z
+powtarzalnymi elementami — `FeatureGrid` + `FeatureCard` — w [kod-sekcji.md](./skills/ipal-block/resources/kod-sekcji.md)):
```tsx
// src/blocks/Hero/Component.tsx — cały komponent
@@ -617,66 +304,17 @@ export function Hero({ header, media, links, settings, locale }: HeroBlock & { l
}
```
-Sekcja z powtarzalnymi elementami — element tablicy to podkomponent:
-
-```ts
-// src/blocks/FeatureGrid/config.ts (fields)
-sectionHeaderField(),
-{
- name: 'items',
- type: 'array',
- interfaceName: 'FeatureItem',
- fields: [
- { name: 'media', type: 'upload', relationTo: 'media' },
- { name: 'heading', type: 'text', localized: true, required: true },
- { name: 'text', type: 'textarea', localized: true },
- linkField({ appearances: ['link'] }),
- ],
-},
-linksField({ maxRows: 1 }),
-sectionSettingsField(),
-```
-
-```tsx
-// src/blocks/FeatureGrid/FeatureCard.tsx
-export function FeatureCard({ item, locale }: { item: FeatureItem; locale: string }) {
- return (
-
-
- {item.heading}
- {item.text && {item.text}
}
-
-
- )
-}
-
-// src/blocks/FeatureGrid/Component.tsx
-export function FeatureGrid({ header, items, links, settings, locale }: FeatureGridBlock & { locale: string }) {
- return (
-
-
-
- {items?.map((item) => )}
-
- {links?.map(({ id, link }) => )}
-
- )
-}
-```
-
**Wydziel podkomponent, gdy którekolwiek jest prawdą:** ten sam JSX 2+ razy;
-element `items[]` ma >5 linii markupu; `Component.tsx` >80 linii JSX; jest stan/
-interakcja (accordion, slider, tabs → osobny `'use client'`). Podkomponent
-jednej sekcji → w jej folderze; używany w 2+ sekcjach → `src/components/ui/`.
-Ikony: upload albo `select` z mapą w `src/components/icons` — nigdy SVG wklejone
-w sekcję.
+element `items[]` ma >5 linii markupu (→ `Card.tsx`); `Component.tsx` >80
+linii JSX; jest stan/interakcja (→ osobny plik `'use client'`, §6.9).
+Podkomponent jednej sekcji → w jej folderze; używany w 2+ sekcjach → `src/components/ui/`.
### 6.5 Stałe słownictwo pól
| Rzecz | Nazwa pola | ZAKAZANE |
|---|---|---|
-| Przyciski / CTA sekcji | `links` (`linksField()`) | `cta`, `ctaLabel`, `ctaHref`, `ctaTarget`, `cta2…`, `buttons`, `buttonText`, `buttonUrl`, `primaryCta` |
-| Pojedynczy link (karta, element) | `link` (`linkField()`) | `href`, `url`, `target`, `linkTo`, `readMoreUrl` |
+| Przyciski / CTA sekcji | `links` (`buildLinksField()`) | `cta`, `ctaLabel`, `ctaHref`, `ctaTarget`, `cta2…`, `buttons`, `buttonText`, `buttonUrl`, `primaryCta` |
+| Pojedynczy link (karta, element) | `link` (`buildLinkField()`) | `href`, `url`, `target`, `linkTo`, `readMoreUrl` |
| Obraz / wideo | `media` | `image`, `img`, `imageUrl`, `photo`, `bgImage`, `heroImage` |
| Plik do pobrania | `link` typu `file` | osobne `pdf`, `pdfUrl`, `file`, `download`, `attachment` |
| Nagłówek sekcji | `header` (`sectionHeaderField()`) | luźne `title`, `headline`, `sectionTitle`, `subheading`, `subtitle` |
@@ -697,7 +335,7 @@ Wyjątek tylko przy dwóch rzeczach tego samego rodzaju o różnej roli
{ name: 'secondaryCtaTarget', type: 'relationship', relationTo: 'pages' },
{ name: 'pdfUrl', type: 'text' },
// DOBRZE
-linksField({ maxRows: 3 })
+buildLinksField({ maxRows: 3 })
```
```tsx
// ŹLE — sekcja sama składa href i stylizuje przycisk
@@ -716,7 +354,7 @@ className={v === 'a' ? 'x' : v === 'b' ? 'y' : 'z'}
### 6.7 Refaktor sekcji-monolitu
1. Spisz, co sekcja wyświetla (nagłówek, obrazy, przyciski, powtórzenia).
-2. Schemat wg §6.5; CTA → `linksField()`.
+2. Schemat wg §6.5; CTA → `buildLinksField()`.
3. **Zmiana nazw pól gubi treść w bazie.** Projekt z treścią → najpierw migracja
(stare pole → nowe), potem usunięcie starych. Pusty projekt → sama zmiana.
4. Komponent: ``, ``, ``, ``,
@@ -725,173 +363,19 @@ className={v === 'a' ? 'x' : v === 'b' ? 'y' : 'z'}
### 6.8 Header i Footer (globale nawigacji)
-Nawigacja, stopka i dane firmy to **globale projektu** (model zależy od klienta
-i kraju), budowane z tych samych wspólnych pól co sekcje. Logo i nazwa są w
-Site Settings — nie duplikuj ich w Header.
+Kod (globale, `resolveNav`, `Header`, `Footer`, `MobileNav`): [kod-nawigacji.md](./skills/ipal-nav/resources/kod-nawigacji.md).
+Skill: **ipal-nav**.
-```ts
-// src/globals/Header.ts
-import type { GlobalConfig } from 'payload'
-import { linkField, linksField } from '@/fields/link'
-
-export const Header: GlobalConfig = {
- slug: 'header',
- access: { read: () => true },
- fields: [
- {
- name: 'navItems',
- type: 'array',
- maxRows: 8,
- fields: [
- linkField({ appearances: false }),
- {
- name: 'subItems', // jeden poziom podmenu — głębiej nie budujemy
- type: 'array',
- maxRows: 10,
- fields: [linkField({ appearances: false })],
- },
- ],
- },
- linksField({ maxRows: 1 }), // przycisk CTA w nagłówku
- {
- name: 'menuLabel',
- type: 'text',
- localized: true,
- admin: { description: 'Accessible label of the mobile menu button, e.g. "Menu".' },
- },
- ],
-}
-```
-
-```ts
-// src/globals/Footer.ts
-import type { GlobalConfig } from 'payload'
-import { linkField } from '@/fields/link'
-
-export const Footer: GlobalConfig = {
- slug: 'footer',
- access: { read: () => true },
- fields: [
- {
- name: 'columns',
- type: 'array',
- maxRows: 4,
- fields: [
- { name: 'heading', type: 'text', localized: true },
- { name: 'items', type: 'array', fields: [linkField({ appearances: false })] },
- ],
- },
- { name: 'note', type: 'textarea', localized: true }, // np. „Wszelkie prawa zastrzeżone”
- ],
-}
-```
-
-- **Linki prawne w stopce** (polityka, cookies, regulamin) renderuj z ról System
- Pages (`getSystemPagePath` + tytuł strony) — nie dodawaj ich ręcznie do `columns`.
-- **Dane firmy** (nazwa, adres, NIP/ABN, telefon) — global `company` projektu;
- stopka i JSON-LD czytają z niego. Rok w copyright licz w kodzie
- (`new Date().getFullYear()`), nazwę bierz z globala.
-- **Odświeżanie:** global zmienia się na każdej stronie → hook `afterChange`
- z `revalidatePath('/', 'layout')` (hooks.md).
-
-Linki rozwiązuj **na serwerze** do zwykłych danych, a do klienta (menu mobilne)
-przekazuj tylko `{ href, label, newTab }` — komponent kliencki nie może wołać
-`CMSLink` (to async server component).
-
-```ts
-// src/lib/navigation.ts
-import type { CmsLink } from '@/payload-types'
-import { resolveLinkHref } from '@/lib/links'
-import { getSettings } from '@/lib/content'
-
-export type NavItem = { href: string; label: string; newTab: boolean; subItems: NavItem[] }
-
-type NavSource = { link?: CmsLink | null; subItems?: { link?: CmsLink | null }[] | null }
-
-function toNavItem(link: CmsLink | null | undefined, locale: string, homeSlug?: string): NavItem | null {
- const href = resolveLinkHref(link, locale, homeSlug)
- if (!link || !href || !link.label) return null
- return { href, label: link.label, newTab: Boolean(link.newTab), subItems: [] }
-}
-
-export async function resolveNav(items: NavSource[] | null | undefined, locale: string): Promise {
- const settings = await getSettings(locale)
- const home = settings?.homepage
- const homeSlug = home && typeof home === 'object' && typeof home.slug === 'string' ? home.slug : undefined
-
- return (items ?? []).flatMap((item) => {
- const node = toNavItem(item.link, locale, homeSlug)
- if (!node) return []
- node.subItems = (item.subItems ?? []).flatMap((sub) => {
- const child = toNavItem(sub.link, locale, homeSlug)
- return child ? [child] : []
- })
- return [node]
- })
-}
-```
-
-```tsx
-// src/components/layout/Header.tsx — serwer
-import Link from 'next/link'
-import type { Header as HeaderData } from '@/payload-types'
-import { resolveNav } from '@/lib/navigation'
-import { CMSLink } from '@/components/ui/CMSLink'
-import { MobileNav } from './MobileNav'
-
-export async function Header({ header, locale }: { header: HeaderData; locale: string }) {
- const items = await resolveNav(header.navItems, locale)
- return (
-
-
- {/* logo: Site Settings → */}
-
- {items.map((item) => (
-
-
- {item.label}
-
-
- ))}
-
- {header.links?.map(({ id, link }) => )}
-
-
-
- )
-}
-```
-
-```tsx
-// src/components/layout/MobileNav.tsx — klient, tylko stan otwarcia
-'use client'
-import { useState } from 'react'
-import Link from 'next/link'
-import type { NavItem } from '@/lib/navigation' // import TYPU — nie ciągnie kodu serwera
-
-export function MobileNav({ items, menuLabel }: { items: NavItem[]; menuLabel: string }) {
- const [open, setOpen] = useState(false)
- return (
-
-
setOpen(!open)}>
- ☰
-
- {open && (
-
- {items.map((item) => (
-
- setOpen(false)}>{item.label}
-
- ))}
-
- )}
-
- )
-}
-```
-
-Header/Footer pobierasz w `[locale]/layout.tsx` (przez cached getter w
-`lib/`) i podajesz jako props — layout to jedyne miejsce, które je składa.
+- Nawigacja, stopka, dane firmy = **globale projektu** (`header`, `footer`, `company`),
+ zbudowane z `buildLinkField` — model danych firmy zależy od kraju (NIP/ABN/EIN).
+- Menu: jeden poziom podmenu, nie głębiej. CTA w nagłówku = `links`.
+- Logo i nazwa z Site Settings — nie duplikuj pól w Header.
+- **Linki prawne w stopce** z ról System Pages (`getSystemPagePath`), nie ręcznie.
+- Linki rozwiązuj **na serwerze** (`resolveNav` → `{ href, label, newTab }`); do
+ komponentu klienckiego idą tylko proste dane — `CMSLink` jest serwerowy.
+- Etykiety a11y (przycisk menu) — pola w panelu.
+- Global zmieniany na każdej stronie → `afterChange` z `revalidatePath('/', 'layout')`.
+- Globale pobiera tylko `[locale]/layout.tsx` i podaje jako props.
### 6.9 Komponenty klienckie (`'use client'`)
@@ -917,64 +401,21 @@ Header/Footer pobierasz w `[locale]/layout.tsx` (przez cached getter w
### 6.10 Ikony
-Dwa źródła, nic pomiędzy:
-- **Dowolna grafika od klienta** → upload do `media` + `` (także logo, ikony SVG marki).
-- **Stały zestaw ikon UI** → pole `select` + mapa `lucide-react`:
-
-```ts
-// src/components/icons/names.ts — same nazwy, importowane przez config bloku
-export const ICON_NAMES = ['phone', 'mail', 'mapPin', 'clock', 'check'] as const
-export type IconName = (typeof ICON_NAMES)[number]
-export const iconField = {
- name: 'icon',
- type: 'select',
- options: ICON_NAMES.map((value) => ({ label: value, value })),
-} as const
-```
-```tsx
-// src/components/icons/Icon.tsx — mapa, importowana tylko przez komponenty
-import { Check, Clock, Mail, MapPin, Phone, type LucideIcon } from 'lucide-react'
-import type { IconName } from './names'
-
-const ICONS: Record = { phone: Phone, mail: Mail, mapPin: MapPin, clock: Clock, check: Check }
-
-export function Icon({ name, className }: { name?: IconName | null; className?: string }) {
- if (!name) return null
- const Component = ICONS[name]
- return
-}
-```
-Nazwy są osobno, żeby config bloku (`payload.config`) nie importował komponentów
-React. **Nigdy** SVG wklejone w JSX sekcji.
+Dwa źródła, nic pomiędzy: **grafika od klienta** (także logo, ikony marki) →
+upload + ``; **stały zestaw ikon UI** → pole `select` z nazwami +
+mapa `lucide-react` w `src/components/icons/` (nazwy w osobnym pliku, żeby config
+bloku nie importował Reacta). Kod: [kod-sekcji.md](./skills/ipal-block/resources/kod-sekcji.md). **Nigdy** SVG wklejone w JSX sekcji.
### 6.11 Style
-- **Tailwind w komponentach**, kolory i fonty jako **tokeny** w `styles.css`
- (`@theme`) — źródłem jest `DESIGN.md` (Impeccable). W komponentach tylko nazwy
- tokenów (`bg-primary`, `text-foreground`), **nigdy** `bg-[#ff6600]` ani hex.
-- Tokeny pluginu mapuj na tokeny projektu — jeden kolor marki w jednym miejscu.
-- Fonty przez `next/font` w layoucie, podpięte zmienną CSS do `@theme`.
+- Tailwind w komponentach; kolory i fonty jako **tokeny** w `styles.css` (`@theme`)
+ ze źródła `DESIGN.md`. W komponentach tylko tokeny (`bg-primary`), **nigdy**
+ `bg-[#ff6600]` ani hex.
+- Tokeny pluginu mapuj na projekt: `--ipal-primary: var(--color-primary)`.
+- Fonty przez `next/font`, podpięte zmienną CSS do `@theme`.
- Bez CSS Modules i `style={{…}}` — wyjątek: wartość dynamiczna z danych.
-- Warianty wizualne → `Record` (§6.3), nie łańcuchy ternary.
-
-```css
-/* src/app/(frontend)/styles.css */
-@import "tailwindcss";
-@source "../../../node_modules/@intecion/ipal-kit/dist/**/*.js";
-
-@theme {
- --color-primary: oklch(0.62 0.19 45);
- --color-background: oklch(0.99 0 0);
- --color-foreground: oklch(0.2 0 0);
- --color-muted: oklch(0.96 0 0);
- --font-sans: var(--font-body); /* next/font: variable '--font-body' */
-}
-
-:root {
- --ipal-primary: var(--color-primary); /* baner cookies, Turnstile = kolor marki */
- --ipal-radius: 0.75rem;
-}
-```
+- Warianty → `Record`, nie łańcuchy ternary.
+Przykładowy `styles.css`: [kod-sekcji.md](./skills/ipal-block/resources/kod-sekcji.md).
### 6.12 Eksporty i importy
@@ -997,6 +438,7 @@ React. **Nigdy** SVG wklejone w JSX sekcji.
| Potrzeba | Użyj | Doc |
|---|---|---|
+| Link / CTA / plik do pobrania | `buildLinkField`, `buildLinksField`, `resolveLinkHref` | links.md |
| Render bloków | `RenderBlocks` + mapa `registry` (nigdy `switch`) | blocks.md |
| Rich text | `RenderRichText` (`/rsc`), styl przez `converters` | richtext.md |
| Wartość zlokalizowana | `resolveLocalized(value, locale)` (nie `getSafeString`) | forms.md |
@@ -1011,10 +453,10 @@ React. **Nigdy** SVG wklejone w JSX sekcji.
| Stary slug → 308 | `trackSlugHistoryHook` + `resolveRedirect` | hooks.md |
| Obrazy między językami | `buildCrossLocaleFieldSync` (języki z configu) | hooks.md |
| Ochrona stron systemowych | `buildPreventDeleteSystemPage`, `buildValidateUniqueRole` | hooks.md |
-| Metadata, sitemap, JSON-LD, llms.txt | `createPageMetadata`, `sitemap`, `build*JsonLd`, `createLlmsTxtRoute` | seo.md |
+| Metadata, sitemap, JSON-LD, llms.txt | `generatePageMetadata` (z `createContentHelpers`), `sitemap`, `build*JsonLd`, `createLlmsTxtRoute` | seo.md |
| Consent, analytics, pixele | `ConsentProvider`, `CookieBanner`, `Analytics` (wewnątrz providera) | consent.md, analytics.md |
| Nagłówki, CSP, 2FA | `buildSecurityHeaders`, `buildCsp`, `twoFactor` (wstrzyknięty `payloadTotp`) | security.md |
-| Media, R2 | `buildR2Storage`, `normalizeFilenameHook`, `MediaPreconnect` | storage.md |
+| Media, R2 | `buildR2Storage(['media'], { s3Storage })` (adapter wstrzyknięty), `normalizeFilenameHook`, `MediaPreconnect` | storage.md |
| Email | `email: mailAdapter()` | email.md |
| Walidacja env | `assertEnv(ipalEnvRules({...}))` | env.md |
@@ -1081,7 +523,7 @@ payloadTotp } })`, nigdy `twoFactor: false` bez decyzji klienta). CSP: najpierw
| favicon renderowany ręcznie | Google go nie pokazuje | `buildIconsMetadata` |
| skopiowany `Analytics` w projekcie | pixele bez zgody (RODO) | opcje pluginu (`defer`) |
| `import('@payload-config')` przez zmienną | `Cannot find module` w buildzie | wstrzyknięcie / props |
-| `ctaLabel`, `buttonUrl`, `pdfUrl` w blokach | zoo pól, brak spójności | `linksField()` |
+| `ctaLabel`, `buttonUrl`, `pdfUrl` w blokach | zoo pól, brak spójności | `buildLinksField()` |
| brak `@source` na plugin w CSS | komponenty pluginu bez stylów | `@source` |
| kolekcja `users`/`settings`/`faq` | duplikat Payloada / zły byt | §5.3 |
@@ -1156,6 +598,7 @@ Cokolwiek wymaga dewelopera → przenieś do panelu.
| Formularze, useForm, honeypot | [forms.md](../forms.md) |
| Hooki | [hooks.md](../hooks.md) |
| i18n, proxy, przełącznik języka | [i18n.md](../i18n.md) |
+| Linki / CTA (pola + href) | [links.md](../links.md) |
| Serwer MCP strony | [mcp.md](../mcp.md) |
| Komunikaty formularzy | [notifications.md](../notifications.md) |
| Strony systemowe, 404, generateStaticParams | [pages.md](../pages.md) |
@@ -1215,12 +658,13 @@ zadanie pasuje — ręcznie: `/`.
`package.json` projektu:
```json
"scripts": {
- "ipal:skills": "mkdir -p .agents/skills && cp -R node_modules/@intecion/ipal-kit/docs/agent/skills/. .agents/skills/"
+ "ipal:skills": "ipal-skills"
}
```
```bash
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.
+`ipal-skills` (komenda z pakietu) kopiuje tylko foldery `ipal-*`: dodaje nowe,
+nadpisuje zmienione, usuwa wycofane. Własne skille projektu nazywaj **bez**
+prefiksu `ipal-` — zostaną nietknięte. Opcje: `--dry-run`, `--dest .claude/skills`
+(Claude Code). Commituj `.agents/skills/ipal-*` do repo projektu.
diff --git a/docs/agent/skills/ipal-audit/scripts/audit.sh b/docs/agent/skills/ipal-audit/scripts/audit.sh
index b8e2afe..f5cbef4 100644
--- a/docs/agent/skills/ipal-audit/scripts/audit.sh
+++ b/docs/agent/skills/ipal-audit/scripts/audit.sh
@@ -130,6 +130,8 @@ 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 "project copy of link fields" "links.md — use buildLinkField / buildLinksField / resolveLinkHref from the plugin" \
+ "$(ls src/fields/link.ts src/lib/links.ts 2>/dev/null; g "from '@/fields/link'|from '@/lib/links'" src --include=*.ts --include=*.tsx)"
report ERROR "manual Lexical rendering" "§7 use RenderRichText" \
"$(g 'node\.type *===|dangerouslySetInnerHTML' src --include=*.tsx)"
diff --git a/docs/agent/skills/ipal-block/SKILL.md b/docs/agent/skills/ipal-block/SKILL.md
index 1cd7503..780b108 100644
--- a/docs/agent/skills/ipal-block/SKILL.md
+++ b/docs/agent/skills/ipal-block/SKILL.md
@@ -1,6 +1,6 @@
---
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.
+description: Builds or refactors one page section (Payload block + React component) in an ipal-kit project the correct way — shared fields (sectionHeaderField, buildLinksField, buildLinkField, 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
@@ -9,9 +9,10 @@ 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
+Sprawdź, czy istnieją: `src/fields/sectionHeader.ts`,
+`sectionSettings.ts`, `src/components/ui/{CMSLink,Button,Media,Section,SectionHeader}.tsx`.
+Linki (`buildLinkField`, `buildLinksField`, `resolveLinkHref`) są w pluginie — nie twórz ich w projekcie.
+Brakuje → najpierw utwórz je 1:1 z `resources/kod-sekcji.md` (ten skill)
(i powiedz o tym użytkownikowi). Nie pisz własnych wersji.
## 1. Plan (pokaż i czekaj na OK)
@@ -23,8 +24,10 @@ Sprawdź, czy istnieją: `src/fields/link.ts`, `sectionHeader.ts`,
- czy sekcja to wariant istniejącego bloku (wtedy pole `variant: select`, nie nowy blok).
## 2. Kod
+Wzorce plików (Hero, FeatureGrid + FeatureCard): `resources/kod-sekcji.md`.
+
1. `src/blocks//config.ts` — `interfaceName: 'Block'`, pola z planu,
- zawsze `sectionSettingsField()`. CTA = `linksField()`, nigdy pola `cta*`/`button*`.
+ zawsze `sectionSettingsField()`. CTA = `buildLinksField()`, nigdy pola `cta*`/`button*`.
Plik do pobrania = link typu `file`. Etykiety i opisy pól po angielsku.
2. `src/blocks//Component.tsx` — nazwany eksport, typ z `@/payload-types`
(`Block & { locale: string }`), struktura:
diff --git a/docs/agent/skills/ipal-block/resources/kod-sekcji.md b/docs/agent/skills/ipal-block/resources/kod-sekcji.md
new file mode 100644
index 0000000..1d1f8a5
--- /dev/null
+++ b/docs/agent/skills/ipal-block/resources/kod-sekcji.md
@@ -0,0 +1,378 @@
+# Kod sekcji — gotowe pliki dla projektu
+
+> Zasoby skilla **ipal-block**. Reguły (dlaczego tak, czego nie robić) są w
+> `node_modules/@intecion/ipal-kit/docs/agent/AGENT.md` §6 — ten plik to tylko kod
+> do utworzenia w projekcie **1:1**. Linki (`buildLinkField`, `buildLinksField`,
+> `resolveLinkHref`) są w pluginie — nie twórz ich kopii.
+
+## Warstwa 1 — wspólne pola
+
+**Link / CTA — z pluginu, nie kopiuj kodu** (`docs/links.md`):
+
+```ts
+import { buildLinkField, buildLinksField } from '@intecion/ipal-kit'
+
+buildLinksField() // 0–2 przyciski sekcji → pole `links`
+buildLinksField({ maxRows: 3, appearances: ['primary', 'secondary'] })
+buildLinkField() // pojedynczy link → pole `link`
+buildLinkField({ disableLabel: true, appearances: false }) // klikalna cała karta
+```
+
+Jeden kształt linku: typ (`internal` strona / `external` URL, mailto, tel, #anchor /
+`file` upload), `label` (localized), `newTab`, `appearance`. W `payload-types.ts`
+powstaje typ `CmsLink`. Opcje: `relationTo` (domyślnie `'pages'`), `uploadTo`
+(domyślnie `'media'`), `required`.
+
+
+**Pliki i obrazy:** `{ name: 'media', type: 'upload', relationTo: 'media' }`.
+Kolekcja `media` dopuszcza PDF (`upload.mimeTypes: ['image/*', 'application/pdf',
+'video/mp4']`), ma `alt` (required, localized) i `normalizeFilenameHook`.
+„Pobierz cennik (PDF)” to **link typu `file`**, nie osobne pole `pdf`/`pdfUrl`.
+
+`src/fields/sectionHeader.ts` i `src/fields/sectionSettings.ts`:
+
+```ts
+import type { GroupField } from 'payload'
+
+export function sectionHeaderField(name = 'header'): GroupField {
+ return {
+ name,
+ type: 'group',
+ interfaceName: 'SectionHeaderData',
+ fields: [
+ { name: 'eyebrow', type: 'text', localized: true },
+ { name: 'heading', type: 'text', localized: true },
+ { name: 'intro', type: 'textarea', localized: true },
+ ],
+ }
+}
+
+export function sectionSettingsField(): GroupField {
+ return {
+ name: 'settings',
+ type: 'group',
+ interfaceName: 'SectionSettings',
+ admin: { position: 'sidebar' },
+ fields: [
+ {
+ name: 'anchor',
+ type: 'text',
+ admin: { description: 'Section id for #links and section nav, e.g. "pricing".' },
+ },
+ {
+ name: 'background',
+ type: 'select',
+ defaultValue: 'default',
+ options: ['default', 'muted', 'inverted'].map((v) => ({ label: v, value: v })),
+ },
+ ],
+ }
+}
+```
+
+Każda sekcja ma `sectionSettingsField()` — żadnych `bgColor`, `darkMode`,
+`sectionId` w poszczególnych blokach. Etykiety pól po angielsku (panel jest EN).
+
+## Warstwa 2 — prymitywy UI
+
+`src/components/ui/CMSLink.tsx` — **każdy** link/przycisk z panelu:
+
+```tsx
+import Link from 'next/link'
+import type { ReactNode } from 'react'
+import { resolveLinkHref } from '@intecion/ipal-kit'
+import type { CmsLink } from '@/payload-types'
+import { i18nConfig } from '@/i18n.config'
+import { getSettings } from '@/lib/content'
+import { buttonClass } from './Button'
+
+type Props = {
+ link: CmsLink | null | undefined
+ locale: string
+ className?: string
+ /** For wrapping links (cards): content instead of link.label. */
+ children?: ReactNode
+}
+
+export async function CMSLink({ link, locale, className, children }: Props) {
+ const settings = await getSettings(locale) // react cache → one query per request
+ const home = settings?.homepage
+ const homeSlug = home && typeof home === 'object' && typeof home.slug === 'string' ? home.slug : undefined
+
+ const href = resolveLinkHref(link, { locale, config: i18nConfig, homeSlug })
+ const content = children ?? link?.label
+ if (!link || !href || !content) return null
+
+ const cls = [link.appearance ? buttonClass(link.appearance) : '', className]
+ .filter(Boolean)
+ .join(' ')
+ const newTab = link.newTab || link.type === 'file'
+ const targetProps = newTab ? { target: '_blank', rel: 'noopener noreferrer' } : {}
+
+ if (link.type === 'internal') {
+ return {content}
+ }
+ return {content}
+}
+```
+
+`src/components/ui/Button.tsx` — warianty jako mapa, nie ternary:
+
+```ts
+import type { LinkAppearance } from '@intecion/ipal-kit'
+
+const VARIANTS: Record = {
+ primary: 'btn btn-primary',
+ secondary: 'btn btn-secondary',
+ link: 'link-arrow',
+}
+
+export function buttonClass(appearance: LinkAppearance): string {
+ return VARIANTS[appearance]
+}
+```
+
+`src/components/ui/Media.tsx` — **każdy** obraz/wideo z panelu:
+
+```tsx
+import Image from 'next/image'
+import type { Media as MediaDoc } from '@/payload-types'
+
+type Props = {
+ resource: MediaDoc | string | number | null | undefined
+ sizes?: string
+ priority?: boolean
+ className?: string
+}
+
+export function Media({ resource, sizes = '100vw', priority = false, className }: Props) {
+ if (!resource || typeof resource !== 'object' || !resource.url) return null
+ const { url, alt, width, height, mimeType } = resource
+
+ if (mimeType?.startsWith('video/')) {
+ return
+ }
+ if (!width || !height) return null // non-image file (PDF) — use CMSLink type 'file'
+
+ return (
+
+ )
+}
+```
+
+`Section.tsx` i `SectionHeader.tsx`:
+
+```tsx
+// src/components/ui/Section.tsx
+import type { ReactNode } from 'react'
+import type { SectionSettings } from '@/payload-types'
+
+const BACKGROUNDS: Record, string> = {
+ default: 'bg-background',
+ muted: 'bg-muted',
+ inverted: 'bg-foreground text-background',
+}
+
+export function Section({ settings, children }: { settings?: SectionSettings | null; children: ReactNode }) {
+ return (
+
+ )
+}
+```
+
+```tsx
+// src/components/ui/SectionHeader.tsx
+import type { SectionHeaderData } from '@/payload-types'
+
+export function SectionHeader({ header, as: H = 'h2' }: { header?: SectionHeaderData | null; as?: 'h1' | 'h2' }) {
+ if (!header?.heading && !header?.eyebrow && !header?.intro) return null
+ return (
+
+ {header.eyebrow && {header.eyebrow}
}
+ {header.heading && {header.heading} }
+ {header.intro && {header.intro}
}
+
+ )
+}
+```
+
+**`locale` dla każdego bloku — raz, w trasie strony:**
+
+```tsx
+const enhanceProps = ({ block }: { block: { blockType: string } }) => ({
+ locale,
+ ...(block.blockType === 'formBlock' ? { turnstileSiteKey } : {}),
+})
+
+```
+
+## Warstwa 3 — sekcja = kompozycja
+
+```ts
+// src/blocks/Hero/config.ts
+import type { Block } from 'payload'
+import { buildLinksField } from '@intecion/ipal-kit'
+import { sectionHeaderField } from '@/fields/sectionHeader'
+import { sectionSettingsField } from '@/fields/sectionSettings'
+
+export const HeroBlock: Block = {
+ slug: 'hero',
+ interfaceName: 'HeroBlock',
+ labels: { singular: 'Hero', plural: 'Heroes' },
+ fields: [
+ sectionHeaderField(),
+ { name: 'media', type: 'upload', relationTo: 'media' },
+ buildLinksField(),
+ sectionSettingsField(),
+ ],
+}
+```
+
+```tsx
+// src/blocks/Hero/Component.tsx — cały komponent
+import type { HeroBlock } from '@/payload-types'
+import { Section } from '@/components/ui/Section'
+import { SectionHeader } from '@/components/ui/SectionHeader'
+import { Media } from '@/components/ui/Media'
+import { CMSLink } from '@/components/ui/CMSLink'
+
+export function Hero({ header, media, links, settings, locale }: HeroBlock & { locale: string }) {
+ return (
+
+
+
+
+ {links?.length ? (
+
+ {links.map(({ id, link }) => )}
+
+ ) : null}
+
+
+
+
+ )
+}
+```
+
+Sekcja z powtarzalnymi elementami — element tablicy to podkomponent:
+
+```ts
+// src/blocks/FeatureGrid/config.ts (fields)
+sectionHeaderField(),
+{
+ name: 'items',
+ type: 'array',
+ interfaceName: 'FeatureItem',
+ fields: [
+ { name: 'media', type: 'upload', relationTo: 'media' },
+ { name: 'heading', type: 'text', localized: true, required: true },
+ { name: 'text', type: 'textarea', localized: true },
+ buildLinkField({ appearances: ['link'] }),
+ ],
+},
+buildLinksField({ maxRows: 1 }),
+sectionSettingsField(),
+```
+
+```tsx
+// src/blocks/FeatureGrid/FeatureCard.tsx
+export function FeatureCard({ item, locale }: { item: FeatureItem; locale: string }) {
+ return (
+
+
+ {item.heading}
+ {item.text && {item.text}
}
+
+
+ )
+}
+
+// src/blocks/FeatureGrid/Component.tsx
+export function FeatureGrid({ header, items, links, settings, locale }: FeatureGridBlock & { locale: string }) {
+ return (
+
+
+
+ {items?.map((item) => )}
+
+ {links?.map(({ id, link }) => )}
+
+ )
+}
+```
+
+**Wydziel podkomponent, gdy którekolwiek jest prawdą:** ten sam JSX 2+ razy;
+element `items[]` ma >5 linii markupu; `Component.tsx` >80 linii JSX; jest stan/
+interakcja (accordion, slider, tabs → osobny `'use client'`). Podkomponent
+jednej sekcji → w jej folderze; używany w 2+ sekcjach → `src/components/ui/`.
+Ikony: upload albo `select` z mapą w `src/components/icons` — nigdy SVG wklejone
+w sekcję.
+
+## Ikony
+
+Dwa źródła, nic pomiędzy:
+- **Dowolna grafika od klienta** → upload do `media` + `` (także logo, ikony SVG marki).
+- **Stały zestaw ikon UI** → pole `select` + mapa `lucide-react`:
+
+```ts
+// src/components/icons/names.ts — same nazwy, importowane przez config bloku
+export const ICON_NAMES = ['phone', 'mail', 'mapPin', 'clock', 'check'] as const
+export type IconName = (typeof ICON_NAMES)[number]
+export const iconField = {
+ name: 'icon',
+ type: 'select',
+ options: ICON_NAMES.map((value) => ({ label: value, value })),
+} as const
+```
+```tsx
+// src/components/icons/Icon.tsx — mapa, importowana tylko przez komponenty
+import { Check, Clock, Mail, MapPin, Phone, type LucideIcon } from 'lucide-react'
+import type { IconName } from './names'
+
+const ICONS: Record = { phone: Phone, mail: Mail, mapPin: MapPin, clock: Clock, check: Check }
+
+export function Icon({ name, className }: { name?: IconName | null; className?: string }) {
+ if (!name) return null
+ const Component = ICONS[name]
+ return
+}
+```
+Nazwy są osobno, żeby config bloku (`payload.config`) nie importował komponentów
+React. **Nigdy** SVG wklejone w JSX sekcji.
+
+## Style
+
+- **Tailwind w komponentach**, kolory i fonty jako **tokeny** w `styles.css`
+ (`@theme`) — źródłem jest `DESIGN.md` (Impeccable). W komponentach tylko nazwy
+ tokenów (`bg-primary`, `text-foreground`), **nigdy** `bg-[#ff6600]` ani hex.
+- Tokeny pluginu mapuj na tokeny projektu — jeden kolor marki w jednym miejscu.
+- Fonty przez `next/font` w layoucie, podpięte zmienną CSS do `@theme`.
+- Bez CSS Modules i `style={{…}}` — wyjątek: wartość dynamiczna z danych.
+- Warianty wizualne → `Record` (§6.3), nie łańcuchy ternary.
+
+```css
+/* src/app/(frontend)/styles.css */
+@import "tailwindcss";
+@source "../../../node_modules/@intecion/ipal-kit/dist/**/*.js";
+
+@theme {
+ --color-primary: oklch(0.62 0.19 45);
+ --color-background: oklch(0.99 0 0);
+ --color-foreground: oklch(0.2 0 0);
+ --color-muted: oklch(0.96 0 0);
+ --font-sans: var(--font-body); /* next/font: variable '--font-body' */
+}
+
+:root {
+ --ipal-primary: var(--color-primary); /* baner cookies, Turnstile = kolor marki */
+ --ipal-radius: 0.75rem;
+}
+```
+
diff --git a/docs/agent/skills/ipal-collection/SKILL.md b/docs/agent/skills/ipal-collection/SKILL.md
index 80ed5c2..a2acbcd 100644
--- a/docs/agent/skills/ipal-collection/SKILL.md
+++ b/docs/agent/skills/ipal-collection/SKILL.md
@@ -30,7 +30,7 @@ slug (camelCase, l.mn.), pola, relacje, czy ma URL-e (archiwum), JSON-LD.
1. `src/collections/.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.
+ `media`, linki przez `buildLinkField()`. 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 (`Archive`). Plugin robi routing, sitemap,
diff --git a/docs/agent/skills/ipal-nav/SKILL.md b/docs/agent/skills/ipal-nav/SKILL.md
index ef9bff9..d0ce50a 100644
--- a/docs/agent/skills/ipal-nav/SKILL.md
+++ b/docs/agent/skills/ipal-nav/SKILL.md
@@ -1,12 +1,12 @@
---
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.
+description: Builds the site header, footer, mobile menu and company data in an ipal-kit project — Header/Footer/Company globals with buildLinkField from the plugin, 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).
+Gotowy kod: `resources/kod-nawigacji.md` (ten skill). Reguły: AGENT.md §6.8.
+Wymaga prymitywów z `../ipal-block/resources/kod-sekcji.md` (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`),
diff --git a/docs/agent/skills/ipal-nav/resources/kod-nawigacji.md b/docs/agent/skills/ipal-nav/resources/kod-nawigacji.md
new file mode 100644
index 0000000..e442803
--- /dev/null
+++ b/docs/agent/skills/ipal-nav/resources/kod-nawigacji.md
@@ -0,0 +1,176 @@
+# Kod nawigacji — Header, Footer, menu mobilne
+
+> Zasoby skilla **ipal-nav**. Reguły: `node_modules/@intecion/ipal-kit/docs/agent/AGENT.md` §6.8.
+> Wymaga prymitywów z `../ipal-block/resources/kod-sekcji.md` (CMSLink, Media).
+
+## Header i Footer (globale nawigacji)
+
+Nawigacja, stopka i dane firmy to **globale projektu** (model zależy od klienta
+i kraju), budowane z tych samych wspólnych pól co sekcje. Logo i nazwa są w
+Site Settings — nie duplikuj ich w Header.
+
+```ts
+// src/globals/Header.ts
+import type { GlobalConfig } from 'payload'
+import { buildLinkField, buildLinksField } from '@intecion/ipal-kit'
+
+export const Header: GlobalConfig = {
+ slug: 'header',
+ access: { read: () => true },
+ fields: [
+ {
+ name: 'navItems',
+ type: 'array',
+ maxRows: 8,
+ fields: [
+ buildLinkField({ appearances: false }),
+ {
+ name: 'subItems', // jeden poziom podmenu — głębiej nie budujemy
+ type: 'array',
+ maxRows: 10,
+ fields: [buildLinkField({ appearances: false })],
+ },
+ ],
+ },
+ buildLinksField({ maxRows: 1 }), // przycisk CTA w nagłówku
+ {
+ name: 'menuLabel',
+ type: 'text',
+ localized: true,
+ admin: { description: 'Accessible label of the mobile menu button, e.g. "Menu".' },
+ },
+ ],
+}
+```
+
+```ts
+// src/globals/Footer.ts
+import type { GlobalConfig } from 'payload'
+import { buildLinkField } from '@intecion/ipal-kit'
+
+export const Footer: GlobalConfig = {
+ slug: 'footer',
+ access: { read: () => true },
+ fields: [
+ {
+ name: 'columns',
+ type: 'array',
+ maxRows: 4,
+ fields: [
+ { name: 'heading', type: 'text', localized: true },
+ { name: 'items', type: 'array', fields: [buildLinkField({ appearances: false })] },
+ ],
+ },
+ { name: 'note', type: 'textarea', localized: true }, // np. „Wszelkie prawa zastrzeżone”
+ ],
+}
+```
+
+- **Linki prawne w stopce** (polityka, cookies, regulamin) renderuj z ról System
+ Pages (`getSystemPagePath` + tytuł strony) — nie dodawaj ich ręcznie do `columns`.
+- **Dane firmy** (nazwa, adres, NIP/ABN, telefon) — global `company` projektu;
+ stopka i JSON-LD czytają z niego. Rok w copyright licz w kodzie
+ (`new Date().getFullYear()`), nazwę bierz z globala.
+- **Odświeżanie:** global zmienia się na każdej stronie → hook `afterChange`
+ z `revalidatePath('/', 'layout')` (hooks.md).
+
+Linki rozwiązuj **na serwerze** do zwykłych danych, a do klienta (menu mobilne)
+przekazuj tylko `{ href, label, newTab }` — komponent kliencki nie może wołać
+`CMSLink` (to async server component).
+
+```ts
+// src/lib/navigation.ts
+import { resolveLinkHref } from '@intecion/ipal-kit'
+import type { CmsLink } from '@/payload-types'
+import { i18nConfig } from '@/i18n.config'
+import { getSettings } from '@/lib/content'
+
+export type NavItem = { href: string; label: string; newTab: boolean; subItems: NavItem[] }
+
+type NavSource = { link?: CmsLink | null; subItems?: { link?: CmsLink | null }[] | null }
+
+function toNavItem(link: CmsLink | null | undefined, locale: string, homeSlug?: string): NavItem | null {
+ const href = resolveLinkHref(link, { locale, config: i18nConfig, homeSlug })
+ if (!link || !href || !link.label) return null
+ return { href, label: link.label, newTab: Boolean(link.newTab), subItems: [] }
+}
+
+export async function resolveNav(items: NavSource[] | null | undefined, locale: string): Promise {
+ const settings = await getSettings(locale)
+ const home = settings?.homepage
+ const homeSlug = home && typeof home === 'object' && typeof home.slug === 'string' ? home.slug : undefined
+
+ return (items ?? []).flatMap((item) => {
+ const node = toNavItem(item.link, locale, homeSlug)
+ if (!node) return []
+ node.subItems = (item.subItems ?? []).flatMap((sub) => {
+ const child = toNavItem(sub.link, locale, homeSlug)
+ return child ? [child] : []
+ })
+ return [node]
+ })
+}
+```
+
+```tsx
+// src/components/layout/Header.tsx — serwer
+import Link from 'next/link'
+import type { Header as HeaderData } from '@/payload-types'
+import { resolveNav } from '@/lib/navigation'
+import { CMSLink } from '@/components/ui/CMSLink'
+import { MobileNav } from './MobileNav'
+
+export async function Header({ header, locale }: { header: HeaderData; locale: string }) {
+ const items = await resolveNav(header.navItems, locale)
+ return (
+
+
+ {/* logo: Site Settings → */}
+
+ {items.map((item) => (
+
+
+ {item.label}
+
+
+ ))}
+
+ {header.links?.map(({ id, link }) => )}
+
+
+
+ )
+}
+```
+
+```tsx
+// src/components/layout/MobileNav.tsx — klient, tylko stan otwarcia
+'use client'
+import { useState } from 'react'
+import Link from 'next/link'
+import type { NavItem } from '@/lib/navigation' // import TYPU — nie ciągnie kodu serwera
+
+export function MobileNav({ items, menuLabel }: { items: NavItem[]; menuLabel: string }) {
+ const [open, setOpen] = useState(false)
+ return (
+
+
setOpen(!open)}>
+ ☰
+
+ {open && (
+
+ {items.map((item) => (
+
+ setOpen(false)}>{item.label}
+
+ ))}
+
+ )}
+
+ )
+}
+```
+
+Header/Footer pobierasz w `[locale]/layout.tsx` (przez cached getter w
+`lib/`) i podajesz jako props — layout to jedyne miejsce, które je składa.
+
diff --git a/docs/agent/skills/ipal-setup/SKILL.md b/docs/agent/skills/ipal-setup/SKILL.md
index 1742348..ee9313c 100644
--- a/docs/agent/skills/ipal-setup/SKILL.md
+++ b/docs/agent/skills/ipal-setup/SKILL.md
@@ -21,10 +21,10 @@ poniżej i doczytaj po `pnpm add`). Reguły: `docs/agent/AGENT.md`.
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`
+4. **Rdzeń** — wspólne pola i prymitywy (`../ipal-block/resources/kod-sekcji.md`), `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).
+ Impeccable albo załóż neutralne tokeny), `@source` na plugin (AGENT.md §6.11, przykład w `../ipal-block/resources/kod-sekcji.md`).
6. **Routing** — `proxy.ts` (`createProxy`), `lib/content.ts`, layout bez
``, 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).
diff --git a/docs/dev/PROGRAMISTA.md b/docs/dev/PROGRAMISTA.md
index 67083fc..779d1ec 100644
--- a/docs/dev/PROGRAMISTA.md
+++ b/docs/dev/PROGRAMISTA.md
@@ -28,6 +28,7 @@ pnpm add @intecion/ipal-kit
pnpm add @payloadcms/plugin-seo @payloadcms/plugin-form-builder \
nodemailer lucide-react slugify server-only
pnpm add @clocklimited/payload-2fa@3.0.0-beta.7 # 2FA (wymuszone)
+pnpm add @payloadcms/storage-s3 # tylko gdy media w R2
pnpm add tailwindcss @tailwindcss/postcss
```
@@ -45,7 +46,8 @@ SEO, brak kolekcji Forms albo crash. W `package.json`:
"@payloadcms/db-postgres": "3.90.2",
"@payloadcms/richtext-lexical": "3.90.2",
"@payloadcms/plugin-seo": "3.90.2",
- "@payloadcms/plugin-form-builder": "3.90.2"
+ "@payloadcms/plugin-form-builder": "3.90.2",
+ "@payloadcms/storage-s3": "3.90.2"
}
}
```
@@ -81,7 +83,7 @@ layout pod `[locale]` (bo `` musi znać język).
```json
// package.json projektu
"scripts": {
- "ipal:skills": "mkdir -p .agents/skills && cp -R node_modules/@intecion/ipal-kit/docs/agent/skills/. .agents/skills/"
+ "ipal:skills": "ipal-skills"
}
```
`pnpm ipal:skills` po instalacji i po każdej aktualizacji ipal-kit; `.agents/skills/`
@@ -137,9 +139,12 @@ export default buildConfig({
`buildNoindexField()`, `layout` typu `blocks` (min. 1 blok), `trackSlugHistoryHook`,
`buildRevalidateHook`.
- `Media`: upload z `mimeTypes` (obrazy + PDF), `alt` (required, localized),
- `normalizeFilenameHook`; R2 przez `buildR2Storage(['media'])` (storage.md).
-- `src/fields/` (link, sectionHeader, sectionSettings) i `src/components/ui/`
- (CMSLink, Button, Media, Section, SectionHeader) — gotowy kod w AGENT.md §6.
+ `normalizeFilenameHook`; R2 przez `buildR2Storage(['media'], { s3Storage })` —
+ `s3Storage` z `@payloadcms/storage-s3`, wstrzykiwany (storage.md).
+- Linki z pluginu (`buildLinkField`, `buildLinksField`, `resolveLinkHref` — links.md),
+ `src/fields/` (sectionHeader, sectionSettings) i `src/components/ui/`
+ (CMSLink, Button, Media, Section, SectionHeader) — gotowy kod w
+ `agent/skills/ipal-block/resources/kod-sekcji.md`, reguły w AGENT.md §6.
Załóż je **przed** pierwszym blokiem.
### 2.5 Tailwind
@@ -181,7 +186,7 @@ import { contentConfig } from '@/content.config'
export const {
getCachedPayload, getSettings, getConfiguredLocales, resolveRoute, getEntries,
- getNotFoundPage, generateStaticParams, sitemap, robots,
+ generatePageMetadata, getNotFoundPage, generateStaticParams, sitemap, robots,
} = createContentHelpers({
config,
content: contentConfig,
@@ -235,21 +240,20 @@ export default async function LocaleLayout({ children, params }: Props) {
import { notFound, permanentRedirect } from 'next/navigation'
import type { Metadata } from 'next'
import { RenderBlocks } from '@intecion/ipal-kit/rsc'
-import { createPageMetadata, resolveRedirect } from '@intecion/ipal-kit'
+import { resolveRedirect } from '@intecion/ipal-kit'
import { i18nConfig } from '@/i18n.config'
import { blockRegistry } from '@/blocks/registry'
-import { getCachedPayload, resolveRoute } from '@/lib/content'
+import { generatePageMetadata, getCachedPayload, resolveRoute } from '@/lib/content'
export { generateStaticParams } from '@/lib/content' // SSG → synchroniczny
export const revalidate = 3600 // ISR
-const pageMetadata = createPageMetadata({ config: i18nConfig, baseUrl: process.env.NEXT_PUBLIC_SERVER_URL })
-
type Args = { params: Promise<{ locale: string; slug?: string[] }> } // bez searchParams!
+// Ten sam cache co strona: jedno odczytanie ustawień i jedno resolveRoute na żądanie
export async function generateMetadata({ params }: Args): Promise {
const { locale, slug } = await params
- return pageMetadata({ payload: await getCachedPayload(), locale, slug })
+ return generatePageMetadata(locale, slug)
}
export default async function Page({ params }: Args) {
@@ -458,6 +462,9 @@ Rób po jednej pozycji, buduj, sprawdzaj. Kolejność wg wagi:
| 13 | Brak health checku | `createHealthRoute` (§2.8) | — |
| 14 | 2FA crash „Cannot find module” | wstrzyknij `plugin: payloadTotp` | security.md |
| 15 | Pola `ctaLabel`/`pdfUrl`, sekcje-monolity | refaktor wg AGENT.md §6.7 (z migracją danych!) | AGENT.md |
+| 15a | `buildR2Storage(['media'])` bez adaptera (od 1.8.1 błąd przy env R2) | `pnpm add @payloadcms/storage-s3`, `buildR2Storage(['media'], { s3Storage })` | storage.md |
+| 15b | `src/fields/link.ts`, `src/lib/links.ts` w projekcie | importy z pluginu, usuń kopie (bez migracji bazy) | links.md |
+| 15c | `createPageMetadata(...)` w `page.tsx` | `generatePageMetadata(locale, slug)` z `lib/content` — wspólny cache z komponentem strony, mniej zapytań | seo.md |
| 16 | 404 na sztywno | rola 404 w System Pages + `getNotFoundPage` | pages.md |
| 16a | `privacyPolicy: { label: 'Polityka prywatności', … }` w layoucie | usuń cały parametr; tekst wpisz w Cookie Settings → Privacy link label | consent.md |
| 17 | Opcjonalnie — AI/GEO | Markdown per strona, llms-full, boty AI w robots, MCP, wyszukiwarka, speakable, aiSummary | content.md, seo.md, mcp.md |
@@ -475,6 +482,7 @@ Po aktualizacji pakietu: `pnpm ipal:skills` (nowe wersje skilli), `rm -rf .next`
| `PayloadComponent not found in importMap` | `pnpm payload generate:importmap` |
| `Cannot destructure property 'config'` | dublet `@payloadcms/ui` w pluginie — `ls node_modules/@intecion/ipal-kit/node_modules/@payloadcms/ui` |
| `Cannot find module '@clocklimited/payload-2fa'` | wstrzyknij `plugin: payloadTotp` w `twoFactor` |
+| `[ipal] R2 storage: … adapter was not injected` | `pnpm add @payloadcms/storage-s3` + `buildR2Storage(['media'], { s3Storage })` |
| Baner bez stylów | brak Tailwinda albo `@source` na plugin |
| `/admin`, `/_next` → 500 | matcher proxy nie jest literałem inline |
| `slug.join is not a function` | `[slug]` zamiast `[[...slug]]` |
@@ -522,7 +530,7 @@ fałszywe 0. Typowe pułapki: `npm version` przed commitem (brudne repo),
function` w projekcie), `pnpm add` przy działającym dev.
### 8.2 package.json pluginu
-- `"files": ["dist", "docs"]` — **docs jadą w pakiecie**; agenci w projektach
+- `"files": ["dist", "docs", "bin"]` — **docs i komenda `ipal-skills` jadą w pakiecie**; agenci w projektach
czytają `node_modules/@intecion/ipal-kit/docs/agent/AGENT.md`. Bez `docs` nie mają nic.
- Jeden blok `exports`, wszystkie ścieżki na `./dist/` (nie `./src/`).
- `payload`, `@payloadcms/*`, `next`, `react`, `react-dom` → **`peerDependencies`**
@@ -530,7 +538,10 @@ function` w projekcie), `pnpm add` przy działającym dev.
- Brak self-reference (nigdy `pnpm add` w katalogu pluginu).
- Plugin nigdy nie importuje `next/server`, `next/cache`, `@payload-config` ani
opcjonalnych pakietów wprost — projekt je wstrzykuje (wzorzec `NextResponse`,
- `revalidatePath`, `payloadTotp`).
+ `revalidatePath`, `payloadTotp`, `s3Storage`). Opcjonalny pakiet = optional
+ `peerDependency` + typ minimalnego kształtu w pluginie, zero importu.
+- Import z `next/*` w komponencie klienckim pluginu: z rozszerzeniem
+ (`'next/navigation.js'`) — `next` nie ma pola `exports`, NodeNext inaczej nie znajdzie.
```bash
grep -c '"exports"' package.json # 1
diff --git a/docs/dev/vibe.md b/docs/dev/vibe.md
index c4b4520..20468c9 100644
--- a/docs/dev/vibe.md
+++ b/docs/dev/vibe.md
@@ -46,7 +46,7 @@ najważniejsze, i wypisz, na którym kroku z node_modules/@intecion/ipal-kit/doc
(sprawdź stan repo: git log, istniejące pliki).
```
Sprawdź: agent wymienia m.in. proxy.ts zamiast middleware, zakaz hardkodowania,
-linksField/CMSLink, minimum kolekcji. Jeśli nie — każ mu przeczytać jeszcze raz.
+buildLinksField/CMSLink, minimum kolekcji. Jeśli nie — każ mu przeczytać jeszcze raz.
---
@@ -100,9 +100,12 @@ Sprawdź: lista języków istnieje tylko w `i18n.config.ts` (grep `'pl'` w `src`
```
Zrób zgodnie z AGENT.md §5.3 i §6.2:
-1. src/fields/link.ts, sectionHeader.ts, sectionSettings.ts — kod 1:1 z AGENT.md §6.2.
+1. src/fields/sectionHeader.ts, sectionSettings.ts — kod 1:1 z
+ node_modules/@intecion/ipal-kit/docs/agent/skills/ipal-block/resources/kod-sekcji.md
+ (linki: buildLinkField/buildLinksField z @intecion/ipal-kit — nie kopiuj).
2. collections/Media.ts: upload (mimeTypes obrazy + PDF + mp4), alt required localized,
- normalizeFilenameHook; jeśli R2 — buildR2Storage(['media']) z env (storage.md).
+ normalizeFilenameHook; jeśli R2 — buildR2Storage(['media'], { s3Storage }) z env, s3Storage
+ wstrzyknięty z @payloadcms/storage-s3 (storage.md).
3. collections/Pages.ts: title localized, buildSlugField, buildNoindexField,
layout typu blocks (na razie jeden blok Content: sectionHeaderField + content richText),
trackSlugHistoryHook, buildRevalidateHook (hooks.md).
@@ -123,7 +126,8 @@ Wcześniej: `/impeccable init` i `/impeccable document` → `PRODUCT.md`, `DESIG
Na podstawie DESIGN.md zrób src/app/(frontend)/styles.css wg AGENT.md §6.11:
@theme z tokenami (primary, background, foreground, muted + fonty), @source na plugin,
mapowanie --ipal-primary / --ipal-radius. Fonty przez next/font.
-Potem prymitywy 1:1 z AGENT.md §6.3: lib/links.ts, components/ui/CMSLink.tsx,
+Potem prymitywy 1:1 z node_modules/@intecion/ipal-kit/docs/agent/skills/ipal-block/resources/kod-sekcji.md:
+components/ui/CMSLink.tsx,
Button.tsx, Media.tsx, Section.tsx, SectionHeader.tsx, oraz components/icons wg §6.10.
Zero hexów w komponentach — tylko tokeny.
Plan najpierw.
@@ -156,7 +160,7 @@ Zrób wg PROGRAMISTA.md §2.8–2.9 i seo.md:
- app/sitemap.ts, robots.ts, manifest.ts (createManifestHandler), llms.txt/route.ts,
api/health/route.ts — każda trasa czytająca bazę z export const dynamic = 'force-dynamic',
- next.config.ts: htmlLimitedBots, buildSecurityHeaders,
-- metadata strony przez createPageMetadata, favicon przez buildIconsMetadata,
+- metadata strony przez generatePageMetadata z lib/content (wspólny cache), favicon przez buildIconsMetadata,
- JSON-LD w root layoucie: Organization + WebSite (seo.md) z danych z panelu,
- src/instrumentation.ts z assertEnv(ipalEnvRules(...)) (env.md).
CSP jeszcze nie — będzie w kroku 14.
@@ -172,7 +176,7 @@ Skrót: `/ipal-nav `.
```
-Zrób wg AGENT.md §6.8:
+Zrób wg AGENT.md §6.8, kod z node_modules/@intecion/ipal-kit/docs/agent/skills/ipal-nav/resources/kod-nawigacji.md:
- globals/Header.ts, Footer.ts (kod z §6.8),
- globals/Company.ts dla rynku : nazwa, adres, , telefon, email —
wszystko localized tam, gdzie tekst,
@@ -203,7 +207,7 @@ Skrót: `/ipal-block — , `.
```
Zbuduj blok wg AGENT.md §6 (warstwa 3):
-- src/blocks//config.ts: sectionHeaderField, linksField, media, items,
+- src/blocks//config.ts: sectionHeaderField, buildLinksField, media, items,
sectionSettingsField — tylko pola z listy z kroku 9a, nazwy z §6.5,
- Component.tsx: Section + SectionHeader + Media + CMSLink, max ~80 linii JSX,
powtarzalne elementy w Card.tsx, interakcja w osobnym pliku 'use client' (§6.9),
@@ -335,7 +339,7 @@ Przenieś do pola w i pokaż diff.
**Zoo pól CTA / sekcja-monolit:**
```
-Stop. AGENT.md §6.5–6.6: CTA = linksField() + CMSLink, obraz = media + Media,
+Stop. AGENT.md §6.5–6.6: CTA = buildLinksField() + CMSLink, obraz = media + Media,
max ~80 linii JSX. Zrefaktoruj wg §6.7. Jeśli w bazie jest treść — najpierw migracja.
```
diff --git a/docs/links.md b/docs/links.md
new file mode 100644
index 0000000..5c74570
--- /dev/null
+++ b/docs/links.md
@@ -0,0 +1,65 @@
+# links
+
+Jeden kształt linku dla całego projektu — przyciski CTA, linki w kartach,
+pliki do pobrania. Pole schematu + funkcja zamieniająca wartość na `href`.
+Wygląd (komponent `CMSLink`, warianty przycisków) zostaje w projekcie.
+
+## Pola
+
+```ts
+import { buildLinkField, buildLinksField } from '@intecion/ipal-kit'
+
+fields: [
+ buildLinksField(), // `links`: 0–2 przyciski sekcji
+ buildLinksField({ maxRows: 3, appearances: ['primary', 'secondary'] }),
+ buildLinkField(), // `link`: pojedynczy link
+ buildLinkField({ disableLabel: true, appearances: false }), // klikalna cała karta
+]
+```
+
+| Opcja | Domyślnie | Co robi |
+|---|---|---|
+| `name` | `'link'` / `'links'` | nazwa pola |
+| `relationTo` | `'pages'` | kolekcja dla typu „Page” |
+| `uploadTo` | `'media'` | kolekcja dla typu „File” (PDF, dokumenty) |
+| `appearances` | `['primary','secondary','link']` | style do wyboru; `false` = bez pola |
+| `disableLabel` | `false` | bez etykiety (link owija kartę / obraz) — tylko `buildLinkField` |
+| `required` | `false` | wymagane pola celu i etykiety |
+| `maxRows` | `2` | tylko `buildLinksField` |
+
+Wartość linku: `type` (`internal` strona · `external` URL, `mailto:`, `tel:`,
+`#anchor` · `file` upload), `page`, `url`, `file`, `label` (localized), `newTab`,
+`appearance`. W `payload-types.ts` powstaje typ **`CmsLink`**.
+
+Plik do pobrania to link typu `file` — **nie** osobne pole `pdfUrl`.
+
+## href
+
+```ts
+import { resolveLinkHref } from '@intecion/ipal-kit'
+
+resolveLinkHref(link, { locale, config: i18nConfig, homeSlug })
+// internal → '/en/about' (strona główna → '/en') · external → URL · file → URL pliku
+// null → pusty link, brak strony w tym języku, strona niezpopulowana (sam ID), brak pliku
+```
+
+Linki wewnętrzne wymagają **zpopulowanej** strony (`depth ≥ 2` w bloku).
+`homeSlug` — slug strony głównej (string albo mapa per język, np. z
+`SiteSettings.homepage`), żeby zwinąć ją do `/{locale}`.
+
+## Render w projekcie
+
+Komponent `CMSLink` jest w projekcie (wygląd przycisków to sprawa projektu) —
+gotowy kod: [kod-sekcji.md](./agent/skills/ipal-block/resources/kod-sekcji.md). Menu: `resolveNav` w
+`lib/navigation.ts` ([kod-nawigacji.md](./agent/skills/ipal-nav/resources/kod-nawigacji.md)) korzysta z tego samego `resolveLinkHref`.
+
+## Migracja z `src/fields/link.ts`
+
+Projekty sprzed 1.8.x mają kopię w `src/fields/link.ts` i `src/lib/links.ts`.
+Kształt danych jest identyczny (`interfaceName: 'CmsLink'`), więc **migracja
+bazy nie jest potrzebna**:
+1. importy `linkField` / `linksField` z `@/fields/link` → `buildLinkField` /
+ `buildLinksField` z `@intecion/ipal-kit`,
+2. `resolveLinkHref(link, locale, homeSlug)` z `@/lib/links` →
+ `resolveLinkHref(link, { locale, config: i18nConfig, homeSlug })` z pluginu,
+3. usuń `src/fields/link.ts` i `src/lib/links.ts`, `pnpm generate:types`.
diff --git a/docs/pages.md b/docs/pages.md
index 4d23f43..6fee489 100644
--- a/docs/pages.md
+++ b/docs/pages.md
@@ -62,27 +62,63 @@ 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`) — pełny przykład w
-`frontend/[locale]/not-found.tsx`:
+Projekt — `app/(frontend)/[locale]/not-found.tsx` (pełny plik):
```tsx
+import React from 'react'
+
import { RenderBlocks } from '@intecion/ipal-kit/rsc'
import { LocaleView } from '@intecion/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 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) // null → brak przypisania
- return [locale, page?.layout?.length
- ? ({ locale })} />
- : null]
- })))
+
+ 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 ? (
+ ({ 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 (
+
+ 404
+
+ )
+ }
+
return
}
```
-> **NIE czytaj `headers()` w `not-found.tsx`** (`LocaleView` od 1.7.13). `not-found.tsx` nie dostaje
+> **NIE czytaj `headers()` w `not-found.tsx`** (`LocaleView` od 1.8.2). `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**
diff --git a/docs/security.md b/docs/security.md
index 01eb33b..184f529 100644
--- a/docs/security.md
+++ b/docs/security.md
@@ -212,6 +212,10 @@ ipalKit({
})
```
+**`robots.txt` przy ukrytym panelu:** domyślny `robots` blokuje `/admin`. Nie
+wpisuj tam `/its` — `robots.txt` jest publiczny i zdradziłby ścieżkę (panel i
+tak ma `noindex`). W `createContentHelpers` ustaw `robots: { adminRoute: false }`.
+
### WYMAGANE — przenieś folder panelu w projekcie
Plugin ustawia `config.routes.admin`, ale NIE tworzy plików w `app/` projektu.
diff --git a/docs/seo.md b/docs/seo.md
index 308a33d..7f07a7d 100644
--- a/docs/seo.md
+++ b/docs/seo.md
@@ -78,10 +78,29 @@ pusty tytuł ani sam siteName.
> coś ze słowami kluczowymi. Fallback page.title nie pomoże, bo problemem jest
> sama treść nazwy, nie brak tytułu.
-## Front — createPageMetadata
+## Front — generatePageMetadata (zalecane)
-Dla zwykłych stron. Zna konwencje pluginu (kolekcja pages, SiteSettings, System
-Pages, grupa meta), więc nie trzeba mu tego opisywać:
+Z `createContentHelpers` (lib/content) — dzieli cache żądania z layoutem i
+komponentem strony: **jedno** odczytanie SiteSettings i **jedno** `resolveRoute`
+na żądanie, zamiast osobnych zapytań w metadata i w stronie:
+
+```ts
+// app/(frontend)/[locale]/[[...slug]]/page.tsx
+import { generatePageMetadata } from '@/lib/content'
+
+export async function generateMetadata({ params }): Promise {
+ const { locale, slug } = await params
+ return generatePageMetadata(locale, slug) // archiwum z paginacją: (locale, slug, page)
+}
+```
+
+Wymaga `i18n` w `createContentHelpers`. Pod spodem to `createPageMetadata` z
+wstrzykniętymi loaderami z cache — wszystko poniżej dotyczy też jego.
+
+## createPageMetadata (niskopoziomowo)
+
+Gdy nie używasz `createContentHelpers` albo trasa ma własne konwencje. Zna
+konwencje pluginu (kolekcja pages, SiteSettings, System Pages, grupa meta):
```ts
// app/(frontend)/[locale]/[[...slug]]/page.tsx
@@ -103,7 +122,8 @@ export async function generateMetadata({ params }): Promise {
```
Wrapper jest konieczny: Next woła `generateMetadata({ params })` bez payloada, a
-plugin nigdy nie wywołuje `getPayload` sam.
+plugin nigdy nie wywołuje `getPayload` sam. Opcja `loaders: { getSettings,
+resolveRoute }` pozwala podać własne funkcje z cache (tak robi `generatePageMetadata`).
Ogarnia: tytuł (order/separator/override z panelu), description, canonical,
hreflang dla wszystkich locale, OG, home zwinięty do `/pl` (slug home czytany z
@@ -318,7 +338,7 @@ Favicon jest GLOBALNY (ten sam wszędzie) — wpina się RAZ w root layout, nie
// app/(frontend)/[locale]/layout.tsx
import type { Metadata } from 'next'
import { buildIconsMetadata } from '@intecion/ipal-kit'
-import { getSettings } from '@/lib/payload'
+import { getSettings } from '@/lib/content' // z createContentHelpers
export async function generateMetadata({ params }): Promise {
const { locale } = await params
@@ -775,21 +795,36 @@ Opcje: `name` (domyślnie `'noindex'`), `label`, `description`, `overrides`
## robots.txt — blokada parametrów (crawl budget)
URL-e z parametrami (`?meter=101-120m2`, `?s=fraza`) marnują budżet indeksowania —
-Google skanuje dziesiątki pustych wariantów. Zablokuj je w robots:
+Google skanuje dziesiątki pustych wariantów. Zablokuj je w robots — **dopisują
+się** do domyślnych `/admin` i `/api`:
```ts
+// lib/content.ts — gotowy handler robots z opcjami
+createContentHelpers({
+ config, content, i18n: i18nConfig, baseUrl,
+ robots: {
+ disallowParams: ['s', 'meter'], // → /*?s=, /*&s=, /*?meter=, /*&meter=
+ extraDisallow: ['/koszyk'], // dodatkowe ścieżki (opcjonalnie)
+ // aiBots: 'block-training', // patrz „wpuść boty AI” niżej
+ },
+})
+
// app/robots.ts
-import { buildRobots } from '@intecion/ipal-kit'
-export default function robots() {
- return buildRobots({
- baseUrl: process.env.NEXT_PUBLIC_SERVER_URL!,
- disallow: ['/admin', '/api', '/*?meter=*', '/*?s=*'], // + parametry
- })
-}
+export { robots as default } from '@/lib/content'
```
-Wzorce `/*?param=*` odcinają parametryzowane URL-e. Realne z audytu: 55
-niezindeksowanych stron kalkulatora — blokada w robots by temu zapobiegła.
+Bez `createContentHelpers`: `buildRobots({ baseUrl, disallowParams: ['s', 'meter'] })`.
+
+| Opcja | Działanie |
+|---|---|
+| `disallowParams` | nazwy parametrów → `/*?nazwa=` i `/*&nazwa=` (parametr nie musi być pierwszy) |
+| `extraDisallow` | ścieżki dopisane do domyślnych |
+| `adminRoute` | ścieżka panelu do zablokowania (domyślnie `/admin`); `false` = nie wpisuj (ukryty panel — patrz security.md) |
+| `disallow` | **pełna** lista — zastępuje domyślne (stary sposób; łatwo zgubić `/admin`) |
+
+**Nie blokuj `page`** — strony archiwum `?page=2` to prawdziwe strony z
+canonical na siebie. Realne z audytu: 55 niezindeksowanych stron kalkulatora
+(`?meter=`) — blokada w robots by temu zapobiegła.
## Local SEO — LocalBusiness, Service, FAQPage (structured data)
@@ -1101,7 +1136,8 @@ komponent opakowujący węzły w `@graph` + bezpieczny `