Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f5a4ceb5bf | ||
|
|
d041fd4bc6 | ||
|
|
e232e6d2a5 | ||
|
|
c738435fe0 | ||
|
|
cca2b20c3d | ||
|
|
105c454d73 | ||
|
|
cf6feefebc | ||
|
|
1857c8f771 | ||
|
|
542ad4ab9c | ||
|
|
9bf8599116 | ||
|
|
170c9a53f1 | ||
|
|
e0d5095099 | ||
|
|
08a8a10478 | ||
|
|
7bbaf14d14 | ||
|
|
b7d0b01122 | ||
|
|
4627266577 | ||
|
|
471ec4b12a | ||
|
|
060a61fd41 | ||
|
|
7cef95225a | ||
|
|
0ae62226bc | ||
|
|
610ab6fdf5 | ||
|
|
81275c0395 |
Vendored
+2
@@ -14,6 +14,8 @@ export { ConsentProvider, CookieBanner, CookieButton, useConsent, useConsentCont
|
|||||||
export type { CookieBannerClassNames } from '../modules/consent/client.js';
|
export type { CookieBannerClassNames } from '../modules/consent/client.js';
|
||||||
export { buildLocalizedPath, getLocaleCodes, getLocalizedSlugs, switchLocalePath, } from '../modules/i18n/index.js';
|
export { buildLocalizedPath, getLocaleCodes, getLocalizedSlugs, switchLocalePath, } from '../modules/i18n/index.js';
|
||||||
export type { I18nConfig, LocalizedSlugs } from '../modules/i18n/index.js';
|
export type { I18nConfig, LocalizedSlugs } from '../modules/i18n/index.js';
|
||||||
|
export { AlternateLinksProvider, AlternateLinksUpdater, LanguageSwitcher, useAlternateLinks, useSetAlternateLinks, } from '../modules/i18n/index.js';
|
||||||
|
export type { AlternateLinks, LanguageSwitcherClassNames } from '../modules/i18n/index.js';
|
||||||
export { Turnstile } from '../modules/turnstile/client.js';
|
export { Turnstile } from '../modules/turnstile/client.js';
|
||||||
export { TurnstileProvider, useTurnstile } from '../modules/turnstile/client.js';
|
export { TurnstileProvider, useTurnstile } from '../modules/turnstile/client.js';
|
||||||
export type { TurnstileProps } from '../modules/turnstile/client.js';
|
export type { TurnstileProps } from '../modules/turnstile/client.js';
|
||||||
|
|||||||
Vendored
+1
@@ -13,6 +13,7 @@ export { Analytics } from '../modules/analytics/client.js';
|
|||||||
// Pure i18n path helpers — no server/RSC deps, safe to import in client
|
// Pure i18n path helpers — no server/RSC deps, safe to import in client
|
||||||
// components (e.g. a LanguageSwitcher that computes locale URLs on the client).
|
// components (e.g. a LanguageSwitcher that computes locale URLs on the client).
|
||||||
export { buildLocalizedPath, getLocaleCodes, getLocalizedSlugs, switchLocalePath } from '../modules/i18n/index.js';
|
export { buildLocalizedPath, getLocaleCodes, getLocalizedSlugs, switchLocalePath } from '../modules/i18n/index.js';
|
||||||
|
export { AlternateLinksProvider, AlternateLinksUpdater, LanguageSwitcher, useAlternateLinks, useSetAlternateLinks } from '../modules/i18n/index.js';
|
||||||
export { Turnstile } from '../modules/turnstile/client.js';
|
export { Turnstile } from '../modules/turnstile/client.js';
|
||||||
export { TurnstileProvider, useTurnstile } from '../modules/turnstile/client.js';
|
export { TurnstileProvider, useTurnstile } from '../modules/turnstile/client.js';
|
||||||
|
|
||||||
|
|||||||
Vendored
+1
-1
@@ -1 +1 @@
|
|||||||
{"version":3,"sources":["../../src/exports/client.ts"],"sourcesContent":["'use client'\nexport { MaskedField } from '../globals/SiteIntegrations/components/MaskedField.js'\nexport { TestEmailButton } from '../globals/SiteIntegrations/components/TestEmailButton.js'\nexport {\n AccessibilityProvider,\n AccessibilityWidget,\n useAccessibility,\n} from '../modules/accessibility/client.js'\nexport type { A11yClassNames, A11yState, A11yTexts } from '../modules/accessibility/client.js'\n\nexport { Analytics } from '../modules/analytics/client.js'\n/**\n * Entry point: ipal-kit/client\n *\n * Client-side ('use client') exports — React hooks, providers, and UI\n * components. Kept separate from the main entry so server bundles don't pull in\n * client-only code.\n */\nexport {\n ConsentProvider,\n CookieBanner,\n CookieButton,\n useConsent,\n useConsentContext,\n} from '../modules/consent/client.js'\nexport type { CookieBannerClassNames } from '../modules/consent/client.js'\n// Pure i18n path helpers — no server/RSC deps, safe to import in client\n// components (e.g. a LanguageSwitcher that computes locale URLs on the client).\nexport {\n buildLocalizedPath,\n getLocaleCodes,\n getLocalizedSlugs,\n switchLocalePath,\n} from '../modules/i18n/index.js'\nexport type { I18nConfig, LocalizedSlugs } from '../modules/i18n/index.js'\nexport { Turnstile } from '../modules/turnstile/client.js'\nexport { TurnstileProvider, useTurnstile } from '../modules/turnstile/client.js'\nexport type { TurnstileProps } from '../modules/turnstile/client.js'\n"],"names":["MaskedField","TestEmailButton","AccessibilityProvider","AccessibilityWidget","useAccessibility","Analytics","ConsentProvider","CookieBanner","CookieButton","useConsent","useConsentContext","buildLocalizedPath","getLocaleCodes","getLocalizedSlugs","switchLocalePath","Turnstile","TurnstileProvider","useTurnstile"],"mappings":"AAAA;AACA,SAASA,WAAW,QAAQ,wDAAuD;AACnF,SAASC,eAAe,QAAQ,4DAA2D;AAC3F,SACEC,qBAAqB,EACrBC,mBAAmB,EACnBC,gBAAgB,QACX,qCAAoC;AAG3C,SAASC,SAAS,QAAQ,iCAAgC;AAC1D;;;;;;CAMC,GACD,SACEC,eAAe,EACfC,YAAY,EACZC,YAAY,EACZC,UAAU,EACVC,iBAAiB,QACZ,+BAA8B;AAErC,wEAAwE;AACxE,gFAAgF;AAChF,SACEC,kBAAkB,EAClBC,cAAc,EACdC,iBAAiB,EACjBC,gBAAgB,QACX,2BAA0B;AAEjC,SAASC,SAAS,QAAQ,iCAAgC;AAC1D,SAASC,iBAAiB,EAAEC,YAAY,QAAQ,iCAAgC"}
|
{"version":3,"sources":["../../src/exports/client.ts"],"sourcesContent":["'use client'\nexport { MaskedField } from '../globals/SiteIntegrations/components/MaskedField.js'\nexport { TestEmailButton } from '../globals/SiteIntegrations/components/TestEmailButton.js'\nexport {\n AccessibilityProvider,\n AccessibilityWidget,\n useAccessibility,\n} from '../modules/accessibility/client.js'\nexport type { A11yClassNames, A11yState, A11yTexts } from '../modules/accessibility/client.js'\nexport { Analytics } from '../modules/analytics/client.js'\n/**\n * Entry point: ipal-kit/client\n *\n * Client-side ('use client') exports — React hooks, providers, and UI\n * components. Kept separate from the main entry so server bundles don't pull in\n * client-only code.\n */\nexport {\n ConsentProvider,\n CookieBanner,\n CookieButton,\n useConsent,\n useConsentContext,\n} from '../modules/consent/client.js'\n\nexport type { CookieBannerClassNames } from '../modules/consent/client.js'\n// Pure i18n path helpers — no server/RSC deps, safe to import in client\n// components (e.g. a LanguageSwitcher that computes locale URLs on the client).\nexport {\n buildLocalizedPath,\n getLocaleCodes,\n getLocalizedSlugs,\n switchLocalePath,\n} from '../modules/i18n/index.js'\nexport type { I18nConfig, LocalizedSlugs } from '../modules/i18n/index.js'\nexport {\n AlternateLinksProvider,\n AlternateLinksUpdater,\n LanguageSwitcher,\n useAlternateLinks,\n useSetAlternateLinks,\n} from '../modules/i18n/index.js'\nexport type { AlternateLinks, LanguageSwitcherClassNames } from '../modules/i18n/index.js'\nexport { Turnstile } from '../modules/turnstile/client.js'\nexport { TurnstileProvider, useTurnstile } from '../modules/turnstile/client.js'\nexport type { TurnstileProps } from '../modules/turnstile/client.js'\n"],"names":["MaskedField","TestEmailButton","AccessibilityProvider","AccessibilityWidget","useAccessibility","Analytics","ConsentProvider","CookieBanner","CookieButton","useConsent","useConsentContext","buildLocalizedPath","getLocaleCodes","getLocalizedSlugs","switchLocalePath","AlternateLinksProvider","AlternateLinksUpdater","LanguageSwitcher","useAlternateLinks","useSetAlternateLinks","Turnstile","TurnstileProvider","useTurnstile"],"mappings":"AAAA;AACA,SAASA,WAAW,QAAQ,wDAAuD;AACnF,SAASC,eAAe,QAAQ,4DAA2D;AAC3F,SACEC,qBAAqB,EACrBC,mBAAmB,EACnBC,gBAAgB,QACX,qCAAoC;AAE3C,SAASC,SAAS,QAAQ,iCAAgC;AAC1D;;;;;;CAMC,GACD,SACEC,eAAe,EACfC,YAAY,EACZC,YAAY,EACZC,UAAU,EACVC,iBAAiB,QACZ,+BAA8B;AAGrC,wEAAwE;AACxE,gFAAgF;AAChF,SACEC,kBAAkB,EAClBC,cAAc,EACdC,iBAAiB,EACjBC,gBAAgB,QACX,2BAA0B;AAEjC,SACEC,sBAAsB,EACtBC,qBAAqB,EACrBC,gBAAgB,EAChBC,iBAAiB,EACjBC,oBAAoB,QACf,2BAA0B;AAEjC,SAASC,SAAS,QAAQ,iCAAgC;AAC1D,SAASC,iBAAiB,EAAEC,YAAY,QAAQ,iCAAgC"}
|
||||||
Vendored
+1
@@ -7,3 +7,4 @@
|
|||||||
*/
|
*/
|
||||||
export { createLocaleMiddleware, DEFAULT_MIDDLEWARE_MATCHER } from '../modules/i18n/index.js';
|
export { createLocaleMiddleware, DEFAULT_MIDDLEWARE_MATCHER } from '../modules/i18n/index.js';
|
||||||
export type { LocaleMiddlewareResult } from '../modules/i18n/index.js';
|
export type { LocaleMiddlewareResult } from '../modules/i18n/index.js';
|
||||||
|
export { createProxy, DEFAULT_PROXY_MATCHER } from '../modules/i18n/index.js';
|
||||||
|
|||||||
Vendored
+1
@@ -5,5 +5,6 @@
|
|||||||
* client project's middleware.ts. Kept as a thin re-export so the Next-facing
|
* client project's middleware.ts. Kept as a thin re-export so the Next-facing
|
||||||
* surface is separate from the main package export.
|
* surface is separate from the main package export.
|
||||||
*/ export { createLocaleMiddleware, DEFAULT_MIDDLEWARE_MATCHER } 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';
|
||||||
|
|
||||||
//# sourceMappingURL=next-middleware.js.map
|
//# sourceMappingURL=next-middleware.js.map
|
||||||
Vendored
+1
-1
@@ -1 +1 @@
|
|||||||
{"version":3,"sources":["../../src/exports/next-middleware.ts"],"sourcesContent":["/**\n * Entry point: ipal-kit/next/middleware\n *\n * Re-exports the locale middleware factory and default matcher for use in a\n * client project's middleware.ts. Kept as a thin re-export so the Next-facing\n * surface is separate from the main package export.\n */\nexport { createLocaleMiddleware, DEFAULT_MIDDLEWARE_MATCHER } from '../modules/i18n/index.js'\nexport type { LocaleMiddlewareResult } from '../modules/i18n/index.js'\n"],"names":["createLocaleMiddleware","DEFAULT_MIDDLEWARE_MATCHER"],"mappings":"AAAA;;;;;;CAMC,GACD,SAASA,sBAAsB,EAAEC,0BAA0B,QAAQ,2BAA0B"}
|
{"version":3,"sources":["../../src/exports/next-middleware.ts"],"sourcesContent":["/**\n * Entry point: ipal-kit/next/middleware\n *\n * Re-exports the locale middleware factory and default matcher for use in a\n * client project's middleware.ts. Kept as a thin re-export so the Next-facing\n * surface is separate from the main package export.\n */\nexport { createLocaleMiddleware, DEFAULT_MIDDLEWARE_MATCHER } from '../modules/i18n/index.js'\nexport type { LocaleMiddlewareResult } from '../modules/i18n/index.js'\nexport { createProxy, DEFAULT_PROXY_MATCHER } from '../modules/i18n/index.js'\n"],"names":["createLocaleMiddleware","DEFAULT_MIDDLEWARE_MATCHER","createProxy","DEFAULT_PROXY_MATCHER"],"mappings":"AAAA;;;;;;CAMC,GACD,SAASA,sBAAsB,EAAEC,0BAA0B,QAAQ,2BAA0B;AAE7F,SAASC,WAAW,EAAEC,qBAAqB,QAAQ,2BAA0B"}
|
||||||
Vendored
+2
@@ -7,4 +7,6 @@
|
|||||||
*/
|
*/
|
||||||
export { RenderBlocks } from '../modules/blocks/index.js';
|
export { RenderBlocks } from '../modules/blocks/index.js';
|
||||||
export type { BlockComponentMap, BlockData, EnhanceProps, RenderBlocksProps, } from '../modules/blocks/index.js';
|
export type { BlockComponentMap, BlockData, EnhanceProps, RenderBlocksProps, } from '../modules/blocks/index.js';
|
||||||
|
export { RenderRichText } from '../modules/richtext/index.js';
|
||||||
|
export type { RenderRichTextProps } from '../modules/richtext/index.js';
|
||||||
export { MediaPreconnect } from '../modules/storage/MediaPreconnect.js';
|
export { MediaPreconnect } from '../modules/storage/MediaPreconnect.js';
|
||||||
|
|||||||
Vendored
+1
@@ -5,6 +5,7 @@
|
|||||||
* lives here rather than in the main package entry to keep React out of the
|
* lives here rather than in the main package entry to keep React out of the
|
||||||
* server-config bundle.
|
* server-config bundle.
|
||||||
*/ export { RenderBlocks } from '../modules/blocks/index.js';
|
*/ export { RenderBlocks } from '../modules/blocks/index.js';
|
||||||
|
export { RenderRichText } from '../modules/richtext/index.js';
|
||||||
export { MediaPreconnect } from '../modules/storage/MediaPreconnect.js';
|
export { MediaPreconnect } from '../modules/storage/MediaPreconnect.js';
|
||||||
|
|
||||||
//# sourceMappingURL=rsc.js.map
|
//# sourceMappingURL=rsc.js.map
|
||||||
Vendored
+1
-1
@@ -1 +1 @@
|
|||||||
{"version":3,"sources":["../../src/exports/rsc.ts"],"sourcesContent":["/**\n * Entry point: ipal-kit/rsc\n *\n * Server-component exports. RenderBlocks is a React Server Component, so it\n * lives here rather than in the main package entry to keep React out of the\n * server-config bundle.\n */\nexport { RenderBlocks } from '../modules/blocks/index.js'\nexport type {\n BlockComponentMap,\n BlockData,\n EnhanceProps,\n RenderBlocksProps,\n} from '../modules/blocks/index.js'\nexport { MediaPreconnect } from '../modules/storage/MediaPreconnect.js'\n"],"names":["RenderBlocks","MediaPreconnect"],"mappings":"AAAA;;;;;;CAMC,GACD,SAASA,YAAY,QAAQ,6BAA4B;AAOzD,SAASC,eAAe,QAAQ,wCAAuC"}
|
{"version":3,"sources":["../../src/exports/rsc.ts"],"sourcesContent":["/**\n * Entry point: ipal-kit/rsc\n *\n * Server-component exports. RenderBlocks is a React Server Component, so it\n * lives here rather than in the main package entry to keep React out of the\n * server-config bundle.\n */\nexport { RenderBlocks } from '../modules/blocks/index.js'\nexport type {\n BlockComponentMap,\n BlockData,\n EnhanceProps,\n RenderBlocksProps,\n} from '../modules/blocks/index.js'\nexport { RenderRichText } from '../modules/richtext/index.js'\nexport type { RenderRichTextProps } from '../modules/richtext/index.js'\nexport { MediaPreconnect } from '../modules/storage/MediaPreconnect.js'\n"],"names":["RenderBlocks","RenderRichText","MediaPreconnect"],"mappings":"AAAA;;;;;;CAMC,GACD,SAASA,YAAY,QAAQ,6BAA4B;AAOzD,SAASC,cAAc,QAAQ,+BAA8B;AAE7D,SAASC,eAAe,QAAQ,wCAAuC"}
|
||||||
Vendored
+3
-1
@@ -23,6 +23,7 @@ export type { I18nConfig, LocaleDefinition, LocalizedSlugs } from './modules/i18
|
|||||||
export { buildLocalizedPath, getDefaultLocale, getLocaleCodes, getLocaleDefinition, getLocalizedSlugs, isValidLocale, LOCALE_COOKIE_NAME, matchAcceptLanguage, negotiateLocale, switchLocalePath, } from './modules/i18n/index.js';
|
export { buildLocalizedPath, getDefaultLocale, getLocaleCodes, getLocaleDefinition, getLocalizedSlugs, isValidLocale, LOCALE_COOKIE_NAME, matchAcceptLanguage, negotiateLocale, switchLocalePath, } from './modules/i18n/index.js';
|
||||||
export type { LocaleMiddlewareResult } from './modules/i18n/index.js';
|
export type { LocaleMiddlewareResult } from './modules/i18n/index.js';
|
||||||
export { createLocaleMiddleware, DEFAULT_MIDDLEWARE_MATCHER } 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 { normalizeFilename, normalizeFilenameHook } from './modules/media/index.js';
|
export { normalizeFilename, normalizeFilenameHook } from './modules/media/index.js';
|
||||||
export { getNotificationTexts, NOTIFICATION_FALLBACK, resolveFormMessage, } from './modules/notifications/index.js';
|
export { getNotificationTexts, NOTIFICATION_FALLBACK, resolveFormMessage, } from './modules/notifications/index.js';
|
||||||
export type { FormNotificationTexts, NotificationTexts } from './modules/notifications/index.js';
|
export type { FormNotificationTexts, NotificationTexts } from './modules/notifications/index.js';
|
||||||
@@ -38,12 +39,13 @@ export type { PageMetadata, SeoMeta, SeoOption } from './modules/seo/index.js';
|
|||||||
export { buildHreflangAlternates, buildMetadata, composeTitle } 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 type { AutoFillMapping, RobotsRules, SitemapEntry } from './modules/seo/index.js';
|
||||||
export { buildAutoFillMetaHook, buildRobots, buildSitemapEntries, createMetadataGenerator, createPageMetadata, injectAutoFillMeta, } from './modules/seo/index.js';
|
export { 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';
|
export { buildIconsMetadata, buildOrganizationJsonLd, validateFaviconField, } from './modules/seo/index.js';
|
||||||
export { buildBreadcrumbJsonLd, buildSiteNavigationJsonLd, buildWebSiteJsonLd, } from './modules/seo/index.js';
|
export { buildBreadcrumbJsonLd, buildSiteNavigationJsonLd, buildWebSiteJsonLd, } from './modules/seo/index.js';
|
||||||
export { buildFaqJsonLd, buildLocalBusinessJsonLd, buildServiceJsonLd, } from './modules/seo/index.js';
|
export { buildFaqJsonLd, buildLocalBusinessJsonLd, buildServiceJsonLd, } from './modules/seo/index.js';
|
||||||
export { buildArticleJsonLd } from './modules/seo/index.js';
|
export { buildArticleJsonLd } from './modules/seo/index.js';
|
||||||
export { buildSitemapXml } from './modules/seo/index.js';
|
|
||||||
export { buildLlmsTxt } from './modules/seo/index.js';
|
export { buildLlmsTxt } from './modules/seo/index.js';
|
||||||
|
export { buildSitemapXml } from './modules/seo/index.js';
|
||||||
export { buildSlugField, toSlug } from './modules/slug/index.js';
|
export { buildSlugField, toSlug } from './modules/slug/index.js';
|
||||||
export { buildR2Storage } from './modules/storage/index.js';
|
export { buildR2Storage } from './modules/storage/index.js';
|
||||||
export { ipalKit } from './plugin.js';
|
export { ipalKit } from './plugin.js';
|
||||||
|
|||||||
Vendored
+3
-1
@@ -14,6 +14,7 @@ export { createContentHelpers } from './modules/frontend/index.js';
|
|||||||
export { buildPreventDeleteSystemPage, buildRevalidateHook, buildValidateUniqueRole, setPublishedAtHook, trackSlugHistoryHook } from './modules/hooks/index.js';
|
export { buildPreventDeleteSystemPage, buildRevalidateHook, buildValidateUniqueRole, setPublishedAtHook, trackSlugHistoryHook } from './modules/hooks/index.js';
|
||||||
export { buildLocalizedPath, getDefaultLocale, getLocaleCodes, getLocaleDefinition, getLocalizedSlugs, isValidLocale, LOCALE_COOKIE_NAME, matchAcceptLanguage, negotiateLocale, switchLocalePath } from './modules/i18n/index.js';
|
export { buildLocalizedPath, getDefaultLocale, getLocaleCodes, getLocaleDefinition, getLocalizedSlugs, isValidLocale, LOCALE_COOKIE_NAME, matchAcceptLanguage, negotiateLocale, switchLocalePath } from './modules/i18n/index.js';
|
||||||
export { createLocaleMiddleware, DEFAULT_MIDDLEWARE_MATCHER } 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 { normalizeFilename, normalizeFilenameHook } from './modules/media/index.js';
|
export { normalizeFilename, normalizeFilenameHook } from './modules/media/index.js';
|
||||||
export { getNotificationTexts, NOTIFICATION_FALLBACK, resolveFormMessage } from './modules/notifications/index.js';
|
export { getNotificationTexts, NOTIFICATION_FALLBACK, resolveFormMessage } from './modules/notifications/index.js';
|
||||||
export { ALL_SYSTEM_PAGE_ROLES, getSystemPagePath } from './modules/pages/index.js';
|
export { ALL_SYSTEM_PAGE_ROLES, getSystemPagePath } from './modules/pages/index.js';
|
||||||
@@ -22,13 +23,14 @@ export { buildSecurityHeaders } from './modules/security/index.js';
|
|||||||
export { buildCsp } 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 } from './modules/seo/index.js';
|
||||||
export { buildAutoFillMetaHook, buildRobots, buildSitemapEntries, createMetadataGenerator, createPageMetadata, injectAutoFillMeta } from './modules/seo/index.js';
|
export { 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';
|
export { buildIconsMetadata, buildOrganizationJsonLd, validateFaviconField } from './modules/seo/index.js';
|
||||||
export { buildBreadcrumbJsonLd, buildSiteNavigationJsonLd, buildWebSiteJsonLd } from './modules/seo/index.js';
|
export { buildBreadcrumbJsonLd, buildSiteNavigationJsonLd, buildWebSiteJsonLd } from './modules/seo/index.js';
|
||||||
// Local SEO structured data — LocalBusiness (map pack), Service (offering), FAQPage.
|
// Local SEO structured data — LocalBusiness (map pack), Service (offering), FAQPage.
|
||||||
export { buildFaqJsonLd, buildLocalBusinessJsonLd, buildServiceJsonLd } from './modules/seo/index.js';
|
export { buildFaqJsonLd, buildLocalBusinessJsonLd, buildServiceJsonLd } from './modules/seo/index.js';
|
||||||
export { buildArticleJsonLd } from './modules/seo/index.js';
|
export { buildArticleJsonLd } from './modules/seo/index.js';
|
||||||
export { buildSitemapXml } from './modules/seo/index.js';
|
|
||||||
export { buildLlmsTxt } from './modules/seo/index.js';
|
export { buildLlmsTxt } from './modules/seo/index.js';
|
||||||
|
export { buildSitemapXml } from './modules/seo/index.js';
|
||||||
export { buildSlugField, toSlug } from './modules/slug/index.js';
|
export { buildSlugField, toSlug } from './modules/slug/index.js';
|
||||||
export { buildR2Storage } from './modules/storage/index.js';
|
export { buildR2Storage } from './modules/storage/index.js';
|
||||||
export { ipalKit } from './plugin.js';
|
export { ipalKit } from './plugin.js';
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+8
@@ -4,6 +4,7 @@ import { Cookie } from 'lucide-react';
|
|||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { CONSENT_CATEGORIES } from './categories.js';
|
import { CONSENT_CATEGORIES } from './categories.js';
|
||||||
import { useConsentContext } from './ConsentContext.js';
|
import { useConsentContext } from './ConsentContext.js';
|
||||||
|
import { useIsMounted } from './useIsMounted.js';
|
||||||
/**
|
/**
|
||||||
* Colours and radius come from CSS custom properties with built-in fallbacks,
|
* Colours and radius come from CSS custom properties with built-in fallbacks,
|
||||||
* so the banner looks right with no setup, and re-skinning per client means
|
* so the banner looks right with no setup, and re-skinning per client means
|
||||||
@@ -36,6 +37,7 @@ const bodyText = 'text-[var(--ipal-text,#404040)] dark:text-[var(--ipal-text-dar
|
|||||||
const strongText = 'text-[var(--ipal-text-strong,#171717)] dark:text-[var(--ipal-text-strong-dark,#f5f5f5)]';
|
const strongText = 'text-[var(--ipal-text-strong,#171717)] dark:text-[var(--ipal-text-strong-dark,#f5f5f5)]';
|
||||||
const mutedText = 'text-[var(--ipal-text-muted,#737373)] dark:text-[var(--ipal-text-muted-dark,#a3a3a3)]';
|
const mutedText = 'text-[var(--ipal-text-muted,#737373)] dark:text-[var(--ipal-text-muted-dark,#a3a3a3)]';
|
||||||
export function CookieBanner({ classNames } = {}) {
|
export function CookieBanner({ classNames } = {}) {
|
||||||
|
const isMounted = useIsMounted();
|
||||||
const { acceptAll, decided, rejectAll, savePreferences, state, texts } = useConsentContext();
|
const { acceptAll, decided, rejectAll, savePreferences, state, texts } = useConsentContext();
|
||||||
const [showSettings, setShowSettings] = useState(false);
|
const [showSettings, setShowSettings] = useState(false);
|
||||||
const [choices, setChoices] = useState(state);
|
const [choices, setChoices] = useState(state);
|
||||||
@@ -44,6 +46,12 @@ export function CookieBanner({ classNames } = {}) {
|
|||||||
}, [
|
}, [
|
||||||
state
|
state
|
||||||
]);
|
]);
|
||||||
|
// Render nothing until mounted — avoids the React 19 hydration mismatch that
|
||||||
|
// projects used to work around with a setTimeout ConsentWrapper. No wrapper
|
||||||
|
// needed now.
|
||||||
|
if (!isMounted) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
if (decided) {
|
if (decided) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+7
@@ -2,6 +2,7 @@
|
|||||||
import { jsx as _jsx } from "react/jsx-runtime";
|
import { jsx as _jsx } from "react/jsx-runtime";
|
||||||
import { Cookie } from 'lucide-react';
|
import { Cookie } from 'lucide-react';
|
||||||
import { useConsentContext } from './ConsentContext.js';
|
import { useConsentContext } from './ConsentContext.js';
|
||||||
|
import { useIsMounted } from './useIsMounted.js';
|
||||||
/**
|
/**
|
||||||
* Floating "cookie settings" button — lets visitors reopen the consent panel
|
* Floating "cookie settings" button — lets visitors reopen the consent panel
|
||||||
* after deciding (GDPR: withdrawing consent must be as easy as giving it).
|
* after deciding (GDPR: withdrawing consent must be as easy as giving it).
|
||||||
@@ -12,7 +13,13 @@ import { useConsentContext } from './ConsentContext.js';
|
|||||||
* palette applies to both without touching either component. Pass className to
|
* palette applies to both without touching either component. Pass className to
|
||||||
* replace the styling outright.
|
* replace the styling outright.
|
||||||
*/ export function CookieButton({ className } = {}) {
|
*/ export function CookieButton({ className } = {}) {
|
||||||
|
const isMounted = useIsMounted();
|
||||||
const { decided, reopen } = useConsentContext();
|
const { decided, reopen } = useConsentContext();
|
||||||
|
// Render nothing until mounted — prevents hydration mismatch (no project
|
||||||
|
// ConsentWrapper workaround needed).
|
||||||
|
if (!isMounted) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
if (!decided) {
|
if (!decided) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
{"version":3,"sources":["../../../src/modules/consent/CookieButton.tsx"],"sourcesContent":["'use client'\nimport { Cookie } from 'lucide-react'\n\nimport { useConsentContext } from './ConsentContext.js'\n\n/**\n * Floating \"cookie settings\" button — lets visitors reopen the consent panel\n * after deciding (GDPR: withdrawing consent must be as easy as giving it).\n * Hidden while the banner is showing.\n *\n * Colours follow the same CSS custom properties as CookieBanner\n * (--ipal-surface, --ipal-border, --ipal-hover, --ipal-text), so a client's\n * palette applies to both without touching either component. Pass className to\n * replace the styling outright.\n */\nexport function CookieButton({ className }: { className?: string } = {}) {\n const { decided, reopen } = useConsentContext()\n\n if (!decided) {return null}\n\n const cls =\n className ??\n 'fixed bottom-4 left-4 z-40 flex h-11 w-11 items-center justify-center rounded-full border shadow-md transition-colors ' +\n 'bg-[var(--ipal-surface,#fff)] border-[var(--ipal-border,#e5e5e5)] hover:bg-[var(--ipal-hover,#f5f5f5)] ' +\n 'dark:bg-[var(--ipal-surface-dark,#171717)] dark:border-[var(--ipal-border-dark,#262626)] dark:hover:bg-[var(--ipal-hover-dark,#262626)]'\n\n return (\n <button aria-label=\"Cookie settings\" className={cls} data-ipal=\"cookie-button\" onClick={reopen}>\n <Cookie\n aria-hidden=\"true\"\n className=\"h-5 w-5 text-[var(--ipal-text,#525252)] dark:text-[var(--ipal-text-dark,#d4d4d4)]\"\n />\n </button>\n )\n}\n"],"names":["Cookie","useConsentContext","CookieButton","className","decided","reopen","cls","button","aria-label","data-ipal","onClick","aria-hidden"],"mappings":"AAAA;;AACA,SAASA,MAAM,QAAQ,eAAc;AAErC,SAASC,iBAAiB,QAAQ,sBAAqB;AAEvD;;;;;;;;;CASC,GACD,OAAO,SAASC,aAAa,EAAEC,SAAS,EAA0B,GAAG,CAAC,CAAC;IACrE,MAAM,EAAEC,OAAO,EAAEC,MAAM,EAAE,GAAGJ;IAE5B,IAAI,CAACG,SAAS;QAAC,OAAO;IAAI;IAE1B,MAAME,MACJH,aACA,2HACE,4GACA;IAEJ,qBACE,KAACI;QAAOC,cAAW;QAAkBL,WAAWG;QAAKG,aAAU;QAAgBC,SAASL;kBACtF,cAAA,KAACL;YACCW,eAAY;YACZR,WAAU;;;AAIlB"}
|
{"version":3,"sources":["../../../src/modules/consent/CookieButton.tsx"],"sourcesContent":["'use client'\nimport { Cookie } from 'lucide-react'\n\nimport { useConsentContext } from './ConsentContext.js'\nimport { useIsMounted } from './useIsMounted.js'\n\n/**\n * Floating \"cookie settings\" button — lets visitors reopen the consent panel\n * after deciding (GDPR: withdrawing consent must be as easy as giving it).\n * Hidden while the banner is showing.\n *\n * Colours follow the same CSS custom properties as CookieBanner\n * (--ipal-surface, --ipal-border, --ipal-hover, --ipal-text), so a client's\n * palette applies to both without touching either component. Pass className to\n * replace the styling outright.\n */\nexport function CookieButton({ className }: { className?: string } = {}) {\n const isMounted = useIsMounted()\n const { decided, reopen } = useConsentContext()\n\n // Render nothing until mounted — prevents hydration mismatch (no project\n // ConsentWrapper workaround needed).\n if (!isMounted) {return null}\n if (!decided) {return null}\n\n const cls =\n className ??\n 'fixed bottom-4 left-4 z-40 flex h-11 w-11 items-center justify-center rounded-full border shadow-md transition-colors ' +\n 'bg-[var(--ipal-surface,#fff)] border-[var(--ipal-border,#e5e5e5)] hover:bg-[var(--ipal-hover,#f5f5f5)] ' +\n 'dark:bg-[var(--ipal-surface-dark,#171717)] dark:border-[var(--ipal-border-dark,#262626)] dark:hover:bg-[var(--ipal-hover-dark,#262626)]'\n\n return (\n <button aria-label=\"Cookie settings\" className={cls} data-ipal=\"cookie-button\" onClick={reopen}>\n <Cookie\n aria-hidden=\"true\"\n className=\"h-5 w-5 text-[var(--ipal-text,#525252)] dark:text-[var(--ipal-text-dark,#d4d4d4)]\"\n />\n </button>\n )\n}\n"],"names":["Cookie","useConsentContext","useIsMounted","CookieButton","className","isMounted","decided","reopen","cls","button","aria-label","data-ipal","onClick","aria-hidden"],"mappings":"AAAA;;AACA,SAASA,MAAM,QAAQ,eAAc;AAErC,SAASC,iBAAiB,QAAQ,sBAAqB;AACvD,SAASC,YAAY,QAAQ,oBAAmB;AAEhD;;;;;;;;;CASC,GACD,OAAO,SAASC,aAAa,EAAEC,SAAS,EAA0B,GAAG,CAAC,CAAC;IACrE,MAAMC,YAAYH;IAClB,MAAM,EAAEI,OAAO,EAAEC,MAAM,EAAE,GAAGN;IAE5B,yEAAyE;IACzE,qCAAqC;IACrC,IAAI,CAACI,WAAW;QAAC,OAAO;IAAI;IAC5B,IAAI,CAACC,SAAS;QAAC,OAAO;IAAI;IAE1B,MAAME,MACJJ,aACA,2HACE,4GACA;IAEJ,qBACE,KAACK;QAAOC,cAAW;QAAkBN,WAAWI;QAAKG,aAAU;QAAgBC,SAASL;kBACtF,cAAA,KAACP;YACCa,eAAY;YACZT,WAAU;;;AAIlB"}
|
||||||
Vendored
+1
@@ -4,3 +4,4 @@ export { getConsentTexts } from './getConsentTexts.js';
|
|||||||
export { setDefaultConsent, updateConsent } from './googleConsent.js';
|
export { setDefaultConsent, updateConsent } from './googleConsent.js';
|
||||||
export { CONSENT_COOKIE, CONSENT_MAX_AGE, CONSENT_VERSION, parseConsent, serializeConsent, } from './storage.js';
|
export { CONSENT_COOKIE, CONSENT_MAX_AGE, CONSENT_VERSION, parseConsent, serializeConsent, } from './storage.js';
|
||||||
export type { ConsentTexts } from './texts.js';
|
export type { ConsentTexts } from './texts.js';
|
||||||
|
export { useIsMounted } from './useIsMounted.js';
|
||||||
|
|||||||
Vendored
+1
@@ -5,5 +5,6 @@ export { ACCEPT_ALL_CONSENT, CONSENT_CATEGORIES, DEFAULT_CONSENT, REJECT_ALL_CON
|
|||||||
export { getConsentTexts } from './getConsentTexts.js';
|
export { getConsentTexts } from './getConsentTexts.js';
|
||||||
export { setDefaultConsent, updateConsent } from './googleConsent.js';
|
export { setDefaultConsent, updateConsent } from './googleConsent.js';
|
||||||
export { CONSENT_COOKIE, CONSENT_MAX_AGE, CONSENT_VERSION, parseConsent, serializeConsent } from './storage.js';
|
export { CONSENT_COOKIE, CONSENT_MAX_AGE, CONSENT_VERSION, parseConsent, serializeConsent } from './storage.js';
|
||||||
|
export { useIsMounted } from './useIsMounted.js';
|
||||||
|
|
||||||
//# sourceMappingURL=index.js.map
|
//# sourceMappingURL=index.js.map
|
||||||
Vendored
+1
-1
@@ -1 +1 @@
|
|||||||
{"version":3,"sources":["../../../src/modules/consent/index.ts"],"sourcesContent":["// Server-safe exports (logic, types, helper). Client components (banner,\n// provider, hook) are exported separately via ./client to keep the RSC/client\n// boundary clean.\nexport {\n ACCEPT_ALL_CONSENT,\n CONSENT_CATEGORIES,\n DEFAULT_CONSENT,\n REJECT_ALL_CONSENT,\n} from './categories.js'\nexport type { ConsentCategory, ConsentState } from './categories.js'\nexport { getConsentTexts } from './getConsentTexts.js'\nexport { setDefaultConsent, updateConsent } from './googleConsent.js'\nexport {\n CONSENT_COOKIE,\n CONSENT_MAX_AGE,\n CONSENT_VERSION,\n parseConsent,\n serializeConsent,\n} from './storage.js'\nexport type { ConsentTexts } from './texts.js'\n"],"names":["ACCEPT_ALL_CONSENT","CONSENT_CATEGORIES","DEFAULT_CONSENT","REJECT_ALL_CONSENT","getConsentTexts","setDefaultConsent","updateConsent","CONSENT_COOKIE","CONSENT_MAX_AGE","CONSENT_VERSION","parseConsent","serializeConsent"],"mappings":"AAAA,yEAAyE;AACzE,8EAA8E;AAC9E,kBAAkB;AAClB,SACEA,kBAAkB,EAClBC,kBAAkB,EAClBC,eAAe,EACfC,kBAAkB,QACb,kBAAiB;AAExB,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,iBAAiB,EAAEC,aAAa,QAAQ,qBAAoB;AACrE,SACEC,cAAc,EACdC,eAAe,EACfC,eAAe,EACfC,YAAY,EACZC,gBAAgB,QACX,eAAc"}
|
{"version":3,"sources":["../../../src/modules/consent/index.ts"],"sourcesContent":["// Server-safe exports (logic, types, helper). Client components (banner,\n// provider, hook) are exported separately via ./client to keep the RSC/client\n// boundary clean.\nexport {\n ACCEPT_ALL_CONSENT,\n CONSENT_CATEGORIES,\n DEFAULT_CONSENT,\n REJECT_ALL_CONSENT,\n} from './categories.js'\nexport type { ConsentCategory, ConsentState } from './categories.js'\nexport { getConsentTexts } from './getConsentTexts.js'\nexport { setDefaultConsent, updateConsent } from './googleConsent.js'\nexport {\n CONSENT_COOKIE,\n CONSENT_MAX_AGE,\n CONSENT_VERSION,\n parseConsent,\n serializeConsent,\n} from './storage.js'\nexport type { ConsentTexts } from './texts.js'\nexport { useIsMounted } from './useIsMounted.js'\n"],"names":["ACCEPT_ALL_CONSENT","CONSENT_CATEGORIES","DEFAULT_CONSENT","REJECT_ALL_CONSENT","getConsentTexts","setDefaultConsent","updateConsent","CONSENT_COOKIE","CONSENT_MAX_AGE","CONSENT_VERSION","parseConsent","serializeConsent","useIsMounted"],"mappings":"AAAA,yEAAyE;AACzE,8EAA8E;AAC9E,kBAAkB;AAClB,SACEA,kBAAkB,EAClBC,kBAAkB,EAClBC,eAAe,EACfC,kBAAkB,QACb,kBAAiB;AAExB,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,iBAAiB,EAAEC,aAAa,QAAQ,qBAAoB;AACrE,SACEC,cAAc,EACdC,eAAe,EACfC,eAAe,EACfC,YAAY,EACZC,gBAAgB,QACX,eAAc;AAErB,SAASC,YAAY,QAAQ,oBAAmB"}
|
||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* Returns true only after the component has mounted on the client. Used to gate
|
||||||
|
* consent UI (CookieBanner, CookieButton) so it renders nothing during SSR /
|
||||||
|
* first paint — preventing the React 19 / Next hydration mismatch that projects
|
||||||
|
* were working around with their own setTimeout-based ConsentWrapper. Built into
|
||||||
|
* the components now, so no project wrapper is needed.
|
||||||
|
*/
|
||||||
|
export declare function useIsMounted(): boolean;
|
||||||
Vendored
+17
@@ -0,0 +1,17 @@
|
|||||||
|
'use client';
|
||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
/**
|
||||||
|
* Returns true only after the component has mounted on the client. Used to gate
|
||||||
|
* consent UI (CookieBanner, CookieButton) so it renders nothing during SSR /
|
||||||
|
* first paint — preventing the React 19 / Next hydration mismatch that projects
|
||||||
|
* were working around with their own setTimeout-based ConsentWrapper. Built into
|
||||||
|
* the components now, so no project wrapper is needed.
|
||||||
|
*/ export function useIsMounted() {
|
||||||
|
const [mounted, setMounted] = useState(false);
|
||||||
|
useEffect(()=>{
|
||||||
|
setMounted(true);
|
||||||
|
}, []);
|
||||||
|
return mounted;
|
||||||
|
}
|
||||||
|
|
||||||
|
//# sourceMappingURL=useIsMounted.js.map
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"sources":["../../../src/modules/consent/useIsMounted.ts"],"sourcesContent":["'use client'\nimport { useEffect, useState } from 'react'\n\n/**\n * Returns true only after the component has mounted on the client. Used to gate\n * consent UI (CookieBanner, CookieButton) so it renders nothing during SSR /\n * first paint — preventing the React 19 / Next hydration mismatch that projects\n * were working around with their own setTimeout-based ConsentWrapper. Built into\n * the components now, so no project wrapper is needed.\n */\nexport function useIsMounted(): boolean {\n const [mounted, setMounted] = useState(false)\n useEffect(() => {\n setMounted(true)\n }, [])\n return mounted\n}\n"],"names":["useEffect","useState","useIsMounted","mounted","setMounted"],"mappings":"AAAA;AACA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAE3C;;;;;;CAMC,GACD,OAAO,SAASC;IACd,MAAM,CAACC,SAASC,WAAW,GAAGH,SAAS;IACvCD,UAAU;QACRI,WAAW;IACb,GAAG,EAAE;IACL,OAAOD;AACT"}
|
||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
/** Map of locale code → absolute-or-relative URL for the current page. */
|
||||||
|
export type AlternateLinks = Record<string, string>;
|
||||||
|
/**
|
||||||
|
* Holds the current page's per-locale URLs so a LanguageSwitcher links to the
|
||||||
|
* CORRECT localized slug instead of naively swapping the locale prefix
|
||||||
|
* (/pl/uslugi → /en/uslugi, which 404s when the English slug is /en/services).
|
||||||
|
*
|
||||||
|
* Wrap the app once; each page reports its own alternates via
|
||||||
|
* <AlternateLinksUpdater> (or useSetAlternateLinks). The switcher reads them
|
||||||
|
* with useAlternateLinks().
|
||||||
|
*
|
||||||
|
* // layout.tsx
|
||||||
|
* import { AlternateLinksProvider } from '@intecion/ipal-kit/client'
|
||||||
|
* <AlternateLinksProvider>{children}</AlternateLinksProvider>
|
||||||
|
*/
|
||||||
|
export declare function AlternateLinksProvider({ children }: {
|
||||||
|
children: React.ReactNode;
|
||||||
|
}): import("react/jsx-runtime").JSX.Element;
|
||||||
|
/** Read the current page's per-locale URLs (for a language switcher). */
|
||||||
|
export declare function useAlternateLinks(): AlternateLinks;
|
||||||
|
/** Setter for the alternates (used by AlternateLinksUpdater). */
|
||||||
|
export declare function useSetAlternateLinks(): (links: AlternateLinks) => void;
|
||||||
+37
@@ -0,0 +1,37 @@
|
|||||||
|
'use client';
|
||||||
|
import { jsx as _jsx } from "react/jsx-runtime";
|
||||||
|
import { createContext, use, useCallback, useState } from 'react';
|
||||||
|
const AlternateLinksContext = /*#__PURE__*/ createContext(null);
|
||||||
|
/**
|
||||||
|
* Holds the current page's per-locale URLs so a LanguageSwitcher links to the
|
||||||
|
* CORRECT localized slug instead of naively swapping the locale prefix
|
||||||
|
* (/pl/uslugi → /en/uslugi, which 404s when the English slug is /en/services).
|
||||||
|
*
|
||||||
|
* Wrap the app once; each page reports its own alternates via
|
||||||
|
* <AlternateLinksUpdater> (or useSetAlternateLinks). The switcher reads them
|
||||||
|
* with useAlternateLinks().
|
||||||
|
*
|
||||||
|
* // layout.tsx
|
||||||
|
* import { AlternateLinksProvider } from '@intecion/ipal-kit/client'
|
||||||
|
* <AlternateLinksProvider>{children}</AlternateLinksProvider>
|
||||||
|
*/ export function AlternateLinksProvider({ children }) {
|
||||||
|
const [links, setLinksState] = useState({});
|
||||||
|
const setLinks = useCallback((next)=>setLinksState(next), []);
|
||||||
|
return /*#__PURE__*/ _jsx(AlternateLinksContext, {
|
||||||
|
value: {
|
||||||
|
links,
|
||||||
|
setLinks
|
||||||
|
},
|
||||||
|
children: children
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/** Read the current page's per-locale URLs (for a language switcher). */ export function useAlternateLinks() {
|
||||||
|
const ctx = use(AlternateLinksContext);
|
||||||
|
return ctx?.links ?? {};
|
||||||
|
}
|
||||||
|
/** Setter for the alternates (used by AlternateLinksUpdater). */ export function useSetAlternateLinks() {
|
||||||
|
const ctx = use(AlternateLinksContext);
|
||||||
|
return ctx?.setLinks ?? (()=>{});
|
||||||
|
}
|
||||||
|
|
||||||
|
//# sourceMappingURL=AlternateLinksContext.js.map
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"sources":["../../../src/modules/i18n/AlternateLinksContext.tsx"],"sourcesContent":["'use client'\n\nimport { createContext, use, useCallback, useState } from 'react'\n\n/** Map of locale code → absolute-or-relative URL for the current page. */\nexport type AlternateLinks = Record<string, string>\n\ntype AlternateLinksContextValue = {\n links: AlternateLinks\n setLinks: (links: AlternateLinks) => void\n}\n\nconst AlternateLinksContext = createContext<AlternateLinksContextValue | null>(null)\n\n/**\n * Holds the current page's per-locale URLs so a LanguageSwitcher links to the\n * CORRECT localized slug instead of naively swapping the locale prefix\n * (/pl/uslugi → /en/uslugi, which 404s when the English slug is /en/services).\n *\n * Wrap the app once; each page reports its own alternates via\n * <AlternateLinksUpdater> (or useSetAlternateLinks). The switcher reads them\n * with useAlternateLinks().\n *\n * // layout.tsx\n * import { AlternateLinksProvider } from '@intecion/ipal-kit/client'\n * <AlternateLinksProvider>{children}</AlternateLinksProvider>\n */\nexport function AlternateLinksProvider({ children }: { children: React.ReactNode }) {\n const [links, setLinksState] = useState<AlternateLinks>({})\n const setLinks = useCallback((next: AlternateLinks) => setLinksState(next), [])\n return (\n <AlternateLinksContext value={{ links, setLinks }}>\n {children}\n </AlternateLinksContext>\n )\n}\n\n/** Read the current page's per-locale URLs (for a language switcher). */\nexport function useAlternateLinks(): AlternateLinks {\n const ctx = use(AlternateLinksContext)\n return ctx?.links ?? {}\n}\n\n/** Setter for the alternates (used by AlternateLinksUpdater). */\nexport function useSetAlternateLinks(): (links: AlternateLinks) => void {\n const ctx = use(AlternateLinksContext)\n return ctx?.setLinks ?? (() => {})\n}\n"],"names":["createContext","use","useCallback","useState","AlternateLinksContext","AlternateLinksProvider","children","links","setLinksState","setLinks","next","value","useAlternateLinks","ctx","useSetAlternateLinks"],"mappings":"AAAA;;AAEA,SAASA,aAAa,EAAEC,GAAG,EAAEC,WAAW,EAAEC,QAAQ,QAAQ,QAAO;AAUjE,MAAMC,sCAAwBJ,cAAiD;AAE/E;;;;;;;;;;;;CAYC,GACD,OAAO,SAASK,uBAAuB,EAAEC,QAAQ,EAAiC;IAChF,MAAM,CAACC,OAAOC,cAAc,GAAGL,SAAyB,CAAC;IACzD,MAAMM,WAAWP,YAAY,CAACQ,OAAyBF,cAAcE,OAAO,EAAE;IAC9E,qBACE,KAACN;QAAsBO,OAAO;YAAEJ;YAAOE;QAAS;kBAC7CH;;AAGP;AAEA,uEAAuE,GACvE,OAAO,SAASM;IACd,MAAMC,MAAMZ,IAAIG;IAChB,OAAOS,KAAKN,SAAS,CAAC;AACxB;AAEA,+DAA+D,GAC/D,OAAO,SAASO;IACd,MAAMD,MAAMZ,IAAIG;IAChB,OAAOS,KAAKJ,YAAa,CAAA,KAAO,CAAA;AAClC"}
|
||||||
+19
@@ -0,0 +1,19 @@
|
|||||||
|
import { type AlternateLinks } from './AlternateLinksContext.js';
|
||||||
|
/**
|
||||||
|
* Reports the current page's per-locale URLs into AlternateLinksProvider. Render
|
||||||
|
* it on each page (a Server Component computes the links via resolveRoute /
|
||||||
|
* getLocalizedSlugs and passes them down). The switcher then links correctly.
|
||||||
|
*
|
||||||
|
* // page.tsx (RSC) — compute alternates from the resolved route
|
||||||
|
* import { AlternateLinksUpdater } from '@intecion/ipal-kit/client'
|
||||||
|
* const alternates = { pl: '/pl/uslugi/karne', en: '/en/services/criminal' }
|
||||||
|
* return <>
|
||||||
|
* <AlternateLinksUpdater links={alternates} />
|
||||||
|
* {/* page content *\/}
|
||||||
|
* </>
|
||||||
|
*
|
||||||
|
* Renders nothing; it only pushes the links into context on mount/change.
|
||||||
|
*/
|
||||||
|
export declare function AlternateLinksUpdater({ links }: {
|
||||||
|
links: AlternateLinks;
|
||||||
|
}): null;
|
||||||
+32
@@ -0,0 +1,32 @@
|
|||||||
|
'use client';
|
||||||
|
import { useEffect } from 'react';
|
||||||
|
import { useSetAlternateLinks } from './AlternateLinksContext.js';
|
||||||
|
/**
|
||||||
|
* Reports the current page's per-locale URLs into AlternateLinksProvider. Render
|
||||||
|
* it on each page (a Server Component computes the links via resolveRoute /
|
||||||
|
* getLocalizedSlugs and passes them down). The switcher then links correctly.
|
||||||
|
*
|
||||||
|
* // page.tsx (RSC) — compute alternates from the resolved route
|
||||||
|
* import { AlternateLinksUpdater } from '@intecion/ipal-kit/client'
|
||||||
|
* const alternates = { pl: '/pl/uslugi/karne', en: '/en/services/criminal' }
|
||||||
|
* return <>
|
||||||
|
* <AlternateLinksUpdater links={alternates} />
|
||||||
|
* {/* page content *\/}
|
||||||
|
* </>
|
||||||
|
*
|
||||||
|
* Renders nothing; it only pushes the links into context on mount/change.
|
||||||
|
*/ export function AlternateLinksUpdater({ links }) {
|
||||||
|
const setLinks = useSetAlternateLinks();
|
||||||
|
const key = JSON.stringify(links);
|
||||||
|
useEffect(()=>{
|
||||||
|
setLinks(links);
|
||||||
|
// key covers link changes; setLinks is stable (useCallback).
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [
|
||||||
|
key,
|
||||||
|
setLinks
|
||||||
|
]);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//# sourceMappingURL=AlternateLinksUpdater.js.map
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"sources":["../../../src/modules/i18n/AlternateLinksUpdater.tsx"],"sourcesContent":["'use client'\n\nimport { useEffect } from 'react'\n\nimport { type AlternateLinks, useSetAlternateLinks } from './AlternateLinksContext.js'\n\n/**\n * Reports the current page's per-locale URLs into AlternateLinksProvider. Render\n * it on each page (a Server Component computes the links via resolveRoute /\n * getLocalizedSlugs and passes them down). The switcher then links correctly.\n *\n * // page.tsx (RSC) — compute alternates from the resolved route\n * import { AlternateLinksUpdater } from '@intecion/ipal-kit/client'\n * const alternates = { pl: '/pl/uslugi/karne', en: '/en/services/criminal' }\n * return <>\n * <AlternateLinksUpdater links={alternates} />\n * {/* page content *\\/}\n * </>\n *\n * Renders nothing; it only pushes the links into context on mount/change.\n */\nexport function AlternateLinksUpdater({ links }: { links: AlternateLinks }) {\n const setLinks = useSetAlternateLinks()\n const key = JSON.stringify(links)\n useEffect(() => {\n setLinks(links)\n // key covers link changes; setLinks is stable (useCallback).\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [key, setLinks])\n return null\n}\n"],"names":["useEffect","useSetAlternateLinks","AlternateLinksUpdater","links","setLinks","key","JSON","stringify"],"mappings":"AAAA;AAEA,SAASA,SAAS,QAAQ,QAAO;AAEjC,SAA8BC,oBAAoB,QAAQ,6BAA4B;AAEtF;;;;;;;;;;;;;;CAcC,GACD,OAAO,SAASC,sBAAsB,EAAEC,KAAK,EAA6B;IACxE,MAAMC,WAAWH;IACjB,MAAMI,MAAMC,KAAKC,SAAS,CAACJ;IAC3BH,UAAU;QACRI,SAASD;IACT,6DAA6D;IAC7D,uDAAuD;IACzD,GAAG;QAACE;QAAKD;KAAS;IAClB,OAAO;AACT"}
|
||||||
+36
@@ -0,0 +1,36 @@
|
|||||||
|
import type { I18nConfig } from './types.js';
|
||||||
|
export type LanguageSwitcherClassNames = {
|
||||||
|
item?: string;
|
||||||
|
itemActive?: string;
|
||||||
|
menu?: string;
|
||||||
|
root?: string;
|
||||||
|
trigger?: string;
|
||||||
|
};
|
||||||
|
type LocaleItem = {
|
||||||
|
code: string;
|
||||||
|
label: string;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Language switcher that links to the CORRECT localized URL per language,
|
||||||
|
* reading the current page's alternates from AlternateLinksProvider — so it
|
||||||
|
* never 404s on differing slugs (/pl/uslugi vs /en/services).
|
||||||
|
*
|
||||||
|
* Unstyled by default (classNames, like CookieBanner) — NOT a fixed
|
||||||
|
* light/dark variant, so it matches any project's design. A locale with no
|
||||||
|
* known alternate falls back to its root (/{code}).
|
||||||
|
*
|
||||||
|
* // layout/header (client), inside AlternateLinksProvider
|
||||||
|
* <LanguageSwitcher
|
||||||
|
* config={i18nConfig}
|
||||||
|
* currentLocale={locale}
|
||||||
|
* classNames={{ root: '...', trigger: '...', menu: '...', item: '...' }}
|
||||||
|
* />
|
||||||
|
*/
|
||||||
|
export declare function LanguageSwitcher({ classNames, config, currentLocale, renderLabel, }: {
|
||||||
|
classNames?: LanguageSwitcherClassNames;
|
||||||
|
config: I18nConfig;
|
||||||
|
currentLocale: string;
|
||||||
|
/** Custom label per locale (e.g. flag + code). Defaults to the config label. */
|
||||||
|
renderLabel?: (locale: LocaleItem) => React.ReactNode;
|
||||||
|
}): import("react/jsx-runtime").JSX.Element;
|
||||||
|
export {};
|
||||||
+65
@@ -0,0 +1,65 @@
|
|||||||
|
'use client';
|
||||||
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
||||||
|
import { useState } from 'react';
|
||||||
|
import { useAlternateLinks } from './AlternateLinksContext.js';
|
||||||
|
/**
|
||||||
|
* Language switcher that links to the CORRECT localized URL per language,
|
||||||
|
* reading the current page's alternates from AlternateLinksProvider — so it
|
||||||
|
* never 404s on differing slugs (/pl/uslugi vs /en/services).
|
||||||
|
*
|
||||||
|
* Unstyled by default (classNames, like CookieBanner) — NOT a fixed
|
||||||
|
* light/dark variant, so it matches any project's design. A locale with no
|
||||||
|
* known alternate falls back to its root (/{code}).
|
||||||
|
*
|
||||||
|
* // layout/header (client), inside AlternateLinksProvider
|
||||||
|
* <LanguageSwitcher
|
||||||
|
* config={i18nConfig}
|
||||||
|
* currentLocale={locale}
|
||||||
|
* classNames={{ root: '...', trigger: '...', menu: '...', item: '...' }}
|
||||||
|
* />
|
||||||
|
*/ export function LanguageSwitcher({ classNames, config, currentLocale, renderLabel }) {
|
||||||
|
const alternates = useAlternateLinks();
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
const cn = classNames ?? {};
|
||||||
|
const locales = config.locales.map((l)=>({
|
||||||
|
code: l.code,
|
||||||
|
label: l.label ?? l.code.toUpperCase()
|
||||||
|
}));
|
||||||
|
const hrefFor = (code)=>alternates[code] ?? `/${code}`;
|
||||||
|
const current = locales.find((l)=>l.code === currentLocale);
|
||||||
|
return /*#__PURE__*/ _jsxs("div", {
|
||||||
|
className: cn.root,
|
||||||
|
"data-ipal-langswitcher": true,
|
||||||
|
children: [
|
||||||
|
/*#__PURE__*/ _jsx("button", {
|
||||||
|
"aria-expanded": open,
|
||||||
|
"aria-haspopup": "true",
|
||||||
|
className: cn.trigger,
|
||||||
|
onClick: ()=>setOpen((o)=>!o),
|
||||||
|
type: "button",
|
||||||
|
children: current ? renderLabel ? renderLabel(current) : current.label : currentLocale
|
||||||
|
}),
|
||||||
|
open && /*#__PURE__*/ _jsx("ul", {
|
||||||
|
className: cn.menu,
|
||||||
|
role: "menu",
|
||||||
|
children: locales.map((loc)=>{
|
||||||
|
const active = loc.code === currentLocale;
|
||||||
|
return /*#__PURE__*/ _jsx("li", {
|
||||||
|
role: "none",
|
||||||
|
children: /*#__PURE__*/ _jsx("a", {
|
||||||
|
"aria-current": active ? 'true' : undefined,
|
||||||
|
className: `${cn.item ?? ''} ${active ? cn.itemActive ?? '' : ''}`.trim(),
|
||||||
|
href: hrefFor(loc.code),
|
||||||
|
hrefLang: loc.code,
|
||||||
|
onClick: ()=>setOpen(false),
|
||||||
|
role: "menuitem",
|
||||||
|
children: renderLabel ? renderLabel(loc) : loc.label
|
||||||
|
})
|
||||||
|
}, loc.code);
|
||||||
|
})
|
||||||
|
})
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//# sourceMappingURL=LanguageSwitcher.js.map
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"sources":["../../../src/modules/i18n/LanguageSwitcher.tsx"],"sourcesContent":["'use client'\n\nimport { useState } from 'react'\n\nimport type { I18nConfig } from './types.js'\n\nimport { useAlternateLinks } from './AlternateLinksContext.js'\n\nexport type LanguageSwitcherClassNames = {\n item?: string\n itemActive?: string\n menu?: string\n root?: string\n trigger?: string\n}\n\ntype LocaleItem = { code: string; label: string }\n\n/**\n * Language switcher that links to the CORRECT localized URL per language,\n * reading the current page's alternates from AlternateLinksProvider — so it\n * never 404s on differing slugs (/pl/uslugi vs /en/services).\n *\n * Unstyled by default (classNames, like CookieBanner) — NOT a fixed\n * light/dark variant, so it matches any project's design. A locale with no\n * known alternate falls back to its root (/{code}).\n *\n * // layout/header (client), inside AlternateLinksProvider\n * <LanguageSwitcher\n * config={i18nConfig}\n * currentLocale={locale}\n * classNames={{ root: '...', trigger: '...', menu: '...', item: '...' }}\n * />\n */\nexport function LanguageSwitcher({\n classNames,\n config,\n currentLocale,\n renderLabel,\n}: {\n classNames?: LanguageSwitcherClassNames\n config: I18nConfig\n currentLocale: string\n /** Custom label per locale (e.g. flag + code). Defaults to the config label. */\n renderLabel?: (locale: LocaleItem) => React.ReactNode\n}) {\n const alternates = useAlternateLinks()\n const [open, setOpen] = useState(false)\n const cn = classNames ?? {}\n\n const locales: LocaleItem[] = config.locales.map((l) => ({\n code: l.code,\n label: l.label ?? l.code.toUpperCase(),\n }))\n\n const hrefFor = (code: string): string => alternates[code] ?? `/${code}`\n\n const current = locales.find((l) => l.code === currentLocale)\n\n return (\n <div className={cn.root} data-ipal-langswitcher>\n <button\n aria-expanded={open}\n aria-haspopup=\"true\"\n className={cn.trigger}\n onClick={() => setOpen((o) => !o)}\n type=\"button\"\n >\n {current ? (renderLabel ? renderLabel(current) : current.label) : currentLocale}\n </button>\n {open && (\n <ul className={cn.menu} role=\"menu\">\n {locales.map((loc) => {\n const active = loc.code === currentLocale\n return (\n <li key={loc.code} role=\"none\">\n <a\n aria-current={active ? 'true' : undefined}\n className={`${cn.item ?? ''} ${active ? (cn.itemActive ?? '') : ''}`.trim()}\n href={hrefFor(loc.code)}\n hrefLang={loc.code}\n onClick={() => setOpen(false)}\n role=\"menuitem\"\n >\n {renderLabel ? renderLabel(loc) : loc.label}\n </a>\n </li>\n )\n })}\n </ul>\n )}\n </div>\n )\n}\n"],"names":["useState","useAlternateLinks","LanguageSwitcher","classNames","config","currentLocale","renderLabel","alternates","open","setOpen","cn","locales","map","l","code","label","toUpperCase","hrefFor","current","find","div","className","root","data-ipal-langswitcher","button","aria-expanded","aria-haspopup","trigger","onClick","o","type","ul","menu","role","loc","active","li","a","aria-current","undefined","item","itemActive","trim","href","hrefLang"],"mappings":"AAAA;;AAEA,SAASA,QAAQ,QAAQ,QAAO;AAIhC,SAASC,iBAAiB,QAAQ,6BAA4B;AAY9D;;;;;;;;;;;;;;;CAeC,GACD,OAAO,SAASC,iBAAiB,EAC/BC,UAAU,EACVC,MAAM,EACNC,aAAa,EACbC,WAAW,EAOZ;IACC,MAAMC,aAAaN;IACnB,MAAM,CAACO,MAAMC,QAAQ,GAAGT,SAAS;IACjC,MAAMU,KAAKP,cAAc,CAAC;IAE1B,MAAMQ,UAAwBP,OAAOO,OAAO,CAACC,GAAG,CAAC,CAACC,IAAO,CAAA;YACvDC,MAAMD,EAAEC,IAAI;YACZC,OAAOF,EAAEE,KAAK,IAAIF,EAAEC,IAAI,CAACE,WAAW;QACtC,CAAA;IAEA,MAAMC,UAAU,CAACH,OAAyBP,UAAU,CAACO,KAAK,IAAI,CAAC,CAAC,EAAEA,MAAM;IAExE,MAAMI,UAAUP,QAAQQ,IAAI,CAAC,CAACN,IAAMA,EAAEC,IAAI,KAAKT;IAE/C,qBACE,MAACe;QAAIC,WAAWX,GAAGY,IAAI;QAAEC,wBAAsB;;0BAC7C,KAACC;gBACCC,iBAAejB;gBACfkB,iBAAc;gBACdL,WAAWX,GAAGiB,OAAO;gBACrBC,SAAS,IAAMnB,QAAQ,CAACoB,IAAM,CAACA;gBAC/BC,MAAK;0BAEJZ,UAAWZ,cAAcA,YAAYY,WAAWA,QAAQH,KAAK,GAAIV;;YAEnEG,sBACC,KAACuB;gBAAGV,WAAWX,GAAGsB,IAAI;gBAAEC,MAAK;0BAC1BtB,QAAQC,GAAG,CAAC,CAACsB;oBACZ,MAAMC,SAASD,IAAIpB,IAAI,KAAKT;oBAC5B,qBACE,KAAC+B;wBAAkBH,MAAK;kCACtB,cAAA,KAACI;4BACCC,gBAAcH,SAAS,SAASI;4BAChClB,WAAW,GAAGX,GAAG8B,IAAI,IAAI,GAAG,CAAC,EAAEL,SAAUzB,GAAG+B,UAAU,IAAI,KAAM,IAAI,CAACC,IAAI;4BACzEC,MAAM1B,QAAQiB,IAAIpB,IAAI;4BACtB8B,UAAUV,IAAIpB,IAAI;4BAClBc,SAAS,IAAMnB,QAAQ;4BACvBwB,MAAK;sCAEJ3B,cAAcA,YAAY4B,OAAOA,IAAInB,KAAK;;uBATtCmB,IAAIpB,IAAI;gBAarB;;;;AAKV"}
|
||||||
Vendored
+65
@@ -0,0 +1,65 @@
|
|||||||
|
import type { I18nConfig } from './types.js';
|
||||||
|
/** Re-exported so the project's proxy.ts config uses the plugin's matcher. */
|
||||||
|
export declare const DEFAULT_PROXY_MATCHER: string[];
|
||||||
|
/**
|
||||||
|
* Minimal structural types — the plugin does NOT import next/server (it's a peer
|
||||||
|
* dep not present at the plugin's own build time, which would cause TS2307).
|
||||||
|
* Next's real NextRequest / NextResponse satisfy these shapes at the call site.
|
||||||
|
*/
|
||||||
|
type ProxyRequest = {
|
||||||
|
cookies: {
|
||||||
|
get: (name: string) => {
|
||||||
|
value: string;
|
||||||
|
} | undefined;
|
||||||
|
};
|
||||||
|
headers: Headers;
|
||||||
|
nextUrl: {
|
||||||
|
clone: () => URL;
|
||||||
|
pathname: string;
|
||||||
|
search: string;
|
||||||
|
};
|
||||||
|
url: string;
|
||||||
|
};
|
||||||
|
type ProxyResponse = {
|
||||||
|
cookies: {
|
||||||
|
set: (name: string, value: string, opts?: Record<string, unknown>) => void;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Next's NextResponse constructor, injected by the project (which has next/server
|
||||||
|
* in scope). The plugin stays free of a next/server import.
|
||||||
|
*/
|
||||||
|
type NextResponseLike = {
|
||||||
|
next: (init?: {
|
||||||
|
request?: {
|
||||||
|
headers: Headers;
|
||||||
|
};
|
||||||
|
}) => ProxyResponse;
|
||||||
|
redirect: (url: string | URL) => ProxyResponse;
|
||||||
|
};
|
||||||
|
type CreateProxyOptions = {
|
||||||
|
consentCategory?: 'functional' | 'necessary';
|
||||||
|
consentCookieName?: string;
|
||||||
|
cookieName?: string;
|
||||||
|
/** Expose x-locale / x-pathname request headers to RSC. Default true. */
|
||||||
|
exposeHeaders?: boolean;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Ready-made Next 16 proxy (the former middleware). Wraps the plugin's locale
|
||||||
|
* logic AND the per-project boilerplate (NextResponse, x-locale / x-pathname
|
||||||
|
* headers, locale cookie, redirect). The project's proxy.ts becomes a few lines.
|
||||||
|
*
|
||||||
|
* `NextResponse` is INJECTED (the plugin never imports next/server — it's a peer
|
||||||
|
* dep absent at the plugin's build time). The project passes it:
|
||||||
|
*
|
||||||
|
* // proxy.ts (Next 16 — NOT middleware.ts)
|
||||||
|
* import { NextResponse } from 'next/server'
|
||||||
|
* import { createProxy, DEFAULT_PROXY_MATCHER } from '@intecion/ipal-kit'
|
||||||
|
* import { i18nConfig } from '@/i18n.config'
|
||||||
|
* export const proxy = createProxy(i18nConfig, { NextResponse })
|
||||||
|
* export const config = { matcher: DEFAULT_PROXY_MATCHER }
|
||||||
|
*/
|
||||||
|
export declare function createProxy(config: I18nConfig, deps: {
|
||||||
|
NextResponse: NextResponseLike;
|
||||||
|
} & CreateProxyOptions): (request: ProxyRequest) => ProxyResponse;
|
||||||
|
export {};
|
||||||
Vendored
+49
@@ -0,0 +1,49 @@
|
|||||||
|
import { isValidLocale } from './helpers.js';
|
||||||
|
import { createLocaleMiddleware, DEFAULT_MIDDLEWARE_MATCHER } from './localeMiddleware.js';
|
||||||
|
/** Re-exported so the project's proxy.ts config uses the plugin's matcher. */ export const DEFAULT_PROXY_MATCHER = DEFAULT_MIDDLEWARE_MATCHER;
|
||||||
|
/**
|
||||||
|
* Ready-made Next 16 proxy (the former middleware). Wraps the plugin's locale
|
||||||
|
* logic AND the per-project boilerplate (NextResponse, x-locale / x-pathname
|
||||||
|
* headers, locale cookie, redirect). The project's proxy.ts becomes a few lines.
|
||||||
|
*
|
||||||
|
* `NextResponse` is INJECTED (the plugin never imports next/server — it's a peer
|
||||||
|
* dep absent at the plugin's build time). The project passes it:
|
||||||
|
*
|
||||||
|
* // proxy.ts (Next 16 — NOT middleware.ts)
|
||||||
|
* import { NextResponse } from 'next/server'
|
||||||
|
* import { createProxy, DEFAULT_PROXY_MATCHER } from '@intecion/ipal-kit'
|
||||||
|
* import { i18nConfig } from '@/i18n.config'
|
||||||
|
* export const proxy = createProxy(i18nConfig, { NextResponse })
|
||||||
|
* export const config = { matcher: DEFAULT_PROXY_MATCHER }
|
||||||
|
*/ export function createProxy(config, deps) {
|
||||||
|
const { exposeHeaders = true, NextResponse, ...mwOptions } = deps;
|
||||||
|
const run = createLocaleMiddleware({
|
||||||
|
config,
|
||||||
|
...mwOptions
|
||||||
|
});
|
||||||
|
return (request)=>{
|
||||||
|
const result = run(request);
|
||||||
|
const requestHeaders = new Headers(request.headers);
|
||||||
|
if (exposeHeaders) {
|
||||||
|
const { pathname } = request.nextUrl;
|
||||||
|
const seg = pathname.split('/').filter(Boolean)[0] ?? '';
|
||||||
|
const locale = isValidLocale(seg, config) ? seg : config.defaultLocale;
|
||||||
|
requestHeaders.set('x-locale', locale);
|
||||||
|
requestHeaders.set('x-pathname', pathname);
|
||||||
|
}
|
||||||
|
const response = result.type === 'redirect' ? NextResponse.redirect(new URL(result.location, request.url)) : NextResponse.next({
|
||||||
|
request: {
|
||||||
|
headers: requestHeaders
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (result.cookie) {
|
||||||
|
response.cookies.set(result.cookie.name, result.cookie.value, {
|
||||||
|
path: '/',
|
||||||
|
sameSite: 'lax'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
//# sourceMappingURL=createProxy.js.map
|
||||||
Vendored
+1
File diff suppressed because one or more lines are too long
Vendored
+6
@@ -1,5 +1,11 @@
|
|||||||
|
export { AlternateLinksProvider, useAlternateLinks, useSetAlternateLinks, } from './AlternateLinksContext.js';
|
||||||
|
export type { AlternateLinks } from './AlternateLinksContext.js';
|
||||||
|
export { AlternateLinksUpdater } from './AlternateLinksUpdater.js';
|
||||||
|
export { createProxy, DEFAULT_PROXY_MATCHER } from './createProxy.js';
|
||||||
export { getLocalizedSlugs } from './getLocalizedSlugs.js';
|
export { getLocalizedSlugs } from './getLocalizedSlugs.js';
|
||||||
export { getDefaultLocale, getLocaleCodes, getLocaleDefinition, isValidLocale } from './helpers.js';
|
export { getDefaultLocale, getLocaleCodes, getLocaleDefinition, isValidLocale } from './helpers.js';
|
||||||
|
export { LanguageSwitcher } from './LanguageSwitcher.js';
|
||||||
|
export type { LanguageSwitcherClassNames } from './LanguageSwitcher.js';
|
||||||
export { createLocaleMiddleware, DEFAULT_MIDDLEWARE_MATCHER } from './localeMiddleware.js';
|
export { createLocaleMiddleware, DEFAULT_MIDDLEWARE_MATCHER } from './localeMiddleware.js';
|
||||||
export type { LocaleMiddlewareResult } from './localeMiddleware.js';
|
export type { LocaleMiddlewareResult } from './localeMiddleware.js';
|
||||||
export { buildLocalizationConfig } from './localizationConfig.js';
|
export { buildLocalizationConfig } from './localizationConfig.js';
|
||||||
|
|||||||
Vendored
+4
@@ -1,5 +1,9 @@
|
|||||||
|
export { AlternateLinksProvider, useAlternateLinks, useSetAlternateLinks } from './AlternateLinksContext.js';
|
||||||
|
export { AlternateLinksUpdater } from './AlternateLinksUpdater.js';
|
||||||
|
export { createProxy, DEFAULT_PROXY_MATCHER } from './createProxy.js';
|
||||||
export { getLocalizedSlugs } from './getLocalizedSlugs.js';
|
export { getLocalizedSlugs } from './getLocalizedSlugs.js';
|
||||||
export { getDefaultLocale, getLocaleCodes, getLocaleDefinition, isValidLocale } from './helpers.js';
|
export { getDefaultLocale, getLocaleCodes, getLocaleDefinition, isValidLocale } from './helpers.js';
|
||||||
|
export { LanguageSwitcher } from './LanguageSwitcher.js';
|
||||||
export { createLocaleMiddleware, DEFAULT_MIDDLEWARE_MATCHER } from './localeMiddleware.js';
|
export { createLocaleMiddleware, DEFAULT_MIDDLEWARE_MATCHER } from './localeMiddleware.js';
|
||||||
export { buildLocalizationConfig } from './localizationConfig.js';
|
export { buildLocalizationConfig } from './localizationConfig.js';
|
||||||
export { buildLocalizedPath, switchLocalePath } from './localizedPath.js';
|
export { buildLocalizedPath, switchLocalePath } from './localizedPath.js';
|
||||||
|
|||||||
Vendored
+1
-1
@@ -1 +1 @@
|
|||||||
{"version":3,"sources":["../../../src/modules/i18n/index.ts"],"sourcesContent":["export { getLocalizedSlugs } from './getLocalizedSlugs.js'\nexport { getDefaultLocale, getLocaleCodes, getLocaleDefinition, isValidLocale } from './helpers.js'\nexport { createLocaleMiddleware, DEFAULT_MIDDLEWARE_MATCHER } from './localeMiddleware.js'\nexport type { LocaleMiddlewareResult } from './localeMiddleware.js'\nexport { buildLocalizationConfig } from './localizationConfig.js'\nexport { buildLocalizedPath, switchLocalePath } from './localizedPath.js'\nexport type { LocalizedSlugs } from './localizedPath.js'\nexport { LOCALE_COOKIE_NAME, matchAcceptLanguage, negotiateLocale } from './negotiateLocale.js'\nexport type { I18nConfig, LocaleDefinition } from './types.js'\nexport { validateI18nConfig } from './validation.js'\n"],"names":["getLocalizedSlugs","getDefaultLocale","getLocaleCodes","getLocaleDefinition","isValidLocale","createLocaleMiddleware","DEFAULT_MIDDLEWARE_MATCHER","buildLocalizationConfig","buildLocalizedPath","switchLocalePath","LOCALE_COOKIE_NAME","matchAcceptLanguage","negotiateLocale","validateI18nConfig"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,yBAAwB;AAC1D,SAASC,gBAAgB,EAAEC,cAAc,EAAEC,mBAAmB,EAAEC,aAAa,QAAQ,eAAc;AACnG,SAASC,sBAAsB,EAAEC,0BAA0B,QAAQ,wBAAuB;AAE1F,SAASC,uBAAuB,QAAQ,0BAAyB;AACjE,SAASC,kBAAkB,EAAEC,gBAAgB,QAAQ,qBAAoB;AAEzE,SAASC,kBAAkB,EAAEC,mBAAmB,EAAEC,eAAe,QAAQ,uBAAsB;AAE/F,SAASC,kBAAkB,QAAQ,kBAAiB"}
|
{"version":3,"sources":["../../../src/modules/i18n/index.ts"],"sourcesContent":["export {\n AlternateLinksProvider,\n useAlternateLinks,\n useSetAlternateLinks,\n} from './AlternateLinksContext.js'\nexport type { AlternateLinks } from './AlternateLinksContext.js'\nexport { AlternateLinksUpdater } from './AlternateLinksUpdater.js'\nexport { createProxy, DEFAULT_PROXY_MATCHER } from './createProxy.js'\nexport { getLocalizedSlugs } from './getLocalizedSlugs.js'\nexport { getDefaultLocale, getLocaleCodes, getLocaleDefinition, isValidLocale } from './helpers.js'\nexport { LanguageSwitcher } from './LanguageSwitcher.js'\nexport type { LanguageSwitcherClassNames } from './LanguageSwitcher.js'\nexport { createLocaleMiddleware, DEFAULT_MIDDLEWARE_MATCHER } from './localeMiddleware.js'\nexport type { LocaleMiddlewareResult } from './localeMiddleware.js'\nexport { buildLocalizationConfig } from './localizationConfig.js'\nexport { buildLocalizedPath, switchLocalePath } from './localizedPath.js'\nexport type { LocalizedSlugs } from './localizedPath.js'\nexport { LOCALE_COOKIE_NAME, matchAcceptLanguage, negotiateLocale } from './negotiateLocale.js'\nexport type { I18nConfig, LocaleDefinition } from './types.js'\nexport { validateI18nConfig } from './validation.js'\n"],"names":["AlternateLinksProvider","useAlternateLinks","useSetAlternateLinks","AlternateLinksUpdater","createProxy","DEFAULT_PROXY_MATCHER","getLocalizedSlugs","getDefaultLocale","getLocaleCodes","getLocaleDefinition","isValidLocale","LanguageSwitcher","createLocaleMiddleware","DEFAULT_MIDDLEWARE_MATCHER","buildLocalizationConfig","buildLocalizedPath","switchLocalePath","LOCALE_COOKIE_NAME","matchAcceptLanguage","negotiateLocale","validateI18nConfig"],"mappings":"AAAA,SACEA,sBAAsB,EACtBC,iBAAiB,EACjBC,oBAAoB,QACf,6BAA4B;AAEnC,SAASC,qBAAqB,QAAQ,6BAA4B;AAClE,SAASC,WAAW,EAAEC,qBAAqB,QAAQ,mBAAkB;AACrE,SAASC,iBAAiB,QAAQ,yBAAwB;AAC1D,SAASC,gBAAgB,EAAEC,cAAc,EAAEC,mBAAmB,EAAEC,aAAa,QAAQ,eAAc;AACnG,SAASC,gBAAgB,QAAQ,wBAAuB;AAExD,SAASC,sBAAsB,EAAEC,0BAA0B,QAAQ,wBAAuB;AAE1F,SAASC,uBAAuB,QAAQ,0BAAyB;AACjE,SAASC,kBAAkB,EAAEC,gBAAgB,QAAQ,qBAAoB;AAEzE,SAASC,kBAAkB,EAAEC,mBAAmB,EAAEC,eAAe,QAAQ,uBAAsB;AAE/F,SAASC,kBAAkB,QAAQ,kBAAiB"}
|
||||||
+48
@@ -0,0 +1,48 @@
|
|||||||
|
import type { SerializedEditorState } from '@payloadcms/richtext-lexical/lexical';
|
||||||
|
import type { JSXConvertersFunction } from '@payloadcms/richtext-lexical/react';
|
||||||
|
export type RenderRichTextProps = {
|
||||||
|
/** Wrapper class (e.g. Tailwind prose classes). */
|
||||||
|
className?: string;
|
||||||
|
/**
|
||||||
|
* Override the JSX for specific node types to apply the project's own
|
||||||
|
* styling. Receives Payload's defaultConverters; return the merged map.
|
||||||
|
* This is where a project puts its Tailwind classes per node (headings,
|
||||||
|
* paragraphs, links, …) — the design stays in the project, the parsing in
|
||||||
|
* the plugin's wrapper over Payload's official converter.
|
||||||
|
*/
|
||||||
|
converters?: JSXConvertersFunction;
|
||||||
|
/**
|
||||||
|
* Lexical editor state from a Payload richText field. Already localized —
|
||||||
|
* Payload returns the current locale's value, so NO per-locale key handling
|
||||||
|
* is needed here (unlike hand-rolled renderers that hardcode `.pl`).
|
||||||
|
*/
|
||||||
|
data: null | SerializedEditorState | undefined;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Renders a Payload Lexical richText field to React — a thin wrapper over
|
||||||
|
* Payload's OFFICIAL converter (@payloadcms/richtext-lexical/react).
|
||||||
|
*
|
||||||
|
* Why not hand-roll it: parsing Lexical by hand (node.type switch, node.format
|
||||||
|
* bit flags) duplicates what Payload already does, misses node types, drifts
|
||||||
|
* on Lexical updates, and tempts shortcuts like dangerouslySetInnerHTML (XSS)
|
||||||
|
* or a hardcoded `.pl` locale. The official converter handles every node,
|
||||||
|
* stays in sync, and is safe. This is the RenderBlocks of rich text: the
|
||||||
|
* plugin owns the engine, the project owns the look via `converters`.
|
||||||
|
*
|
||||||
|
* // project — a Server Component
|
||||||
|
* import { RenderRichText } from '@intecion/ipal-kit/rsc'
|
||||||
|
* <RenderRichText data={page.content} className="prose" />
|
||||||
|
*
|
||||||
|
* // with project styling per node:
|
||||||
|
* const converters: JSXConvertersFunction = ({ defaultConverters }) => ({
|
||||||
|
* ...defaultConverters,
|
||||||
|
* heading: ({ node, nodesToJSX }) => {
|
||||||
|
* const children = nodesToJSX({ nodes: node.children })
|
||||||
|
* const cls = { h2: 'text-2xl font-semibold mt-10', h3: 'text-xl mt-7' }[node.tag] ?? ''
|
||||||
|
* const Tag = node.tag as 'h1'|'h2'|'h3'|'h4'
|
||||||
|
* return <Tag className={cls}>{children}</Tag>
|
||||||
|
* },
|
||||||
|
* })
|
||||||
|
* <RenderRichText data={page.content} converters={converters} />
|
||||||
|
*/
|
||||||
|
export declare function RenderRichText({ className, converters, data }: RenderRichTextProps): import("react/jsx-runtime").JSX.Element | null;
|
||||||
+40
@@ -0,0 +1,40 @@
|
|||||||
|
import { jsx as _jsx } from "react/jsx-runtime";
|
||||||
|
import { RichText as PayloadRichText } from '@payloadcms/richtext-lexical/react';
|
||||||
|
/**
|
||||||
|
* Renders a Payload Lexical richText field to React — a thin wrapper over
|
||||||
|
* Payload's OFFICIAL converter (@payloadcms/richtext-lexical/react).
|
||||||
|
*
|
||||||
|
* Why not hand-roll it: parsing Lexical by hand (node.type switch, node.format
|
||||||
|
* bit flags) duplicates what Payload already does, misses node types, drifts
|
||||||
|
* on Lexical updates, and tempts shortcuts like dangerouslySetInnerHTML (XSS)
|
||||||
|
* or a hardcoded `.pl` locale. The official converter handles every node,
|
||||||
|
* stays in sync, and is safe. This is the RenderBlocks of rich text: the
|
||||||
|
* plugin owns the engine, the project owns the look via `converters`.
|
||||||
|
*
|
||||||
|
* // project — a Server Component
|
||||||
|
* import { RenderRichText } from '@intecion/ipal-kit/rsc'
|
||||||
|
* <RenderRichText data={page.content} className="prose" />
|
||||||
|
*
|
||||||
|
* // with project styling per node:
|
||||||
|
* const converters: JSXConvertersFunction = ({ defaultConverters }) => ({
|
||||||
|
* ...defaultConverters,
|
||||||
|
* heading: ({ node, nodesToJSX }) => {
|
||||||
|
* const children = nodesToJSX({ nodes: node.children })
|
||||||
|
* const cls = { h2: 'text-2xl font-semibold mt-10', h3: 'text-xl mt-7' }[node.tag] ?? ''
|
||||||
|
* const Tag = node.tag as 'h1'|'h2'|'h3'|'h4'
|
||||||
|
* return <Tag className={cls}>{children}</Tag>
|
||||||
|
* },
|
||||||
|
* })
|
||||||
|
* <RenderRichText data={page.content} converters={converters} />
|
||||||
|
*/ export function RenderRichText({ className, converters, data }) {
|
||||||
|
if (!data) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return /*#__PURE__*/ _jsx(PayloadRichText, {
|
||||||
|
className: className,
|
||||||
|
converters: converters,
|
||||||
|
data: data
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//# sourceMappingURL=RenderRichText.js.map
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"sources":["../../../src/modules/richtext/RenderRichText.tsx"],"sourcesContent":["import type { SerializedEditorState } from '@payloadcms/richtext-lexical/lexical'\nimport type { JSXConvertersFunction } from '@payloadcms/richtext-lexical/react'\n\nimport { RichText as PayloadRichText } from '@payloadcms/richtext-lexical/react'\n\nexport type RenderRichTextProps = {\n /** Wrapper class (e.g. Tailwind prose classes). */\n className?: string\n /**\n * Override the JSX for specific node types to apply the project's own\n * styling. Receives Payload's defaultConverters; return the merged map.\n * This is where a project puts its Tailwind classes per node (headings,\n * paragraphs, links, …) — the design stays in the project, the parsing in\n * the plugin's wrapper over Payload's official converter.\n */\n converters?: JSXConvertersFunction\n /**\n * Lexical editor state from a Payload richText field. Already localized —\n * Payload returns the current locale's value, so NO per-locale key handling\n * is needed here (unlike hand-rolled renderers that hardcode `.pl`).\n */\n data: null | SerializedEditorState | undefined\n}\n\n/**\n * Renders a Payload Lexical richText field to React — a thin wrapper over\n * Payload's OFFICIAL converter (@payloadcms/richtext-lexical/react).\n *\n * Why not hand-roll it: parsing Lexical by hand (node.type switch, node.format\n * bit flags) duplicates what Payload already does, misses node types, drifts\n * on Lexical updates, and tempts shortcuts like dangerouslySetInnerHTML (XSS)\n * or a hardcoded `.pl` locale. The official converter handles every node,\n * stays in sync, and is safe. This is the RenderBlocks of rich text: the\n * plugin owns the engine, the project owns the look via `converters`.\n *\n * // project — a Server Component\n * import { RenderRichText } from '@intecion/ipal-kit/rsc'\n * <RenderRichText data={page.content} className=\"prose\" />\n *\n * // with project styling per node:\n * const converters: JSXConvertersFunction = ({ defaultConverters }) => ({\n * ...defaultConverters,\n * heading: ({ node, nodesToJSX }) => {\n * const children = nodesToJSX({ nodes: node.children })\n * const cls = { h2: 'text-2xl font-semibold mt-10', h3: 'text-xl mt-7' }[node.tag] ?? ''\n * const Tag = node.tag as 'h1'|'h2'|'h3'|'h4'\n * return <Tag className={cls}>{children}</Tag>\n * },\n * })\n * <RenderRichText data={page.content} converters={converters} />\n */\nexport function RenderRichText({ className, converters, data }: RenderRichTextProps) {\n if (!data) {return null}\n return <PayloadRichText className={className} converters={converters} data={data} />\n}\n"],"names":["RichText","PayloadRichText","RenderRichText","className","converters","data"],"mappings":";AAGA,SAASA,YAAYC,eAAe,QAAQ,qCAAoC;AAqBhF;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BC,GACD,OAAO,SAASC,eAAe,EAAEC,SAAS,EAAEC,UAAU,EAAEC,IAAI,EAAuB;IACjF,IAAI,CAACA,MAAM;QAAC,OAAO;IAAI;IACvB,qBAAO,KAACJ;QAAgBE,WAAWA;QAAWC,YAAYA;QAAYC,MAAMA;;AAC9E"}
|
||||||
Vendored
+2
@@ -0,0 +1,2 @@
|
|||||||
|
export { RenderRichText } from './RenderRichText.js';
|
||||||
|
export type { RenderRichTextProps } from './RenderRichText.js';
|
||||||
Vendored
+3
@@ -0,0 +1,3 @@
|
|||||||
|
export { RenderRichText } from './RenderRichText.js';
|
||||||
|
|
||||||
|
//# sourceMappingURL=index.js.map
|
||||||
Vendored
+1
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"sources":["../../../src/modules/richtext/index.ts"],"sourcesContent":["export { RenderRichText } from './RenderRichText.js'\nexport type { RenderRichTextProps } from './RenderRichText.js'\n"],"names":["RenderRichText"],"mappings":"AAAA,SAASA,cAAc,QAAQ,sBAAqB"}
|
||||||
Vendored
+76
@@ -0,0 +1,76 @@
|
|||||||
|
/*
|
||||||
|
* Starter stylesheet for a sitemap served via buildSitemapXml({ cssUrl }).
|
||||||
|
* Uses type="text/css" on XML (W3C "Associating Style Sheets with XML") — NOT
|
||||||
|
* XSLT, so no browser deprecation warning. Selectors are the XML tag names.
|
||||||
|
*
|
||||||
|
* Copy to your project's /public/sitemap.css and adjust colors/spacing to taste.
|
||||||
|
* Crawlers ignore this; it only affects the human-readable browser view.
|
||||||
|
*/
|
||||||
|
|
||||||
|
urlset {
|
||||||
|
display: block;
|
||||||
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
||||||
|
background: #090d16;
|
||||||
|
color: #f1f5f9;
|
||||||
|
padding: 2rem 1.5rem;
|
||||||
|
max-width: 1200px;
|
||||||
|
margin: 0 auto;
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Each URL entry as a card. */
|
||||||
|
url {
|
||||||
|
display: block;
|
||||||
|
background: #111827;
|
||||||
|
border: 1px solid #1e293b;
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 1rem 1.25rem;
|
||||||
|
margin-bottom: 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The URL itself. */
|
||||||
|
loc {
|
||||||
|
display: block;
|
||||||
|
font-size: 0.95rem;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #f97316;
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Metadata line: lastmod / changefreq / priority, each with a label. */
|
||||||
|
lastmod,
|
||||||
|
changefreq,
|
||||||
|
priority {
|
||||||
|
display: inline-block;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
color: #94a3b8;
|
||||||
|
margin-right: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
lastmod::before {
|
||||||
|
content: 'Ostatnia modyfikacja: ';
|
||||||
|
color: #64748b;
|
||||||
|
}
|
||||||
|
|
||||||
|
changefreq::before {
|
||||||
|
content: 'Częstotliwość: ';
|
||||||
|
color: #64748b;
|
||||||
|
}
|
||||||
|
|
||||||
|
priority::before {
|
||||||
|
content: 'Priorytet: ';
|
||||||
|
color: #64748b;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* hreflang alternates as small pills. */
|
||||||
|
link {
|
||||||
|
display: inline-block;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
background: #1e293b;
|
||||||
|
color: #38bdf8;
|
||||||
|
border: 1px solid #334155;
|
||||||
|
padding: 0.15rem 0.45rem;
|
||||||
|
border-radius: 4px;
|
||||||
|
margin: 0.4rem 0.35rem 0 0;
|
||||||
|
}
|
||||||
Vendored
+154
@@ -0,0 +1,154 @@
|
|||||||
|
/*
|
||||||
|
* Universal, minimalist & elegant stylesheet for XML Sitemap.
|
||||||
|
* Neutral palette with automatic dark and light mode support.
|
||||||
|
* W3C standard: type="text/css" on XML (zero browser deprecation warnings).
|
||||||
|
*
|
||||||
|
* Ships with @intecion/ipal-kit. Copy to /public/sitemap.css and adjust freely.
|
||||||
|
*/
|
||||||
|
|
||||||
|
:root {
|
||||||
|
--bg: #fafafa;
|
||||||
|
--card: #ffffff;
|
||||||
|
--border: #e5e7eb;
|
||||||
|
--border-hover: #d1d5db;
|
||||||
|
--text-main: #111827;
|
||||||
|
--text-secondary: #4b5563;
|
||||||
|
--text-muted: #9ca3af;
|
||||||
|
--url-color: #1e293b;
|
||||||
|
--badge-bg: #f3f4f6;
|
||||||
|
--badge-border: #e5e7eb;
|
||||||
|
--badge-text: #4b5563;
|
||||||
|
--accent: #027bd0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
:root {
|
||||||
|
--bg: #090a0f;
|
||||||
|
--card: #12131a;
|
||||||
|
--border: #1e202e;
|
||||||
|
--border-hover: #2e3247;
|
||||||
|
--text-main: #f9fafb;
|
||||||
|
--text-secondary: #9ca3af;
|
||||||
|
--text-muted: #6b7280;
|
||||||
|
--url-color: #f3f4f6;
|
||||||
|
--badge-bg: #1a1c26;
|
||||||
|
--badge-border: #282b3d;
|
||||||
|
--badge-text: #9ca3af;
|
||||||
|
--accent: #027bd0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
urlset {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
|
||||||
|
background-color: var(--bg);
|
||||||
|
color: var(--text-main);
|
||||||
|
padding: 3rem 1.5rem;
|
||||||
|
max-width: 1040px;
|
||||||
|
margin: 0 auto;
|
||||||
|
min-height: 100vh;
|
||||||
|
box-sizing: border-box;
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Minimalist header */
|
||||||
|
urlset::before {
|
||||||
|
content: "XML Sitemap";
|
||||||
|
display: block;
|
||||||
|
order: -2;
|
||||||
|
font-size: 1.35rem;
|
||||||
|
font-weight: 600;
|
||||||
|
letter-spacing: -0.02em;
|
||||||
|
color: var(--text-main);
|
||||||
|
padding-bottom: 0.4rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brand note under the header — crafted by Intecion Group */
|
||||||
|
urlset::after {
|
||||||
|
content: "Intecion.com, Technology — engineered for modern digital experiences.";
|
||||||
|
display: block;
|
||||||
|
order: -1;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
color: var(--text-muted);
|
||||||
|
padding-bottom: 1.25rem;
|
||||||
|
margin-bottom: 1.5rem;
|
||||||
|
border-bottom: 1px solid var(--border);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* URL card */
|
||||||
|
url {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
order: 0;
|
||||||
|
background-color: var(--card);
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 1rem 1.25rem;
|
||||||
|
margin-bottom: 0.65rem;
|
||||||
|
box-sizing: border-box;
|
||||||
|
transition: border-color 0.15s ease, box-shadow 0.15s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
url:hover {
|
||||||
|
border-color: var(--border-hover);
|
||||||
|
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* URL address */
|
||||||
|
loc {
|
||||||
|
display: block;
|
||||||
|
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
|
||||||
|
font-size: 0.875rem;
|
||||||
|
font-weight: 500;
|
||||||
|
color: var(--url-color);
|
||||||
|
word-break: break-all;
|
||||||
|
line-height: 1.45;
|
||||||
|
margin-bottom: 0.45rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Metadata row */
|
||||||
|
lastmod,
|
||||||
|
changefreq,
|
||||||
|
priority {
|
||||||
|
display: inline-block;
|
||||||
|
font-size: 0.775rem;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
margin-right: 1.25rem;
|
||||||
|
margin-top: 0.15rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
lastmod::before {
|
||||||
|
content: "Updated: ";
|
||||||
|
color: var(--text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
changefreq::before {
|
||||||
|
content: "Frequency: ";
|
||||||
|
color: var(--text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
priority::before {
|
||||||
|
content: "Priority: ";
|
||||||
|
color: var(--text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Alternate language pills */
|
||||||
|
link {
|
||||||
|
display: inline-block;
|
||||||
|
font-size: 0.7rem;
|
||||||
|
font-weight: 600;
|
||||||
|
background-color: var(--badge-bg);
|
||||||
|
border: 1px solid var(--badge-border);
|
||||||
|
color: var(--badge-text);
|
||||||
|
padding: 0.1rem 0.45rem;
|
||||||
|
border-radius: 4px;
|
||||||
|
margin-right: 0.3rem;
|
||||||
|
margin-top: 0.35rem;
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
|
||||||
|
link::before {
|
||||||
|
content: attr(hreflang);
|
||||||
|
}
|
||||||
|
|
||||||
Vendored
+33
@@ -0,0 +1,33 @@
|
|||||||
|
import type { BasePayload } from 'payload';
|
||||||
|
import type { I18nConfig } from '../i18n/index.js';
|
||||||
|
type ManifestIcon = {
|
||||||
|
sizes?: string;
|
||||||
|
src: string;
|
||||||
|
type?: string;
|
||||||
|
};
|
||||||
|
type Manifest = {
|
||||||
|
background_color?: string;
|
||||||
|
display: 'standalone';
|
||||||
|
icons: ManifestIcon[];
|
||||||
|
name?: string;
|
||||||
|
short_name?: string;
|
||||||
|
start_url: string;
|
||||||
|
theme_color?: string;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Builds a Next Web App Manifest from SiteSettings — replaces the ~50 lines of
|
||||||
|
* icon/mimeType parsing copied into every project's manifest.ts. Values come
|
||||||
|
* from the panel; missing fields are omitted (no hardcoded client data).
|
||||||
|
*
|
||||||
|
* // app/manifest.ts
|
||||||
|
* import { createManifestHandler } from '@intecion/ipal-kit'
|
||||||
|
* import { getCachedPayload } from '@/lib/content'
|
||||||
|
* import { i18nConfig } from '@/i18n.config'
|
||||||
|
* export default createManifestHandler({ getCachedPayload, config: i18nConfig })
|
||||||
|
*/
|
||||||
|
export declare function createManifestHandler(opts: {
|
||||||
|
config: I18nConfig;
|
||||||
|
getCachedPayload: () => Promise<BasePayload>;
|
||||||
|
settingsSlug?: string;
|
||||||
|
}): () => Promise<Manifest>;
|
||||||
|
export {};
|
||||||
Vendored
+65
@@ -0,0 +1,65 @@
|
|||||||
|
import { getDefaultLocale } from '../i18n/index.js';
|
||||||
|
/**
|
||||||
|
* Builds a Next Web App Manifest from SiteSettings — replaces the ~50 lines of
|
||||||
|
* icon/mimeType parsing copied into every project's manifest.ts. Values come
|
||||||
|
* from the panel; missing fields are omitted (no hardcoded client data).
|
||||||
|
*
|
||||||
|
* // app/manifest.ts
|
||||||
|
* import { createManifestHandler } from '@intecion/ipal-kit'
|
||||||
|
* import { getCachedPayload } from '@/lib/content'
|
||||||
|
* import { i18nConfig } from '@/i18n.config'
|
||||||
|
* export default createManifestHandler({ getCachedPayload, config: i18nConfig })
|
||||||
|
*/ export function createManifestHandler(opts) {
|
||||||
|
return async ()=>{
|
||||||
|
const defaultLocale = getDefaultLocale(opts.config);
|
||||||
|
const payload = await opts.getCachedPayload();
|
||||||
|
const settings = await payload.findGlobal({
|
||||||
|
slug: opts.settingsSlug ?? 'site-settings',
|
||||||
|
depth: 1,
|
||||||
|
locale: defaultLocale
|
||||||
|
}).catch(()=>null);
|
||||||
|
const start_url = `/${defaultLocale}`;
|
||||||
|
if (!settings) {
|
||||||
|
return {
|
||||||
|
display: 'standalone',
|
||||||
|
icons: [],
|
||||||
|
start_url
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const iconSource = settings.favicon ?? settings.logo;
|
||||||
|
const icons = [];
|
||||||
|
if (iconSource?.url) {
|
||||||
|
const type = iconSource.mimeType ?? (iconSource.url.endsWith('.svg') ? 'image/svg+xml' : undefined);
|
||||||
|
const isSvg = type === 'image/svg+xml';
|
||||||
|
const size = iconSource.width && iconSource.height ? `${iconSource.width}x${iconSource.height}` : undefined;
|
||||||
|
icons.push({
|
||||||
|
src: iconSource.url,
|
||||||
|
...isSvg ? {
|
||||||
|
sizes: 'any'
|
||||||
|
} : size ? {
|
||||||
|
sizes: size
|
||||||
|
} : {},
|
||||||
|
...type ? {
|
||||||
|
type
|
||||||
|
} : {}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
...settings.siteName ? {
|
||||||
|
name: settings.siteName,
|
||||||
|
short_name: settings.siteName
|
||||||
|
} : {},
|
||||||
|
display: 'standalone',
|
||||||
|
start_url,
|
||||||
|
...settings.backgroundColor ? {
|
||||||
|
background_color: settings.backgroundColor
|
||||||
|
} : {},
|
||||||
|
...settings.themeColor ? {
|
||||||
|
theme_color: settings.themeColor
|
||||||
|
} : {},
|
||||||
|
icons
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
//# sourceMappingURL=buildManifest.js.map
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"sources":["../../../src/modules/seo/buildManifest.ts"],"sourcesContent":["import type { BasePayload } from 'payload'\n\nimport type { I18nConfig } from '../i18n/index.js'\n\nimport { getDefaultLocale } from '../i18n/index.js'\n\ntype MediaLike =\n | { height?: null | number; mimeType?: null | string; url?: null | string; width?: null | number }\n | null\n | undefined\n\ntype ManifestIcon = { sizes?: string; src: string; type?: string }\n\ntype Manifest = {\n background_color?: string\n display: 'standalone'\n icons: ManifestIcon[]\n name?: string\n short_name?: string\n start_url: string\n theme_color?: string\n}\n\ntype SettingsShape = {\n backgroundColor?: null | string\n favicon?: MediaLike\n logo?: MediaLike\n siteName?: null | string\n themeColor?: null | string\n}\n\n/**\n * Builds a Next Web App Manifest from SiteSettings — replaces the ~50 lines of\n * icon/mimeType parsing copied into every project's manifest.ts. Values come\n * from the panel; missing fields are omitted (no hardcoded client data).\n *\n * // app/manifest.ts\n * import { createManifestHandler } from '@intecion/ipal-kit'\n * import { getCachedPayload } from '@/lib/content'\n * import { i18nConfig } from '@/i18n.config'\n * export default createManifestHandler({ getCachedPayload, config: i18nConfig })\n */\nexport function createManifestHandler(opts: {\n config: I18nConfig\n getCachedPayload: () => Promise<BasePayload>\n settingsSlug?: string\n}): () => Promise<Manifest> {\n return async () => {\n const defaultLocale = getDefaultLocale(opts.config)\n const payload = await opts.getCachedPayload()\n const settings = (await payload\n .findGlobal({\n slug: (opts.settingsSlug ?? 'site-settings') as never,\n depth: 1,\n locale: defaultLocale as never,\n })\n .catch(() => null)) as null | SettingsShape\n\n const start_url = `/${defaultLocale}`\n if (!settings) {\n return { display: 'standalone', icons: [], start_url }\n }\n\n const iconSource = settings.favicon ?? settings.logo\n const icons: ManifestIcon[] = []\n if (iconSource?.url) {\n const type =\n iconSource.mimeType ?? (iconSource.url.endsWith('.svg') ? 'image/svg+xml' : undefined)\n const isSvg = type === 'image/svg+xml'\n const size =\n iconSource.width && iconSource.height\n ? `${iconSource.width}x${iconSource.height}`\n : undefined\n icons.push({\n src: iconSource.url,\n ...(isSvg ? { sizes: 'any' } : size ? { sizes: size } : {}),\n ...(type ? { type } : {}),\n })\n }\n\n return {\n ...(settings.siteName ? { name: settings.siteName, short_name: settings.siteName } : {}),\n display: 'standalone',\n start_url,\n ...(settings.backgroundColor ? { background_color: settings.backgroundColor } : {}),\n ...(settings.themeColor ? { theme_color: settings.themeColor } : {}),\n icons,\n }\n }\n}\n"],"names":["getDefaultLocale","createManifestHandler","opts","defaultLocale","config","payload","getCachedPayload","settings","findGlobal","slug","settingsSlug","depth","locale","catch","start_url","display","icons","iconSource","favicon","logo","url","type","mimeType","endsWith","undefined","isSvg","size","width","height","push","src","sizes","siteName","name","short_name","backgroundColor","background_color","themeColor","theme_color"],"mappings":"AAIA,SAASA,gBAAgB,QAAQ,mBAAkB;AA2BnD;;;;;;;;;;CAUC,GACD,OAAO,SAASC,sBAAsBC,IAIrC;IACC,OAAO;QACL,MAAMC,gBAAgBH,iBAAiBE,KAAKE,MAAM;QAClD,MAAMC,UAAU,MAAMH,KAAKI,gBAAgB;QAC3C,MAAMC,WAAY,MAAMF,QACrBG,UAAU,CAAC;YACVC,MAAOP,KAAKQ,YAAY,IAAI;YAC5BC,OAAO;YACPC,QAAQT;QACV,GACCU,KAAK,CAAC,IAAM;QAEf,MAAMC,YAAY,CAAC,CAAC,EAAEX,eAAe;QACrC,IAAI,CAACI,UAAU;YACb,OAAO;gBAAEQ,SAAS;gBAAcC,OAAO,EAAE;gBAAEF;YAAU;QACvD;QAEA,MAAMG,aAAaV,SAASW,OAAO,IAAIX,SAASY,IAAI;QACpD,MAAMH,QAAwB,EAAE;QAChC,IAAIC,YAAYG,KAAK;YACnB,MAAMC,OACJJ,WAAWK,QAAQ,IAAKL,CAAAA,WAAWG,GAAG,CAACG,QAAQ,CAAC,UAAU,kBAAkBC,SAAQ;YACtF,MAAMC,QAAQJ,SAAS;YACvB,MAAMK,OACJT,WAAWU,KAAK,IAAIV,WAAWW,MAAM,GACjC,GAAGX,WAAWU,KAAK,CAAC,CAAC,EAAEV,WAAWW,MAAM,EAAE,GAC1CJ;YACNR,MAAMa,IAAI,CAAC;gBACTC,KAAKb,WAAWG,GAAG;gBACnB,GAAIK,QAAQ;oBAAEM,OAAO;gBAAM,IAAIL,OAAO;oBAAEK,OAAOL;gBAAK,IAAI,CAAC,CAAC;gBAC1D,GAAIL,OAAO;oBAAEA;gBAAK,IAAI,CAAC,CAAC;YAC1B;QACF;QAEA,OAAO;YACL,GAAId,SAASyB,QAAQ,GAAG;gBAAEC,MAAM1B,SAASyB,QAAQ;gBAAEE,YAAY3B,SAASyB,QAAQ;YAAC,IAAI,CAAC,CAAC;YACvFjB,SAAS;YACTD;YACA,GAAIP,SAAS4B,eAAe,GAAG;gBAAEC,kBAAkB7B,SAAS4B,eAAe;YAAC,IAAI,CAAC,CAAC;YAClF,GAAI5B,SAAS8B,UAAU,GAAG;gBAAEC,aAAa/B,SAAS8B,UAAU;YAAC,IAAI,CAAC,CAAC;YACnErB;QACF;IACF;AACF"}
|
||||||
Vendored
+16
-1
@@ -17,12 +17,27 @@ export type PageMetadata = {
|
|||||||
url: string;
|
url: string;
|
||||||
}[];
|
}[];
|
||||||
locale?: string;
|
locale?: string;
|
||||||
|
/** Site/brand name for the OG card. */
|
||||||
|
siteName?: string;
|
||||||
title: string;
|
title: string;
|
||||||
|
/** 'website' | 'article' etc. Defaults to 'website'. */
|
||||||
|
type?: string;
|
||||||
|
/** Canonical URL of this page. */
|
||||||
|
url?: string;
|
||||||
};
|
};
|
||||||
/** robots directives — set to noindex/follow for legal/thin/search pages. */
|
/**
|
||||||
|
* robots directives. Indexed pages get generous snippet/preview limits by
|
||||||
|
* default (Google shows richer results); noindex pages get index:false.
|
||||||
|
*/
|
||||||
robots?: {
|
robots?: {
|
||||||
follow: boolean;
|
follow: boolean;
|
||||||
index: boolean;
|
index: boolean;
|
||||||
|
/** 'none' | 'standard' | 'large' — image preview size in results. */
|
||||||
|
'max-image-preview'?: 'large' | 'none' | 'standard';
|
||||||
|
/** Max text snippet length; -1 = no limit. Next maps to max-snippet. */
|
||||||
|
'max-snippet'?: number;
|
||||||
|
/** Max video preview seconds; -1 = no limit. */
|
||||||
|
'max-video-preview'?: number;
|
||||||
};
|
};
|
||||||
title: string;
|
title: string;
|
||||||
};
|
};
|
||||||
|
|||||||
Vendored
+20
-4
@@ -71,16 +71,32 @@ import { buildHreflangAlternates } from './hreflang.js';
|
|||||||
...images && {
|
...images && {
|
||||||
images
|
images
|
||||||
},
|
},
|
||||||
locale
|
type: 'website',
|
||||||
|
locale,
|
||||||
|
...siteName ? {
|
||||||
|
siteName
|
||||||
|
} : {},
|
||||||
|
...canonical ? {
|
||||||
|
url: canonical
|
||||||
|
} : {}
|
||||||
},
|
},
|
||||||
// noindex → tell search engines to exclude the page but still follow links
|
// robots: noindex pages are excluded (follow keeps link authority). Indexed
|
||||||
// (authority flows through). For legal/thin/search-result pages.
|
// pages get generous snippet/preview limits so Google can show rich results
|
||||||
|
// (long snippets, large image previews, full video previews).
|
||||||
...meta?.noindex ? {
|
...meta?.noindex ? {
|
||||||
robots: {
|
robots: {
|
||||||
follow: true,
|
follow: true,
|
||||||
index: false
|
index: false
|
||||||
}
|
}
|
||||||
} : {}
|
} : {
|
||||||
|
robots: {
|
||||||
|
follow: true,
|
||||||
|
index: true,
|
||||||
|
'max-image-preview': 'large',
|
||||||
|
'max-snippet': -1,
|
||||||
|
'max-video-preview': -1
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+2
@@ -6,6 +6,7 @@ export { buildFaqJsonLd } from './buildFaqJsonLd.js';
|
|||||||
export { buildIconsMetadata } from './buildIconsMetadata.js';
|
export { buildIconsMetadata } from './buildIconsMetadata.js';
|
||||||
export { buildLlmsTxt } from './buildLlmsTxt.js';
|
export { buildLlmsTxt } from './buildLlmsTxt.js';
|
||||||
export { buildLocalBusinessJsonLd } from './buildLocalBusinessJsonLd.js';
|
export { buildLocalBusinessJsonLd } from './buildLocalBusinessJsonLd.js';
|
||||||
|
export { createManifestHandler } from './buildManifest.js';
|
||||||
export { buildMetadata } from './buildMetadata.js';
|
export { buildMetadata } from './buildMetadata.js';
|
||||||
export type { PageMetadata } from './buildMetadata.js';
|
export type { PageMetadata } from './buildMetadata.js';
|
||||||
export { buildOrganizationJsonLd } from './buildOrganizationJsonLd.js';
|
export { buildOrganizationJsonLd } from './buildOrganizationJsonLd.js';
|
||||||
@@ -26,6 +27,7 @@ export { injectAutoFillMeta } from './injectAutoFillMeta.js';
|
|||||||
export { injectSeoTabs } from './injectSeoTabs.js';
|
export { injectSeoTabs } from './injectSeoTabs.js';
|
||||||
export { readSiteMetaConfig } from './readSiteMetaConfig.js';
|
export { readSiteMetaConfig } from './readSiteMetaConfig.js';
|
||||||
export type { SiteMetaConfig } from './readSiteMetaConfig.js';
|
export type { SiteMetaConfig } from './readSiteMetaConfig.js';
|
||||||
|
export { createLlmsTxtRoute, createSitemapRouteHandler } from './routeHandlers.js';
|
||||||
export { buildSeoPlugin } from './seoPluginConfig.js';
|
export { buildSeoPlugin } from './seoPluginConfig.js';
|
||||||
export { slugsAcrossLocales } from './slugsAcrossLocales.js';
|
export { slugsAcrossLocales } from './slugsAcrossLocales.js';
|
||||||
export type { SeoMeta, SeoOption } from './types.js';
|
export type { SeoMeta, SeoOption } from './types.js';
|
||||||
|
|||||||
Vendored
+2
@@ -5,6 +5,7 @@ export { buildFaqJsonLd } from './buildFaqJsonLd.js';
|
|||||||
export { buildIconsMetadata } from './buildIconsMetadata.js';
|
export { buildIconsMetadata } from './buildIconsMetadata.js';
|
||||||
export { buildLlmsTxt } from './buildLlmsTxt.js';
|
export { buildLlmsTxt } from './buildLlmsTxt.js';
|
||||||
export { buildLocalBusinessJsonLd } from './buildLocalBusinessJsonLd.js';
|
export { buildLocalBusinessJsonLd } from './buildLocalBusinessJsonLd.js';
|
||||||
|
export { createManifestHandler } from './buildManifest.js';
|
||||||
export { buildMetadata } from './buildMetadata.js';
|
export { buildMetadata } from './buildMetadata.js';
|
||||||
export { buildOrganizationJsonLd } from './buildOrganizationJsonLd.js';
|
export { buildOrganizationJsonLd } from './buildOrganizationJsonLd.js';
|
||||||
export { buildRobots } from './buildRobots.js';
|
export { buildRobots } from './buildRobots.js';
|
||||||
@@ -20,6 +21,7 @@ export { buildHreflangAlternates } from './hreflang.js';
|
|||||||
export { injectAutoFillMeta } from './injectAutoFillMeta.js';
|
export { injectAutoFillMeta } from './injectAutoFillMeta.js';
|
||||||
export { injectSeoTabs } from './injectSeoTabs.js';
|
export { injectSeoTabs } from './injectSeoTabs.js';
|
||||||
export { readSiteMetaConfig } from './readSiteMetaConfig.js';
|
export { readSiteMetaConfig } from './readSiteMetaConfig.js';
|
||||||
|
export { createLlmsTxtRoute, createSitemapRouteHandler } from './routeHandlers.js';
|
||||||
export { buildSeoPlugin } from './seoPluginConfig.js';
|
export { buildSeoPlugin } from './seoPluginConfig.js';
|
||||||
export { slugsAcrossLocales } from './slugsAcrossLocales.js';
|
export { slugsAcrossLocales } from './slugsAcrossLocales.js';
|
||||||
export { validateFaviconField } from './validateFavicon.js';
|
export { validateFaviconField } from './validateFavicon.js';
|
||||||
|
|||||||
Vendored
+1
-1
@@ -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 { buildMetadata } from './buildMetadata.js'\nexport type { PageMetadata } from './buildMetadata.js'\nexport { buildOrganizationJsonLd } from './buildOrganizationJsonLd.js'\nexport { 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 { 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 { readSiteMetaConfig } from './readSiteMetaConfig.js'\nexport type { SiteMetaConfig } from './readSiteMetaConfig.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","buildMetadata","buildOrganizationJsonLd","buildRobots","buildServiceJsonLd","buildSitemapEntries","buildSitemapXml","buildSiteNavigationJsonLd","buildWebSiteJsonLd","composeTitle","createMetadataGenerator","createPageMetadata","buildHreflangAlternates","injectAutoFillMeta","injectSeoTabs","readSiteMetaConfig","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,aAAa,QAAQ,qBAAoB;AAElD,SAASC,uBAAuB,QAAQ,+BAA8B;AACtE,SAASC,WAAW,QAAQ,mBAAkB;AAE9C,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,mBAAmB,QAAQ,2BAA0B;AAE9D,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,yBAAyB,QAAQ,iCAAgC;AAC1E,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,kBAAkB,QAAQ,0BAAyB;AAE5D,SAASC,cAAc,QAAQ,uBAAsB;AACrD,SAASC,kBAAkB,QAAQ,0BAAyB;AAE5D,SAASC,oBAAoB,QAAQ,uBAAsB"}
|
{"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 { buildOrganizationJsonLd } from './buildOrganizationJsonLd.js'\nexport { 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 { 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 { 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","buildOrganizationJsonLd","buildRobots","buildServiceJsonLd","buildSitemapEntries","buildSitemapXml","buildSiteNavigationJsonLd","buildWebSiteJsonLd","composeTitle","createMetadataGenerator","createPageMetadata","buildHreflangAlternates","injectAutoFillMeta","injectSeoTabs","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,uBAAuB,QAAQ,+BAA8B;AACtE,SAASC,WAAW,QAAQ,mBAAkB;AAE9C,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,mBAAmB,QAAQ,2BAA0B;AAE9D,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,yBAAyB,QAAQ,iCAAgC;AAC1E,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,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"}
|
||||||
Vendored
+40
@@ -0,0 +1,40 @@
|
|||||||
|
import type { BasePayload } from 'payload';
|
||||||
|
import type { I18nConfig } from '../i18n/index.js';
|
||||||
|
import type { SitemapEntry } from './buildSitemapEntries.js';
|
||||||
|
/**
|
||||||
|
* Ready-made Next route handler for /llms.txt. Replaces the ~60-line try/catch
|
||||||
|
* every project was copying. buildLlmsTxt already handles collections without
|
||||||
|
* drafts, so no workaround is needed here.
|
||||||
|
*
|
||||||
|
* // app/llms.txt/route.ts
|
||||||
|
* import { createLlmsTxtRoute } from '@intecion/ipal-kit'
|
||||||
|
* import { getCachedPayload } from '@/lib/content'
|
||||||
|
* import { i18nConfig } from '@/i18n.config'
|
||||||
|
* export const dynamic = 'force-dynamic'
|
||||||
|
* export const GET = createLlmsTxtRoute({ getCachedPayload, config: i18nConfig,
|
||||||
|
* baseUrl: process.env.NEXT_PUBLIC_SERVER_URL! })
|
||||||
|
*/
|
||||||
|
export declare function createLlmsTxtRoute(opts: {
|
||||||
|
baseUrl: string;
|
||||||
|
config: I18nConfig;
|
||||||
|
getCachedPayload: () => Promise<BasePayload>;
|
||||||
|
pagesSlug?: string;
|
||||||
|
settingsSlug?: string;
|
||||||
|
}): () => Promise<Response>;
|
||||||
|
/**
|
||||||
|
* Ready-made Next route handler for /sitemap.xml with the CSS stylesheet.
|
||||||
|
* Replaces the hand-written route in every project. Pass the project's `sitemap`
|
||||||
|
* helper (from createContentHelpers) and optionally a cssUrl.
|
||||||
|
*
|
||||||
|
* // app/sitemap.xml/route.ts
|
||||||
|
* import { createSitemapRouteHandler } from '@intecion/ipal-kit'
|
||||||
|
* import { sitemap } from '@/lib/content'
|
||||||
|
* export const dynamic = 'force-dynamic'
|
||||||
|
* export const GET = createSitemapRouteHandler(sitemap, { cssUrl: '/sitemap.css' })
|
||||||
|
*
|
||||||
|
* Remember: if you use this, DON'T also keep app/sitemap.ts (two sitemaps
|
||||||
|
* confuse crawlers).
|
||||||
|
*/
|
||||||
|
export declare function createSitemapRouteHandler(sitemap: () => Promise<SitemapEntry[]>, opts?: {
|
||||||
|
cssUrl?: string;
|
||||||
|
}): () => Promise<Response>;
|
||||||
Vendored
+81
@@ -0,0 +1,81 @@
|
|||||||
|
import { buildLlmsTxt } from './buildLlmsTxt.js';
|
||||||
|
import { buildSitemapXml } from './buildSitemapXml.js';
|
||||||
|
/**
|
||||||
|
* Ready-made Next route handler for /llms.txt. Replaces the ~60-line try/catch
|
||||||
|
* every project was copying. buildLlmsTxt already handles collections without
|
||||||
|
* drafts, so no workaround is needed here.
|
||||||
|
*
|
||||||
|
* // app/llms.txt/route.ts
|
||||||
|
* import { createLlmsTxtRoute } from '@intecion/ipal-kit'
|
||||||
|
* import { getCachedPayload } from '@/lib/content'
|
||||||
|
* import { i18nConfig } from '@/i18n.config'
|
||||||
|
* export const dynamic = 'force-dynamic'
|
||||||
|
* export const GET = createLlmsTxtRoute({ getCachedPayload, config: i18nConfig,
|
||||||
|
* baseUrl: process.env.NEXT_PUBLIC_SERVER_URL! })
|
||||||
|
*/ export function createLlmsTxtRoute(opts) {
|
||||||
|
return async ()=>{
|
||||||
|
try {
|
||||||
|
const payload = await opts.getCachedPayload();
|
||||||
|
const body = await buildLlmsTxt({
|
||||||
|
baseUrl: opts.baseUrl,
|
||||||
|
config: opts.config,
|
||||||
|
pagesSlug: opts.pagesSlug,
|
||||||
|
payload,
|
||||||
|
settingsSlug: opts.settingsSlug
|
||||||
|
});
|
||||||
|
return new Response(body, {
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'text/plain; charset=utf-8'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
// DB unreachable at build (container) — return a minimal valid file so the
|
||||||
|
// route doesn't 500; it fills in at runtime. No per-project try/catch.
|
||||||
|
console.warn('[ipal] createLlmsTxtRoute: could not build llms.txt:', err);
|
||||||
|
return new Response('# llms.txt\n', {
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'text/plain; charset=utf-8'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Ready-made Next route handler for /sitemap.xml with the CSS stylesheet.
|
||||||
|
* Replaces the hand-written route in every project. Pass the project's `sitemap`
|
||||||
|
* helper (from createContentHelpers) and optionally a cssUrl.
|
||||||
|
*
|
||||||
|
* // app/sitemap.xml/route.ts
|
||||||
|
* import { createSitemapRouteHandler } from '@intecion/ipal-kit'
|
||||||
|
* import { sitemap } from '@/lib/content'
|
||||||
|
* export const dynamic = 'force-dynamic'
|
||||||
|
* export const GET = createSitemapRouteHandler(sitemap, { cssUrl: '/sitemap.css' })
|
||||||
|
*
|
||||||
|
* Remember: if you use this, DON'T also keep app/sitemap.ts (two sitemaps
|
||||||
|
* confuse crawlers).
|
||||||
|
*/ export function createSitemapRouteHandler(sitemap, opts = {}) {
|
||||||
|
return async ()=>{
|
||||||
|
try {
|
||||||
|
const entries = await sitemap();
|
||||||
|
const xml = buildSitemapXml(entries, {
|
||||||
|
cssUrl: opts.cssUrl
|
||||||
|
});
|
||||||
|
return new Response(xml, {
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/xml; charset=utf-8'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
console.warn('[ipal] createSitemapRouteHandler: could not build sitemap:', err);
|
||||||
|
// Valid empty urlset so the route doesn't 500 during a DB-less build.
|
||||||
|
const empty = '<?xml version="1.0" encoding="UTF-8"?>\n' + '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"></urlset>';
|
||||||
|
return new Response(empty, {
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/xml; charset=utf-8'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
//# sourceMappingURL=routeHandlers.js.map
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"sources":["../../../src/modules/seo/routeHandlers.ts"],"sourcesContent":["import type { BasePayload } from 'payload'\n\nimport type { I18nConfig } from '../i18n/index.js'\nimport type { SitemapEntry } from './buildSitemapEntries.js'\n\nimport { buildLlmsTxt } from './buildLlmsTxt.js'\nimport { buildSitemapXml } from './buildSitemapXml.js'\n\n/**\n * Ready-made Next route handler for /llms.txt. Replaces the ~60-line try/catch\n * every project was copying. buildLlmsTxt already handles collections without\n * drafts, so no workaround is needed here.\n *\n * // app/llms.txt/route.ts\n * import { createLlmsTxtRoute } from '@intecion/ipal-kit'\n * import { getCachedPayload } from '@/lib/content'\n * import { i18nConfig } from '@/i18n.config'\n * export const dynamic = 'force-dynamic'\n * export const GET = createLlmsTxtRoute({ getCachedPayload, config: i18nConfig,\n * baseUrl: process.env.NEXT_PUBLIC_SERVER_URL! })\n */\nexport function createLlmsTxtRoute(opts: {\n baseUrl: string\n config: I18nConfig\n getCachedPayload: () => Promise<BasePayload>\n pagesSlug?: string\n settingsSlug?: string\n}): () => Promise<Response> {\n return async () => {\n try {\n const payload = await opts.getCachedPayload()\n const body = await buildLlmsTxt({\n baseUrl: opts.baseUrl,\n config: opts.config,\n pagesSlug: opts.pagesSlug,\n payload,\n settingsSlug: opts.settingsSlug,\n })\n return new Response(body, {\n headers: { 'Content-Type': 'text/plain; charset=utf-8' },\n })\n } catch (err) {\n // DB unreachable at build (container) — return a minimal valid file so the\n // route doesn't 500; it fills in at runtime. No per-project try/catch.\n console.warn('[ipal] createLlmsTxtRoute: could not build llms.txt:', err)\n return new Response('# llms.txt\\n', {\n headers: { 'Content-Type': 'text/plain; charset=utf-8' },\n })\n }\n }\n}\n\n/**\n * Ready-made Next route handler for /sitemap.xml with the CSS stylesheet.\n * Replaces the hand-written route in every project. Pass the project's `sitemap`\n * helper (from createContentHelpers) and optionally a cssUrl.\n *\n * // app/sitemap.xml/route.ts\n * import { createSitemapRouteHandler } from '@intecion/ipal-kit'\n * import { sitemap } from '@/lib/content'\n * export const dynamic = 'force-dynamic'\n * export const GET = createSitemapRouteHandler(sitemap, { cssUrl: '/sitemap.css' })\n *\n * Remember: if you use this, DON'T also keep app/sitemap.ts (two sitemaps\n * confuse crawlers).\n */\nexport function createSitemapRouteHandler(\n sitemap: () => Promise<SitemapEntry[]>,\n opts: { cssUrl?: string } = {},\n): () => Promise<Response> {\n return async () => {\n try {\n const entries = await sitemap()\n const xml = buildSitemapXml(entries, { cssUrl: opts.cssUrl })\n return new Response(xml, {\n headers: { 'Content-Type': 'application/xml; charset=utf-8' },\n })\n } catch (err) {\n console.warn('[ipal] createSitemapRouteHandler: could not build sitemap:', err)\n // Valid empty urlset so the route doesn't 500 during a DB-less build.\n const empty =\n '<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n' +\n '<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"></urlset>'\n return new Response(empty, {\n headers: { 'Content-Type': 'application/xml; charset=utf-8' },\n })\n }\n }\n}\n"],"names":["buildLlmsTxt","buildSitemapXml","createLlmsTxtRoute","opts","payload","getCachedPayload","body","baseUrl","config","pagesSlug","settingsSlug","Response","headers","err","console","warn","createSitemapRouteHandler","sitemap","entries","xml","cssUrl","empty"],"mappings":"AAKA,SAASA,YAAY,QAAQ,oBAAmB;AAChD,SAASC,eAAe,QAAQ,uBAAsB;AAEtD;;;;;;;;;;;;CAYC,GACD,OAAO,SAASC,mBAAmBC,IAMlC;IACC,OAAO;QACL,IAAI;YACF,MAAMC,UAAU,MAAMD,KAAKE,gBAAgB;YAC3C,MAAMC,OAAO,MAAMN,aAAa;gBAC9BO,SAASJ,KAAKI,OAAO;gBACrBC,QAAQL,KAAKK,MAAM;gBACnBC,WAAWN,KAAKM,SAAS;gBACzBL;gBACAM,cAAcP,KAAKO,YAAY;YACjC;YACA,OAAO,IAAIC,SAASL,MAAM;gBACxBM,SAAS;oBAAE,gBAAgB;gBAA4B;YACzD;QACF,EAAE,OAAOC,KAAK;YACZ,2EAA2E;YAC3E,uEAAuE;YACvEC,QAAQC,IAAI,CAAC,wDAAwDF;YACrE,OAAO,IAAIF,SAAS,gBAAgB;gBAClCC,SAAS;oBAAE,gBAAgB;gBAA4B;YACzD;QACF;IACF;AACF;AAEA;;;;;;;;;;;;;CAaC,GACD,OAAO,SAASI,0BACdC,OAAsC,EACtCd,OAA4B,CAAC,CAAC;IAE9B,OAAO;QACL,IAAI;YACF,MAAMe,UAAU,MAAMD;YACtB,MAAME,MAAMlB,gBAAgBiB,SAAS;gBAAEE,QAAQjB,KAAKiB,MAAM;YAAC;YAC3D,OAAO,IAAIT,SAASQ,KAAK;gBACvBP,SAAS;oBAAE,gBAAgB;gBAAiC;YAC9D;QACF,EAAE,OAAOC,KAAK;YACZC,QAAQC,IAAI,CAAC,8DAA8DF;YAC3E,sEAAsE;YACtE,MAAMQ,QACJ,6CACA;YACF,OAAO,IAAIV,SAASU,OAAO;gBACzBT,SAAS;oBAAE,gBAAgB;gBAAiC;YAC9D;QACF;IACF;AACF"}
|
||||||
Vendored
+44
-4
@@ -42,6 +42,50 @@ import { buildSeoPlugin, injectAutoFillMeta, injectSeoTabs } from './modules/seo
|
|||||||
let config = {
|
let config = {
|
||||||
...incomingConfig
|
...incomingConfig
|
||||||
};
|
};
|
||||||
|
// --- custom admin route (e.g. '/its' instead of '/admin') ---
|
||||||
|
// Sets config.routes.admin; the project must move its app/(payload)/<route>/
|
||||||
|
// folder to match (plugin can't create files in the project's app/).
|
||||||
|
if (options.adminRoute) {
|
||||||
|
config.routes = {
|
||||||
|
...config.routes ?? {},
|
||||||
|
admin: options.adminRoute
|
||||||
|
};
|
||||||
|
}
|
||||||
|
// --- enforced 2FA (TOTP) via @clocklimited/payload-2fa ---
|
||||||
|
// Enforced by default (forceSetup) unless twoFactor is explicitly false. The
|
||||||
|
// plugin is a PEER dependency imported dynamically — ipal-kit doesn't bundle
|
||||||
|
// it, so projects that opt out (twoFactor: false) needn't install it, and the
|
||||||
|
// import never runs under generate:importmap when 2FA is off. Wrapping access
|
||||||
|
// control (not just admin UI) means TOTP gates data access — no API bypass.
|
||||||
|
if (options.twoFactor !== false) {
|
||||||
|
const tf = options.twoFactor;
|
||||||
|
if (!tf?.issuer) {
|
||||||
|
throw new Error('[ipal] twoFactor.issuer is required (name shown in the authenticator ' + 'app). Pass twoFactor: { issuer: "Your Site" }, or twoFactor: false to ' + 'opt out (discouraged).');
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
// Dynamic specifier via a variable so TS doesn't try to resolve this
|
||||||
|
// optional peer dependency at build time (it isn't in the plugin's own
|
||||||
|
// node_modules). Avoids TS2307 without @ts-expect-error; the module
|
||||||
|
// exists at runtime in projects that installed it.
|
||||||
|
// @ts-ignore
|
||||||
|
const mod = await import('@clocklimited/payload-2fa');
|
||||||
|
// The package exports `payloadTotp`; older/other builds may use
|
||||||
|
// `totpPlugin`. Accept either so a rename doesn't break us.
|
||||||
|
const totp = mod.payloadTotp ?? mod.totpPlugin;
|
||||||
|
if (typeof totp !== 'function') {
|
||||||
|
throw new Error('expected export payloadTotp (or totpPlugin) to be a function — ' + 'check the installed @clocklimited/payload-2fa version');
|
||||||
|
}
|
||||||
|
config = await totp({
|
||||||
|
collection: tf.collectionSlug ?? 'users',
|
||||||
|
forceSetup: true,
|
||||||
|
totp: {
|
||||||
|
issuer: tf.issuer
|
||||||
|
}
|
||||||
|
})(config);
|
||||||
|
} catch (err) {
|
||||||
|
throw new Error('[ipal] 2FA is enforced but @clocklimited/payload-2fa is not installed. ' + 'Run: pnpm add @clocklimited/payload-2fa — or set twoFactor: false to ' + `opt out (discouraged). Original error: ${String(err)}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
// --- i18n ---
|
// --- i18n ---
|
||||||
config.localization = buildLocalizationConfig(options.i18n);
|
config.localization = buildLocalizationConfig(options.i18n);
|
||||||
// --- access: inject roles into the client's auth collection ---
|
// --- access: inject roles into the client's auth collection ---
|
||||||
@@ -88,10 +132,6 @@ import { buildSeoPlugin, injectAutoFillMeta, injectSeoTabs } from './modules/seo
|
|||||||
buildCookieSettings(),
|
buildCookieSettings(),
|
||||||
buildNotifications()
|
buildNotifications()
|
||||||
];
|
];
|
||||||
// --- endpoints ---
|
|
||||||
// Test-email endpoint (admin-only): POST /api/ipal/test-email sends a probe
|
|
||||||
// message through the currently selected transport, so the panel's "send
|
|
||||||
// test" button can confirm delivery without leaving the admin UI.
|
|
||||||
config.endpoints = [
|
config.endpoints = [
|
||||||
...config.endpoints ?? [],
|
...config.endpoints ?? [],
|
||||||
testEmailEndpoint
|
testEmailEndpoint
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+27
@@ -15,6 +15,17 @@ export type IpalOptions = {
|
|||||||
* (admin > editor > user) into the client's auth collection.
|
* (admin > editor > user) into the client's auth collection.
|
||||||
*/
|
*/
|
||||||
access?: AccessOption;
|
access?: AccessOption;
|
||||||
|
/**
|
||||||
|
* Custom admin panel route, e.g. '/its' instead of the default '/admin'.
|
||||||
|
* The plugin sets config.routes.admin. IMPORTANT: this alone isn't enough —
|
||||||
|
* the project must ALSO move its panel folder to match:
|
||||||
|
* app/(payload)/its/[[...segments]]/page.tsx (and the not-found). The plugin
|
||||||
|
* can't create files in the project's app/. See docs/security.md.
|
||||||
|
*
|
||||||
|
* This is obscurity, not security: it hides the panel from dumb bots scanning
|
||||||
|
* /admin, but real protection is strong auth + 2FA + rate limiting.
|
||||||
|
*/
|
||||||
|
adminRoute?: string;
|
||||||
/**
|
/**
|
||||||
* Collections whose entries live under an archive page — blog posts, case
|
* Collections whose entries live under an archive page — blog posts, case
|
||||||
* studies, anything with a listing. Adds an "archive page" assignment per
|
* studies, anything with a listing. Adds an "archive page" assignment per
|
||||||
@@ -45,4 +56,20 @@ export type IpalOptions = {
|
|||||||
seo?: SeoOption;
|
seo?: SeoOption;
|
||||||
/** Additional fields injected into SiteSettings global */
|
/** Additional fields injected into SiteSettings global */
|
||||||
siteSettingsFields?: Field[];
|
siteSettingsFields?: Field[];
|
||||||
|
/**
|
||||||
|
* Two-factor authentication (TOTP), ENFORCED for every user. Wires
|
||||||
|
* @clocklimited/payload-2fa with forceSetup — no per-project opt-out. Every
|
||||||
|
* user must configure an authenticator app after login; TOTP is checked before
|
||||||
|
* data access (not just the admin UI). Requires the peer dep installed and an
|
||||||
|
* issuer name (shown in the authenticator app).
|
||||||
|
*
|
||||||
|
* Pass `false` ONLY for a project that genuinely can't use 2FA (rare, discouraged)
|
||||||
|
* — default is enforced. See docs/security.md.
|
||||||
|
*/
|
||||||
|
twoFactor?: {
|
||||||
|
/** Auth collection slug. Defaults to 'users'. */
|
||||||
|
collectionSlug?: string;
|
||||||
|
/** Name shown in the authenticator app (e.g. company/site name). */
|
||||||
|
issuer: string;
|
||||||
|
} | false;
|
||||||
};
|
};
|
||||||
|
|||||||
Vendored
+1
-1
@@ -1 +1 @@
|
|||||||
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { Field } from 'payload'\n\nimport type { AccessOption } from './modules/access/types.js'\nimport type { ContentOption } from './modules/content/types.js'\nimport type { FormsOption } from './modules/forms/types.js'\nimport type { I18nConfig } from './modules/i18n/types.js'\nimport type { PagesOption } from './modules/pages/types.js'\nimport type { SeoOption } from './modules/seo/types.js'\n\n/**\n * Configuration options for the IPAL plugin.\n * Passed by the client project in payload.config.ts.\n */\nexport type IpalOptions = {\n /**\n * Role-based access control. Injects a fixed `roles` field\n * (admin > editor > user) into the client's auth collection.\n */\n access?: AccessOption\n\n /**\n * Collections whose entries live under an archive page — blog posts, case\n * studies, anything with a listing. Adds an \"archive page\" assignment per\n * collection in SiteSettings; the assigned page's localized slug becomes the\n * URL segment (/pl/artykuly/moj-post, /en/articles/my-post). Requires `pages`.\n */\n content?: ContentOption\n\n /** Disable the plugin without uninstalling (keeps DB schema intact) */\n enabled?: boolean\n\n /**\n * Forms — form-builder collections (forms, form-submissions) plus the\n * callable submitForm (Turnstile + persistence + SMTP-from-panel email).\n */\n forms?: FormsOption\n\n /** Internationalization — locales, default locale, fallback behavior */\n i18n: I18nConfig\n\n /** Additional fields injected into SiteIntegrations global */\n integrationsFields?: Field[]\n\n /**\n * System-page assignments (homepage, privacy, cookies) in SiteSettings.\n * Provide the slug of the client's Pages collection to enable.\n */\n pages?: PagesOption\n\n /**\n * SEO — adds meta fields to chosen collections (via @payloadcms/plugin-seo)\n * and enables locale-aware metadata helpers.\n */\n seo?: SeoOption\n\n /** Additional fields injected into SiteSettings global */\n siteSettingsFields?: Field[]\n}\n"],"names":[],"mappings":"AASA;;;CAGC,GACD,WA4CC"}
|
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { Field } from 'payload'\n\nimport type { AccessOption } from './modules/access/types.js'\nimport type { ContentOption } from './modules/content/types.js'\nimport type { FormsOption } from './modules/forms/types.js'\nimport type { I18nConfig } from './modules/i18n/types.js'\nimport type { PagesOption } from './modules/pages/types.js'\nimport type { SeoOption } from './modules/seo/types.js'\n\n/**\n * Configuration options for the IPAL plugin.\n * Passed by the client project in payload.config.ts.\n */\nexport type IpalOptions = {\n /**\n * Role-based access control. Injects a fixed `roles` field\n * (admin > editor > user) into the client's auth collection.\n */\n access?: AccessOption\n\n /**\n * Custom admin panel route, e.g. '/its' instead of the default '/admin'.\n * The plugin sets config.routes.admin. IMPORTANT: this alone isn't enough —\n * the project must ALSO move its panel folder to match:\n * app/(payload)/its/[[...segments]]/page.tsx (and the not-found). The plugin\n * can't create files in the project's app/. See docs/security.md.\n *\n * This is obscurity, not security: it hides the panel from dumb bots scanning\n * /admin, but real protection is strong auth + 2FA + rate limiting.\n */\n adminRoute?: string\n\n /**\n * Collections whose entries live under an archive page — blog posts, case\n * studies, anything with a listing. Adds an \"archive page\" assignment per\n * collection in SiteSettings; the assigned page's localized slug becomes the\n * URL segment (/pl/artykuly/moj-post, /en/articles/my-post). Requires `pages`.\n */\n content?: ContentOption\n\n /** Disable the plugin without uninstalling (keeps DB schema intact) */\n enabled?: boolean\n\n /**\n * Forms — form-builder collections (forms, form-submissions) plus the\n * callable submitForm (Turnstile + persistence + SMTP-from-panel email).\n */\n forms?: FormsOption\n\n /** Internationalization — locales, default locale, fallback behavior */\n i18n: I18nConfig\n\n /** Additional fields injected into SiteIntegrations global */\n integrationsFields?: Field[]\n\n /**\n * System-page assignments (homepage, privacy, cookies) in SiteSettings.\n * Provide the slug of the client's Pages collection to enable.\n */\n pages?: PagesOption\n\n /**\n * SEO — adds meta fields to chosen collections (via @payloadcms/plugin-seo)\n * and enables locale-aware metadata helpers.\n */\n seo?: SeoOption\n\n /** Additional fields injected into SiteSettings global */\n siteSettingsFields?: Field[]\n\n /**\n * Two-factor authentication (TOTP), ENFORCED for every user. Wires\n * @clocklimited/payload-2fa with forceSetup — no per-project opt-out. Every\n * user must configure an authenticator app after login; TOTP is checked before\n * data access (not just the admin UI). Requires the peer dep installed and an\n * issuer name (shown in the authenticator app).\n *\n * Pass `false` ONLY for a project that genuinely can't use 2FA (rare, discouraged)\n * — default is enforced. See docs/security.md.\n */\n twoFactor?:\n | {\n /** Auth collection slug. Defaults to 'users'. */\n collectionSlug?: string\n /** Name shown in the authenticator app (e.g. company/site name). */\n issuer: string\n }\n | false\n}\n"],"names":[],"mappings":"AASA;;;CAGC,GACD,WA2EC"}
|
||||||
+61
-1
@@ -248,4 +248,64 @@ Jeśli klient później doda drugi język, to PRZEBUDOWA, nie przełącznik:
|
|||||||
|
|
||||||
Warto to przewidzieć na starcie: jeśli jest szansa na drugi język, rozważ od razu
|
Warto to przewidzieć na starcie: jeśli jest szansa na drugi język, rozważ od razu
|
||||||
strukturę wielojęzyczną (z [locale]), nawet dla jednego locale — wtedy prefiks
|
strukturę wielojęzyczną (z [locale]), nawet dla jednego locale — wtedy prefiks
|
||||||
`/pl` jest, ale dodanie języka to tylko config, nie przebudowa struktury.
|
`/pl` jest, ale dodanie języka to tylko config, nie przebudowa struktury.
|
||||||
|
|
||||||
|
## Przełącznik języka bez 404 (AlternateLinks + LanguageSwitcher)
|
||||||
|
|
||||||
|
Gdy slug różni się per język (`/pl/uslugi/karne` vs `/en/services/criminal`),
|
||||||
|
naiwny przełącznik (podmiana prefiksu `/pl` → `/en`) prowadzi do 404. Plugin
|
||||||
|
rozwiązuje to przez kontekst alternatywnych URL-i.
|
||||||
|
|
||||||
|
### Jak to działa
|
||||||
|
|
||||||
|
1. **AlternateLinksProvider** w layoutcie — trzyma URL-e per język bieżącej strony
|
||||||
|
2. **AlternateLinksUpdater** na każdej stronie — zgłasza jej alternatywne URL-e
|
||||||
|
(strona RSC wylicza je z resolveRoute/getLocalizedSlugs)
|
||||||
|
3. **LanguageSwitcher** — linkuje do poprawnych URL-i z kontekstu
|
||||||
|
|
||||||
|
### Wpięcie
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
// layout.tsx
|
||||||
|
import { AlternateLinksProvider } from '@intecion/ipal-kit/client'
|
||||||
|
<AlternateLinksProvider>{children}</AlternateLinksProvider>
|
||||||
|
|
||||||
|
// page.tsx (RSC) — wylicz alternatywy z routingu
|
||||||
|
import { AlternateLinksUpdater } from '@intecion/ipal-kit/client'
|
||||||
|
const alternates = { pl: '/pl/uslugi/karne', en: '/en/services/criminal' }
|
||||||
|
return <>
|
||||||
|
<AlternateLinksUpdater links={alternates} />
|
||||||
|
{/* treść */}
|
||||||
|
</>
|
||||||
|
|
||||||
|
// header (client) — przełącznik, headless, classNames jak CookieBanner
|
||||||
|
import { LanguageSwitcher } from '@intecion/ipal-kit/client'
|
||||||
|
<LanguageSwitcher
|
||||||
|
config={i18nConfig}
|
||||||
|
currentLocale={locale}
|
||||||
|
classNames={{ root: '...', trigger: '...', menu: '...', item: '...', itemActive: '...' }}
|
||||||
|
/>
|
||||||
|
```
|
||||||
|
|
||||||
|
LanguageSwitcher jest BEZ stylów (classNames) — nie `variant="light|dark"`, żeby
|
||||||
|
pasował do każdego designu projektu. Locale bez znanego alternatywnego URL →
|
||||||
|
fallback na root `/{code}`.
|
||||||
|
|
||||||
|
> **Skąd alternates na stronie:** strona RSC już rozwiązuje trasę (resolveRoute);
|
||||||
|
> z tego samego źródła wylicz slugi per język (getLocalizedSlugs/buildLocalizedPath)
|
||||||
|
> i przekaż do AlternateLinksUpdater. To eliminuje własny AlternateLinksContext
|
||||||
|
> (~150 linii) kopiowany w projektach.
|
||||||
|
|
||||||
|
## Next matcher — MUSI być literałem inline
|
||||||
|
|
||||||
|
Next.js analizuje `config.matcher` STATYCZNIE (AST) — musi być literałem tablicy
|
||||||
|
w pliku proxy/middleware, nie importem/zmienną. Mimo że plugin eksportuje
|
||||||
|
`DEFAULT_PROXY_MATCHER`, Next może nie rozpoznać go jako importu. Bezpiecznie:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
// proxy.ts — matcher INLINE (nie import)
|
||||||
|
export const config = { matcher: ['/((?!api|admin|_next|.*\\..*).*)'] }
|
||||||
|
```
|
||||||
|
|
||||||
|
`DEFAULT_PROXY_MATCHER` używaj jako referencji wartości, ale jeśli Next narzeka
|
||||||
|
na matcher — wklej go inline. To ograniczenie Next, nie pluginu.
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
# Rich text (Lexical) — RenderRichText
|
||||||
|
|
||||||
|
Renderowanie pól `richText` (edytor Lexical) na froncie. Plugin dostarcza
|
||||||
|
`RenderRichText` — cienki wrapper nad OFICJALNYM konwerterem Payload
|
||||||
|
(`@payloadcms/richtext-lexical/react`). To RenderBlocks rich textu: plugin
|
||||||
|
dostarcza silnik, projekt dostarcza wygląd.
|
||||||
|
|
||||||
|
> **NIGDY nie pisz własnego renderera Lexical** (switch po `node.type`, flagi
|
||||||
|
> bitowe `node.format & 1`). To powiela to, co Payload już robi, pomija typy
|
||||||
|
> węzłów, rozjeżdża się przy aktualizacjach Lexical i kusi do
|
||||||
|
> `dangerouslySetInnerHTML` (XSS) oraz hardkodu locale (`.pl`). Użyj
|
||||||
|
> RenderRichText.
|
||||||
|
|
||||||
|
## Podstawowe użycie (RSC)
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
import { RenderRichText } from '@intecion/ipal-kit/rsc'
|
||||||
|
|
||||||
|
<RenderRichText data={page.content} className="prose prose-slate max-w-none" />
|
||||||
|
```
|
||||||
|
|
||||||
|
`data` to pole richText z dokumentu — JUŻ zlokalizowane (Payload zwraca wartość
|
||||||
|
bieżącego locale). Zero obsługi kluczy per język, zero hardkodu `.pl`.
|
||||||
|
|
||||||
|
## Własne style per węzeł (converters)
|
||||||
|
|
||||||
|
Styl zostaje w projekcie (Tailwind), parsowanie w pluginie. Nadpisujesz JSX
|
||||||
|
konkretnych węzłów przez `converters`:
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
import { RenderRichText } from '@intecion/ipal-kit/rsc'
|
||||||
|
import type { JSXConvertersFunction } from '@payloadcms/richtext-lexical/react'
|
||||||
|
|
||||||
|
const converters: JSXConvertersFunction = ({ defaultConverters }) => ({
|
||||||
|
...defaultConverters,
|
||||||
|
heading: ({ node, nodesToJSX }) => {
|
||||||
|
const children = nodesToJSX({ nodes: node.children })
|
||||||
|
const cls: Record<string, string> = {
|
||||||
|
h2: 'font-display text-2xl font-semibold mt-10 mb-4',
|
||||||
|
h3: 'font-display text-xl font-semibold mt-7 mb-3',
|
||||||
|
}
|
||||||
|
const Tag = node.tag as 'h1' | 'h2' | 'h3' | 'h4'
|
||||||
|
return <Tag className={cls[node.tag] ?? ''}>{children}</Tag>
|
||||||
|
},
|
||||||
|
paragraph: ({ node, nodesToJSX }) => (
|
||||||
|
<p className="text-base leading-relaxed mb-5">{nodesToJSX({ nodes: node.children })}</p>
|
||||||
|
),
|
||||||
|
})
|
||||||
|
|
||||||
|
<RenderRichText data={page.content} converters={converters} />
|
||||||
|
```
|
||||||
|
|
||||||
|
Spread `defaultConverters` — nadpisujesz tylko te węzły, które chcesz. Reszta
|
||||||
|
(listy, tabele, obrazy, linki) działa z oficjalnej obsługi Payload.
|
||||||
|
|
||||||
|
## Zależność
|
||||||
|
|
||||||
|
Oficjalny konwerter jest częścią `@payloadcms/richtext-lexical`, które projekt
|
||||||
|
Payload już ma (to edytor). Zero dodatkowych zależności.
|
||||||
|
|
||||||
|
## Czego to unika (vs ręczny renderer)
|
||||||
|
|
||||||
|
- **XSS** — brak `dangerouslySetInnerHTML`
|
||||||
|
- **Hardkod locale** — brak `val.alt.pl` (dane już zlokalizowane)
|
||||||
|
- **Brakujące węzły** — oficjalny konwerter obsługuje wszystkie (zagnieżdżone
|
||||||
|
listy, upload, relacje, horizontal rule…)
|
||||||
|
- **Rozjazd przy aktualizacji** — Payload utrzymuje konwerter, nie Ty
|
||||||
|
- **`any`** — typowane (SerializedEditorState)
|
||||||
+105
-1
@@ -197,4 +197,108 @@ NIE wymuszaj `require-trusted-types-for 'script'`. Powód:
|
|||||||
przy zewnętrznych skryptach manipulujących DOM stringami (Turnstile, GA)
|
przy zewnętrznych skryptach manipulujących DOM stringami (Turnstile, GA)
|
||||||
- Zysk bezpieczeństwa nie równoważy ryzyka zepsucia strony
|
- Zysk bezpieczeństwa nie równoważy ryzyka zepsucia strony
|
||||||
|
|
||||||
Zostaw Trusted Types poza CSP, dopóki Next/React nie da natywnego wsparcia.
|
Zostaw Trusted Types poza CSP, dopóki Next/React nie da natywnego wsparcia.
|
||||||
|
|
||||||
|
## Zmiana ścieżki panelu admina (/admin → /its)
|
||||||
|
|
||||||
|
Ukrycie panelu przed botami skanującymi znane ścieżki (`/admin`, `/wp-admin`).
|
||||||
|
Plugin ustawia ścieżkę przez opcję `adminRoute`:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
// payload.config.ts
|
||||||
|
ipalKit({
|
||||||
|
i18n: i18nConfig,
|
||||||
|
adminRoute: '/its', // panel pod /its zamiast /admin
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
### WYMAGANE — przenieś folder panelu w projekcie
|
||||||
|
|
||||||
|
Plugin ustawia `config.routes.admin`, ale NIE tworzy plików w `app/` projektu.
|
||||||
|
Musisz przenieść folder panelu, żeby ścieżka zadziałała:
|
||||||
|
|
||||||
|
```
|
||||||
|
# PRZED:
|
||||||
|
app/(payload)/admin/[[...segments]]/page.tsx
|
||||||
|
app/(payload)/admin/[[...segments]]/not-found.tsx
|
||||||
|
|
||||||
|
# PO (nazwa folderu = adminRoute bez ukośnika):
|
||||||
|
app/(payload)/its/[[...segments]]/page.tsx
|
||||||
|
app/(payload)/its/[[...segments]]/not-found.tsx
|
||||||
|
```
|
||||||
|
|
||||||
|
Bez przeniesienia folderu: `config.routes.admin = '/its'`, ale `/its` daje 404
|
||||||
|
(brak pliku), a `/admin` też nie działa (config zmieniony). Oba muszą się zgadzać.
|
||||||
|
|
||||||
|
### To OBSCURITY, nie SECURITY
|
||||||
|
|
||||||
|
Zmiana ścieżki utrudnia automatyczne skany, ale NIE jest zabezpieczeniem.
|
||||||
|
Prawdziwa ochrona panelu:
|
||||||
|
- **2FA** dla każdego użytkownika (planowane — wymuszenie przez plugin)
|
||||||
|
- Silne hasła
|
||||||
|
- Rate limiting na logowaniu
|
||||||
|
- IP allowlist (jeśli panel tylko dla zespołu)
|
||||||
|
- buildSecurityHeaders (nagłówki)
|
||||||
|
|
||||||
|
Zmiana `/admin → /its` to warstwa (odsiewa głupie boty), nie zamek. Traktuj jako
|
||||||
|
dodatek do prawdziwych zabezpieczeń, nie zamiast nich.
|
||||||
|
|
||||||
|
## 2FA (TOTP) — WYMUSZONE dla każdego użytkownika
|
||||||
|
|
||||||
|
Plugin wymusza dwuskładnikowe uwierzytelnianie (TOTP) dla WSZYSTKICH użytkowników
|
||||||
|
panelu — bez możliwości wyłączenia per użytkownik. Każdy projekt ma to z automatu.
|
||||||
|
Używa sprawdzonego `@clocklimited/payload-2fa` (wrapuje access control — TOTP
|
||||||
|
sprawdzane przed dostępem do DANYCH, nie tylko UI panelu).
|
||||||
|
|
||||||
|
### Zależność
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pnpm add @clocklimited/payload-2fa@3.0.0-beta.7
|
||||||
|
```
|
||||||
|
Uwaga: pakiet nie ma jeszcze stabilnego 3.0.0 — użyj konkretnej wersji beta
|
||||||
|
(albo `^3.0.0-0`, żeby dopuścić prereleasy). Sam `^3.0.0` da błąd
|
||||||
|
ERR_PNPM_NO_MATCHING_VERSION.
|
||||||
|
To PEER dependency — ipal-kit importuje ją dynamicznie tylko gdy 2FA włączone
|
||||||
|
(domyślnie). Bez niej i z włączonym 2FA plugin rzuci jasny błąd.
|
||||||
|
|
||||||
|
### Konfiguracja (payload.config.ts)
|
||||||
|
|
||||||
|
```ts
|
||||||
|
ipalKit({
|
||||||
|
i18n: i18nConfig,
|
||||||
|
twoFactor: {
|
||||||
|
issuer: 'Nazwa Firmy', // pokazywane w aplikacji authenticator (Google Auth itp.)
|
||||||
|
// collectionSlug: 'users', // domyślnie 'users'
|
||||||
|
},
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
Plugin ustawia `forceSetup: true` — każdy użytkownik MUSI skonfigurować TOTP po
|
||||||
|
zalogowaniu (przekierowanie na setup). Nie ma opcji „włącz/wyłącz" dla użytkownika.
|
||||||
|
|
||||||
|
### Wyłączenie (ODRADZANE)
|
||||||
|
|
||||||
|
```ts
|
||||||
|
twoFactor: false // TYLKO gdy projekt naprawdę nie może użyć 2FA (rzadkie)
|
||||||
|
```
|
||||||
|
Domyślnie 2FA jest WYMUSZONE. `false` to świadoma rezygnacja — unikaj.
|
||||||
|
|
||||||
|
### Jak działa dla użytkownika
|
||||||
|
|
||||||
|
1. Loguje się (email + hasło)
|
||||||
|
2. Przy pierwszym logowaniu: przekierowanie na Setup TOTP (QR + sekret)
|
||||||
|
3. Skanuje QR aplikacją (Google Authenticator, Authy, 1Password, Microsoft Auth)
|
||||||
|
4. Wpisuje kod → 2FA aktywne
|
||||||
|
5. Kolejne logowania: email + hasło + kod TOTP
|
||||||
|
|
||||||
|
### Reset 2FA (admin)
|
||||||
|
|
||||||
|
Admin może zresetować 2FA innego użytkownika (gdy zgubi telefon) — przez
|
||||||
|
`adminManageAccess` w konfiguracji @clocklimited. Patrz jego dokumentacja.
|
||||||
|
|
||||||
|
### Dlaczego @clocklimited, nie inne
|
||||||
|
|
||||||
|
Wybrany, bo wrapuje ACCESS CONTROL (TOTP przed dostępem do danych) + forceSetup
|
||||||
|
(wymuszenie dla wszystkich). Inne pluginy 2FA dla Payload gatują tylko nawigację
|
||||||
|
/admin — user z hasłem może omijać przez REST/GraphQL/Bearer. @clocklimited chroni
|
||||||
|
dostęp do danych, nie tylko UI.
|
||||||
+150
-121
@@ -19,14 +19,14 @@ admina i bez importMap się nie wyrenderują.
|
|||||||
|
|
||||||
```ts
|
```ts
|
||||||
ipalKit({
|
ipalKit({
|
||||||
seo: {
|
seo: {
|
||||||
collections: ['pages', 'posts'], // które kolekcje dostają meta
|
collections: ['pages', 'posts'], // które kolekcje dostają meta
|
||||||
// generateTitle: ({ doc }) => `${doc.title}`, // opcjonalne
|
// generateTitle: ({ doc }) => `${doc.title}`, // opcjonalne
|
||||||
// generateDescription: ({ doc }) => doc.excerpt ?? '',
|
// generateDescription: ({ doc }) => doc.excerpt ?? '',
|
||||||
// fields: [...], // extra pola w grupie SEO
|
// fields: [...], // extra pola w grupie SEO
|
||||||
// autoFill: { title: 'title', description: 'excerpt' }, // mapowanie auto-fill
|
// autoFill: { title: 'title', description: 'excerpt' }, // mapowanie auto-fill
|
||||||
// autoFill: false, // wyłącz auto-fill
|
// autoFill: false, // wyłącz auto-fill
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -89,16 +89,16 @@ import { createPageMetadata } from '@intecion/ipal-kit'
|
|||||||
import { i18nConfig } from '@/i18n.config'
|
import { i18nConfig } from '@/i18n.config'
|
||||||
|
|
||||||
const pageMetadata = createPageMetadata({
|
const pageMetadata = createPageMetadata({
|
||||||
config: i18nConfig,
|
config: i18nConfig,
|
||||||
baseUrl: process.env.NEXT_PUBLIC_SERVER_URL,
|
baseUrl: process.env.NEXT_PUBLIC_SERVER_URL,
|
||||||
// collection: 'pages', // domyślne
|
// collection: 'pages', // domyślne
|
||||||
// settingsSlug: 'site-settings', // domyślne
|
// settingsSlug: 'site-settings', // domyślne
|
||||||
// siteNameField: 'siteName', // domyślne
|
// siteNameField: 'siteName', // domyślne
|
||||||
})
|
})
|
||||||
|
|
||||||
export async function generateMetadata({ params }): Promise<Metadata> {
|
export async function generateMetadata({ params }): Promise<Metadata> {
|
||||||
const { locale, slug } = await params
|
const { locale, slug } = await params
|
||||||
return pageMetadata({ payload: await getPayload({ config }), locale, slug })
|
return pageMetadata({ payload: await getPayload({ config }), locale, slug })
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -121,43 +121,43 @@ global. Klient dostarcza resolvery.
|
|||||||
import { createMetadataGenerator } from '@intecion/ipal-kit'
|
import { createMetadataGenerator } from '@intecion/ipal-kit'
|
||||||
|
|
||||||
const generate = createMetadataGenerator({
|
const generate = createMetadataGenerator({
|
||||||
config: i18nConfig,
|
config: i18nConfig,
|
||||||
baseUrl: process.env.NEXT_PUBLIC_SERVER_URL,
|
baseUrl: process.env.NEXT_PUBLIC_SERVER_URL,
|
||||||
homeSlug: 'homepage',
|
homeSlug: 'homepage',
|
||||||
|
|
||||||
resolveDocument: async ({ payload, params, locale }) => {
|
resolveDocument: async ({ payload, params, locale }) => {
|
||||||
const slug = (params.slug as string[])?.join('/')
|
const slug = (params.slug as string[])?.join('/')
|
||||||
|
|
||||||
// meta MUSI przyjść w konkretnym locale (stringi), a slug jako mapa
|
// meta MUSI przyjść w konkretnym locale (stringi), a slug jako mapa
|
||||||
// locale→wartość (hreflang) — to dwa różne odczyty.
|
// locale→wartość (hreflang) — to dwa różne odczyty.
|
||||||
const found = await payload.find({
|
const found = await payload.find({
|
||||||
collection: 'posts',
|
collection: 'posts',
|
||||||
where: { slug: { equals: slug } },
|
where: { slug: { equals: slug } },
|
||||||
locale,
|
locale,
|
||||||
depth: 1,
|
depth: 1,
|
||||||
limit: 1,
|
limit: 1,
|
||||||
})
|
})
|
||||||
const doc = found.docs[0]
|
const doc = found.docs[0]
|
||||||
if (!doc) return null
|
if (!doc) return null
|
||||||
|
|
||||||
const allLocales = await payload.findByID({
|
const allLocales = await payload.findByID({
|
||||||
collection: 'posts',
|
collection: 'posts',
|
||||||
id: doc.id,
|
id: doc.id,
|
||||||
locale: 'all',
|
locale: 'all',
|
||||||
depth: 0,
|
depth: 0,
|
||||||
})
|
})
|
||||||
|
|
||||||
return { ...doc, slug: allLocales.slug }
|
return { ...doc, slug: allLocales.slug }
|
||||||
},
|
},
|
||||||
|
|
||||||
resolveSiteName: async ({ payload, locale }) =>
|
resolveSiteName: async ({ payload, locale }) =>
|
||||||
(await getSiteSettings(payload, { locale })).siteName ?? null,
|
(await getSiteSettings(payload, { locale })).siteName ?? null,
|
||||||
resolveImageUrl: async ({ doc }) => doc.meta?.image?.url ?? null,
|
resolveImageUrl: async ({ doc }) => doc.meta?.image?.url ?? null,
|
||||||
})
|
})
|
||||||
|
|
||||||
export async function generateMetadata({ params }) {
|
export async function generateMetadata({ params }) {
|
||||||
const { locale, slug } = await params
|
const { locale, slug } = await params
|
||||||
return generate({ payload: await getPayload({ config }), params: { slug }, locale })
|
return generate({ payload: await getPayload({ config }), params: { slug }, locale })
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -176,16 +176,16 @@ Gdy chcesz pełną kontrolę:
|
|||||||
import { buildMetadata, getLocalizedSlugs } from '@intecion/ipal-kit'
|
import { buildMetadata, getLocalizedSlugs } from '@intecion/ipal-kit'
|
||||||
|
|
||||||
return buildMetadata({
|
return buildMetadata({
|
||||||
meta: doc.meta, // z plugin-seo
|
meta: doc.meta, // z plugin-seo
|
||||||
siteName: settings.siteName,
|
siteName: settings.siteName,
|
||||||
imageUrl: '/og.png',
|
imageUrl: '/og.png',
|
||||||
locale: 'pl',
|
locale: 'pl',
|
||||||
slugs: getLocalizedSlugs({ slugField: docAllLocales.slug, config }),
|
slugs: getLocalizedSlugs({ slugField: docAllLocales.slug, config }),
|
||||||
config,
|
config,
|
||||||
baseUrl: 'https://example.com',
|
baseUrl: 'https://example.com',
|
||||||
separator: ' – ', // opcjonalne
|
separator: ' – ', // opcjonalne
|
||||||
order: 'site-first', // opcjonalne
|
order: 'site-first', // opcjonalne
|
||||||
homeSlug: 'homepage',
|
homeSlug: 'homepage',
|
||||||
})
|
})
|
||||||
// → { title, description, openGraph, alternates: { canonical, languages } }
|
// → { title, description, openGraph, alternates: { canonical, languages } }
|
||||||
```
|
```
|
||||||
@@ -232,10 +232,10 @@ nie rozjedzie się z tym, co strony serwują. Handlery są gotowe w
|
|||||||
```ts
|
```ts
|
||||||
// src/lib/content.ts
|
// src/lib/content.ts
|
||||||
export const { /* ... */, sitemap, robots } = createContentHelpers({
|
export const { /* ... */, sitemap, robots } = createContentHelpers({
|
||||||
config,
|
config,
|
||||||
content: contentConfig,
|
content: contentConfig,
|
||||||
i18n: i18nConfig, // wymagane dla sitemap (hreflang)
|
i18n: i18nConfig, // wymagane dla sitemap (hreflang)
|
||||||
baseUrl: process.env.NEXT_PUBLIC_SERVER_URL,
|
baseUrl: process.env.NEXT_PUBLIC_SERVER_URL,
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -278,7 +278,7 @@ Niskopoziomowo (własna trasa zamiast handlera z fabryki):
|
|||||||
import { buildSitemapEntries, buildRobots } from '@intecion/ipal-kit'
|
import { buildSitemapEntries, buildRobots } from '@intecion/ipal-kit'
|
||||||
|
|
||||||
const entries = await buildSitemapEntries({
|
const entries = await buildSitemapEntries({
|
||||||
payload, config: i18nConfig, baseUrl, content: contentConfig,
|
payload, config: i18nConfig, baseUrl, content: contentConfig,
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -321,9 +321,9 @@ import { buildIconsMetadata } from '@intecion/ipal-kit'
|
|||||||
import { getSettings } from '@/lib/payload'
|
import { getSettings } from '@/lib/payload'
|
||||||
|
|
||||||
export async function generateMetadata({ params }): Promise<Metadata> {
|
export async function generateMetadata({ params }): Promise<Metadata> {
|
||||||
const { locale } = await params
|
const { locale } = await params
|
||||||
const settings = await getSettings(locale)
|
const settings = await getSettings(locale)
|
||||||
return buildIconsMetadata(settings.favicon) // z pola favicon (panel)
|
return buildIconsMetadata(settings.favicon) // z pola favicon (panel)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -346,16 +346,16 @@ wynikach, logo w knowledge panel.
|
|||||||
import { buildOrganizationJsonLd } from '@intecion/ipal-kit'
|
import { buildOrganizationJsonLd } from '@intecion/ipal-kit'
|
||||||
|
|
||||||
const jsonLd = buildOrganizationJsonLd({
|
const jsonLd = buildOrganizationJsonLd({
|
||||||
name: settings.siteName,
|
name: settings.siteName,
|
||||||
url: process.env.NEXT_PUBLIC_SERVER_URL!,
|
url: process.env.NEXT_PUBLIC_SERVER_URL!,
|
||||||
logo: settings.logo,
|
logo: settings.logo,
|
||||||
sameAs: settings.socialLinks, // opcjonalne: profile społecznościowe
|
sameAs: settings.socialLinks, // opcjonalne: profile społecznościowe
|
||||||
})
|
})
|
||||||
|
|
||||||
// w JSX layoutu:
|
// w JSX layoutu:
|
||||||
<script
|
<script
|
||||||
type="application/ld+json"
|
type="application/ld+json"
|
||||||
dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }}
|
dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }}
|
||||||
/>
|
/>
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -403,42 +403,42 @@ import { i18nConfig } from '@/i18n.config'
|
|||||||
import type { SiteSetting } from '@/payload-types'
|
import type { SiteSetting } from '@/payload-types'
|
||||||
|
|
||||||
export default async function manifest(): Promise<MetadataRoute.Manifest> {
|
export default async function manifest(): Promise<MetadataRoute.Manifest> {
|
||||||
const payload = await getCachedPayload()
|
const payload = await getCachedPayload()
|
||||||
const settings = await getSiteSettings<SiteSetting>(payload, {
|
const settings = await getSiteSettings<SiteSetting>(payload, {
|
||||||
locale: i18nConfig.defaultLocale as never,
|
locale: i18nConfig.defaultLocale as never,
|
||||||
})
|
})
|
||||||
|
|
||||||
const siteName = settings?.siteName?.trim()
|
const siteName = settings?.siteName?.trim()
|
||||||
|
|
||||||
// Ikona z panelu (favicon → logo). Dla PNG podaj KONKRETNY rozmiar z media
|
// Ikona z panelu (favicon → logo). Dla PNG podaj KONKRETNY rozmiar z media
|
||||||
// (nie 'any' — 'any' jest tylko dla SVG). Bez ikony → pomiń pole icons.
|
// (nie 'any' — 'any' jest tylko dla SVG). Bez ikony → pomiń pole icons.
|
||||||
const icon = settings?.favicon ?? settings?.logo
|
const icon = settings?.favicon ?? settings?.logo
|
||||||
const iconEntry =
|
const iconEntry =
|
||||||
typeof icon === 'object' && icon?.url
|
typeof icon === 'object' && icon?.url
|
||||||
? (() => {
|
? (() => {
|
||||||
const isSvg = icon.mimeType === 'image/svg+xml' || icon.url.endsWith('.svg')
|
const isSvg = icon.mimeType === 'image/svg+xml' || icon.url.endsWith('.svg')
|
||||||
const size =
|
const size =
|
||||||
typeof icon.width === 'number' && typeof icon.height === 'number'
|
typeof icon.width === 'number' && typeof icon.height === 'number'
|
||||||
? `${Math.min(icon.width, icon.height)}x${Math.min(icon.width, icon.height)}`
|
? `${Math.min(icon.width, icon.height)}x${Math.min(icon.width, icon.height)}`
|
||||||
: '512x512'
|
: '512x512'
|
||||||
return {
|
return {
|
||||||
src: icon.url,
|
src: icon.url,
|
||||||
type: icon.mimeType ?? 'image/png',
|
type: icon.mimeType ?? 'image/png',
|
||||||
sizes: isSvg ? 'any' : size, // 'any' tylko dla SVG
|
sizes: isSvg ? 'any' : size, // 'any' tylko dla SVG
|
||||||
}
|
}
|
||||||
})()
|
})()
|
||||||
: undefined
|
: undefined
|
||||||
|
|
||||||
// Buduj TYLKO z tego, co jest. Brak pola → nie ma go w manifeście (zamiast
|
// Buduj TYLKO z tego, co jest. Brak pola → nie ma go w manifeście (zamiast
|
||||||
// zaszytego fallbacku). start_url z configu, nie zaszyte '/pl'.
|
// zaszytego fallbacku). start_url z configu, nie zaszyte '/pl'.
|
||||||
return {
|
return {
|
||||||
...(siteName ? { name: siteName, short_name: siteName } : {}),
|
...(siteName ? { name: siteName, short_name: siteName } : {}),
|
||||||
start_url: `/${i18nConfig.defaultLocale}`,
|
start_url: `/${i18nConfig.defaultLocale}`,
|
||||||
display: 'standalone',
|
display: 'standalone',
|
||||||
...(iconEntry ? { icons: [iconEntry] } : {}),
|
...(iconEntry ? { icons: [iconEntry] } : {}),
|
||||||
// theme_color / background_color / description — TYLKO jeśli dodasz pola w
|
// theme_color / background_color / description — TYLKO jeśli dodasz pola w
|
||||||
// panelu i je odczytasz. NIE zaszywaj '#0e1e24' ani opisu klienta.
|
// panelu i je odczytasz. NIE zaszywaj '#0e1e24' ani opisu klienta.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -522,16 +522,16 @@ zanim strona wygeneruje metadane. To pcha metadata do body. NIE deklaruj `<head>
|
|||||||
```tsx
|
```tsx
|
||||||
// ŹLE — jawny <head> zamyka head za wcześnie
|
// ŹLE — jawny <head> zamyka head za wcześnie
|
||||||
<html lang={locale}>
|
<html lang={locale}>
|
||||||
<head><MediaPreconnect /></head>
|
<head><MediaPreconnect /></head>
|
||||||
<body>{children}</body>
|
<body>{children}</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
// DOBRZE — MediaPreconnect w body, React 19 hoistuje link do head
|
// DOBRZE — MediaPreconnect w body, React 19 hoistuje link do head
|
||||||
<html lang={locale}>
|
<html lang={locale}>
|
||||||
<body>
|
<body>
|
||||||
<MediaPreconnect />
|
<MediaPreconnect />
|
||||||
{children}
|
{children}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -546,8 +546,8 @@ z jakiegoś powodu nie może być ISR):
|
|||||||
```ts
|
```ts
|
||||||
// next.config.ts
|
// next.config.ts
|
||||||
const nextConfig: NextConfig = {
|
const nextConfig: NextConfig = {
|
||||||
htmlLimitedBots:
|
htmlLimitedBots:
|
||||||
/Googlebot|Google-InspectionTool|Storebot-Google|Bingbot|Yandex|DuckDuckBot|Baiduspider|Screaming Frog|AhrefsBot|SemrushBot/i,
|
/Googlebot|Google-InspectionTool|Storebot-Google|Bingbot|Yandex|DuckDuckBot|Baiduspider|Screaming Frog|AhrefsBot|SemrushBot/i,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -652,10 +652,10 @@ searchbox (pole wyszukiwania pod wynikiem marki). RAZ w root layout:
|
|||||||
```tsx
|
```tsx
|
||||||
import { buildWebSiteJsonLd } from '@intecion/ipal-kit'
|
import { buildWebSiteJsonLd } from '@intecion/ipal-kit'
|
||||||
const jsonLd = buildWebSiteJsonLd({
|
const jsonLd = buildWebSiteJsonLd({
|
||||||
name: settings.siteName,
|
name: settings.siteName,
|
||||||
url: baseUrl,
|
url: baseUrl,
|
||||||
// TYLKO jeśli masz działającą stronę wyszukiwania:
|
// TYLKO jeśli masz działającą stronę wyszukiwania:
|
||||||
search: { target: `${baseUrl}/szukaj?q={search_term_string}` },
|
search: { target: `${baseUrl}/szukaj?q={search_term_string}` },
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
Pomiń `search`, jeśli nie ma realnej wyszukiwarki — SearchAction wskazujący na
|
Pomiń `search`, jeśli nie ma realnej wyszukiwarki — SearchAction wskazujący na
|
||||||
@@ -666,9 +666,9 @@ Detailing) + Google rozumie hierarchię. PER STRONA, z pozycji strony:
|
|||||||
```tsx
|
```tsx
|
||||||
import { buildBreadcrumbJsonLd } from '@intecion/ipal-kit'
|
import { buildBreadcrumbJsonLd } from '@intecion/ipal-kit'
|
||||||
const jsonLd = buildBreadcrumbJsonLd([
|
const jsonLd = buildBreadcrumbJsonLd([
|
||||||
{ name: 'Strona główna', url: `${base}/pl` },
|
{ name: 'Strona główna', url: `${base}/pl` },
|
||||||
{ name: 'Usługi', url: `${base}/pl/uslugi` },
|
{ name: 'Usługi', url: `${base}/pl/uslugi` },
|
||||||
{ name: 'Detailing', url: `${base}/pl/uslugi/detailing` },
|
{ name: 'Detailing', url: `${base}/pl/uslugi/detailing` },
|
||||||
])
|
])
|
||||||
```
|
```
|
||||||
Okruszki buduj z RZECZYWISTEJ pozycji strony (resolveRoute / ścieżka URL), NIE z
|
Okruszki buduj z RZECZYWISTEJ pozycji strony (resolveRoute / ścieżka URL), NIE z
|
||||||
@@ -679,7 +679,7 @@ samych pozycji co menu w headerze:
|
|||||||
```tsx
|
```tsx
|
||||||
import { buildSiteNavigationJsonLd } from '@intecion/ipal-kit'
|
import { buildSiteNavigationJsonLd } from '@intecion/ipal-kit'
|
||||||
const jsonLd = buildSiteNavigationJsonLd(
|
const jsonLd = buildSiteNavigationJsonLd(
|
||||||
navItems.map(i => ({ name: i.label, url: `${base}${i.href}` }))
|
navItems.map(i => ({ name: i.label, url: `${base}${i.href}` }))
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
Dane z tego samego źródła co widoczne menu — nie osobna zaszyta lista.
|
Dane z tego samego źródła co widoczne menu — nie osobna zaszyta lista.
|
||||||
@@ -843,6 +843,31 @@ const jsonLd = buildArticleJsonLd({
|
|||||||
|
|
||||||
Dane z dokumentu/panelu. Google wymaga headline + dat dla rich result.
|
Dane z dokumentu/panelu. Google wymaga headline + dat dla rich result.
|
||||||
|
|
||||||
|
## Robots — rich results (max-snippet, image/video preview)
|
||||||
|
|
||||||
|
Strony indeksowane dostają automatycznie dyrektywy pozwalające Google na bogate
|
||||||
|
wyniki (buildMetadata generuje):
|
||||||
|
- `max-snippet: -1` — pełnej długości snippet (bez limitu)
|
||||||
|
- `max-image-preview: large` — duży podgląd obrazu w wynikach
|
||||||
|
- `max-video-preview: -1` — pełny podgląd wideo
|
||||||
|
|
||||||
|
Strony noindex (polityki) dostają `index: false, follow: true` — bez powyższych.
|
||||||
|
Zero konfiguracji — działa automatycznie dla każdej strony przez createPageMetadata.
|
||||||
|
|
||||||
|
## Open Graph — pełne pola (type, siteName, url, description)
|
||||||
|
|
||||||
|
buildMetadata generuje kompletny OG dla social share (Facebook, LinkedIn, Slack):
|
||||||
|
- `og:title` — tytuł strony
|
||||||
|
- `og:description` — meta.description → fallback siteDescription (dziedziczy)
|
||||||
|
- `og:image` — defaultShareImage / obraz strony
|
||||||
|
- `og:type` — 'website'
|
||||||
|
- `og:site_name` — siteName z panelu
|
||||||
|
- `og:url` — canonical strony
|
||||||
|
- `og:locale` — język strony
|
||||||
|
|
||||||
|
Wszystko z panelu, automatycznie. Opis OG dziedziczy z meta.description (albo
|
||||||
|
globalnego siteDescription gdy pusty) — patrz niżej.
|
||||||
|
|
||||||
## Fallback meta description (siteDescription)
|
## Fallback meta description (siteDescription)
|
||||||
|
|
||||||
Strona bez `meta.description` → plugin używa globalnego `siteDescription` z
|
Strona bez `meta.description` → plugin używa globalnego `siteDescription` z
|
||||||
@@ -929,7 +954,11 @@ const xml = buildSitemapXml(entries, { cssUrl: '/sitemap.css' })
|
|||||||
|
|
||||||
### Starter CSS (public/sitemap.css)
|
### Starter CSS (public/sitemap.css)
|
||||||
|
|
||||||
Skopiuj do `public/sitemap.css` w projekcie, dostosuj do designu. Selektory to
|
Plugin dostarcza gotowy plik — skopiuj do projektu:
|
||||||
|
```bash
|
||||||
|
cp node_modules/@intecion/ipal-kit/dist/modules/seo/assets/sitemap.css public/sitemap.css
|
||||||
|
```
|
||||||
|
Albo skopiuj poniższy starter i dostosuj do designu. Selektory to
|
||||||
bezpośrednio nazwy tagów XML:
|
bezpośrednio nazwy tagów XML:
|
||||||
|
|
||||||
```css
|
```css
|
||||||
|
|||||||
+2
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@intecion/ipal-kit",
|
"name": "@intecion/ipal-kit",
|
||||||
"version": "1.4.2",
|
"version": "1.6.0",
|
||||||
"description": "Intecion Payload Advanced Library — a Payload CMS 3 plugin: i18n, SEO, forms, consent, analytics, blog/archives.",
|
"description": "Intecion Payload Advanced Library — a Payload CMS 3 plugin: i18n, SEO, forms, consent, analytics, blog/archives.",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -67,6 +67,7 @@
|
|||||||
"slugify": "^1.6.6"
|
"slugify": "^1.6.6"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
|
"@clocklimited/payload-2fa": "^3.0.0",
|
||||||
"@payloadcms/next": "^3.88.0",
|
"@payloadcms/next": "^3.88.0",
|
||||||
"@payloadcms/plugin-form-builder": "^3.88.0",
|
"@payloadcms/plugin-form-builder": "^3.88.0",
|
||||||
"@payloadcms/plugin-seo": "^3.88.0",
|
"@payloadcms/plugin-seo": "^3.88.0",
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ export {
|
|||||||
useAccessibility,
|
useAccessibility,
|
||||||
} from '../modules/accessibility/client.js'
|
} from '../modules/accessibility/client.js'
|
||||||
export type { A11yClassNames, A11yState, A11yTexts } from '../modules/accessibility/client.js'
|
export type { A11yClassNames, A11yState, A11yTexts } from '../modules/accessibility/client.js'
|
||||||
|
|
||||||
export { Analytics } from '../modules/analytics/client.js'
|
export { Analytics } from '../modules/analytics/client.js'
|
||||||
/**
|
/**
|
||||||
* Entry point: ipal-kit/client
|
* Entry point: ipal-kit/client
|
||||||
@@ -23,6 +22,7 @@ export {
|
|||||||
useConsent,
|
useConsent,
|
||||||
useConsentContext,
|
useConsentContext,
|
||||||
} from '../modules/consent/client.js'
|
} from '../modules/consent/client.js'
|
||||||
|
|
||||||
export type { CookieBannerClassNames } from '../modules/consent/client.js'
|
export type { CookieBannerClassNames } from '../modules/consent/client.js'
|
||||||
// Pure i18n path helpers — no server/RSC deps, safe to import in client
|
// Pure i18n path helpers — no server/RSC deps, safe to import in client
|
||||||
// components (e.g. a LanguageSwitcher that computes locale URLs on the client).
|
// components (e.g. a LanguageSwitcher that computes locale URLs on the client).
|
||||||
@@ -33,6 +33,14 @@ export {
|
|||||||
switchLocalePath,
|
switchLocalePath,
|
||||||
} from '../modules/i18n/index.js'
|
} from '../modules/i18n/index.js'
|
||||||
export type { I18nConfig, LocalizedSlugs } from '../modules/i18n/index.js'
|
export type { I18nConfig, LocalizedSlugs } from '../modules/i18n/index.js'
|
||||||
|
export {
|
||||||
|
AlternateLinksProvider,
|
||||||
|
AlternateLinksUpdater,
|
||||||
|
LanguageSwitcher,
|
||||||
|
useAlternateLinks,
|
||||||
|
useSetAlternateLinks,
|
||||||
|
} from '../modules/i18n/index.js'
|
||||||
|
export type { AlternateLinks, LanguageSwitcherClassNames } from '../modules/i18n/index.js'
|
||||||
export { Turnstile } from '../modules/turnstile/client.js'
|
export { Turnstile } from '../modules/turnstile/client.js'
|
||||||
export { TurnstileProvider, useTurnstile } from '../modules/turnstile/client.js'
|
export { TurnstileProvider, useTurnstile } from '../modules/turnstile/client.js'
|
||||||
export type { TurnstileProps } from '../modules/turnstile/client.js'
|
export type { TurnstileProps } from '../modules/turnstile/client.js'
|
||||||
|
|||||||
@@ -7,3 +7,4 @@
|
|||||||
*/
|
*/
|
||||||
export { createLocaleMiddleware, DEFAULT_MIDDLEWARE_MATCHER } from '../modules/i18n/index.js'
|
export { createLocaleMiddleware, DEFAULT_MIDDLEWARE_MATCHER } from '../modules/i18n/index.js'
|
||||||
export type { LocaleMiddlewareResult } from '../modules/i18n/index.js'
|
export type { LocaleMiddlewareResult } from '../modules/i18n/index.js'
|
||||||
|
export { createProxy, DEFAULT_PROXY_MATCHER } from '../modules/i18n/index.js'
|
||||||
|
|||||||
@@ -12,4 +12,6 @@ export type {
|
|||||||
EnhanceProps,
|
EnhanceProps,
|
||||||
RenderBlocksProps,
|
RenderBlocksProps,
|
||||||
} from '../modules/blocks/index.js'
|
} from '../modules/blocks/index.js'
|
||||||
|
export { RenderRichText } from '../modules/richtext/index.js'
|
||||||
|
export type { RenderRichTextProps } from '../modules/richtext/index.js'
|
||||||
export { MediaPreconnect } from '../modules/storage/MediaPreconnect.js'
|
export { MediaPreconnect } from '../modules/storage/MediaPreconnect.js'
|
||||||
|
|||||||
+8
-2
@@ -90,6 +90,7 @@ export {
|
|||||||
} from './modules/i18n/index.js'
|
} from './modules/i18n/index.js'
|
||||||
export type { LocaleMiddlewareResult } from './modules/i18n/index.js'
|
export type { LocaleMiddlewareResult } from './modules/i18n/index.js'
|
||||||
export { createLocaleMiddleware, DEFAULT_MIDDLEWARE_MATCHER } 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 { normalizeFilename, normalizeFilenameHook } from './modules/media/index.js'
|
export { normalizeFilename, normalizeFilenameHook } from './modules/media/index.js'
|
||||||
export {
|
export {
|
||||||
getNotificationTexts,
|
getNotificationTexts,
|
||||||
@@ -109,9 +110,9 @@ export {
|
|||||||
} from './modules/payload/index.js'
|
} from './modules/payload/index.js'
|
||||||
export { buildSecurityHeaders } from './modules/security/index.js'
|
export { buildSecurityHeaders } from './modules/security/index.js'
|
||||||
export { buildCsp } from './modules/security/index.js'
|
export { buildCsp } from './modules/security/index.js'
|
||||||
|
|
||||||
export type { BuildCspArgs } from './modules/security/index.js'
|
export type { BuildCspArgs } from './modules/security/index.js'
|
||||||
export type { BuildSecurityHeadersArgs, SecurityHeader } 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 type { PageMetadata, SeoMeta, SeoOption } from './modules/seo/index.js'
|
||||||
export { buildHreflangAlternates, buildMetadata, composeTitle } 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 type { AutoFillMapping, RobotsRules, SitemapEntry } from './modules/seo/index.js'
|
||||||
@@ -123,6 +124,11 @@ export {
|
|||||||
createPageMetadata,
|
createPageMetadata,
|
||||||
injectAutoFillMeta,
|
injectAutoFillMeta,
|
||||||
} from './modules/seo/index.js'
|
} from './modules/seo/index.js'
|
||||||
|
export {
|
||||||
|
createLlmsTxtRoute,
|
||||||
|
createManifestHandler,
|
||||||
|
createSitemapRouteHandler,
|
||||||
|
} from './modules/seo/index.js'
|
||||||
export {
|
export {
|
||||||
buildIconsMetadata,
|
buildIconsMetadata,
|
||||||
buildOrganizationJsonLd,
|
buildOrganizationJsonLd,
|
||||||
@@ -140,8 +146,8 @@ export {
|
|||||||
buildServiceJsonLd,
|
buildServiceJsonLd,
|
||||||
} from './modules/seo/index.js'
|
} from './modules/seo/index.js'
|
||||||
export { buildArticleJsonLd } from './modules/seo/index.js'
|
export { buildArticleJsonLd } from './modules/seo/index.js'
|
||||||
export { buildSitemapXml } from './modules/seo/index.js'
|
|
||||||
export { buildLlmsTxt } from './modules/seo/index.js'
|
export { buildLlmsTxt } from './modules/seo/index.js'
|
||||||
|
export { buildSitemapXml } from './modules/seo/index.js'
|
||||||
export { buildSlugField, toSlug } from './modules/slug/index.js'
|
export { buildSlugField, toSlug } from './modules/slug/index.js'
|
||||||
export { buildR2Storage } from './modules/storage/index.js'
|
export { buildR2Storage } from './modules/storage/index.js'
|
||||||
export { ipalKit } from './plugin.js'
|
export { ipalKit } from './plugin.js'
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { useEffect, useState } from 'react'
|
|||||||
|
|
||||||
import { CONSENT_CATEGORIES, type ConsentCategory } from './categories.js'
|
import { CONSENT_CATEGORIES, type ConsentCategory } from './categories.js'
|
||||||
import { useConsentContext } from './ConsentContext.js'
|
import { useConsentContext } from './ConsentContext.js'
|
||||||
|
import { useIsMounted } from './useIsMounted.js'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optional class overrides — for when tokens aren't enough, e.g. turning the
|
* Optional class overrides — for when tokens aren't enough, e.g. turning the
|
||||||
@@ -53,6 +54,7 @@ const mutedText =
|
|||||||
'text-[var(--ipal-text-muted,#737373)] dark:text-[var(--ipal-text-muted-dark,#a3a3a3)]'
|
'text-[var(--ipal-text-muted,#737373)] dark:text-[var(--ipal-text-muted-dark,#a3a3a3)]'
|
||||||
|
|
||||||
export function CookieBanner({ classNames }: { classNames?: CookieBannerClassNames } = {}) {
|
export function CookieBanner({ classNames }: { classNames?: CookieBannerClassNames } = {}) {
|
||||||
|
const isMounted = useIsMounted()
|
||||||
const { acceptAll, decided, rejectAll, savePreferences, state, texts } = useConsentContext()
|
const { acceptAll, decided, rejectAll, savePreferences, state, texts } = useConsentContext()
|
||||||
const [showSettings, setShowSettings] = useState(false)
|
const [showSettings, setShowSettings] = useState(false)
|
||||||
const [choices, setChoices] = useState<Record<ConsentCategory, boolean>>(state)
|
const [choices, setChoices] = useState<Record<ConsentCategory, boolean>>(state)
|
||||||
@@ -61,6 +63,10 @@ export function CookieBanner({ classNames }: { classNames?: CookieBannerClassNam
|
|||||||
setChoices(state)
|
setChoices(state)
|
||||||
}, [state])
|
}, [state])
|
||||||
|
|
||||||
|
// Render nothing until mounted — avoids the React 19 hydration mismatch that
|
||||||
|
// projects used to work around with a setTimeout ConsentWrapper. No wrapper
|
||||||
|
// needed now.
|
||||||
|
if (!isMounted) {return null}
|
||||||
if (decided) {return null}
|
if (decided) {return null}
|
||||||
|
|
||||||
const toggle = (cat: ConsentCategory) => {
|
const toggle = (cat: ConsentCategory) => {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
import { Cookie } from 'lucide-react'
|
import { Cookie } from 'lucide-react'
|
||||||
|
|
||||||
import { useConsentContext } from './ConsentContext.js'
|
import { useConsentContext } from './ConsentContext.js'
|
||||||
|
import { useIsMounted } from './useIsMounted.js'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Floating "cookie settings" button — lets visitors reopen the consent panel
|
* Floating "cookie settings" button — lets visitors reopen the consent panel
|
||||||
@@ -14,8 +15,12 @@ import { useConsentContext } from './ConsentContext.js'
|
|||||||
* replace the styling outright.
|
* replace the styling outright.
|
||||||
*/
|
*/
|
||||||
export function CookieButton({ className }: { className?: string } = {}) {
|
export function CookieButton({ className }: { className?: string } = {}) {
|
||||||
|
const isMounted = useIsMounted()
|
||||||
const { decided, reopen } = useConsentContext()
|
const { decided, reopen } = useConsentContext()
|
||||||
|
|
||||||
|
// Render nothing until mounted — prevents hydration mismatch (no project
|
||||||
|
// ConsentWrapper workaround needed).
|
||||||
|
if (!isMounted) {return null}
|
||||||
if (!decided) {return null}
|
if (!decided) {return null}
|
||||||
|
|
||||||
const cls =
|
const cls =
|
||||||
|
|||||||
@@ -18,3 +18,4 @@ export {
|
|||||||
serializeConsent,
|
serializeConsent,
|
||||||
} from './storage.js'
|
} from './storage.js'
|
||||||
export type { ConsentTexts } from './texts.js'
|
export type { ConsentTexts } from './texts.js'
|
||||||
|
export { useIsMounted } from './useIsMounted.js'
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
'use client'
|
||||||
|
import { useEffect, useState } from 'react'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true only after the component has mounted on the client. Used to gate
|
||||||
|
* consent UI (CookieBanner, CookieButton) so it renders nothing during SSR /
|
||||||
|
* first paint — preventing the React 19 / Next hydration mismatch that projects
|
||||||
|
* were working around with their own setTimeout-based ConsentWrapper. Built into
|
||||||
|
* the components now, so no project wrapper is needed.
|
||||||
|
*/
|
||||||
|
export function useIsMounted(): boolean {
|
||||||
|
const [mounted, setMounted] = useState(false)
|
||||||
|
useEffect(() => {
|
||||||
|
setMounted(true)
|
||||||
|
}, [])
|
||||||
|
return mounted
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
'use client'
|
||||||
|
|
||||||
|
import { createContext, use, useCallback, useState } from 'react'
|
||||||
|
|
||||||
|
/** Map of locale code → absolute-or-relative URL for the current page. */
|
||||||
|
export type AlternateLinks = Record<string, string>
|
||||||
|
|
||||||
|
type AlternateLinksContextValue = {
|
||||||
|
links: AlternateLinks
|
||||||
|
setLinks: (links: AlternateLinks) => void
|
||||||
|
}
|
||||||
|
|
||||||
|
const AlternateLinksContext = createContext<AlternateLinksContextValue | null>(null)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Holds the current page's per-locale URLs so a LanguageSwitcher links to the
|
||||||
|
* CORRECT localized slug instead of naively swapping the locale prefix
|
||||||
|
* (/pl/uslugi → /en/uslugi, which 404s when the English slug is /en/services).
|
||||||
|
*
|
||||||
|
* Wrap the app once; each page reports its own alternates via
|
||||||
|
* <AlternateLinksUpdater> (or useSetAlternateLinks). The switcher reads them
|
||||||
|
* with useAlternateLinks().
|
||||||
|
*
|
||||||
|
* // layout.tsx
|
||||||
|
* import { AlternateLinksProvider } from '@intecion/ipal-kit/client'
|
||||||
|
* <AlternateLinksProvider>{children}</AlternateLinksProvider>
|
||||||
|
*/
|
||||||
|
export function AlternateLinksProvider({ children }: { children: React.ReactNode }) {
|
||||||
|
const [links, setLinksState] = useState<AlternateLinks>({})
|
||||||
|
const setLinks = useCallback((next: AlternateLinks) => setLinksState(next), [])
|
||||||
|
return (
|
||||||
|
<AlternateLinksContext value={{ links, setLinks }}>
|
||||||
|
{children}
|
||||||
|
</AlternateLinksContext>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Read the current page's per-locale URLs (for a language switcher). */
|
||||||
|
export function useAlternateLinks(): AlternateLinks {
|
||||||
|
const ctx = use(AlternateLinksContext)
|
||||||
|
return ctx?.links ?? {}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Setter for the alternates (used by AlternateLinksUpdater). */
|
||||||
|
export function useSetAlternateLinks(): (links: AlternateLinks) => void {
|
||||||
|
const ctx = use(AlternateLinksContext)
|
||||||
|
return ctx?.setLinks ?? (() => {})
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
'use client'
|
||||||
|
|
||||||
|
import { useEffect } from 'react'
|
||||||
|
|
||||||
|
import { type AlternateLinks, useSetAlternateLinks } from './AlternateLinksContext.js'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reports the current page's per-locale URLs into AlternateLinksProvider. Render
|
||||||
|
* it on each page (a Server Component computes the links via resolveRoute /
|
||||||
|
* getLocalizedSlugs and passes them down). The switcher then links correctly.
|
||||||
|
*
|
||||||
|
* // page.tsx (RSC) — compute alternates from the resolved route
|
||||||
|
* import { AlternateLinksUpdater } from '@intecion/ipal-kit/client'
|
||||||
|
* const alternates = { pl: '/pl/uslugi/karne', en: '/en/services/criminal' }
|
||||||
|
* return <>
|
||||||
|
* <AlternateLinksUpdater links={alternates} />
|
||||||
|
* {/* page content *\/}
|
||||||
|
* </>
|
||||||
|
*
|
||||||
|
* Renders nothing; it only pushes the links into context on mount/change.
|
||||||
|
*/
|
||||||
|
export function AlternateLinksUpdater({ links }: { links: AlternateLinks }) {
|
||||||
|
const setLinks = useSetAlternateLinks()
|
||||||
|
const key = JSON.stringify(links)
|
||||||
|
useEffect(() => {
|
||||||
|
setLinks(links)
|
||||||
|
// key covers link changes; setLinks is stable (useCallback).
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [key, setLinks])
|
||||||
|
return null
|
||||||
|
}
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
'use client'
|
||||||
|
|
||||||
|
import { useState } from 'react'
|
||||||
|
|
||||||
|
import type { I18nConfig } from './types.js'
|
||||||
|
|
||||||
|
import { useAlternateLinks } from './AlternateLinksContext.js'
|
||||||
|
|
||||||
|
export type LanguageSwitcherClassNames = {
|
||||||
|
item?: string
|
||||||
|
itemActive?: string
|
||||||
|
menu?: string
|
||||||
|
root?: string
|
||||||
|
trigger?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
type LocaleItem = { code: string; label: string }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Language switcher that links to the CORRECT localized URL per language,
|
||||||
|
* reading the current page's alternates from AlternateLinksProvider — so it
|
||||||
|
* never 404s on differing slugs (/pl/uslugi vs /en/services).
|
||||||
|
*
|
||||||
|
* Unstyled by default (classNames, like CookieBanner) — NOT a fixed
|
||||||
|
* light/dark variant, so it matches any project's design. A locale with no
|
||||||
|
* known alternate falls back to its root (/{code}).
|
||||||
|
*
|
||||||
|
* // layout/header (client), inside AlternateLinksProvider
|
||||||
|
* <LanguageSwitcher
|
||||||
|
* config={i18nConfig}
|
||||||
|
* currentLocale={locale}
|
||||||
|
* classNames={{ root: '...', trigger: '...', menu: '...', item: '...' }}
|
||||||
|
* />
|
||||||
|
*/
|
||||||
|
export function LanguageSwitcher({
|
||||||
|
classNames,
|
||||||
|
config,
|
||||||
|
currentLocale,
|
||||||
|
renderLabel,
|
||||||
|
}: {
|
||||||
|
classNames?: LanguageSwitcherClassNames
|
||||||
|
config: I18nConfig
|
||||||
|
currentLocale: string
|
||||||
|
/** Custom label per locale (e.g. flag + code). Defaults to the config label. */
|
||||||
|
renderLabel?: (locale: LocaleItem) => React.ReactNode
|
||||||
|
}) {
|
||||||
|
const alternates = useAlternateLinks()
|
||||||
|
const [open, setOpen] = useState(false)
|
||||||
|
const cn = classNames ?? {}
|
||||||
|
|
||||||
|
const locales: LocaleItem[] = config.locales.map((l) => ({
|
||||||
|
code: l.code,
|
||||||
|
label: l.label ?? l.code.toUpperCase(),
|
||||||
|
}))
|
||||||
|
|
||||||
|
const hrefFor = (code: string): string => alternates[code] ?? `/${code}`
|
||||||
|
|
||||||
|
const current = locales.find((l) => l.code === currentLocale)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={cn.root} data-ipal-langswitcher>
|
||||||
|
<button
|
||||||
|
aria-expanded={open}
|
||||||
|
aria-haspopup="true"
|
||||||
|
className={cn.trigger}
|
||||||
|
onClick={() => setOpen((o) => !o)}
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
{current ? (renderLabel ? renderLabel(current) : current.label) : currentLocale}
|
||||||
|
</button>
|
||||||
|
{open && (
|
||||||
|
<ul className={cn.menu} role="menu">
|
||||||
|
{locales.map((loc) => {
|
||||||
|
const active = loc.code === currentLocale
|
||||||
|
return (
|
||||||
|
<li key={loc.code} role="none">
|
||||||
|
<a
|
||||||
|
aria-current={active ? 'true' : undefined}
|
||||||
|
className={`${cn.item ?? ''} ${active ? (cn.itemActive ?? '') : ''}`.trim()}
|
||||||
|
href={hrefFor(loc.code)}
|
||||||
|
hrefLang={loc.code}
|
||||||
|
onClick={() => setOpen(false)}
|
||||||
|
role="menuitem"
|
||||||
|
>
|
||||||
|
{renderLabel ? renderLabel(loc) : loc.label}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</ul>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
import type { I18nConfig } from './types.js'
|
||||||
|
|
||||||
|
import { isValidLocale } from './helpers.js'
|
||||||
|
import { createLocaleMiddleware, DEFAULT_MIDDLEWARE_MATCHER } from './localeMiddleware.js'
|
||||||
|
|
||||||
|
/** Re-exported so the project's proxy.ts config uses the plugin's matcher. */
|
||||||
|
export const DEFAULT_PROXY_MATCHER = DEFAULT_MIDDLEWARE_MATCHER
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Minimal structural types — the plugin does NOT import next/server (it's a peer
|
||||||
|
* dep not present at the plugin's own build time, which would cause TS2307).
|
||||||
|
* Next's real NextRequest / NextResponse satisfy these shapes at the call site.
|
||||||
|
*/
|
||||||
|
type ProxyRequest = {
|
||||||
|
cookies: { get: (name: string) => { value: string } | undefined }
|
||||||
|
// Matches localeMiddleware's MiddlewareRequest shape; a real NextRequest
|
||||||
|
// satisfies all of this structurally.
|
||||||
|
headers: Headers
|
||||||
|
nextUrl: { clone: () => URL; pathname: string; search: string }
|
||||||
|
url: string
|
||||||
|
}
|
||||||
|
|
||||||
|
type ProxyResponse = {
|
||||||
|
cookies: { set: (name: string, value: string, opts?: Record<string, unknown>) => void }
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Next's NextResponse constructor, injected by the project (which has next/server
|
||||||
|
* in scope). The plugin stays free of a next/server import.
|
||||||
|
*/
|
||||||
|
type NextResponseLike = {
|
||||||
|
next: (init?: { request?: { headers: Headers } }) => ProxyResponse
|
||||||
|
redirect: (url: string | URL) => ProxyResponse
|
||||||
|
}
|
||||||
|
|
||||||
|
type CreateProxyOptions = {
|
||||||
|
consentCategory?: 'functional' | 'necessary'
|
||||||
|
consentCookieName?: string
|
||||||
|
cookieName?: string
|
||||||
|
/** Expose x-locale / x-pathname request headers to RSC. Default true. */
|
||||||
|
exposeHeaders?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ready-made Next 16 proxy (the former middleware). Wraps the plugin's locale
|
||||||
|
* logic AND the per-project boilerplate (NextResponse, x-locale / x-pathname
|
||||||
|
* headers, locale cookie, redirect). The project's proxy.ts becomes a few lines.
|
||||||
|
*
|
||||||
|
* `NextResponse` is INJECTED (the plugin never imports next/server — it's a peer
|
||||||
|
* dep absent at the plugin's build time). The project passes it:
|
||||||
|
*
|
||||||
|
* // proxy.ts (Next 16 — NOT middleware.ts)
|
||||||
|
* import { NextResponse } from 'next/server'
|
||||||
|
* import { createProxy, DEFAULT_PROXY_MATCHER } from '@intecion/ipal-kit'
|
||||||
|
* import { i18nConfig } from '@/i18n.config'
|
||||||
|
* export const proxy = createProxy(i18nConfig, { NextResponse })
|
||||||
|
* export const config = { matcher: DEFAULT_PROXY_MATCHER }
|
||||||
|
*/
|
||||||
|
export function createProxy(
|
||||||
|
config: I18nConfig,
|
||||||
|
deps: { NextResponse: NextResponseLike } & CreateProxyOptions,
|
||||||
|
): (request: ProxyRequest) => ProxyResponse {
|
||||||
|
const { exposeHeaders = true, NextResponse, ...mwOptions } = deps
|
||||||
|
const run = createLocaleMiddleware({ config, ...mwOptions })
|
||||||
|
|
||||||
|
return (request: ProxyRequest): ProxyResponse => {
|
||||||
|
const result = run(request)
|
||||||
|
|
||||||
|
const requestHeaders = new Headers(request.headers)
|
||||||
|
if (exposeHeaders) {
|
||||||
|
const { pathname } = request.nextUrl
|
||||||
|
const seg = pathname.split('/').filter(Boolean)[0] ?? ''
|
||||||
|
const locale = isValidLocale(seg, config) ? seg : config.defaultLocale
|
||||||
|
requestHeaders.set('x-locale', locale)
|
||||||
|
requestHeaders.set('x-pathname', pathname)
|
||||||
|
}
|
||||||
|
|
||||||
|
const response =
|
||||||
|
result.type === 'redirect'
|
||||||
|
? NextResponse.redirect(new URL(result.location, request.url))
|
||||||
|
: NextResponse.next({ request: { headers: requestHeaders } })
|
||||||
|
|
||||||
|
if (result.cookie) {
|
||||||
|
response.cookies.set(result.cookie.name, result.cookie.value, {
|
||||||
|
path: '/',
|
||||||
|
sameSite: 'lax',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return response
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,15 @@
|
|||||||
|
export {
|
||||||
|
AlternateLinksProvider,
|
||||||
|
useAlternateLinks,
|
||||||
|
useSetAlternateLinks,
|
||||||
|
} from './AlternateLinksContext.js'
|
||||||
|
export type { AlternateLinks } from './AlternateLinksContext.js'
|
||||||
|
export { AlternateLinksUpdater } from './AlternateLinksUpdater.js'
|
||||||
|
export { createProxy, DEFAULT_PROXY_MATCHER } from './createProxy.js'
|
||||||
export { getLocalizedSlugs } from './getLocalizedSlugs.js'
|
export { getLocalizedSlugs } from './getLocalizedSlugs.js'
|
||||||
export { getDefaultLocale, getLocaleCodes, getLocaleDefinition, isValidLocale } from './helpers.js'
|
export { getDefaultLocale, getLocaleCodes, getLocaleDefinition, isValidLocale } from './helpers.js'
|
||||||
|
export { LanguageSwitcher } from './LanguageSwitcher.js'
|
||||||
|
export type { LanguageSwitcherClassNames } from './LanguageSwitcher.js'
|
||||||
export { createLocaleMiddleware, DEFAULT_MIDDLEWARE_MATCHER } from './localeMiddleware.js'
|
export { createLocaleMiddleware, DEFAULT_MIDDLEWARE_MATCHER } from './localeMiddleware.js'
|
||||||
export type { LocaleMiddlewareResult } from './localeMiddleware.js'
|
export type { LocaleMiddlewareResult } from './localeMiddleware.js'
|
||||||
export { buildLocalizationConfig } from './localizationConfig.js'
|
export { buildLocalizationConfig } from './localizationConfig.js'
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
import type { SerializedEditorState } from '@payloadcms/richtext-lexical/lexical'
|
||||||
|
import type { JSXConvertersFunction } from '@payloadcms/richtext-lexical/react'
|
||||||
|
|
||||||
|
import { RichText as PayloadRichText } from '@payloadcms/richtext-lexical/react'
|
||||||
|
|
||||||
|
export type RenderRichTextProps = {
|
||||||
|
/** Wrapper class (e.g. Tailwind prose classes). */
|
||||||
|
className?: string
|
||||||
|
/**
|
||||||
|
* Override the JSX for specific node types to apply the project's own
|
||||||
|
* styling. Receives Payload's defaultConverters; return the merged map.
|
||||||
|
* This is where a project puts its Tailwind classes per node (headings,
|
||||||
|
* paragraphs, links, …) — the design stays in the project, the parsing in
|
||||||
|
* the plugin's wrapper over Payload's official converter.
|
||||||
|
*/
|
||||||
|
converters?: JSXConvertersFunction
|
||||||
|
/**
|
||||||
|
* Lexical editor state from a Payload richText field. Already localized —
|
||||||
|
* Payload returns the current locale's value, so NO per-locale key handling
|
||||||
|
* is needed here (unlike hand-rolled renderers that hardcode `.pl`).
|
||||||
|
*/
|
||||||
|
data: null | SerializedEditorState | undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renders a Payload Lexical richText field to React — a thin wrapper over
|
||||||
|
* Payload's OFFICIAL converter (@payloadcms/richtext-lexical/react).
|
||||||
|
*
|
||||||
|
* Why not hand-roll it: parsing Lexical by hand (node.type switch, node.format
|
||||||
|
* bit flags) duplicates what Payload already does, misses node types, drifts
|
||||||
|
* on Lexical updates, and tempts shortcuts like dangerouslySetInnerHTML (XSS)
|
||||||
|
* or a hardcoded `.pl` locale. The official converter handles every node,
|
||||||
|
* stays in sync, and is safe. This is the RenderBlocks of rich text: the
|
||||||
|
* plugin owns the engine, the project owns the look via `converters`.
|
||||||
|
*
|
||||||
|
* // project — a Server Component
|
||||||
|
* import { RenderRichText } from '@intecion/ipal-kit/rsc'
|
||||||
|
* <RenderRichText data={page.content} className="prose" />
|
||||||
|
*
|
||||||
|
* // with project styling per node:
|
||||||
|
* const converters: JSXConvertersFunction = ({ defaultConverters }) => ({
|
||||||
|
* ...defaultConverters,
|
||||||
|
* heading: ({ node, nodesToJSX }) => {
|
||||||
|
* const children = nodesToJSX({ nodes: node.children })
|
||||||
|
* const cls = { h2: 'text-2xl font-semibold mt-10', h3: 'text-xl mt-7' }[node.tag] ?? ''
|
||||||
|
* const Tag = node.tag as 'h1'|'h2'|'h3'|'h4'
|
||||||
|
* return <Tag className={cls}>{children}</Tag>
|
||||||
|
* },
|
||||||
|
* })
|
||||||
|
* <RenderRichText data={page.content} converters={converters} />
|
||||||
|
*/
|
||||||
|
export function RenderRichText({ className, converters, data }: RenderRichTextProps) {
|
||||||
|
if (!data) {return null}
|
||||||
|
return <PayloadRichText className={className} converters={converters} data={data} />
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
export { RenderRichText } from './RenderRichText.js'
|
||||||
|
export type { RenderRichTextProps } from './RenderRichText.js'
|
||||||
@@ -0,0 +1,154 @@
|
|||||||
|
/*
|
||||||
|
* Universal, minimalist & elegant stylesheet for XML Sitemap.
|
||||||
|
* Neutral palette with automatic dark and light mode support.
|
||||||
|
* W3C standard: type="text/css" on XML (zero browser deprecation warnings).
|
||||||
|
*
|
||||||
|
* Ships with @intecion/ipal-kit. Copy to /public/sitemap.css and adjust freely.
|
||||||
|
*/
|
||||||
|
|
||||||
|
:root {
|
||||||
|
--bg: #fafafa;
|
||||||
|
--card: #ffffff;
|
||||||
|
--border: #e5e7eb;
|
||||||
|
--border-hover: #d1d5db;
|
||||||
|
--text-main: #111827;
|
||||||
|
--text-secondary: #4b5563;
|
||||||
|
--text-muted: #9ca3af;
|
||||||
|
--url-color: #1e293b;
|
||||||
|
--badge-bg: #f3f4f6;
|
||||||
|
--badge-border: #e5e7eb;
|
||||||
|
--badge-text: #4b5563;
|
||||||
|
--accent: #027bd0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
:root {
|
||||||
|
--bg: #090a0f;
|
||||||
|
--card: #12131a;
|
||||||
|
--border: #1e202e;
|
||||||
|
--border-hover: #2e3247;
|
||||||
|
--text-main: #f9fafb;
|
||||||
|
--text-secondary: #9ca3af;
|
||||||
|
--text-muted: #6b7280;
|
||||||
|
--url-color: #f3f4f6;
|
||||||
|
--badge-bg: #1a1c26;
|
||||||
|
--badge-border: #282b3d;
|
||||||
|
--badge-text: #9ca3af;
|
||||||
|
--accent: #027bd0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
urlset {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
|
||||||
|
background-color: var(--bg);
|
||||||
|
color: var(--text-main);
|
||||||
|
padding: 3rem 1.5rem;
|
||||||
|
max-width: 1040px;
|
||||||
|
margin: 0 auto;
|
||||||
|
min-height: 100vh;
|
||||||
|
box-sizing: border-box;
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Minimalist header */
|
||||||
|
urlset::before {
|
||||||
|
content: "XML Sitemap";
|
||||||
|
display: block;
|
||||||
|
order: -2;
|
||||||
|
font-size: 1.35rem;
|
||||||
|
font-weight: 600;
|
||||||
|
letter-spacing: -0.02em;
|
||||||
|
color: var(--text-main);
|
||||||
|
padding-bottom: 0.4rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brand note under the header — crafted by Intecion Group */
|
||||||
|
urlset::after {
|
||||||
|
content: "Intecion.com, Technology — engineered for modern digital experiences.";
|
||||||
|
display: block;
|
||||||
|
order: -1;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
color: var(--text-muted);
|
||||||
|
padding-bottom: 1.25rem;
|
||||||
|
margin-bottom: 1.5rem;
|
||||||
|
border-bottom: 1px solid var(--border);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* URL card */
|
||||||
|
url {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
order: 0;
|
||||||
|
background-color: var(--card);
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 1rem 1.25rem;
|
||||||
|
margin-bottom: 0.65rem;
|
||||||
|
box-sizing: border-box;
|
||||||
|
transition: border-color 0.15s ease, box-shadow 0.15s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
url:hover {
|
||||||
|
border-color: var(--border-hover);
|
||||||
|
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* URL address */
|
||||||
|
loc {
|
||||||
|
display: block;
|
||||||
|
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
|
||||||
|
font-size: 0.875rem;
|
||||||
|
font-weight: 500;
|
||||||
|
color: var(--url-color);
|
||||||
|
word-break: break-all;
|
||||||
|
line-height: 1.45;
|
||||||
|
margin-bottom: 0.45rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Metadata row */
|
||||||
|
lastmod,
|
||||||
|
changefreq,
|
||||||
|
priority {
|
||||||
|
display: inline-block;
|
||||||
|
font-size: 0.775rem;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
margin-right: 1.25rem;
|
||||||
|
margin-top: 0.15rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
lastmod::before {
|
||||||
|
content: "Updated: ";
|
||||||
|
color: var(--text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
changefreq::before {
|
||||||
|
content: "Frequency: ";
|
||||||
|
color: var(--text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
priority::before {
|
||||||
|
content: "Priority: ";
|
||||||
|
color: var(--text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Alternate language pills */
|
||||||
|
link {
|
||||||
|
display: inline-block;
|
||||||
|
font-size: 0.7rem;
|
||||||
|
font-weight: 600;
|
||||||
|
background-color: var(--badge-bg);
|
||||||
|
border: 1px solid var(--badge-border);
|
||||||
|
color: var(--badge-text);
|
||||||
|
padding: 0.1rem 0.45rem;
|
||||||
|
border-radius: 4px;
|
||||||
|
margin-right: 0.3rem;
|
||||||
|
margin-top: 0.35rem;
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
|
||||||
|
link::before {
|
||||||
|
content: attr(hreflang);
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
import type { BasePayload } from 'payload'
|
||||||
|
|
||||||
|
import type { I18nConfig } from '../i18n/index.js'
|
||||||
|
|
||||||
|
import { getDefaultLocale } from '../i18n/index.js'
|
||||||
|
|
||||||
|
type MediaLike =
|
||||||
|
| { height?: null | number; mimeType?: null | string; url?: null | string; width?: null | number }
|
||||||
|
| null
|
||||||
|
| undefined
|
||||||
|
|
||||||
|
type ManifestIcon = { sizes?: string; src: string; type?: string }
|
||||||
|
|
||||||
|
type Manifest = {
|
||||||
|
background_color?: string
|
||||||
|
display: 'standalone'
|
||||||
|
icons: ManifestIcon[]
|
||||||
|
name?: string
|
||||||
|
short_name?: string
|
||||||
|
start_url: string
|
||||||
|
theme_color?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
type SettingsShape = {
|
||||||
|
backgroundColor?: null | string
|
||||||
|
favicon?: MediaLike
|
||||||
|
logo?: MediaLike
|
||||||
|
siteName?: null | string
|
||||||
|
themeColor?: null | string
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds a Next Web App Manifest from SiteSettings — replaces the ~50 lines of
|
||||||
|
* icon/mimeType parsing copied into every project's manifest.ts. Values come
|
||||||
|
* from the panel; missing fields are omitted (no hardcoded client data).
|
||||||
|
*
|
||||||
|
* // app/manifest.ts
|
||||||
|
* import { createManifestHandler } from '@intecion/ipal-kit'
|
||||||
|
* import { getCachedPayload } from '@/lib/content'
|
||||||
|
* import { i18nConfig } from '@/i18n.config'
|
||||||
|
* export default createManifestHandler({ getCachedPayload, config: i18nConfig })
|
||||||
|
*/
|
||||||
|
export function createManifestHandler(opts: {
|
||||||
|
config: I18nConfig
|
||||||
|
getCachedPayload: () => Promise<BasePayload>
|
||||||
|
settingsSlug?: string
|
||||||
|
}): () => Promise<Manifest> {
|
||||||
|
return async () => {
|
||||||
|
const defaultLocale = getDefaultLocale(opts.config)
|
||||||
|
const payload = await opts.getCachedPayload()
|
||||||
|
const settings = (await payload
|
||||||
|
.findGlobal({
|
||||||
|
slug: (opts.settingsSlug ?? 'site-settings') as never,
|
||||||
|
depth: 1,
|
||||||
|
locale: defaultLocale as never,
|
||||||
|
})
|
||||||
|
.catch(() => null)) as null | SettingsShape
|
||||||
|
|
||||||
|
const start_url = `/${defaultLocale}`
|
||||||
|
if (!settings) {
|
||||||
|
return { display: 'standalone', icons: [], start_url }
|
||||||
|
}
|
||||||
|
|
||||||
|
const iconSource = settings.favicon ?? settings.logo
|
||||||
|
const icons: ManifestIcon[] = []
|
||||||
|
if (iconSource?.url) {
|
||||||
|
const type =
|
||||||
|
iconSource.mimeType ?? (iconSource.url.endsWith('.svg') ? 'image/svg+xml' : undefined)
|
||||||
|
const isSvg = type === 'image/svg+xml'
|
||||||
|
const size =
|
||||||
|
iconSource.width && iconSource.height
|
||||||
|
? `${iconSource.width}x${iconSource.height}`
|
||||||
|
: undefined
|
||||||
|
icons.push({
|
||||||
|
src: iconSource.url,
|
||||||
|
...(isSvg ? { sizes: 'any' } : size ? { sizes: size } : {}),
|
||||||
|
...(type ? { type } : {}),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
...(settings.siteName ? { name: settings.siteName, short_name: settings.siteName } : {}),
|
||||||
|
display: 'standalone',
|
||||||
|
start_url,
|
||||||
|
...(settings.backgroundColor ? { background_color: settings.backgroundColor } : {}),
|
||||||
|
...(settings.themeColor ? { theme_color: settings.themeColor } : {}),
|
||||||
|
icons,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,12 +20,27 @@ export type PageMetadata = {
|
|||||||
description?: string
|
description?: string
|
||||||
images?: { url: string }[]
|
images?: { url: string }[]
|
||||||
locale?: string
|
locale?: string
|
||||||
|
/** Site/brand name for the OG card. */
|
||||||
|
siteName?: string
|
||||||
title: string
|
title: string
|
||||||
|
/** 'website' | 'article' etc. Defaults to 'website'. */
|
||||||
|
type?: string
|
||||||
|
/** Canonical URL of this page. */
|
||||||
|
url?: string
|
||||||
}
|
}
|
||||||
/** robots directives — set to noindex/follow for legal/thin/search pages. */
|
/**
|
||||||
|
* robots directives. Indexed pages get generous snippet/preview limits by
|
||||||
|
* default (Google shows richer results); noindex pages get index:false.
|
||||||
|
*/
|
||||||
robots?: {
|
robots?: {
|
||||||
follow: boolean
|
follow: boolean
|
||||||
index: boolean
|
index: boolean
|
||||||
|
/** 'none' | 'standard' | 'large' — image preview size in results. */
|
||||||
|
'max-image-preview'?: 'large' | 'none' | 'standard'
|
||||||
|
/** Max text snippet length; -1 = no limit. Next maps to max-snippet. */
|
||||||
|
'max-snippet'?: number
|
||||||
|
/** Max video preview seconds; -1 = no limit. */
|
||||||
|
'max-video-preview'?: number
|
||||||
}
|
}
|
||||||
title: string
|
title: string
|
||||||
}
|
}
|
||||||
@@ -140,10 +155,24 @@ export function buildMetadata({
|
|||||||
title,
|
title,
|
||||||
...(description && { description }),
|
...(description && { description }),
|
||||||
...(images && { images }),
|
...(images && { images }),
|
||||||
|
type: 'website',
|
||||||
locale,
|
locale,
|
||||||
|
...(siteName ? { siteName } : {}),
|
||||||
|
...(canonical ? { url: canonical } : {}),
|
||||||
},
|
},
|
||||||
// noindex → tell search engines to exclude the page but still follow links
|
// robots: noindex pages are excluded (follow keeps link authority). Indexed
|
||||||
// (authority flows through). For legal/thin/search-result pages.
|
// pages get generous snippet/preview limits so Google can show rich results
|
||||||
...(meta?.noindex ? { robots: { follow: true, index: false } } : {}),
|
// (long snippets, large image previews, full video previews).
|
||||||
|
...(meta?.noindex
|
||||||
|
? { robots: { follow: true, index: false } }
|
||||||
|
: {
|
||||||
|
robots: {
|
||||||
|
follow: true,
|
||||||
|
index: true,
|
||||||
|
'max-image-preview': 'large' as const,
|
||||||
|
'max-snippet': -1,
|
||||||
|
'max-video-preview': -1,
|
||||||
|
},
|
||||||
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ export { buildFaqJsonLd } from './buildFaqJsonLd.js'
|
|||||||
export { buildIconsMetadata } from './buildIconsMetadata.js'
|
export { buildIconsMetadata } from './buildIconsMetadata.js'
|
||||||
export { buildLlmsTxt } from './buildLlmsTxt.js'
|
export { buildLlmsTxt } from './buildLlmsTxt.js'
|
||||||
export { buildLocalBusinessJsonLd } from './buildLocalBusinessJsonLd.js'
|
export { buildLocalBusinessJsonLd } from './buildLocalBusinessJsonLd.js'
|
||||||
|
export { createManifestHandler } from './buildManifest.js'
|
||||||
export { buildMetadata } from './buildMetadata.js'
|
export { buildMetadata } from './buildMetadata.js'
|
||||||
export type { PageMetadata } from './buildMetadata.js'
|
export type { PageMetadata } from './buildMetadata.js'
|
||||||
export { buildOrganizationJsonLd } from './buildOrganizationJsonLd.js'
|
export { buildOrganizationJsonLd } from './buildOrganizationJsonLd.js'
|
||||||
@@ -26,6 +27,7 @@ export { injectAutoFillMeta } from './injectAutoFillMeta.js'
|
|||||||
export { injectSeoTabs } from './injectSeoTabs.js'
|
export { injectSeoTabs } from './injectSeoTabs.js'
|
||||||
export { readSiteMetaConfig } from './readSiteMetaConfig.js'
|
export { readSiteMetaConfig } from './readSiteMetaConfig.js'
|
||||||
export type { SiteMetaConfig } from './readSiteMetaConfig.js'
|
export type { SiteMetaConfig } from './readSiteMetaConfig.js'
|
||||||
|
export { createLlmsTxtRoute, createSitemapRouteHandler } from './routeHandlers.js'
|
||||||
export { buildSeoPlugin } from './seoPluginConfig.js'
|
export { buildSeoPlugin } from './seoPluginConfig.js'
|
||||||
export { slugsAcrossLocales } from './slugsAcrossLocales.js'
|
export { slugsAcrossLocales } from './slugsAcrossLocales.js'
|
||||||
export type { SeoMeta, SeoOption } from './types.js'
|
export type { SeoMeta, SeoOption } from './types.js'
|
||||||
|
|||||||
@@ -0,0 +1,89 @@
|
|||||||
|
import type { BasePayload } from 'payload'
|
||||||
|
|
||||||
|
import type { I18nConfig } from '../i18n/index.js'
|
||||||
|
import type { SitemapEntry } from './buildSitemapEntries.js'
|
||||||
|
|
||||||
|
import { buildLlmsTxt } from './buildLlmsTxt.js'
|
||||||
|
import { buildSitemapXml } from './buildSitemapXml.js'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ready-made Next route handler for /llms.txt. Replaces the ~60-line try/catch
|
||||||
|
* every project was copying. buildLlmsTxt already handles collections without
|
||||||
|
* drafts, so no workaround is needed here.
|
||||||
|
*
|
||||||
|
* // app/llms.txt/route.ts
|
||||||
|
* import { createLlmsTxtRoute } from '@intecion/ipal-kit'
|
||||||
|
* import { getCachedPayload } from '@/lib/content'
|
||||||
|
* import { i18nConfig } from '@/i18n.config'
|
||||||
|
* export const dynamic = 'force-dynamic'
|
||||||
|
* export const GET = createLlmsTxtRoute({ getCachedPayload, config: i18nConfig,
|
||||||
|
* baseUrl: process.env.NEXT_PUBLIC_SERVER_URL! })
|
||||||
|
*/
|
||||||
|
export function createLlmsTxtRoute(opts: {
|
||||||
|
baseUrl: string
|
||||||
|
config: I18nConfig
|
||||||
|
getCachedPayload: () => Promise<BasePayload>
|
||||||
|
pagesSlug?: string
|
||||||
|
settingsSlug?: string
|
||||||
|
}): () => Promise<Response> {
|
||||||
|
return async () => {
|
||||||
|
try {
|
||||||
|
const payload = await opts.getCachedPayload()
|
||||||
|
const body = await buildLlmsTxt({
|
||||||
|
baseUrl: opts.baseUrl,
|
||||||
|
config: opts.config,
|
||||||
|
pagesSlug: opts.pagesSlug,
|
||||||
|
payload,
|
||||||
|
settingsSlug: opts.settingsSlug,
|
||||||
|
})
|
||||||
|
return new Response(body, {
|
||||||
|
headers: { 'Content-Type': 'text/plain; charset=utf-8' },
|
||||||
|
})
|
||||||
|
} catch (err) {
|
||||||
|
// DB unreachable at build (container) — return a minimal valid file so the
|
||||||
|
// route doesn't 500; it fills in at runtime. No per-project try/catch.
|
||||||
|
console.warn('[ipal] createLlmsTxtRoute: could not build llms.txt:', err)
|
||||||
|
return new Response('# llms.txt\n', {
|
||||||
|
headers: { 'Content-Type': 'text/plain; charset=utf-8' },
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ready-made Next route handler for /sitemap.xml with the CSS stylesheet.
|
||||||
|
* Replaces the hand-written route in every project. Pass the project's `sitemap`
|
||||||
|
* helper (from createContentHelpers) and optionally a cssUrl.
|
||||||
|
*
|
||||||
|
* // app/sitemap.xml/route.ts
|
||||||
|
* import { createSitemapRouteHandler } from '@intecion/ipal-kit'
|
||||||
|
* import { sitemap } from '@/lib/content'
|
||||||
|
* export const dynamic = 'force-dynamic'
|
||||||
|
* export const GET = createSitemapRouteHandler(sitemap, { cssUrl: '/sitemap.css' })
|
||||||
|
*
|
||||||
|
* Remember: if you use this, DON'T also keep app/sitemap.ts (two sitemaps
|
||||||
|
* confuse crawlers).
|
||||||
|
*/
|
||||||
|
export function createSitemapRouteHandler(
|
||||||
|
sitemap: () => Promise<SitemapEntry[]>,
|
||||||
|
opts: { cssUrl?: string } = {},
|
||||||
|
): () => Promise<Response> {
|
||||||
|
return async () => {
|
||||||
|
try {
|
||||||
|
const entries = await sitemap()
|
||||||
|
const xml = buildSitemapXml(entries, { cssUrl: opts.cssUrl })
|
||||||
|
return new Response(xml, {
|
||||||
|
headers: { 'Content-Type': 'application/xml; charset=utf-8' },
|
||||||
|
})
|
||||||
|
} catch (err) {
|
||||||
|
console.warn('[ipal] createSitemapRouteHandler: could not build sitemap:', err)
|
||||||
|
// Valid empty urlset so the route doesn't 500 during a DB-less build.
|
||||||
|
const empty =
|
||||||
|
'<?xml version="1.0" encoding="UTF-8"?>\n' +
|
||||||
|
'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"></urlset>'
|
||||||
|
return new Response(empty, {
|
||||||
|
headers: { 'Content-Type': 'application/xml; charset=utf-8' },
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+56
-7
@@ -49,6 +49,61 @@ export const ipalKit = (options: IpalOptions): Plugin => {
|
|||||||
|
|
||||||
let config = { ...incomingConfig }
|
let config = { ...incomingConfig }
|
||||||
|
|
||||||
|
// --- custom admin route (e.g. '/its' instead of '/admin') ---
|
||||||
|
// Sets config.routes.admin; the project must move its app/(payload)/<route>/
|
||||||
|
// folder to match (plugin can't create files in the project's app/).
|
||||||
|
if (options.adminRoute) {
|
||||||
|
config.routes = { ...(config.routes ?? {}), admin: options.adminRoute }
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- enforced 2FA (TOTP) via @clocklimited/payload-2fa ---
|
||||||
|
// Enforced by default (forceSetup) unless twoFactor is explicitly false. The
|
||||||
|
// plugin is a PEER dependency imported dynamically — ipal-kit doesn't bundle
|
||||||
|
// it, so projects that opt out (twoFactor: false) needn't install it, and the
|
||||||
|
// import never runs under generate:importmap when 2FA is off. Wrapping access
|
||||||
|
// control (not just admin UI) means TOTP gates data access — no API bypass.
|
||||||
|
if (options.twoFactor !== false) {
|
||||||
|
const tf = options.twoFactor
|
||||||
|
if (!tf?.issuer) {
|
||||||
|
throw new Error(
|
||||||
|
'[ipal] twoFactor.issuer is required (name shown in the authenticator ' +
|
||||||
|
'app). Pass twoFactor: { issuer: "Your Site" }, or twoFactor: false to ' +
|
||||||
|
'opt out (discouraged).',
|
||||||
|
)
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
// Dynamic specifier via a variable so TS doesn't try to resolve this
|
||||||
|
// optional peer dependency at build time (it isn't in the plugin's own
|
||||||
|
// node_modules). Avoids TS2307 without @ts-expect-error; the module
|
||||||
|
// exists at runtime in projects that installed it.
|
||||||
|
// @ts-ignore
|
||||||
|
const mod = (await import('@clocklimited/payload-2fa')) as {
|
||||||
|
payloadTotp?: (opts: Record<string, unknown>) => Plugin
|
||||||
|
totpPlugin?: (opts: Record<string, unknown>) => Plugin
|
||||||
|
}
|
||||||
|
// The package exports `payloadTotp`; older/other builds may use
|
||||||
|
// `totpPlugin`. Accept either so a rename doesn't break us.
|
||||||
|
const totp = mod.payloadTotp ?? mod.totpPlugin
|
||||||
|
if (typeof totp !== 'function') {
|
||||||
|
throw new Error(
|
||||||
|
'expected export payloadTotp (or totpPlugin) to be a function — ' +
|
||||||
|
'check the installed @clocklimited/payload-2fa version',
|
||||||
|
)
|
||||||
|
}
|
||||||
|
config = await totp({
|
||||||
|
collection: tf.collectionSlug ?? 'users',
|
||||||
|
forceSetup: true, // ENFORCED — every user must set up TOTP; no opt-out
|
||||||
|
totp: { issuer: tf.issuer },
|
||||||
|
})(config)
|
||||||
|
} catch (err) {
|
||||||
|
throw new Error(
|
||||||
|
'[ipal] 2FA is enforced but @clocklimited/payload-2fa is not installed. ' +
|
||||||
|
'Run: pnpm add @clocklimited/payload-2fa — or set twoFactor: false to ' +
|
||||||
|
`opt out (discouraged). Original error: ${String(err)}`,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// --- i18n ---
|
// --- i18n ---
|
||||||
config.localization = buildLocalizationConfig(options.i18n)
|
config.localization = buildLocalizationConfig(options.i18n)
|
||||||
|
|
||||||
@@ -99,18 +154,12 @@ export const ipalKit = (options: IpalOptions): Plugin => {
|
|||||||
buildNotifications(),
|
buildNotifications(),
|
||||||
]
|
]
|
||||||
|
|
||||||
// --- endpoints ---
|
|
||||||
// Test-email endpoint (admin-only): POST /api/ipal/test-email sends a probe
|
|
||||||
// message through the currently selected transport, so the panel's "send
|
|
||||||
// test" button can confirm delivery without leaving the admin UI.
|
|
||||||
config.endpoints = [...(config.endpoints ?? []), testEmailEndpoint]
|
config.endpoints = [...(config.endpoints ?? []), testEmailEndpoint]
|
||||||
|
|
||||||
// --- hooks: onInit ---
|
// --- hooks: onInit ---
|
||||||
const incomingOnInit = config.onInit
|
const incomingOnInit = config.onInit
|
||||||
config.onInit = async (payload) => {
|
config.onInit = async (payload) => {
|
||||||
if (incomingOnInit) {
|
if (incomingOnInit) {await incomingOnInit(payload)}
|
||||||
await incomingOnInit(payload)
|
|
||||||
}
|
|
||||||
payload.logger.info('[ipal] Plugin initialized.')
|
payload.logger.info('[ipal] Plugin initialized.')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,18 @@ export type IpalOptions = {
|
|||||||
*/
|
*/
|
||||||
access?: AccessOption
|
access?: AccessOption
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom admin panel route, e.g. '/its' instead of the default '/admin'.
|
||||||
|
* The plugin sets config.routes.admin. IMPORTANT: this alone isn't enough —
|
||||||
|
* the project must ALSO move its panel folder to match:
|
||||||
|
* app/(payload)/its/[[...segments]]/page.tsx (and the not-found). The plugin
|
||||||
|
* can't create files in the project's app/. See docs/security.md.
|
||||||
|
*
|
||||||
|
* This is obscurity, not security: it hides the panel from dumb bots scanning
|
||||||
|
* /admin, but real protection is strong auth + 2FA + rate limiting.
|
||||||
|
*/
|
||||||
|
adminRoute?: string
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Collections whose entries live under an archive page — blog posts, case
|
* Collections whose entries live under an archive page — blog posts, case
|
||||||
* studies, anything with a listing. Adds an "archive page" assignment per
|
* studies, anything with a listing. Adds an "archive page" assignment per
|
||||||
@@ -55,4 +67,23 @@ export type IpalOptions = {
|
|||||||
|
|
||||||
/** Additional fields injected into SiteSettings global */
|
/** Additional fields injected into SiteSettings global */
|
||||||
siteSettingsFields?: Field[]
|
siteSettingsFields?: Field[]
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Two-factor authentication (TOTP), ENFORCED for every user. Wires
|
||||||
|
* @clocklimited/payload-2fa with forceSetup — no per-project opt-out. Every
|
||||||
|
* user must configure an authenticator app after login; TOTP is checked before
|
||||||
|
* data access (not just the admin UI). Requires the peer dep installed and an
|
||||||
|
* issuer name (shown in the authenticator app).
|
||||||
|
*
|
||||||
|
* Pass `false` ONLY for a project that genuinely can't use 2FA (rare, discouraged)
|
||||||
|
* — default is enforced. See docs/security.md.
|
||||||
|
*/
|
||||||
|
twoFactor?:
|
||||||
|
| {
|
||||||
|
/** Auth collection slug. Defaults to 'users'. */
|
||||||
|
collectionSlug?: string
|
||||||
|
/** Name shown in the authenticator app (e.g. company/site name). */
|
||||||
|
issuer: string
|
||||||
|
}
|
||||||
|
| false
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user