From a24777b915525712cbbd45cebe938e7704c1799a Mon Sep 17 00:00:00 2001 From: rasm-its Date: Tue, 13 Oct 2026 23:41:05 +0200 Subject: [PATCH] Sitemap.css is now builded in plugin --- dist/index.d.ts | 109 +++---- dist/index.js | 68 ++--- dist/index.js.map | 2 +- .../frontend/createContentHelpers.d.ts | 15 +- dist/modules/frontend/createContentHelpers.js | 27 +- .../frontend/createContentHelpers.js.map | 2 +- dist/modules/seo/index.d.ts | 63 ++-- dist/modules/seo/index.js | 49 ++-- dist/modules/seo/index.js.map | 2 +- dist/modules/seo/routeHandlers.d.ts | 49 ++-- dist/modules/seo/routeHandlers.js | 49 +++- dist/modules/seo/routeHandlers.js.map | 2 +- dist/modules/seo/sitemapStyle.d.ts | 21 ++ dist/modules/seo/sitemapStyle.js | 70 +++++ dist/modules/seo/sitemapStyle.js.map | 1 + docs/agent/AGENT.md | 5 +- docs/agent/skills/ipal-audit/scripts/audit.sh | 9 + docs/agent/skills/ipal-setup/SKILL.md | 2 +- docs/dev/PROGRAMISTA.md | 10 +- docs/dev/vibe.md | 2 +- docs/seo.md | 69 ++--- src/index.ts | 275 +++++++++--------- src/modules/frontend/createContentHelpers.ts | 40 ++- src/modules/seo/index.ts | 63 ++-- src/modules/seo/routeHandlers.ts | 77 +++-- src/modules/seo/sitemapStyle.ts | 90 ++++++ 26 files changed, 740 insertions(+), 431 deletions(-) create mode 100644 dist/modules/seo/sitemapStyle.d.ts create mode 100644 dist/modules/seo/sitemapStyle.js create mode 100644 dist/modules/seo/sitemapStyle.js.map create mode 100644 src/modules/seo/sitemapStyle.ts diff --git a/dist/index.d.ts b/dist/index.d.ts index a59dc59..5a361c0 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -1,73 +1,74 @@ -export { ipalKit } from './plugin.js'; -export type { IpalOptions } from './types.js'; -export type { I18nConfig, LocaleDefinition, LocalizedSlugs } 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 { PagesOption, SystemPageRole } from './modules/pages/index.js'; -export { ALL_SYSTEM_PAGE_ROLES, getSystemPagePath } from './modules/pages/index.js'; export type { AccessOption, Role } from './modules/access/index.js'; export { adminOnly, adminOnlyField, adminOrEditor, adminOrEditorField, adminOrSelf, authenticated, hasMinimumRole, isAdmin, isEditor, requireRole, requireRoleField, ROLE_HIERARCHY, } from './modules/access/index.js'; -export type { GlobalQueryOptions } from './modules/payload/index.js'; -export { getGlobal, getSiteSettings, getSiteIntegrations, SITE_SETTINGS_SLUG, SITE_INTEGRATIONS_SLUG, } from './modules/payload/index.js'; -export type { SeoOption, SeoMeta, PageMetadata } from './modules/seo/index.js'; -export { composeTitle, buildHreflangAlternates, buildMetadata, readSiteMetaConfig, slugsAcrossLocales, } from './modules/seo/index.js'; -export type { SiteMetaConfig } from './modules/seo/index.js'; -export type { ContentOption, ContentCollectionOption, ResolvedRoute } from './modules/content/index.js'; -export { createContentHelpers } from './modules/frontend/index.js'; -export { resolveRoute, resolveRedirect, resolveNotFoundPage, blocksToMarkdown, createMarkdownRenderer, markdownResponse, prefersMarkdown, markdownHref, MARKDOWN_PREFIX, searchContent, createSearchRoute, archiveFieldName, getArchiveEntries, buildArchivePath, buildEntryPath, parsePageParam, } from './modules/content/index.js'; +export { A11Y_COOKIE, A11Y_DEFAULT, a11yAttributes, parseA11y, serializeA11y } from './modules/accessibility/index.js'; +export type { A11yState } from './modules/accessibility/index.js'; +export { rowLabel } from './modules/admin-ui/index.js'; +export type { RowLabelProps } from './modules/admin-ui/index.js'; +export type { AnalyticsConfig } from './modules/analytics/index.js'; +export { getAnalyticsConfig } from './modules/analytics/index.js'; +export { ACCEPT_ALL_CONSENT, CONSENT_CATEGORIES, CONSENT_COOKIE, CONSENT_MAX_AGE, CONSENT_VERSION, DEFAULT_CONSENT, getConsentTexts, parseConsent, REJECT_ALL_CONSENT, serializeConsent, setDefaultConsent, updateConsent, } from './modules/consent/index.js'; +export type { ConsentCategory, ConsentState, ConsentTexts } from './modules/consent/index.js'; +export type { ContentCollectionOption, ContentOption, ResolvedRoute } from './modules/content/index.js'; +export { archiveFieldName, blocksToMarkdown, buildArchivePath, buildEntryPath, createMarkdownRenderer, createSearchRoute, getArchiveEntries, MARKDOWN_PREFIX, markdownHref, markdownResponse, parsePageParam, prefersMarkdown, resolveNotFoundPage, resolveRedirect, resolveRoute, searchContent, } from './modules/content/index.js'; export type { ArchiveEntries } from './modules/content/index.js'; export type { SearchResult } from './modules/content/index.js'; -export { lexicalToMarkdown } from './modules/richtext/index.js'; -export type { AutoFillMapping, SitemapEntry, RobotsRules, RobotsOptions } from './modules/seo/index.js'; -export { buildAutoFillMetaHook, injectAutoFillMeta, createMetadataGenerator, createPageMetadata, buildSitemapEntries, buildRobots, AI_ASSISTANT_BOTS, AI_TRAINING_BOTS, } from './modules/seo/index.js'; +export { graphAdapter } from './modules/email/graphAdapter.js'; +export type { GraphAdapterArgs } from './modules/email/graphAdapter.js'; +export { mailAdapter } from './modules/email/mailAdapter.js'; +export type { MailAdapterArgs } from './modules/email/mailAdapter.js'; +export { panelSmtpAdapter } from './modules/email/panelSmtpAdapter.js'; +export type { PanelSmtpAdapterArgs } from './modules/email/panelSmtpAdapter.js'; +export { assertEnv, ipalEnvRules } from './modules/env/index.js'; +export type { AssertEnvOptions, EnvKind, EnvRule, IpalEnvFeatures } from './modules/env/index.js'; +export { buildFormAnalyticsFields } from './modules/forms/formAnalyticsFields.js'; +export { buildFormsPlugin } from './modules/forms/formsPluginConfig.js'; +export { HONEYPOT_FIELD, honeypotInputProps, isHoneypotTripped } from './modules/forms/honeypot.js'; +export type { FormsCollectionOverrides, FormsFieldsOverride, FormsOption, } from './modules/forms/types.js'; +export type { FormErrors, FormSubmitAction, Validator } from './modules/forms/useForm.js'; +export { buildValidator, checked, custom, email, isEmail, maxLength, minLength, pattern, required, } from './modules/forms/validators.js'; +export type { Rule } from './modules/forms/validators.js'; +export { createContentHelpers } from './modules/frontend/index.js'; +export { createHealthRoute } from './modules/health/index.js'; +export { buildCrossLocaleFieldSync, buildPreventDeleteSystemPage, buildRevalidateHook, buildValidateUniqueRole, setPublishedAtHook, trackSlugHistoryHook } from './modules/hooks/index.js'; +export type { I18nConfig, LocaleDefinition, LocalizedSlugs } 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 { createLocaleMiddleware, DEFAULT_MIDDLEWARE_MATCHER, } from './modules/i18n/index.js'; export { createProxy, DEFAULT_PROXY_MATCHER } from './modules/i18n/index.js'; export { resolveLocalized } from './modules/i18n/index.js'; -export { CONSENT_CATEGORIES, DEFAULT_CONSENT, ACCEPT_ALL_CONSENT, REJECT_ALL_CONSENT, CONSENT_COOKIE, CONSENT_VERSION, CONSENT_MAX_AGE, serializeConsent, parseConsent, setDefaultConsent, updateConsent, getConsentTexts, } from './modules/consent/index.js'; -export type { ConsentCategory, ConsentState, ConsentTexts } from './modules/consent/index.js'; -export { panelSmtpAdapter } from './modules/email/panelSmtpAdapter.js'; -export { graphAdapter } from './modules/email/graphAdapter.js'; -export { mailAdapter } from './modules/email/mailAdapter.js'; -export type { MailAdapterArgs } from './modules/email/mailAdapter.js'; -export type { GraphAdapterArgs } from './modules/email/graphAdapter.js'; -export type { PanelSmtpAdapterArgs } from './modules/email/panelSmtpAdapter.js'; -export { buildFormsPlugin } from './modules/forms/formsPluginConfig.js'; -export type { FormsOption, FormsCollectionOverrides, FormsFieldsOverride, } from './modules/forms/types.js'; -export { buildValidator, isEmail, required, email, minLength, maxLength, checked, pattern, custom, } from './modules/forms/validators.js'; -export type { Rule } from './modules/forms/validators.js'; -export type { FormErrors, FormSubmitAction, Validator } from './modules/forms/useForm.js'; -export { HONEYPOT_FIELD, honeypotInputProps, isHoneypotTripped } from './modules/forms/honeypot.js'; -export { buildFormAnalyticsFields } from './modules/forms/formAnalyticsFields.js'; -export { createHealthRoute } from './modules/health/index.js'; +export { buildLinkField, buildLinksField, resolveLinkHref } from './modules/links/index.js'; +export type { BuildLinkFieldOptions, BuildLinksFieldOptions, LinkAppearance, LinkValue, ResolveLinkHrefOptions, } from './modules/links/index.js'; export { createMcpRoute } from './modules/mcp/index.js'; -export { assertEnv, ipalEnvRules } from './modules/env/index.js'; -export type { EnvRule, EnvKind, AssertEnvOptions, IpalEnvFeatures } from './modules/env/index.js'; -export type { AnalyticsConfig } from './modules/analytics/index.js'; -export { getAnalyticsConfig } from './modules/analytics/index.js'; -export { buildSlugField, toSlug } from './modules/slug/index.js'; -export { createLlmsTxtRoute, createSitemapRouteHandler, createManifestHandler } from './modules/seo/index.js'; -export { getNotificationTexts, resolveFormMessage, NOTIFICATION_FALLBACK } from './modules/notifications/index.js'; +export { buildOptimizeUploadField, buildOptimizeUploadHook, normalizeFilename, normalizeFilenameHook } from './modules/media/index.js'; +export type { OptimizeUploadOptions } from './modules/media/index.js'; +export { getNotificationTexts, NOTIFICATION_FALLBACK, resolveFormMessage } from './modules/notifications/index.js'; +export type { FormNotificationTexts, NotificationTexts } from './modules/notifications/index.js'; +export type { PagesOption, SystemPageRole } from './modules/pages/index.js'; +export { ALL_SYSTEM_PAGE_ROLES, getSystemPagePath } from './modules/pages/index.js'; +export type { GlobalQueryOptions } from './modules/payload/index.js'; +export { getGlobal, getSiteIntegrations, getSiteSettings, SITE_INTEGRATIONS_SLUG, SITE_SETTINGS_SLUG, } from './modules/payload/index.js'; +export { lexicalToMarkdown } from './modules/richtext/index.js'; export { buildSecurityHeaders } from './modules/security/index.js'; export { buildCsp } from './modules/security/index.js'; export type { BuildCspArgs } from './modules/security/index.js'; +export type { BuildSecurityHeadersArgs, SecurityHeader } from './modules/security/index.js'; +export type { PageMetadata, SeoMeta, SeoOption } from './modules/seo/index.js'; +export { buildHreflangAlternates, buildMetadata, composeTitle, readSiteMetaConfig, slugsAcrossLocales, } from './modules/seo/index.js'; +export type { SiteMetaConfig } from './modules/seo/index.js'; +export type { AutoFillMapping, RobotsOptions, RobotsRules, SitemapEntry } from './modules/seo/index.js'; +export { AI_ASSISTANT_BOTS, AI_TRAINING_BOTS, buildAutoFillMetaHook, buildRobots, buildSitemapEntries, createMetadataGenerator, createPageMetadata, injectAutoFillMeta, } from './modules/seo/index.js'; +export { createLlmsTxtRoute, createManifestHandler, createSitemapRouteHandler } from './modules/seo/index.js'; export { buildIconsMetadata, buildOrganizationJsonLd, validateFaviconField } from './modules/seo/index.js'; export { buildNoindexField } from './modules/seo/index.js'; -export { rowLabel } from './modules/admin-ui/index.js'; -export type { RowLabelProps } from './modules/admin-ui/index.js'; -export { buildLinkField, buildLinksField, resolveLinkHref } from './modules/links/index.js'; -export type { LinkAppearance, LinkValue, BuildLinkFieldOptions, BuildLinksFieldOptions, ResolveLinkHrefOptions, } from './modules/links/index.js'; export { buildSpeakableJsonLd } from './modules/seo/index.js'; export { buildSummaryField } from './modules/seo/index.js'; -export { buildWebSiteJsonLd, buildBreadcrumbJsonLd, buildSiteNavigationJsonLd } from './modules/seo/index.js'; -export { buildLocalBusinessJsonLd, buildFaqJsonLd, buildServiceJsonLd } from './modules/seo/index.js'; +export { buildBreadcrumbJsonLd, buildSiteNavigationJsonLd, buildWebSiteJsonLd } from './modules/seo/index.js'; +export { buildFaqJsonLd, buildLocalBusinessJsonLd, buildServiceJsonLd } from './modules/seo/index.js'; export { buildArticleJsonLd } from './modules/seo/index.js'; export { buildLlmsTxt } from './modules/seo/index.js'; -export { buildSitemapXml } from './modules/seo/index.js'; +export { buildSitemapCss, buildSitemapXml, DEFAULT_SITEMAP_CREDIT, SITEMAP_STYLE_PARAM } from './modules/seo/index.js'; +export type { SitemapRouteOptions, SitemapStyleOptions } from './modules/seo/index.js'; +export { buildSlugField, toSlug } from './modules/slug/index.js'; export { buildR2Storage } from './modules/storage/index.js'; -export { normalizeFilename, normalizeFilenameHook, buildOptimizeUploadHook, buildOptimizeUploadField } from './modules/media/index.js'; -export type { OptimizeUploadOptions } from './modules/media/index.js'; -export { buildRevalidateHook, setPublishedAtHook, buildPreventDeleteSystemPage, buildValidateUniqueRole, trackSlugHistoryHook, buildCrossLocaleFieldSync } from './modules/hooks/index.js'; -export { A11Y_COOKIE, A11Y_DEFAULT, a11yAttributes, parseA11y, serializeA11y } from './modules/accessibility/index.js'; -export type { A11yState } from './modules/accessibility/index.js'; -export type { SecurityHeader, BuildSecurityHeadersArgs } from './modules/security/index.js'; -export type { NotificationTexts, FormNotificationTexts } from './modules/notifications/index.js'; +export { ipalKit } from './plugin.js'; +export type { IpalOptions } from './types.js'; diff --git a/dist/index.js b/dist/index.js index 3f16d2e..1307e11 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,59 +1,59 @@ -export { ipalKit } from './plugin.js'; -export { buildLocalizedPath, getDefaultLocale, getLocaleCodes, getLocaleDefinition, getLocalizedSlugs, isValidLocale, LOCALE_COOKIE_NAME, matchAcceptLanguage, negotiateLocale, switchLocalePath } from './modules/i18n/index.js'; -export { ALL_SYSTEM_PAGE_ROLES, getSystemPagePath } from './modules/pages/index.js'; export { adminOnly, adminOnlyField, adminOrEditor, adminOrEditorField, adminOrSelf, authenticated, hasMinimumRole, isAdmin, isEditor, requireRole, requireRoleField, ROLE_HIERARCHY } from './modules/access/index.js'; -export { getGlobal, getSiteSettings, getSiteIntegrations, SITE_SETTINGS_SLUG, SITE_INTEGRATIONS_SLUG } from './modules/payload/index.js'; -export { composeTitle, buildHreflangAlternates, buildMetadata, readSiteMetaConfig, slugsAcrossLocales } from './modules/seo/index.js'; -export { createContentHelpers } from './modules/frontend/index.js'; -export { resolveRoute, resolveRedirect, resolveNotFoundPage, blocksToMarkdown, createMarkdownRenderer, markdownResponse, prefersMarkdown, markdownHref, MARKDOWN_PREFIX, searchContent, createSearchRoute, archiveFieldName, getArchiveEntries, buildArchivePath, buildEntryPath, parsePageParam } from './modules/content/index.js'; -// Lexical → Markdown (pure, no React) — for AI-readable output. -export { lexicalToMarkdown } from './modules/richtext/index.js'; -export { buildAutoFillMetaHook, injectAutoFillMeta, createMetadataGenerator, createPageMetadata, buildSitemapEntries, buildRobots, AI_ASSISTANT_BOTS, AI_TRAINING_BOTS } from './modules/seo/index.js'; -export { createLocaleMiddleware, DEFAULT_MIDDLEWARE_MATCHER } from './modules/i18n/index.js'; -export { createProxy, DEFAULT_PROXY_MATCHER } from './modules/i18n/index.js'; -export { resolveLocalized } from './modules/i18n/index.js'; -export { CONSENT_CATEGORIES, DEFAULT_CONSENT, ACCEPT_ALL_CONSENT, REJECT_ALL_CONSENT, CONSENT_COOKIE, CONSENT_VERSION, CONSENT_MAX_AGE, serializeConsent, parseConsent, setDefaultConsent, updateConsent, getConsentTexts } from './modules/consent/index.js'; +export { A11Y_COOKIE, A11Y_DEFAULT, a11yAttributes, parseA11y, serializeA11y } from './modules/accessibility/index.js'; +export { rowLabel } from './modules/admin-ui/index.js'; +export { getAnalyticsConfig } from './modules/analytics/index.js'; +export { ACCEPT_ALL_CONSENT, CONSENT_CATEGORIES, CONSENT_COOKIE, CONSENT_MAX_AGE, CONSENT_VERSION, DEFAULT_CONSENT, getConsentTexts, parseConsent, REJECT_ALL_CONSENT, serializeConsent, setDefaultConsent, updateConsent } from './modules/consent/index.js'; +export { archiveFieldName, blocksToMarkdown, buildArchivePath, buildEntryPath, createMarkdownRenderer, createSearchRoute, getArchiveEntries, MARKDOWN_PREFIX, markdownHref, markdownResponse, parsePageParam, prefersMarkdown, resolveNotFoundPage, resolveRedirect, resolveRoute, searchContent } from './modules/content/index.js'; +export { graphAdapter } from './modules/email/graphAdapter.js'; +export { mailAdapter } from './modules/email/mailAdapter.js'; // Imported straight from the file, NOT from ./modules/email/index.js — that // barrel re-exports sendEmail, which imports 'server-only' and would crash when // Payload loads the config (or runs generate:importmap) as a plain Node script. export { panelSmtpAdapter } from './modules/email/panelSmtpAdapter.js'; -export { graphAdapter } from './modules/email/graphAdapter.js'; -export { mailAdapter } from './modules/email/mailAdapter.js'; +// Boot-time environment validation (fail fast on misconfigured deploys). +export { assertEnv, ipalEnvRules } from './modules/env/index.js'; +// Panel-managed form analytics (config-time field builder). +export { buildFormAnalyticsFields } from './modules/forms/formAnalyticsFields.js'; export { buildFormsPlugin } from './modules/forms/formsPluginConfig.js'; +export { HONEYPOT_FIELD, honeypotInputProps, isHoneypotTripped } from './modules/forms/honeypot.js'; // Validation rules are pure — exported server-side too, for re-validating a // submission inside a server action. (useForm/useContactForm are client-only → // '@intecion/ipal-kit/client'.) -export { buildValidator, isEmail, required, email, minLength, maxLength, checked, pattern, custom } from './modules/forms/validators.js'; -export { HONEYPOT_FIELD, honeypotInputProps, isHoneypotTripped } from './modules/forms/honeypot.js'; -// Panel-managed form analytics (config-time field builder). -export { buildFormAnalyticsFields } from './modules/forms/formAnalyticsFields.js'; +export { buildValidator, checked, custom, email, isEmail, maxLength, minLength, pattern, required } from './modules/forms/validators.js'; +export { createContentHelpers } from './modules/frontend/index.js'; // Healthcheck route (Coolify/Docker liveness with a real DB round-trip). export { createHealthRoute } from './modules/health/index.js'; +export { buildCrossLocaleFieldSync, 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 { createLocaleMiddleware, DEFAULT_MIDDLEWARE_MATCHER } from './modules/i18n/index.js'; +export { createProxy, DEFAULT_PROXY_MATCHER } from './modules/i18n/index.js'; +export { resolveLocalized } from './modules/i18n/index.js'; +export { buildLinkField, buildLinksField, resolveLinkHref } from './modules/links/index.js'; // Read-only MCP server (Claude/agents connect to the site and query it). export { createMcpRoute } from './modules/mcp/index.js'; -// Boot-time environment validation (fail fast on misconfigured deploys). -export { assertEnv, ipalEnvRules } from './modules/env/index.js'; -export { getAnalyticsConfig } from './modules/analytics/index.js'; -export { buildSlugField, toSlug } from './modules/slug/index.js'; -export { createLlmsTxtRoute, createSitemapRouteHandler, createManifestHandler } from './modules/seo/index.js'; -export { getNotificationTexts, resolveFormMessage, NOTIFICATION_FALLBACK } from './modules/notifications/index.js'; +export { buildOptimizeUploadField, buildOptimizeUploadHook, normalizeFilename, normalizeFilenameHook } from './modules/media/index.js'; +export { getNotificationTexts, NOTIFICATION_FALLBACK, resolveFormMessage } from './modules/notifications/index.js'; +export { ALL_SYSTEM_PAGE_ROLES, getSystemPagePath } from './modules/pages/index.js'; +export { getGlobal, getSiteIntegrations, getSiteSettings, SITE_INTEGRATIONS_SLUG, SITE_SETTINGS_SLUG } from './modules/payload/index.js'; +// Lexical → Markdown (pure, no React) — for AI-readable output. +export { lexicalToMarkdown } from './modules/richtext/index.js'; export { buildSecurityHeaders } from './modules/security/index.js'; export { buildCsp } from './modules/security/index.js'; +export { buildHreflangAlternates, buildMetadata, composeTitle, readSiteMetaConfig, slugsAcrossLocales } from './modules/seo/index.js'; +export { AI_ASSISTANT_BOTS, AI_TRAINING_BOTS, buildAutoFillMetaHook, buildRobots, buildSitemapEntries, createMetadataGenerator, createPageMetadata, injectAutoFillMeta } from './modules/seo/index.js'; +export { createLlmsTxtRoute, createManifestHandler, createSitemapRouteHandler } from './modules/seo/index.js'; export { buildIconsMetadata, buildOrganizationJsonLd, validateFaviconField } from './modules/seo/index.js'; export { buildNoindexField } from './modules/seo/index.js'; -export { rowLabel } from './modules/admin-ui/index.js'; -export { buildLinkField, buildLinksField, resolveLinkHref } from './modules/links/index.js'; export { buildSpeakableJsonLd } from './modules/seo/index.js'; export { buildSummaryField } from './modules/seo/index.js'; -export { buildWebSiteJsonLd, buildBreadcrumbJsonLd, buildSiteNavigationJsonLd } from './modules/seo/index.js'; +export { buildBreadcrumbJsonLd, buildSiteNavigationJsonLd, buildWebSiteJsonLd } from './modules/seo/index.js'; // Local SEO structured data — LocalBusiness (map pack), Service (offering), FAQPage. -export { buildLocalBusinessJsonLd, buildFaqJsonLd, buildServiceJsonLd } from './modules/seo/index.js'; +export { buildFaqJsonLd, buildLocalBusinessJsonLd, buildServiceJsonLd } from './modules/seo/index.js'; export { buildArticleJsonLd } from './modules/seo/index.js'; export { buildLlmsTxt } from './modules/seo/index.js'; -export { buildSitemapXml } from './modules/seo/index.js'; +export { buildSitemapCss, buildSitemapXml, DEFAULT_SITEMAP_CREDIT, SITEMAP_STYLE_PARAM } from './modules/seo/index.js'; +export { buildSlugField, toSlug } from './modules/slug/index.js'; export { buildR2Storage } from './modules/storage/index.js'; -export { normalizeFilename, normalizeFilenameHook, buildOptimizeUploadHook, buildOptimizeUploadField } from './modules/media/index.js'; -export { buildRevalidateHook, setPublishedAtHook, buildPreventDeleteSystemPage, buildValidateUniqueRole, trackSlugHistoryHook, buildCrossLocaleFieldSync } from './modules/hooks/index.js'; -export { A11Y_COOKIE, A11Y_DEFAULT, a11yAttributes, parseA11y, serializeA11y } from './modules/accessibility/index.js'; +export { ipalKit } from './plugin.js'; //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/index.js.map b/dist/index.js.map index 668e7fe..2a5fcd9 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { ipalKit } from './plugin.js'\nexport type { IpalOptions } from './types.js'\nexport type { I18nConfig, LocaleDefinition, LocalizedSlugs } from './modules/i18n/index.js'\nexport {\n buildLocalizedPath,\n getDefaultLocale,\n getLocaleCodes,\n getLocaleDefinition,\n getLocalizedSlugs,\n isValidLocale,\n LOCALE_COOKIE_NAME,\n matchAcceptLanguage,\n negotiateLocale,\n switchLocalePath,\n} from './modules/i18n/index.js'\nexport type { PagesOption, SystemPageRole } from './modules/pages/index.js'\nexport { ALL_SYSTEM_PAGE_ROLES, getSystemPagePath } from './modules/pages/index.js'\nexport type { AccessOption, Role } from './modules/access/index.js'\nexport {\n adminOnly,\n adminOnlyField,\n adminOrEditor,\n adminOrEditorField,\n adminOrSelf,\n authenticated,\n hasMinimumRole,\n isAdmin,\n isEditor,\n requireRole,\n requireRoleField,\n ROLE_HIERARCHY,\n} from './modules/access/index.js'\nexport type { GlobalQueryOptions } from './modules/payload/index.js'\nexport {\n getGlobal,\n getSiteSettings,\n getSiteIntegrations,\n SITE_SETTINGS_SLUG,\n SITE_INTEGRATIONS_SLUG,\n} from './modules/payload/index.js'\nexport type { SeoOption, SeoMeta, PageMetadata } from './modules/seo/index.js'\nexport {\n composeTitle,\n buildHreflangAlternates,\n buildMetadata,\n readSiteMetaConfig,\n slugsAcrossLocales,\n} from './modules/seo/index.js'\nexport type { SiteMetaConfig } from './modules/seo/index.js'\nexport type { ContentOption, ContentCollectionOption, ResolvedRoute } from './modules/content/index.js'\nexport { createContentHelpers } from './modules/frontend/index.js'\nexport {\n resolveRoute,\n resolveRedirect,\n resolveNotFoundPage,\n blocksToMarkdown,\n createMarkdownRenderer,\n markdownResponse,\n prefersMarkdown,\n markdownHref,\n MARKDOWN_PREFIX,\n searchContent,\n createSearchRoute,\n archiveFieldName,\n getArchiveEntries,\n buildArchivePath,\n buildEntryPath,\n parsePageParam,\n} from './modules/content/index.js'\nexport type { ArchiveEntries } from './modules/content/index.js'\nexport type { SearchResult } from './modules/content/index.js'\n// Lexical → Markdown (pure, no React) — for AI-readable output.\nexport { lexicalToMarkdown } from './modules/richtext/index.js'\nexport type { AutoFillMapping, SitemapEntry, RobotsRules, RobotsOptions } from './modules/seo/index.js'\nexport {\n buildAutoFillMetaHook,\n injectAutoFillMeta,\n createMetadataGenerator,\n createPageMetadata,\n buildSitemapEntries,\n buildRobots,\n AI_ASSISTANT_BOTS,\n AI_TRAINING_BOTS,\n} from './modules/seo/index.js'\nexport type { LocaleMiddlewareResult } from './modules/i18n/index.js'\nexport {\n createLocaleMiddleware,\n DEFAULT_MIDDLEWARE_MATCHER,\n} from './modules/i18n/index.js'\nexport { createProxy, DEFAULT_PROXY_MATCHER } from './modules/i18n/index.js'\nexport { resolveLocalized } from './modules/i18n/index.js'\nexport {\n CONSENT_CATEGORIES,\n DEFAULT_CONSENT,\n ACCEPT_ALL_CONSENT,\n REJECT_ALL_CONSENT,\n CONSENT_COOKIE,\n CONSENT_VERSION,\n CONSENT_MAX_AGE,\n serializeConsent,\n parseConsent,\n setDefaultConsent,\n updateConsent,\n getConsentTexts,\n} from './modules/consent/index.js'\nexport type { ConsentCategory, ConsentState, ConsentTexts } from './modules/consent/index.js'\n// Imported straight from the file, NOT from ./modules/email/index.js — that\n// barrel re-exports sendEmail, which imports 'server-only' and would crash when\n// Payload loads the config (or runs generate:importmap) as a plain Node script.\nexport { panelSmtpAdapter } from './modules/email/panelSmtpAdapter.js'\nexport { graphAdapter } from './modules/email/graphAdapter.js'\nexport { mailAdapter } from './modules/email/mailAdapter.js'\nexport type { MailAdapterArgs } from './modules/email/mailAdapter.js'\nexport type { GraphAdapterArgs } from './modules/email/graphAdapter.js'\nexport type { PanelSmtpAdapterArgs } from './modules/email/panelSmtpAdapter.js'\nexport { buildFormsPlugin } from './modules/forms/formsPluginConfig.js'\nexport type {\n FormsOption,\n FormsCollectionOverrides,\n FormsFieldsOverride,\n} from './modules/forms/types.js'\n// Validation rules are pure — exported server-side too, for re-validating a\n// submission inside a server action. (useForm/useContactForm are client-only →\n// '@intecion/ipal-kit/client'.)\nexport {\n buildValidator,\n isEmail,\n required,\n email,\n minLength,\n maxLength,\n checked,\n pattern,\n custom,\n} from './modules/forms/validators.js'\nexport type { Rule } from './modules/forms/validators.js'\nexport type { FormErrors, FormSubmitAction, Validator } from './modules/forms/useForm.js'\nexport { HONEYPOT_FIELD, honeypotInputProps, isHoneypotTripped } from './modules/forms/honeypot.js'\n// Panel-managed form analytics (config-time field builder).\nexport { buildFormAnalyticsFields } from './modules/forms/formAnalyticsFields.js'\n// Healthcheck route (Coolify/Docker liveness with a real DB round-trip).\nexport { createHealthRoute } from './modules/health/index.js'\n// Read-only MCP server (Claude/agents connect to the site and query it).\nexport { createMcpRoute } from './modules/mcp/index.js'\n// Boot-time environment validation (fail fast on misconfigured deploys).\nexport { assertEnv, ipalEnvRules } from './modules/env/index.js'\nexport type { EnvRule, EnvKind, AssertEnvOptions, IpalEnvFeatures } from './modules/env/index.js'\nexport type { AnalyticsConfig } from './modules/analytics/index.js'\nexport { getAnalyticsConfig } from './modules/analytics/index.js'\nexport { buildSlugField, toSlug } from './modules/slug/index.js'\nexport { createLlmsTxtRoute, createSitemapRouteHandler, createManifestHandler } from './modules/seo/index.js'\n\nexport { getNotificationTexts, resolveFormMessage, NOTIFICATION_FALLBACK } from './modules/notifications/index.js'\nexport { buildSecurityHeaders } from './modules/security/index.js'\nexport { buildCsp } from './modules/security/index.js'\nexport type { BuildCspArgs } from './modules/security/index.js'\nexport { buildIconsMetadata, buildOrganizationJsonLd, validateFaviconField } from './modules/seo/index.js'\nexport { buildNoindexField } from './modules/seo/index.js'\nexport { rowLabel } from './modules/admin-ui/index.js'\nexport type { RowLabelProps } from './modules/admin-ui/index.js'\nexport { buildLinkField, buildLinksField, resolveLinkHref } from './modules/links/index.js'\nexport type {\n LinkAppearance,\n LinkValue,\n BuildLinkFieldOptions,\n BuildLinksFieldOptions,\n ResolveLinkHrefOptions,\n} from './modules/links/index.js'\nexport { buildSpeakableJsonLd } from './modules/seo/index.js'\nexport { buildSummaryField } from './modules/seo/index.js'\nexport { buildWebSiteJsonLd, buildBreadcrumbJsonLd, buildSiteNavigationJsonLd } from './modules/seo/index.js'\n// Local SEO structured data — LocalBusiness (map pack), Service (offering), FAQPage.\nexport { buildLocalBusinessJsonLd, buildFaqJsonLd, buildServiceJsonLd } from './modules/seo/index.js'\nexport { buildArticleJsonLd } from './modules/seo/index.js'\nexport { buildLlmsTxt } from './modules/seo/index.js'\nexport { buildSitemapXml } from './modules/seo/index.js'\nexport { buildR2Storage } from './modules/storage/index.js'\nexport { normalizeFilename, normalizeFilenameHook, buildOptimizeUploadHook, buildOptimizeUploadField } from './modules/media/index.js'\nexport type { OptimizeUploadOptions } from './modules/media/index.js'\nexport { buildRevalidateHook, setPublishedAtHook, buildPreventDeleteSystemPage, buildValidateUniqueRole, trackSlugHistoryHook, buildCrossLocaleFieldSync } from './modules/hooks/index.js'\nexport { A11Y_COOKIE, A11Y_DEFAULT, a11yAttributes, parseA11y, serializeA11y } from './modules/accessibility/index.js'\nexport type { A11yState } from './modules/accessibility/index.js'\nexport type { SecurityHeader, BuildSecurityHeadersArgs } from './modules/security/index.js'\nexport type { NotificationTexts, FormNotificationTexts } from './modules/notifications/index.js'\n"],"names":["ipalKit","buildLocalizedPath","getDefaultLocale","getLocaleCodes","getLocaleDefinition","getLocalizedSlugs","isValidLocale","LOCALE_COOKIE_NAME","matchAcceptLanguage","negotiateLocale","switchLocalePath","ALL_SYSTEM_PAGE_ROLES","getSystemPagePath","adminOnly","adminOnlyField","adminOrEditor","adminOrEditorField","adminOrSelf","authenticated","hasMinimumRole","isAdmin","isEditor","requireRole","requireRoleField","ROLE_HIERARCHY","getGlobal","getSiteSettings","getSiteIntegrations","SITE_SETTINGS_SLUG","SITE_INTEGRATIONS_SLUG","composeTitle","buildHreflangAlternates","buildMetadata","readSiteMetaConfig","slugsAcrossLocales","createContentHelpers","resolveRoute","resolveRedirect","resolveNotFoundPage","blocksToMarkdown","createMarkdownRenderer","markdownResponse","prefersMarkdown","markdownHref","MARKDOWN_PREFIX","searchContent","createSearchRoute","archiveFieldName","getArchiveEntries","buildArchivePath","buildEntryPath","parsePageParam","lexicalToMarkdown","buildAutoFillMetaHook","injectAutoFillMeta","createMetadataGenerator","createPageMetadata","buildSitemapEntries","buildRobots","AI_ASSISTANT_BOTS","AI_TRAINING_BOTS","createLocaleMiddleware","DEFAULT_MIDDLEWARE_MATCHER","createProxy","DEFAULT_PROXY_MATCHER","resolveLocalized","CONSENT_CATEGORIES","DEFAULT_CONSENT","ACCEPT_ALL_CONSENT","REJECT_ALL_CONSENT","CONSENT_COOKIE","CONSENT_VERSION","CONSENT_MAX_AGE","serializeConsent","parseConsent","setDefaultConsent","updateConsent","getConsentTexts","panelSmtpAdapter","graphAdapter","mailAdapter","buildFormsPlugin","buildValidator","isEmail","required","email","minLength","maxLength","checked","pattern","custom","HONEYPOT_FIELD","honeypotInputProps","isHoneypotTripped","buildFormAnalyticsFields","createHealthRoute","createMcpRoute","assertEnv","ipalEnvRules","getAnalyticsConfig","buildSlugField","toSlug","createLlmsTxtRoute","createSitemapRouteHandler","createManifestHandler","getNotificationTexts","resolveFormMessage","NOTIFICATION_FALLBACK","buildSecurityHeaders","buildCsp","buildIconsMetadata","buildOrganizationJsonLd","validateFaviconField","buildNoindexField","rowLabel","buildLinkField","buildLinksField","resolveLinkHref","buildSpeakableJsonLd","buildSummaryField","buildWebSiteJsonLd","buildBreadcrumbJsonLd","buildSiteNavigationJsonLd","buildLocalBusinessJsonLd","buildFaqJsonLd","buildServiceJsonLd","buildArticleJsonLd","buildLlmsTxt","buildSitemapXml","buildR2Storage","normalizeFilename","normalizeFilenameHook","buildOptimizeUploadHook","buildOptimizeUploadField","buildRevalidateHook","setPublishedAtHook","buildPreventDeleteSystemPage","buildValidateUniqueRole","trackSlugHistoryHook","buildCrossLocaleFieldSync","A11Y_COOKIE","A11Y_DEFAULT","a11yAttributes","parseA11y","serializeA11y"],"mappings":"AAAA,SAASA,OAAO,QAAQ,cAAa;AAGrC,SACEC,kBAAkB,EAClBC,gBAAgB,EAChBC,cAAc,EACdC,mBAAmB,EACnBC,iBAAiB,EACjBC,aAAa,EACbC,kBAAkB,EAClBC,mBAAmB,EACnBC,eAAe,EACfC,gBAAgB,QACX,0BAAyB;AAEhC,SAASC,qBAAqB,EAAEC,iBAAiB,QAAQ,2BAA0B;AAEnF,SACEC,SAAS,EACTC,cAAc,EACdC,aAAa,EACbC,kBAAkB,EACl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B,QAAQ,yBAAwB;AAC3D,SAASC,YAAY,QAAQ,yBAAwB;AACrD,SAASC,eAAe,QAAQ,yBAAwB;AACxD,SAASC,cAAc,QAAQ,6BAA4B;AAC3D,SAASC,iBAAiB,EAAEC,qBAAqB,EAAEC,uBAAuB,EAAEC,wBAAwB,QAAQ,2BAA0B;AAEtI,SAASC,mBAAmB,EAAEC,kBAAkB,EAAEC,4BAA4B,EAAEC,uBAAuB,EAAEC,oBAAoB,EAAEC,yBAAyB,QAAQ,2BAA0B;AAC1L,SAASC,WAAW,EAAEC,YAAY,EAAEC,cAAc,EAAEC,SAAS,EAAEC,aAAa,QAAQ,mCAAkC"} \ No newline at end of file +{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export type { AccessOption, Role } from './modules/access/index.js'\nexport {\n adminOnly,\n adminOnlyField,\n adminOrEditor,\n adminOrEditorField,\n adminOrSelf,\n authenticated,\n hasMinimumRole,\n isAdmin,\n isEditor,\n requireRole,\n requireRoleField,\n ROLE_HIERARCHY,\n} from './modules/access/index.js'\nexport { A11Y_COOKIE, A11Y_DEFAULT, a11yAttributes, parseA11y, serializeA11y } from './modules/accessibility/index.js'\nexport type { A11yState } from './modules/accessibility/index.js'\nexport { rowLabel } from './modules/admin-ui/index.js'\nexport type { RowLabelProps } from './modules/admin-ui/index.js'\nexport type { AnalyticsConfig } from './modules/analytics/index.js'\nexport { getAnalyticsConfig } from './modules/analytics/index.js'\nexport {\n ACCEPT_ALL_CONSENT,\n CONSENT_CATEGORIES,\n CONSENT_COOKIE,\n CONSENT_MAX_AGE,\n CONSENT_VERSION,\n DEFAULT_CONSENT,\n getConsentTexts,\n parseConsent,\n REJECT_ALL_CONSENT,\n serializeConsent,\n setDefaultConsent,\n updateConsent,\n} from './modules/consent/index.js'\nexport type { ConsentCategory, ConsentState, ConsentTexts } from './modules/consent/index.js'\nexport type { ContentCollectionOption, ContentOption, ResolvedRoute } from './modules/content/index.js'\nexport {\n archiveFieldName,\n blocksToMarkdown,\n buildArchivePath,\n buildEntryPath,\n createMarkdownRenderer,\n createSearchRoute,\n getArchiveEntries,\n MARKDOWN_PREFIX,\n markdownHref,\n markdownResponse,\n parsePageParam,\n prefersMarkdown,\n resolveNotFoundPage,\n resolveRedirect,\n resolveRoute,\n searchContent,\n} from './modules/content/index.js'\nexport type { ArchiveEntries } from './modules/content/index.js'\nexport type { SearchResult } from './modules/content/index.js'\nexport { graphAdapter } from './modules/email/graphAdapter.js'\nexport type { GraphAdapterArgs } from './modules/email/graphAdapter.js'\nexport { mailAdapter } from './modules/email/mailAdapter.js'\nexport type { MailAdapterArgs } from './modules/email/mailAdapter.js'\n// Imported straight from the file, NOT from ./modules/email/index.js — that\n// barrel re-exports sendEmail, which imports 'server-only' and would crash when\n// Payload loads the config (or runs generate:importmap) as a plain Node script.\nexport { panelSmtpAdapter } from './modules/email/panelSmtpAdapter.js'\nexport type { PanelSmtpAdapterArgs } from './modules/email/panelSmtpAdapter.js'\n// Boot-time environment validation (fail fast on misconfigured deploys).\nexport { assertEnv, ipalEnvRules } from './modules/env/index.js'\nexport type { AssertEnvOptions, EnvKind, EnvRule, IpalEnvFeatures } from './modules/env/index.js'\n// Panel-managed form analytics (config-time field builder).\nexport { buildFormAnalyticsFields } from './modules/forms/formAnalyticsFields.js'\nexport { buildFormsPlugin } from './modules/forms/formsPluginConfig.js'\nexport { HONEYPOT_FIELD, honeypotInputProps, isHoneypotTripped } from './modules/forms/honeypot.js'\nexport type {\n FormsCollectionOverrides,\n FormsFieldsOverride,\n FormsOption,\n} from './modules/forms/types.js'\nexport type { FormErrors, FormSubmitAction, Validator } from './modules/forms/useForm.js'\n// Validation rules are pure — exported server-side too, for re-validating a\n// submission inside a server action. (useForm/useContactForm are client-only →\n// '@intecion/ipal-kit/client'.)\nexport {\n buildValidator,\n checked,\n custom,\n email,\n isEmail,\n maxLength,\n minLength,\n pattern,\n required,\n} from './modules/forms/validators.js'\nexport type { Rule } from './modules/forms/validators.js'\nexport { createContentHelpers } from './modules/frontend/index.js'\n// Healthcheck route (Coolify/Docker liveness with a real DB round-trip).\nexport { createHealthRoute } from './modules/health/index.js'\nexport { buildCrossLocaleFieldSync, buildPreventDeleteSystemPage, buildRevalidateHook, buildValidateUniqueRole, setPublishedAtHook, trackSlugHistoryHook } from './modules/hooks/index.js'\nexport type { I18nConfig, LocaleDefinition, LocalizedSlugs } from './modules/i18n/index.js'\nexport {\n buildLocalizedPath,\n getDefaultLocale,\n getLocaleCodes,\n getLocaleDefinition,\n getLocalizedSlugs,\n isValidLocale,\n LOCALE_COOKIE_NAME,\n matchAcceptLanguage,\n negotiateLocale,\n switchLocalePath,\n} from './modules/i18n/index.js'\nexport type { LocaleMiddlewareResult } from './modules/i18n/index.js'\nexport {\n createLocaleMiddleware,\n DEFAULT_MIDDLEWARE_MATCHER,\n} from './modules/i18n/index.js'\nexport { createProxy, DEFAULT_PROXY_MATCHER } from './modules/i18n/index.js'\nexport { resolveLocalized } from './modules/i18n/index.js'\nexport { buildLinkField, buildLinksField, resolveLinkHref } from './modules/links/index.js'\nexport type {\n BuildLinkFieldOptions,\n BuildLinksFieldOptions,\n LinkAppearance,\n LinkValue,\n ResolveLinkHrefOptions,\n} from './modules/links/index.js'\n// Read-only MCP server (Claude/agents connect to the site and query it).\nexport { createMcpRoute } from './modules/mcp/index.js'\nexport { buildOptimizeUploadField, buildOptimizeUploadHook, normalizeFilename, normalizeFilenameHook } from './modules/media/index.js'\nexport type { OptimizeUploadOptions } from './modules/media/index.js'\nexport { getNotificationTexts, NOTIFICATION_FALLBACK, resolveFormMessage } from './modules/notifications/index.js'\nexport type { FormNotificationTexts, NotificationTexts } from './modules/notifications/index.js'\nexport type { PagesOption, SystemPageRole } from './modules/pages/index.js'\nexport { ALL_SYSTEM_PAGE_ROLES, getSystemPagePath } from './modules/pages/index.js'\nexport type { GlobalQueryOptions } from './modules/payload/index.js'\n\nexport {\n getGlobal,\n getSiteIntegrations,\n getSiteSettings,\n SITE_INTEGRATIONS_SLUG,\n SITE_SETTINGS_SLUG,\n} from './modules/payload/index.js'\n// Lexical → Markdown (pure, no React) — for AI-readable output.\nexport { lexicalToMarkdown } from './modules/richtext/index.js'\nexport { buildSecurityHeaders } from './modules/security/index.js'\nexport { buildCsp } from './modules/security/index.js'\nexport type { BuildCspArgs } from './modules/security/index.js'\nexport type { BuildSecurityHeadersArgs, SecurityHeader } from './modules/security/index.js'\nexport type { PageMetadata, SeoMeta, SeoOption } from './modules/seo/index.js'\nexport {\n buildHreflangAlternates,\n buildMetadata,\n composeTitle,\n readSiteMetaConfig,\n slugsAcrossLocales,\n} from './modules/seo/index.js'\nexport type { SiteMetaConfig } from './modules/seo/index.js'\nexport type { AutoFillMapping, RobotsOptions, RobotsRules, SitemapEntry } from './modules/seo/index.js'\nexport {\n AI_ASSISTANT_BOTS,\n AI_TRAINING_BOTS,\n buildAutoFillMetaHook,\n buildRobots,\n buildSitemapEntries,\n createMetadataGenerator,\n createPageMetadata,\n injectAutoFillMeta,\n} from './modules/seo/index.js'\nexport { createLlmsTxtRoute, createManifestHandler, createSitemapRouteHandler } from './modules/seo/index.js'\nexport { buildIconsMetadata, buildOrganizationJsonLd, validateFaviconField } from './modules/seo/index.js'\nexport { buildNoindexField } from './modules/seo/index.js'\nexport { buildSpeakableJsonLd } from './modules/seo/index.js'\nexport { buildSummaryField } from './modules/seo/index.js'\nexport { buildBreadcrumbJsonLd, buildSiteNavigationJsonLd, buildWebSiteJsonLd } from './modules/seo/index.js'\n// Local SEO structured data — LocalBusiness (map pack), Service (offering), FAQPage.\nexport { buildFaqJsonLd, buildLocalBusinessJsonLd, buildServiceJsonLd } from './modules/seo/index.js'\nexport { buildArticleJsonLd } from './modules/seo/index.js'\nexport { buildLlmsTxt } from './modules/seo/index.js'\nexport { buildSitemapCss, buildSitemapXml, DEFAULT_SITEMAP_CREDIT, SITEMAP_STYLE_PARAM } from './modules/seo/index.js'\nexport type { SitemapRouteOptions, SitemapStyleOptions } from './modules/seo/index.js'\nexport { buildSlugField, toSlug } from './modules/slug/index.js'\nexport { buildR2Storage } from './modules/storage/index.js'\nexport { ipalKit } from './plugin.js'\nexport type { IpalOptions } from './types.js'\n"],"names":["adminOnly","adminOnlyField","adminOrEditor","adminOrEditorField","adminOrSelf","authenticated","hasMinimumRole","isAdmin","isEditor","requireRole","requireRoleField","ROLE_HIERARCHY","A11Y_COOKIE","A11Y_DEFAULT","a11yAttributes","parseA11y","serializeA11y","rowLabel","getAnalyticsConfig","ACCEPT_ALL_CONSENT","CONSENT_CATEGORIES","CONSENT_COOKIE","CONSENT_MAX_AGE","CONSENT_VERSION","DEFAULT_CONSENT","getConsentTexts","parseConsent","REJECT_ALL_CONSENT","serializeConsent","setDefaultConsent","updateConsent","archiveFieldName","blocksToMarkdown","buildArchivePath","buildEntryPath","createMarkdownRenderer","createSearchRoute","getArchiveEntries","MARKDOWN_PREFIX","markdownHref","markdownResponse","parsePageParam","prefersMarkdown","resolveNotFoundPage","resolveRedirect","resolveRoute","searchContent","graphAdapter","mailAdapter","panelSmtpAdapter","assertEnv","ipalEnvRules","buildFormAnalyticsFields","buildFormsPlugin","HONEYPOT_FIELD","honeypotInputProps","isHoneypotTripped","buildValidator","checked","custom","email","isEmail","maxLength","minLength","pattern","required","createContentHelpers","createHealthRoute","buildCrossLocaleFieldSync","buildPreventDeleteSystemPage","buildRevalidateHook","buildValidateUniqueRole","setPublishedAtHook","trackSlugHistoryHook","buildLocalizedPath","getDefaultLocale","getLocaleCodes","getLocaleDefinition","getLocalizedSlugs","isValidLocale","LOCALE_COOKIE_NAME","matchAcceptLanguage","negotiateLocale","switchLocalePath","createLocaleMiddleware","DEFAULT_MIDDLEWARE_MATCHER","createProxy","DEFAULT_PROXY_MATCHER","resolveLocalized","buildLinkField","buildLinksField","resolveLinkHref","createMcpRoute","buildOptimizeUploadField","buildOptimizeUploadHook","normalizeFilename","normalizeFilenameHook","getNotificationTexts","NOTIFICATION_FALLBACK","resolveFormMessage","ALL_SYSTEM_PAGE_ROLES","getSystemPagePath","getGlobal","getSiteIntegrations","getSiteSettings","SITE_INTEGRATIONS_SLUG","SITE_SETTINGS_SLUG","lexicalToMarkdown","buildSecurityHeaders","buildCsp","buildHreflangAlternates","buildMetadata","composeTitle","readSiteMetaConfig","slugsAcrossLocales","AI_ASSISTANT_BOTS","AI_TRAINING_BOTS","buildAutoFillMetaHook","buildRobots","buildSitemapEntries","createMetadataGenerator","createPageMetadata","injectAutoFillMeta","createLlmsTxtRoute","createManifestHandler","createSitemapRouteHandler","buildIconsMetadata","buildOrganizationJsonLd","validateFaviconField","buildNoindexField","buildSpeakableJsonLd","buildSummaryField","buildBreadcrumbJsonLd","buildSiteNavigationJsonLd","buildWebSiteJsonLd","buildFaqJsonLd","buildLocalBusinessJsonLd","buildServiceJsonLd","buildArticleJsonLd","buildLlmsTxt","buildSitemapCss","buildSitemapXml","DEFAULT_SITEMAP_CREDIT","SITEMAP_STYLE_PARAM","buildSlugField","toSlug","buildR2Storage","ipalKit"],"mappings":"AACA,SACEA,SAAS,EACTC,cAAc,EACdC,aAAa,EACbC,kBAAkB,EAClBC,WAAW,EACXC,aAAa,EACbC,cAAc,EACdC,OAAO,EACPC,QAAQ,EACRC,WAAW,EACXC,gBAAgB,EAChBC,cAAc,QACT,4BAA2B;AAClC,SAASC,WAAW,EAAEC,YAAY,EAAEC,cAAc,EAAEC,SAAS,EAAEC,aAAa,QAAQ,mCAAkC;AAEtH,SAASC,QAAQ,QAAQ,8BAA6B;AAGtD,SAASC,kBAAkB,QAAQ,+BAA8B;AACjE,SACEC,kBAAkB,EAClBC,kBAAkB,EAClBC,cAAc,EACdC,eAAe,EACfC,eAAe,EACfC,eAAe,EACfC,eAAe,EACfC,YAAY,EACZC,kBAAkB,EAClBC,gBAAgB,EAChBC,iBAAiB,EACjBC,aAAa,QACR,6BAA4B;AAGnC,SACEC,gBAAgB,EAChBC,gBAAgB,EAChBC,gBAAgB,EAChBC,cAAc,EACdC,sBAAsB,EACtBC,iBAAiB,EACjBC,iBAAiB,EAC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AmB,QAAQ,yBAAwB;AAEtH,SAASC,cAAc,EAAEC,MAAM,QAAQ,0BAAyB;AAChE,SAASC,cAAc,QAAQ,6BAA4B;AAC3D,SAASC,OAAO,QAAQ,cAAa"} \ No newline at end of file diff --git a/dist/modules/frontend/createContentHelpers.d.ts b/dist/modules/frontend/createContentHelpers.d.ts index 3646752..1d3fc64 100644 --- a/dist/modules/frontend/createContentHelpers.d.ts +++ b/dist/modules/frontend/createContentHelpers.d.ts @@ -1,7 +1,7 @@ import type { BasePayload, SanitizedConfig } from 'payload'; import type { ArchiveEntries, ContentOption, ResolvedRoute } from '../content/index.js'; import type { I18nConfig } from '../i18n/index.js'; -import type { PageMetadata, RobotsOptions, RobotsRules, SitemapEntry } from '../seo/index.js'; +import type { PageMetadata, RobotsOptions, RobotsRules, SitemapEntry, SitemapStyleOptions } from '../seo/index.js'; type CreateContentHelpersArgs = { /** * Absolute site origin for sitemap/robots URLs. Falls back to @@ -31,6 +31,16 @@ type CreateContentHelpersArgs = { robots?: RobotsOptions; /** SiteSettings global slug. Defaults to 'site-settings'. */ settingsSlug?: string; + /** + * Browser look of `sitemapRoute` (/sitemap.xml). Default: built-in style, + * header = Site Settings `siteName` (default locale), credit "Technology by + * Intecion.com". `false` = raw XML. `{ credit: false }` hides the credit line. + */ + sitemapStyle?: { + title?: string; + } & Omit | false; + /** Site Settings field with the site name (sitemap header). Default 'siteName'. */ + siteNameField?: string; }; /** * Bundles the per-request data helpers a frontend needs — the same cached @@ -58,7 +68,7 @@ type CreateContentHelpersArgs = { * a URL is, fetching gets the listing. Metadata generation needs the first and * not the second, and a page component composes them in two obvious lines. */ -export declare function createContentHelpers({ baseUrl, config, content, i18n, pagesSlug, robots: robotsOptions, settingsSlug, }: CreateContentHelpersArgs): { +export declare function createContentHelpers({ baseUrl, config, content, i18n, pagesSlug, robots: robotsOptions, settingsSlug, sitemapStyle, siteNameField, }: CreateContentHelpersArgs): { generatePageMetadata: (locale: string, segments: string[] | undefined, page?: number) => Promise; generateStaticParams: () => Promise Promise; robots: () => RobotsRules; sitemap: () => Promise; + sitemapRoute: (req?: Request) => Promise; }; export {}; diff --git a/dist/modules/frontend/createContentHelpers.js b/dist/modules/frontend/createContentHelpers.js index 30139b4..4009bf9 100644 --- a/dist/modules/frontend/createContentHelpers.js +++ b/dist/modules/frontend/createContentHelpers.js @@ -1,7 +1,7 @@ import { getPayload } from 'payload'; import { cache } from 'react'; import { getArchiveEntries, resolveRoute as resolveRouteRaw } from '../content/index.js'; -import { buildRobots, buildSitemapEntries, createPageMetadata } from '../seo/index.js'; +import { buildRobots, buildSitemapEntries, createPageMetadata, createSitemapRouteHandler } from '../seo/index.js'; /** * Bundles the per-request data helpers a frontend needs — the same cached * wrappers every project was writing by hand (getPayload, settings, locale @@ -27,7 +27,7 @@ import { buildRobots, buildSitemapEntries, createPageMetadata } from '../seo/ind * `resolveRoute` and `getEntries` are separate on purpose: routing decides what * a URL is, fetching gets the listing. Metadata generation needs the first and * not the second, and a page component composes them in two obvious lines. - */ export function createContentHelpers({ baseUrl, config, content, i18n, pagesSlug = 'pages', robots: robotsOptions, settingsSlug = 'site-settings' }) { + */ export function createContentHelpers({ baseUrl, config, content, i18n, pagesSlug = 'pages', robots: robotsOptions, settingsSlug = 'site-settings', sitemapStyle, siteNameField = 'siteName' }) { const origin = baseUrl ?? process.env.NEXT_PUBLIC_SERVER_URL ?? ''; const getCachedPayload = cache(async ()=>getPayload({ config: await config @@ -311,6 +311,26 @@ import { buildRobots, buildSitemapEntries, createPageMetadata } from '../seo/ind return []; } }; + /** + * Route handler for app/sitemap.xml/route.ts — XML for crawlers, styled for + * people (`?style` serves the CSS from the plugin; nothing in /public): + * + * export { sitemapRoute as GET } from '@/lib/content' + * export const dynamic = 'force-dynamic' + */ const sitemapRoute = createSitemapRouteHandler(sitemap, { + style: sitemapStyle === false ? false : { + ...sitemapStyle, + title: sitemapStyle?.title ?? (async ()=>{ + const locale = i18n?.defaultLocale; + if (!locale) { + return undefined; + } + const s = await getSettings(locale); + const name = s?.[siteNameField]; + return typeof name === 'string' ? name : undefined; + }) + } + }); return { generatePageMetadata, generateStaticParams, @@ -321,7 +341,8 @@ import { buildRobots, buildSitemapEntries, createPageMetadata } from '../seo/ind getSettings, resolveRoute, robots, - sitemap + sitemap, + sitemapRoute }; } diff --git a/dist/modules/frontend/createContentHelpers.js.map b/dist/modules/frontend/createContentHelpers.js.map index d433e72..b685e89 100644 --- a/dist/modules/frontend/createContentHelpers.js.map +++ b/dist/modules/frontend/createContentHelpers.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../../src/modules/frontend/createContentHelpers.ts"],"sourcesContent":["import type { BasePayload, SanitizedConfig } from 'payload'\n\nimport { getPayload } from 'payload'\nimport { cache } from 'react'\n\nimport type { ArchiveEntries, ContentOption, ResolvedRoute } from '../content/index.js'\nimport type { I18nConfig } from '../i18n/index.js'\nimport type { PageMetadata, RobotsOptions, RobotsRules, SitemapEntry } from '../seo/index.js'\n\nimport { getArchiveEntries, resolveRoute as resolveRouteRaw } from '../content/index.js'\nimport { buildRobots, buildSitemapEntries, createPageMetadata } from '../seo/index.js'\n\ntype CreateContentHelpersArgs = {\n /**\n * Absolute site origin for sitemap/robots URLs. Falls back to\n * NEXT_PUBLIC_SERVER_URL, then to a relative origin (which most crawlers\n * reject, so set one in production).\n */\n baseUrl?: string\n /**\n * The client's payload config promise (the default export of payload.config).\n * Passed in because the plugin never imports the client's config directly.\n */\n config: Promise | SanitizedConfig\n /** Archive-backed collections, same value as the plugin option. */\n content?: ContentOption\n /**\n * i18n config. Required only if you want the ready-made `sitemap` / `robots`\n * handlers — they need the locale list to emit hreflang.\n */\n i18n?: I18nConfig\n /** Pages collection slug. Defaults to 'pages'. */\n pagesSlug?: string\n /**\n * Options for the ready-made `robots` handler, e.g.\n * `{ disallowParams: ['s', 'meter'], aiBots: 'block-training' }`, or\n * `{ adminRoute: false }` when the admin path is hidden (ipalKit adminRoute).\n */\n robots?: RobotsOptions\n /** SiteSettings global slug. Defaults to 'site-settings'. */\n settingsSlug?: string\n}\n\n/**\n * Bundles the per-request data helpers a frontend needs — the same cached\n * wrappers every project was writing by hand (getPayload, settings, locale\n * list, route resolution, archive entries).\n *\n * Everything is wrapped in React `cache()`, so within one request a value is\n * fetched once no matter how many times it's asked for — which matters because\n * Next runs generateMetadata and the page component separately, and both hit\n * these. Crucially the Payload instance is cached *here*, once, so every helper\n * shares it; that's why this is a factory and not loose functions importing a\n * shared module.\n *\n * ```ts\n * // src/lib/content.ts\n * import { createContentHelpers } from 'ipal-kit'\n * import config from '@/payload.config'\n * import { contentConfig } from '@/content.config'\n *\n * export const { getCachedPayload, getSettings, getConfiguredLocales, resolveRoute, getEntries } =\n * createContentHelpers({ config, content: contentConfig })\n * ```\n *\n * `resolveRoute` and `getEntries` are separate on purpose: routing decides what\n * a URL is, fetching gets the listing. Metadata generation needs the first and\n * not the second, and a page component composes them in two obvious lines.\n */\nexport function createContentHelpers({\n baseUrl,\n config,\n content,\n i18n,\n pagesSlug = 'pages',\n robots: robotsOptions,\n settingsSlug = 'site-settings',\n}: CreateContentHelpersArgs) {\n const origin = baseUrl ?? process.env.NEXT_PUBLIC_SERVER_URL ?? ''\n const getCachedPayload = cache(\n async (): Promise => getPayload({ config: await config }),\n )\n\n const getConfiguredLocales = cache(async (): Promise => {\n const c = await config\n return c.localization ? c.localization.locales.map((l) => l.code) : []\n })\n\n /**\n * SiteSettings for a locale — ONE query per locale per request, shared by the\n * layout, generatePageMetadata, resolveRoute and anything else that asks.\n */\n const getSettings = cache(async (locale: string) => {\n const payload = await getCachedPayload()\n return payload.findGlobal({ slug: settingsSlug as never, depth: 2, locale: locale as never })\n })\n\n /** What does this URL point at? Routing only — no listing data. */\n const resolveRoute = cache(\n async (\n locale: string,\n segments: string[] | undefined,\n page: number,\n ): Promise => {\n const payload = await getCachedPayload()\n const settings = (await getSettings(locale)) as Record\n return resolveRouteRaw({\n content,\n locale,\n page,\n pagesSlug,\n payload,\n segments,\n settings,\n settingsSlug,\n })\n },\n )\n\n /**\n * generateMetadata for the catch-all page, sharing the request cache with\n * the page component: the same settings read and the same resolveRoute call\n * (React cache spans generateMetadata and the page within one request), so\n * metadata costs no extra route/settings queries.\n *\n * export async function generateMetadata({ params }) {\n * const { locale, slug } = await params\n * return generatePageMetadata(locale, slug)\n * }\n */\n let pageMetadata: ReturnType | undefined\n const generatePageMetadata = async (\n locale: string,\n segments: string[] | undefined,\n page = 1,\n ): Promise => {\n if (!i18n) {\n throw new Error('[ipal] createContentHelpers: pass `i18n` to use generatePageMetadata.')\n }\n pageMetadata ??= createPageMetadata({\n baseUrl: origin || undefined,\n collection: pagesSlug,\n config: i18n,\n content,\n loaders: {\n getSettings: async (l) => (await getSettings(l)) as Record,\n resolveRoute,\n },\n settingsSlug,\n })\n return pageMetadata({ slug: segments, locale, page, payload: await getCachedPayload() })\n }\n\n /** ID of the page assigned as 404 — the relation isn't localized, so one read serves every locale. */\n const getNotFoundPageId = cache(async (): Promise => {\n const payload = await getCachedPayload()\n const settings = (await payload.findGlobal({\n slug: settingsSlug as never,\n depth: 0,\n })) as { notFound?: unknown }\n const rel = settings.notFound\n if (typeof rel === 'string' || typeof rel === 'number') {return rel}\n if (rel && typeof rel === 'object') {\n const id = (rel as { id?: unknown }).id\n if (typeof id === 'string' || typeof id === 'number') {return id}\n }\n return null\n })\n\n /**\n * The page assigned as 404 in System Pages (or null → built-in fallback).\n * For app/not-found.tsx; never throws. not-found.tsx receives no params and\n * must NOT read headers() (breaks SSG/ISR) — call this for every configured\n * locale and let (client) pick the one from the URL. See pages.md.\n */\n const getNotFoundPage = cache(async (locale: string) => {\n try {\n const id = await getNotFoundPageId()\n if (id === null) {return null}\n const payload = await getCachedPayload()\n const doc = await payload.findByID({\n id,\n collection: pagesSlug as never,\n depth: 2,\n locale: locale as never,\n })\n return (doc as null | Record) ?? null\n } catch {\n return null // DB unreachable (container build) or page deleted — fallback view\n }\n })\n\n /** One page of a collection's entries, for an archive listing. */\n const getEntries = cache(\n async (\n collection: string,\n locale: string,\n page: number,\n perPage: number,\n ): Promise => {\n const payload = await getCachedPayload()\n return getArchiveEntries({ collection, locale, page, payload, perPage })\n },\n )\n\n /**\n * Ready-made handler for Next's `app/sitemap.ts` — every page and entry with\n * per-URL hreflang and lastmod. Re-export it directly:\n *\n * ```ts\n * // app/sitemap.ts\n * export { sitemap as default } from '@/lib/content'\n * export const dynamic = 'force-dynamic' // generate at runtime, not build\n * ```\n *\n * IMPORTANT — container deploys (Coolify/Docker/Railway/CI): Next treats\n * sitemap.ts as STATIC by default and prerenders it during `next build`, which\n * calls into Payload → the database. The build container usually has no access\n * to the internal Docker network, so the DB connection fails (ENOTFOUND) and\n * the build dies. Two defenses:\n * 1. `export const dynamic = 'force-dynamic'` in app/sitemap.ts — skips build\n * prerender, generates at runtime when the DB is reachable (recommended).\n * 2. This handler also catches DB errors and returns [] so that even without\n * (1) the build won't crash — it just ships an empty sitemap until the\n * next runtime regeneration. (1) is still preferred; (2) is a safety net.\n */\n const sitemap = cache(async (): Promise => {\n if (!i18n) {\n throw new Error(\n '[ipal] createContentHelpers: pass `i18n` to use the sitemap handler.',\n )\n }\n try {\n return await buildSitemapEntries({\n baseUrl: origin,\n config: i18n,\n content,\n pagesSlug,\n payload: await getCachedPayload(),\n settingsSlug,\n })\n } catch (error) {\n // DB unreachable (typically a container build with no DB network) — return\n // an empty sitemap instead of failing the build. Runtime regeneration will\n // produce the real one once the DB is reachable. See dynamic='force-dynamic'.\n console.warn(\n '[ipal] sitemap: could not reach the database, returning empty entries ' +\n \"(add `export const dynamic = 'force-dynamic'` to app/sitemap.ts to \" +\n 'generate at runtime and avoid build-time DB access):',\n error,\n )\n return []\n }\n })\n\n /**\n * Ready-made handler for Next's `app/robots.ts`. Re-export directly:\n *\n * ```ts\n * // app/robots.ts\n * export { robots as default } from '@/lib/content'\n * ```\n */\n const robots = (): RobotsRules => buildRobots({ ...robotsOptions, baseUrl: origin })\n\n /**\n * Next.js generateStaticParams for the [[...slug]] route (or\n * [locale]/[[...slug]]). Returns every routable page as a params object, so\n * Next PRE-RENDERS them as static (SSG) instead of dynamic.\n *\n * Why this matters beyond convenience: an optional catch-all with no\n * generateStaticParams is treated as a DYNAMIC route (ƒ), which streams\n * metadata into (crawlers miss it). Providing generateStaticParams\n * compiles routes as SSG (●) — the is synchronous and complete. This is\n * the strongest fix for the metadata-in-head problem (stronger than ISR alone).\n *\n * Handles automatically:\n * - pages collection + content collections (with their archive prefix)\n * - excludes the homepage (maps to { slug: [] } — the root)\n * - excludes drafts and 404/500/system slugs\n * - KEEPS noindex pages (they must still render — noindex controls indexing,\n * not existence; skipping them would force dynamic rendering)\n * - localized slugs (string or per-locale map) both handled\n * - single-locale → { slug }[]; multi-locale → { locale, slug }[]\n *\n * Wire it in the project:\n * // app/(frontend)/[[...slug]]/page.tsx (or [locale]/[[...slug]])\n * export { generateStaticParams } from '@/lib/content'\n */\n const generateStaticParams = async (): Promise<\n Array<{ locale: string; slug: string[] } | { slug: string[] }>\n > => {\n try {\n const payload = await getCachedPayload()\n const locales = i18n ? i18n.locales.map((l) => l.code) : [undefined]\n const singleLocale = !i18n || i18n.locales.length === 1\n\n // Home slug per locale, to exclude the homepage (it's the root, slug []).\n const settings = (await payload\n .findGlobal({ slug: settingsSlug as never, depth: 1, locale: 'all' as never })\n .catch(() => null)) as {\n homepage?: { id?: number | string; slug?: unknown }\n notFound?: { id?: number | string } | null\n } | null\n const homeId = settings?.homepage?.id\n // The assigned 404 page renders via not-found.tsx, never as its own URL.\n const notFoundId =\n settings?.notFound?.id !== undefined && settings.notFound.id !== homeId\n ? settings.notFound.id\n : undefined\n\n const EXCLUDED = new Set(['404', '500', 'error', 'not-found'])\n const params: Array<{ locale: string; slug: string[] } | { slug: string[] }> = []\n\n for (const locale of locales) {\n // NO where:{_status} filter — collections without drafts enabled don't\n // register the _status field, and querying it throws\n // \"path cannot be queried: _status\". We filter drafts in memory below,\n // which is safe for every collection (with or without drafts).\n const result = await payload.find({\n collection: pagesSlug as never,\n depth: 0,\n limit: 1000,\n locale: (locale ?? 'all') as never,\n })\n\n for (const raw of result.docs as Array<{\n _status?: string\n id: number | string\n meta?: { noindex?: boolean } | null\n slug?: unknown\n }>) {\n // Draft filter in memory (safe whether or not the collection has drafts).\n if (raw._status && raw._status !== 'published') {continue}\n if (notFoundId !== undefined && raw.id === notFoundId) {continue}\n\n // NOTE: unlike the sitemap, we do NOT skip meta.noindex here. A noindex\n // page (privacy, cookies, terms) still needs to render — users reach it\n // from the footer and crawlers read its . Pre-render\n // it as SSG so it's fast and its is complete; noindex controls\n // INDEXING, not whether the page exists. Skipping it would force dynamic\n // rendering (the very streaming problem we're avoiding).\n\n if (homeId && raw.id === homeId) {\n // Homepage → root. Emit an empty-slug param so '/' (or '/pl') builds.\n const empty = singleLocale ? { slug: [] } : { slug: [], locale: locale as string }\n if (!params.some((p) => JSON.stringify(p) === JSON.stringify(empty))) {params.push(empty)}\n continue\n }\n\n // Slug may be a plain string OR a localized map ({ pl: 'kontakt' }) when\n // read with locale:'all' or left unflattened. Handle both, or localized\n // pages get silently dropped.\n const rawSlug = raw.slug\n const slug =\n typeof rawSlug === 'string'\n ? rawSlug\n : rawSlug && typeof rawSlug === 'object'\n ? ((rawSlug as Record)[locale ?? ''] as string | undefined) ??\n (Object.values(rawSlug as Record)[0] as string | undefined)\n : undefined\n\n if (!slug || EXCLUDED.has(slug)) {continue}\n\n // Multi-level slugs ('atrakcje/telefon') → array segments.\n const segments = String(slug).split('/').filter(Boolean)\n params.push(singleLocale ? { slug: segments } : { slug: segments, locale: locale as string })\n }\n }\n\n return params\n } catch (err) {\n // DB unreachable — typically a container build (Docker/Coolify/CI) with no\n // database network. Return [] so the build doesn't crash: Next falls back\n // to on-demand rendering for the routes, which fill in once the DB is\n // reachable at runtime. Without this every project would need its own\n // try/catch here. (Same graceful-degradation as the sitemap handler.)\n console.warn(\n '[ipal] generateStaticParams: database not reachable during build ' +\n '(Docker/CI) — returning empty params; routes render on-demand at runtime:',\n err,\n )\n return []\n }\n }\n\n return {\n generatePageMetadata,\n generateStaticParams,\n getCachedPayload,\n getConfiguredLocales,\n getEntries,\n getNotFoundPage,\n getSettings,\n resolveRoute,\n robots,\n sitemap,\n }\n}\n"],"names":["getPayload","cache","getArchiveEntries","resolveRoute","resolveRouteRaw","buildRobots","buildSitemapEntries","createPageMetadata","createContentHelpers","baseUrl","config","content","i18n","pagesSlug","robots","robotsOptions","settingsSlug","origin","process","env","NEXT_PUBLIC_SERVER_URL","getCachedPayload","getConfiguredLocales","c","localization","locales","map","l","code","getSettings","locale","payload","findGlobal","slug","depth","segments","page","settings","pageMetadata","generatePageMetadata","Error","undefined","collection","loaders","getNotFoundPageId","rel","notFound","id","getNotFoundPage","doc","findByID","getEntries","perPage","sitemap","error","console","warn","generateStaticParams","singleLocale","length","catch","homeId","homepage","notFoundId","EXCLUDED","Set","params","result","find","limit","raw","docs","_status","empty","some","p","JSON","stringify","push","rawSlug","Object","values","has","String","split","filter","Boolean","err"],"mappings":"AAEA,SAASA,UAAU,QAAQ,UAAS;AACpC,SAASC,KAAK,QAAQ,QAAO;AAM7B,SAASC,iBAAiB,EAAEC,gBAAgBC,eAAe,QAAQ,sBAAqB;AACxF,SAASC,WAAW,EAAEC,mBAAmB,EAAEC,kBAAkB,QAAQ,kBAAiB;AAiCtF;;;;;;;;;;;;;;;;;;;;;;;;;CAyBC,GACD,OAAO,SAASC,qBAAqB,EACnCC,OAAO,EACPC,MAAM,EACNC,OAAO,EACPC,IAAI,EACJC,YAAY,OAAO,EACnBC,QAAQC,aAAa,EACrBC,eAAe,eAAe,EACL;IACzB,MAAMC,SAASR,WAAWS,QAAQC,GAAG,CAACC,sBAAsB,IAAI;IAChE,MAAMC,mBAAmBpB,MACvB,UAAkCD,WAAW;YAAEU,QAAQ,MAAMA;QAAO;IAGtE,MAAMY,uBAAuBrB,MAAM;QACjC,MAAMsB,IAAI,MAAMb;QAChB,OAAOa,EAAEC,YAAY,GAAGD,EAAEC,YAAY,CA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OQ,IAAI,CAAC,CAACC,IAAMC,KAAKC,SAAS,CAACF,OAAOC,KAAKC,SAAS,CAACJ,SAAS;4BAACP,OAAOY,IAAI,CAACL;wBAAM;wBACzF;oBACF;oBAEA,yEAAyE;oBACzE,wEAAwE;oBACxE,8BAA8B;oBAC9B,MAAMM,UAAUT,IAAIrC,IAAI;oBACxB,MAAMA,OACJ,OAAO8C,YAAY,WACfA,UACAA,WAAW,OAAOA,YAAY,WAC5B,AAAC,AAACA,OAAmC,CAACjD,UAAU,GAAG,IAClDkD,OAAOC,MAAM,CAACF,QAAmC,CAAC,EAAE,GACrDtC;oBAER,IAAI,CAACR,QAAQ+B,SAASkB,GAAG,CAACjD,OAAO;wBAAC;oBAAQ;oBAE1C,2DAA2D;oBAC3D,MAAME,WAAWgD,OAAOlD,MAAMmD,KAAK,CAAC,KAAKC,MAAM,CAACC;oBAChDpB,OAAOY,IAAI,CAACpB,eAAe;wBAAEzB,MAAME;oBAAS,IAAI;wBAAEF,MAAME;wBAAUL,QAAQA;oBAAiB;gBAC7F;YACF;YAEE,OAAOoC;QACT,EAAE,OAAOqB,KAAK;YACZ,2EAA2E;YAC3E,0EAA0E;YAC1E,sEAAsE;YACtE,sEAAsE;YACtE,sEAAsE;YACtEhC,QAAQC,IAAI,CACV,sEACE,6EACF+B;YAEF,OAAO,EAAE;QACX;IACF;IAEA,OAAO;QACLhD;QACAkB;QACApC;QACAC;QACA6B;QACAH;QACAnB;QACA1B;QACAW;QACAuC;IACF;AACF"} \ No newline at end of file +{"version":3,"sources":["../../../src/modules/frontend/createContentHelpers.ts"],"sourcesContent":["import type { BasePayload, SanitizedConfig } from 'payload'\n\nimport { getPayload } from 'payload'\nimport { cache } from 'react'\n\nimport type { ArchiveEntries, ContentOption, ResolvedRoute } from '../content/index.js'\nimport type { I18nConfig } from '../i18n/index.js'\nimport type { PageMetadata, RobotsOptions, RobotsRules, SitemapEntry, SitemapStyleOptions } from '../seo/index.js'\n\nimport { getArchiveEntries, resolveRoute as resolveRouteRaw } from '../content/index.js'\nimport { buildRobots, buildSitemapEntries, createPageMetadata, createSitemapRouteHandler } from '../seo/index.js'\n\ntype CreateContentHelpersArgs = {\n /**\n * Absolute site origin for sitemap/robots URLs. Falls back to\n * NEXT_PUBLIC_SERVER_URL, then to a relative origin (which most crawlers\n * reject, so set one in production).\n */\n baseUrl?: string\n /**\n * The client's payload config promise (the default export of payload.config).\n * Passed in because the plugin never imports the client's config directly.\n */\n config: Promise | SanitizedConfig\n /** Archive-backed collections, same value as the plugin option. */\n content?: ContentOption\n /**\n * i18n config. Required only if you want the ready-made `sitemap` / `robots`\n * handlers — they need the locale list to emit hreflang.\n */\n i18n?: I18nConfig\n /** Pages collection slug. Defaults to 'pages'. */\n pagesSlug?: string\n /**\n * Options for the ready-made `robots` handler, e.g.\n * `{ disallowParams: ['s', 'meter'], aiBots: 'block-training' }`, or\n * `{ adminRoute: false }` when the admin path is hidden (ipalKit adminRoute).\n */\n robots?: RobotsOptions\n /** SiteSettings global slug. Defaults to 'site-settings'. */\n settingsSlug?: string\n /**\n * Browser look of `sitemapRoute` (/sitemap.xml). Default: built-in style,\n * header = Site Settings `siteName` (default locale), credit \"Technology by\n * Intecion.com\". `false` = raw XML. `{ credit: false }` hides the credit line.\n */\n sitemapStyle?: { title?: string } & Omit | false\n /** Site Settings field with the site name (sitemap header). Default 'siteName'. */\n siteNameField?: string\n}\n\n/**\n * Bundles the per-request data helpers a frontend needs — the same cached\n * wrappers every project was writing by hand (getPayload, settings, locale\n * list, route resolution, archive entries).\n *\n * Everything is wrapped in React `cache()`, so within one request a value is\n * fetched once no matter how many times it's asked for — which matters because\n * Next runs generateMetadata and the page component separately, and both hit\n * these. Crucially the Payload instance is cached *here*, once, so every helper\n * shares it; that's why this is a factory and not loose functions importing a\n * shared module.\n *\n * ```ts\n * // src/lib/content.ts\n * import { createContentHelpers } from 'ipal-kit'\n * import config from '@/payload.config'\n * import { contentConfig } from '@/content.config'\n *\n * export const { getCachedPayload, getSettings, getConfiguredLocales, resolveRoute, getEntries } =\n * createContentHelpers({ config, content: contentConfig })\n * ```\n *\n * `resolveRoute` and `getEntries` are separate on purpose: routing decides what\n * a URL is, fetching gets the listing. Metadata generation needs the first and\n * not the second, and a page component composes them in two obvious lines.\n */\nexport function createContentHelpers({\n baseUrl,\n config,\n content,\n i18n,\n pagesSlug = 'pages',\n robots: robotsOptions,\n settingsSlug = 'site-settings',\n sitemapStyle,\n siteNameField = 'siteName',\n}: CreateContentHelpersArgs) {\n const origin = baseUrl ?? process.env.NEXT_PUBLIC_SERVER_URL ?? ''\n const getCachedPayload = cache(\n async (): Promise => getPayload({ config: await config }),\n )\n\n const getConfiguredLocales = cache(async (): Promise => {\n const c = await config\n return c.localization ? c.localization.locales.map((l) => l.code) : []\n })\n\n /**\n * SiteSettings for a locale — ONE query per locale per request, shared by the\n * layout, generatePageMetadata, resolveRoute and anything else that asks.\n */\n const getSettings = cache(async (locale: string) => {\n const payload = await getCachedPayload()\n return payload.findGlobal({ slug: settingsSlug as never, depth: 2, locale: locale as never })\n })\n\n /** What does this URL point at? Routing only — no listing data. */\n const resolveRoute = cache(\n async (\n locale: string,\n segments: string[] | undefined,\n page: number,\n ): Promise => {\n const payload = await getCachedPayload()\n const settings = (await getSettings(locale)) as Record\n return resolveRouteRaw({\n content,\n locale,\n page,\n pagesSlug,\n payload,\n segments,\n settings,\n settingsSlug,\n })\n },\n )\n\n /**\n * generateMetadata for the catch-all page, sharing the request cache with\n * the page component: the same settings read and the same resolveRoute call\n * (React cache spans generateMetadata and the page within one request), so\n * metadata costs no extra route/settings queries.\n *\n * export async function generateMetadata({ params }) {\n * const { locale, slug } = await params\n * return generatePageMetadata(locale, slug)\n * }\n */\n let pageMetadata: ReturnType | undefined\n const generatePageMetadata = async (\n locale: string,\n segments: string[] | undefined,\n page = 1,\n ): Promise => {\n if (!i18n) {\n throw new Error('[ipal] createContentHelpers: pass `i18n` to use generatePageMetadata.')\n }\n pageMetadata ??= createPageMetadata({\n baseUrl: origin || undefined,\n collection: pagesSlug,\n config: i18n,\n content,\n loaders: {\n getSettings: async (l) => (await getSettings(l)) as Record,\n resolveRoute,\n },\n settingsSlug,\n })\n return pageMetadata({ slug: segments, locale, page, payload: await getCachedPayload() })\n }\n\n /** ID of the page assigned as 404 — the relation isn't localized, so one read serves every locale. */\n const getNotFoundPageId = cache(async (): Promise => {\n const payload = await getCachedPayload()\n const settings = (await payload.findGlobal({\n slug: settingsSlug as never,\n depth: 0,\n })) as { notFound?: unknown }\n const rel = settings.notFound\n if (typeof rel === 'string' || typeof rel === 'number') {return rel}\n if (rel && typeof rel === 'object') {\n const id = (rel as { id?: unknown }).id\n if (typeof id === 'string' || typeof id === 'number') {return id}\n }\n return null\n })\n\n /**\n * The page assigned as 404 in System Pages (or null → built-in fallback).\n * For app/not-found.tsx; never throws. not-found.tsx receives no params and\n * must NOT read headers() (breaks SSG/ISR) — call this for every configured\n * locale and let (client) pick the one from the URL. See pages.md.\n */\n const getNotFoundPage = cache(async (locale: string) => {\n try {\n const id = await getNotFoundPageId()\n if (id === null) {return null}\n const payload = await getCachedPayload()\n const doc = await payload.findByID({\n id,\n collection: pagesSlug as never,\n depth: 2,\n locale: locale as never,\n })\n return (doc as null | Record) ?? null\n } catch {\n return null // DB unreachable (container build) or page deleted — fallback view\n }\n })\n\n /** One page of a collection's entries, for an archive listing. */\n const getEntries = cache(\n async (\n collection: string,\n locale: string,\n page: number,\n perPage: number,\n ): Promise => {\n const payload = await getCachedPayload()\n return getArchiveEntries({ collection, locale, page, payload, perPage })\n },\n )\n\n /**\n * Ready-made handler for Next's `app/sitemap.ts` — every page and entry with\n * per-URL hreflang and lastmod. Re-export it directly:\n *\n * ```ts\n * // app/sitemap.ts\n * export { sitemap as default } from '@/lib/content'\n * export const dynamic = 'force-dynamic' // generate at runtime, not build\n * ```\n *\n * IMPORTANT — container deploys (Coolify/Docker/Railway/CI): Next treats\n * sitemap.ts as STATIC by default and prerenders it during `next build`, which\n * calls into Payload → the database. The build container usually has no access\n * to the internal Docker network, so the DB connection fails (ENOTFOUND) and\n * the build dies. Two defenses:\n * 1. `export const dynamic = 'force-dynamic'` in app/sitemap.ts — skips build\n * prerender, generates at runtime when the DB is reachable (recommended).\n * 2. This handler also catches DB errors and returns [] so that even without\n * (1) the build won't crash — it just ships an empty sitemap until the\n * next runtime regeneration. (1) is still preferred; (2) is a safety net.\n */\n const sitemap = cache(async (): Promise => {\n if (!i18n) {\n throw new Error(\n '[ipal] createContentHelpers: pass `i18n` to use the sitemap handler.',\n )\n }\n try {\n return await buildSitemapEntries({\n baseUrl: origin,\n config: i18n,\n content,\n pagesSlug,\n payload: await getCachedPayload(),\n settingsSlug,\n })\n } catch (error) {\n // DB unreachable (typically a container build with no DB network) — return\n // an empty sitemap instead of failing the build. Runtime regeneration will\n // produce the real one once the DB is reachable. See dynamic='force-dynamic'.\n console.warn(\n '[ipal] sitemap: could not reach the database, returning empty entries ' +\n \"(add `export const dynamic = 'force-dynamic'` to app/sitemap.ts to \" +\n 'generate at runtime and avoid build-time DB access):',\n error,\n )\n return []\n }\n })\n\n /**\n * Ready-made handler for Next's `app/robots.ts`. Re-export directly:\n *\n * ```ts\n * // app/robots.ts\n * export { robots as default } from '@/lib/content'\n * ```\n */\n const robots = (): RobotsRules => buildRobots({ ...robotsOptions, baseUrl: origin })\n\n /**\n * Next.js generateStaticParams for the [[...slug]] route (or\n * [locale]/[[...slug]]). Returns every routable page as a params object, so\n * Next PRE-RENDERS them as static (SSG) instead of dynamic.\n *\n * Why this matters beyond convenience: an optional catch-all with no\n * generateStaticParams is treated as a DYNAMIC route (ƒ), which streams\n * metadata into (crawlers miss it). Providing generateStaticParams\n * compiles routes as SSG (●) — the is synchronous and complete. This is\n * the strongest fix for the metadata-in-head problem (stronger than ISR alone).\n *\n * Handles automatically:\n * - pages collection + content collections (with their archive prefix)\n * - excludes the homepage (maps to { slug: [] } — the root)\n * - excludes drafts and 404/500/system slugs\n * - KEEPS noindex pages (they must still render — noindex controls indexing,\n * not existence; skipping them would force dynamic rendering)\n * - localized slugs (string or per-locale map) both handled\n * - single-locale → { slug }[]; multi-locale → { locale, slug }[]\n *\n * Wire it in the project:\n * // app/(frontend)/[[...slug]]/page.tsx (or [locale]/[[...slug]])\n * export { generateStaticParams } from '@/lib/content'\n */\n const generateStaticParams = async (): Promise<\n Array<{ locale: string; slug: string[] } | { slug: string[] }>\n > => {\n try {\n const payload = await getCachedPayload()\n const locales = i18n ? i18n.locales.map((l) => l.code) : [undefined]\n const singleLocale = !i18n || i18n.locales.length === 1\n\n // Home slug per locale, to exclude the homepage (it's the root, slug []).\n const settings = (await payload\n .findGlobal({ slug: settingsSlug as never, depth: 1, locale: 'all' as never })\n .catch(() => null)) as {\n homepage?: { id?: number | string; slug?: unknown }\n notFound?: { id?: number | string } | null\n } | null\n const homeId = settings?.homepage?.id\n // The assigned 404 page renders via not-found.tsx, never as its own URL.\n const notFoundId =\n settings?.notFound?.id !== undefined && settings.notFound.id !== homeId\n ? settings.notFound.id\n : undefined\n\n const EXCLUDED = new Set(['404', '500', 'error', 'not-found'])\n const params: Array<{ locale: string; slug: string[] } | { slug: string[] }> = []\n\n for (const locale of locales) {\n // NO where:{_status} filter — collections without drafts enabled don't\n // register the _status field, and querying it throws\n // \"path cannot be queried: _status\". We filter drafts in memory below,\n // which is safe for every collection (with or without drafts).\n const result = await payload.find({\n collection: pagesSlug as never,\n depth: 0,\n limit: 1000,\n locale: (locale ?? 'all') as never,\n })\n\n for (const raw of result.docs as Array<{\n _status?: string\n id: number | string\n meta?: { noindex?: boolean } | null\n slug?: unknown\n }>) {\n // Draft filter in memory (safe whether or not the collection has drafts).\n if (raw._status && raw._status !== 'published') {continue}\n if (notFoundId !== undefined && raw.id === notFoundId) {continue}\n\n // NOTE: unlike the sitemap, we do NOT skip meta.noindex here. A noindex\n // page (privacy, cookies, terms) still needs to render — users reach it\n // from the footer and crawlers read its . Pre-render\n // it as SSG so it's fast and its is complete; noindex controls\n // INDEXING, not whether the page exists. Skipping it would force dynamic\n // rendering (the very streaming problem we're avoiding).\n\n if (homeId && raw.id === homeId) {\n // Homepage → root. Emit an empty-slug param so '/' (or '/pl') builds.\n const empty = singleLocale ? { slug: [] } : { slug: [], locale: locale as string }\n if (!params.some((p) => JSON.stringify(p) === JSON.stringify(empty))) {params.push(empty)}\n continue\n }\n\n // Slug may be a plain string OR a localized map ({ pl: 'kontakt' }) when\n // read with locale:'all' or left unflattened. Handle both, or localized\n // pages get silently dropped.\n const rawSlug = raw.slug\n const slug =\n typeof rawSlug === 'string'\n ? rawSlug\n : rawSlug && typeof rawSlug === 'object'\n ? ((rawSlug as Record)[locale ?? ''] as string | undefined) ??\n (Object.values(rawSlug as Record)[0] as string | undefined)\n : undefined\n\n if (!slug || EXCLUDED.has(slug)) {continue}\n\n // Multi-level slugs ('atrakcje/telefon') → array segments.\n const segments = String(slug).split('/').filter(Boolean)\n params.push(singleLocale ? { slug: segments } : { slug: segments, locale: locale as string })\n }\n }\n\n return params\n } catch (err) {\n // DB unreachable — typically a container build (Docker/Coolify/CI) with no\n // database network. Return [] so the build doesn't crash: Next falls back\n // to on-demand rendering for the routes, which fill in once the DB is\n // reachable at runtime. Without this every project would need its own\n // try/catch here. (Same graceful-degradation as the sitemap handler.)\n console.warn(\n '[ipal] generateStaticParams: database not reachable during build ' +\n '(Docker/CI) — returning empty params; routes render on-demand at runtime:',\n err,\n )\n return []\n }\n }\n\n /**\n * Route handler for app/sitemap.xml/route.ts — XML for crawlers, styled for\n * people (`?style` serves the CSS from the plugin; nothing in /public):\n *\n * export { sitemapRoute as GET } from '@/lib/content'\n * export const dynamic = 'force-dynamic'\n */\n const sitemapRoute = createSitemapRouteHandler(sitemap, {\n style:\n sitemapStyle === false\n ? false\n : {\n ...sitemapStyle,\n title:\n sitemapStyle?.title ??\n (async () => {\n const locale = i18n?.defaultLocale\n if (!locale) {return undefined}\n const s = (await getSettings(locale)) as Record\n const name = s?.[siteNameField]\n return typeof name === 'string' ? name : undefined\n }),\n },\n })\n\n return {\n generatePageMetadata,\n generateStaticParams,\n getCachedPayload,\n getConfiguredLocales,\n getEntries,\n getNotFoundPage,\n getSettings,\n resolveRoute,\n robots,\n sitemap,\n sitemapRoute,\n }\n}\n"],"names":["getPayload","cache","getArchiveEntries","resolveRoute","resolveRouteRaw","buildRobots","buildSitemapEntries","createPageMetadata","createSitemapRouteHandler","createContentHelpers","baseUrl","config","content","i18n","pagesSlug","robots","robotsOptions","settingsSlug","sitemapStyle","siteNameField","origin","process","env","NEXT_PUBLIC_SERVER_URL","getCachedPayload","getConfiguredLocales","c","localization","locales","map","l","code","getSettings","locale","payload","findGlobal","slug","depth","segments","page","settings","pageMetadata","generatePageMetadata","Error","undefined","collection","loaders","getNotFoundPageId","rel","notFound","id","getNotFoundPage","doc","findByID","getEntries","perPage","sitemap","error","console","warn","generateStaticParams","singleLocale","length","catch","homeId","homepage","notFoundId","EXCLUDED","Set","params","result","find","limit","raw","docs","_status","empty","some","p","JSON","stringify","push","rawSlug","Object","values","has","String","split","filter","Boolean","err","sitemapRoute","style","title","defaultLocale","s","name"],"mappings":"AAEA,SAASA,UAAU,QAAQ,UAAS;AACpC,SAASC,KAAK,QAAQ,QAAO;AAM7B,SAASC,iBAAiB,EAAEC,gBAAgBC,eAAe,QAAQ,sBAAqB;AACxF,SAASC,WAAW,EAAEC,mBAAmB,EAAEC,kBAAkB,EAAEC,yBAAyB,QAAQ,kBAAiB;AAyCjH;;;;;;;;;;;;;;;;;;;;;;;;;CAyBC,GACD,OAAO,SAASC,qBAAqB,EACnCC,OAAO,EACPC,MAAM,EACNC,OAAO,EACPC,IAAI,EACJC,YAAY,OAAO,EACnBC,QAAQC,aAAa,EACrBC,eAAe,eAAe,EAC9BC,YAAY,EACZC,gBAAgB,UAAU,EACD;IACzB,MAAMC,SAASV,WAAWW,QAAQC,GAAG,CAACC,sBAAsB,IAAI;IAChE,MAAMC,mBAAmBvB,MACvB,UAAkCD,WAAW;YAAEW,QAAQ,MAAMA;QA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GAAG,CAAC5E,cAAc;gBAC/B,OAAO,OAAO6E,SAAS,WAAWA,OAAOpD;YAC3C,CAAA;QACJ;IACR;IAEA,OAAO;QACLF;QACAkB;QACApC;QACAC;QACA6B;QACAH;QACAnB;QACA7B;QACAY;QACAyC;QACAmC;IACF;AACF"} \ No newline at end of file diff --git a/dist/modules/seo/index.d.ts b/dist/modules/seo/index.d.ts index a4c91be..4b8c67d 100644 --- a/dist/modules/seo/index.d.ts +++ b/dist/modules/seo/index.d.ts @@ -1,38 +1,41 @@ -export { buildAutoFillMetaHook } from './autoFillMeta.js'; -export type { AutoFillMapping } from './autoFillMeta.js'; -export { buildArticleJsonLd } from './buildArticleJsonLd.js'; -export { buildBreadcrumbJsonLd } from './buildBreadcrumbJsonLd.js'; -export { buildFaqJsonLd } from './buildFaqJsonLd.js'; -export { buildIconsMetadata } from './buildIconsMetadata.js'; -export { buildLlmsTxt } from './buildLlmsTxt.js'; -export { buildLocalBusinessJsonLd } from './buildLocalBusinessJsonLd.js'; -export { createManifestHandler } from './buildManifest.js'; +export type { SeoOption, SeoMeta } from './types.js'; +export { composeTitle } from './composeTitle.js'; +export type { TitleOrder } from './composeTitle.js'; +export { buildHreflangAlternates } from './hreflang.js'; export { buildMetadata } from './buildMetadata.js'; export type { PageMetadata } from './buildMetadata.js'; -export { buildNoindexField } from './buildNoindexField.js'; -export { buildOrganizationJsonLd } from './buildOrganizationJsonLd.js'; -export { AI_ASSISTANT_BOTS, AI_TRAINING_BOTS, buildRobots } from './buildRobots.js'; -export type { RobotsOptions, RobotsRules } from './buildRobots.js'; -export { buildServiceJsonLd } from './buildServiceJsonLd.js'; +export { buildSeoPlugin } from './seoPluginConfig.js'; +export { buildAutoFillMetaHook } from './autoFillMeta.js'; +export { injectAutoFillMeta } from './injectAutoFillMeta.js'; +export { injectSeoTabs } from './injectSeoTabs.js'; +export type { AutoFillMapping } from './autoFillMeta.js'; +export { createMetadataGenerator } from './createMetadataGenerator.js'; +export { createPageMetadata } from './createPageMetadata.js'; +export { readSiteMetaConfig } from './readSiteMetaConfig.js'; +export type { SiteMetaConfig } from './readSiteMetaConfig.js'; +export { slugsAcrossLocales } from './slugsAcrossLocales.js'; export { buildSitemapEntries } from './buildSitemapEntries.js'; -export type { SitemapEntry } from './buildSitemapEntries.js'; export { buildSitemapXml } from './buildSitemapXml.js'; -export { buildSiteNavigationJsonLd } from './buildSiteNavigationJsonLd.js'; +export type { SitemapEntry } from './buildSitemapEntries.js'; +export { buildRobots, AI_ASSISTANT_BOTS, AI_TRAINING_BOTS } from './buildRobots.js'; +export type { RobotsRules, RobotsOptions } from './buildRobots.js'; +export { buildIconsMetadata } from './buildIconsMetadata.js'; +export { buildOrganizationJsonLd } from './buildOrganizationJsonLd.js'; +export { validateFaviconField } from './validateFavicon.js'; +export { buildNoindexField } from './buildNoindexField.js'; export { buildSpeakableJsonLd } from './buildSpeakableJsonLd.js'; export { buildSummaryField } from './buildSummaryField.js'; export { buildWebSiteJsonLd } from './buildWebSiteJsonLd.js'; -export { composeTitle } from './composeTitle.js'; -export type { TitleOrder } from './composeTitle.js'; -export { createMetadataGenerator } from './createMetadataGenerator.js'; -export { createPageMetadata } from './createPageMetadata.js'; -export { buildHreflangAlternates } from './hreflang.js'; -export { injectAutoFillMeta } from './injectAutoFillMeta.js'; -export { injectSeoTabs } from './injectSeoTabs.js'; -export { JsonLdGraph } from './JsonLdGraph.js'; -export { readSiteMetaConfig } from './readSiteMetaConfig.js'; -export type { SiteMetaConfig } from './readSiteMetaConfig.js'; +export { buildBreadcrumbJsonLd } from './buildBreadcrumbJsonLd.js'; +export { buildSiteNavigationJsonLd } from './buildSiteNavigationJsonLd.js'; +export { buildLocalBusinessJsonLd } from './buildLocalBusinessJsonLd.js'; +export { buildFaqJsonLd } from './buildFaqJsonLd.js'; +export { buildServiceJsonLd } from './buildServiceJsonLd.js'; +export { buildArticleJsonLd } from './buildArticleJsonLd.js'; +export { buildLlmsTxt } from './buildLlmsTxt.js'; export { createLlmsTxtRoute, createSitemapRouteHandler } from './routeHandlers.js'; -export { buildSeoPlugin } from './seoPluginConfig.js'; -export { slugsAcrossLocales } from './slugsAcrossLocales.js'; -export type { SeoMeta, SeoOption } from './types.js'; -export { validateFaviconField } from './validateFavicon.js'; +export type { SitemapRouteOptions } from './routeHandlers.js'; +export { buildSitemapCss, SITEMAP_STYLE_PARAM, DEFAULT_SITEMAP_CREDIT } from './sitemapStyle.js'; +export type { SitemapStyleOptions } from './sitemapStyle.js'; +export { createManifestHandler } from './buildManifest.js'; +export { JsonLdGraph } from './JsonLdGraph.js'; diff --git a/dist/modules/seo/index.js b/dist/modules/seo/index.js index 1c9b8ce..634a2ae 100644 --- a/dist/modules/seo/index.js +++ b/dist/modules/seo/index.js @@ -1,33 +1,34 @@ -export { buildAutoFillMetaHook } from './autoFillMeta.js'; -export { buildArticleJsonLd } from './buildArticleJsonLd.js'; -export { buildBreadcrumbJsonLd } from './buildBreadcrumbJsonLd.js'; -export { buildFaqJsonLd } from './buildFaqJsonLd.js'; -export { buildIconsMetadata } from './buildIconsMetadata.js'; -export { buildLlmsTxt } from './buildLlmsTxt.js'; -export { buildLocalBusinessJsonLd } from './buildLocalBusinessJsonLd.js'; -export { createManifestHandler } from './buildManifest.js'; +export { composeTitle } from './composeTitle.js'; +export { buildHreflangAlternates } from './hreflang.js'; export { buildMetadata } from './buildMetadata.js'; -export { buildNoindexField } from './buildNoindexField.js'; -export { buildOrganizationJsonLd } from './buildOrganizationJsonLd.js'; -export { AI_ASSISTANT_BOTS, AI_TRAINING_BOTS, buildRobots } from './buildRobots.js'; -export { buildServiceJsonLd } from './buildServiceJsonLd.js'; +export { buildSeoPlugin } from './seoPluginConfig.js'; +export { buildAutoFillMetaHook } from './autoFillMeta.js'; +export { injectAutoFillMeta } from './injectAutoFillMeta.js'; +export { injectSeoTabs } from './injectSeoTabs.js'; +export { createMetadataGenerator } from './createMetadataGenerator.js'; +export { createPageMetadata } from './createPageMetadata.js'; +export { readSiteMetaConfig } from './readSiteMetaConfig.js'; +export { slugsAcrossLocales } from './slugsAcrossLocales.js'; export { buildSitemapEntries } from './buildSitemapEntries.js'; export { buildSitemapXml } from './buildSitemapXml.js'; -export { buildSiteNavigationJsonLd } from './buildSiteNavigationJsonLd.js'; +export { buildRobots, AI_ASSISTANT_BOTS, AI_TRAINING_BOTS } from './buildRobots.js'; +export { buildIconsMetadata } from './buildIconsMetadata.js'; +export { buildOrganizationJsonLd } from './buildOrganizationJsonLd.js'; +export { validateFaviconField } from './validateFavicon.js'; +export { buildNoindexField } from './buildNoindexField.js'; export { buildSpeakableJsonLd } from './buildSpeakableJsonLd.js'; export { buildSummaryField } from './buildSummaryField.js'; export { buildWebSiteJsonLd } from './buildWebSiteJsonLd.js'; -export { composeTitle } from './composeTitle.js'; -export { createMetadataGenerator } from './createMetadataGenerator.js'; -export { createPageMetadata } from './createPageMetadata.js'; -export { buildHreflangAlternates } from './hreflang.js'; -export { injectAutoFillMeta } from './injectAutoFillMeta.js'; -export { injectSeoTabs } from './injectSeoTabs.js'; -export { JsonLdGraph } from './JsonLdGraph.js'; -export { readSiteMetaConfig } from './readSiteMetaConfig.js'; +export { buildBreadcrumbJsonLd } from './buildBreadcrumbJsonLd.js'; +export { buildSiteNavigationJsonLd } from './buildSiteNavigationJsonLd.js'; +export { buildLocalBusinessJsonLd } from './buildLocalBusinessJsonLd.js'; +export { buildFaqJsonLd } from './buildFaqJsonLd.js'; +export { buildServiceJsonLd } from './buildServiceJsonLd.js'; +export { buildArticleJsonLd } from './buildArticleJsonLd.js'; +export { buildLlmsTxt } from './buildLlmsTxt.js'; export { createLlmsTxtRoute, createSitemapRouteHandler } from './routeHandlers.js'; -export { buildSeoPlugin } from './seoPluginConfig.js'; -export { slugsAcrossLocales } from './slugsAcrossLocales.js'; -export { validateFaviconField } from './validateFavicon.js'; +export { buildSitemapCss, SITEMAP_STYLE_PARAM, DEFAULT_SITEMAP_CREDIT } from './sitemapStyle.js'; +export { createManifestHandler } from './buildManifest.js'; +export { JsonLdGraph } from './JsonLdGraph.js'; //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/modules/seo/index.js.map b/dist/modules/seo/index.js.map index 8b0d56d..578c3b6 100644 --- a/dist/modules/seo/index.js.map +++ b/dist/modules/seo/index.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../../src/modules/seo/index.ts"],"sourcesContent":["export { buildAutoFillMetaHook } from './autoFillMeta.js'\nexport type { AutoFillMapping } from './autoFillMeta.js'\nexport { buildArticleJsonLd } from './buildArticleJsonLd.js'\nexport { buildBreadcrumbJsonLd } from './buildBreadcrumbJsonLd.js'\nexport { buildFaqJsonLd } from './buildFaqJsonLd.js'\nexport { buildIconsMetadata } from './buildIconsMetadata.js'\nexport { buildLlmsTxt } from './buildLlmsTxt.js'\nexport { buildLocalBusinessJsonLd } from './buildLocalBusinessJsonLd.js'\nexport { createManifestHandler } from './buildManifest.js'\nexport { buildMetadata } from './buildMetadata.js'\nexport type { PageMetadata } from './buildMetadata.js'\nexport { buildNoindexField } from './buildNoindexField.js'\nexport { buildOrganizationJsonLd } from './buildOrganizationJsonLd.js'\nexport { AI_ASSISTANT_BOTS, AI_TRAINING_BOTS, buildRobots } from './buildRobots.js'\nexport type { RobotsOptions, RobotsRules } from './buildRobots.js'\nexport { buildServiceJsonLd } from './buildServiceJsonLd.js'\nexport { buildSitemapEntries } from './buildSitemapEntries.js'\nexport type { SitemapEntry } from './buildSitemapEntries.js'\nexport { buildSitemapXml } from './buildSitemapXml.js'\nexport { buildSiteNavigationJsonLd } from './buildSiteNavigationJsonLd.js'\nexport { buildSpeakableJsonLd } from './buildSpeakableJsonLd.js'\nexport { buildSummaryField } from './buildSummaryField.js'\nexport { buildWebSiteJsonLd } from './buildWebSiteJsonLd.js'\nexport { composeTitle } from './composeTitle.js'\nexport type { TitleOrder } from './composeTitle.js'\nexport { createMetadataGenerator } from './createMetadataGenerator.js'\nexport { createPageMetadata } from './createPageMetadata.js'\nexport { buildHreflangAlternates } from './hreflang.js'\nexport { injectAutoFillMeta } from './injectAutoFillMeta.js'\nexport { injectSeoTabs } from './injectSeoTabs.js'\nexport { JsonLdGraph } from './JsonLdGraph.js'\nexport { readSiteMetaConfig } from './readSiteMetaConfig.js'\nexport type { SiteMetaConfig } from './readSiteMetaConfig.js'\nexport { createLlmsTxtRoute, createSitemapRouteHandler } from './routeHandlers.js'\nexport { buildSeoPlugin } from './seoPluginConfig.js'\nexport { slugsAcrossLocales } from './slugsAcrossLocales.js'\nexport type { SeoMeta, SeoOption } from './types.js'\nexport { validateFaviconField } from './validateFavicon.js'\n"],"names":["buildAutoFillMetaHook","buildArticleJsonLd","buildBreadcrumbJsonLd","buildFaqJsonLd","buildIconsMetadata","buildLlmsTxt","buildLocalBusinessJsonLd","createManifestHandler","buildMetadata","buildNoindexField","buildOrganizationJsonLd","AI_ASSISTANT_BOTS","AI_TRAINING_BOTS","buildRobots","buildServiceJsonLd","buildSitemapEntries","buildSitemapXml","buildSiteNavigationJsonLd","buildSpeakableJsonLd","buildSummaryField","buildWebSiteJsonLd","composeTitle","createMetadataGenerator","createPageMetadata","buildHreflangAlternates","injectAutoFillMeta","injectSeoTabs","JsonLdGraph","readSiteMetaConfig","createLlmsTxtRoute","createSitemapRouteHandler","buildSeoPlugin","slugsAcrossLocales","validateFaviconField"],"mappings":"AAAA,SAASA,qBAAqB,QAAQ,oBAAmB;AAEzD,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,qBAAqB,QAAQ,6BAA4B;AAClE,SAASC,cAAc,QAAQ,sBAAqB;AACpD,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,wBAAwB,QAAQ,gCAA+B;AACxE,SAASC,qBAAqB,QAAQ,qBAAoB;AAC1D,SAASC,aAAa,QAAQ,qBAAoB;AAElD,SAASC,iBAAiB,QAAQ,yBAAwB;AAC1D,SAASC,uBAAuB,QAAQ,+BAA8B;AACtE,SAASC,iBAAiB,EAAEC,gBAAgB,EAAEC,WAAW,QAAQ,mBAAkB;AAEnF,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,mBAAmB,QAAQ,2BAA0B;AAE9D,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,yBAAyB,QAAQ,iCAAgC;AAC1E,SAASC,oBAAoB,QAAQ,4BAA2B;AAChE,SAASC,iBAAiB,QAAQ,yBAAwB;AAC1D,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,YAAY,QAAQ,oBAAmB;AAEhD,SAASC,uBAAuB,QAAQ,+BAA8B;AACtE,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,uBAAuB,QAAQ,gBAAe;AACvD,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,WAAW,QAAQ,mBAAkB;AAC9C,SAASC,kBAAkB,QAAQ,0BAAyB;AAE5D,SAASC,kBAAkB,EAAEC,yBAAyB,QAAQ,qBAAoB;AAClF,SAASC,cAAc,QAAQ,uBAAsB;AACrD,SAASC,kBAAkB,QAAQ,0BAAyB;AAE5D,SAASC,oBAAoB,QAAQ,uBAAsB"} \ No newline at end of file +{"version":3,"sources":["../../../src/modules/seo/index.ts"],"sourcesContent":["export type { SeoOption, SeoMeta } from './types.js'\nexport { composeTitle } from './composeTitle.js'\nexport type { TitleOrder } from './composeTitle.js'\nexport { buildHreflangAlternates } from './hreflang.js'\nexport { buildMetadata } from './buildMetadata.js'\nexport type { PageMetadata } from './buildMetadata.js'\nexport { buildSeoPlugin } from './seoPluginConfig.js'\nexport { buildAutoFillMetaHook } from './autoFillMeta.js'\nexport { injectAutoFillMeta } from './injectAutoFillMeta.js'\nexport { injectSeoTabs } from './injectSeoTabs.js'\nexport type { AutoFillMapping } from './autoFillMeta.js'\nexport { createMetadataGenerator } from './createMetadataGenerator.js'\nexport { createPageMetadata } from './createPageMetadata.js'\nexport { readSiteMetaConfig } from './readSiteMetaConfig.js'\nexport type { SiteMetaConfig } from './readSiteMetaConfig.js'\nexport { slugsAcrossLocales } from './slugsAcrossLocales.js'\nexport { buildSitemapEntries } from './buildSitemapEntries.js'\nexport { buildSitemapXml } from './buildSitemapXml.js'\nexport type { SitemapEntry } from './buildSitemapEntries.js'\nexport { buildRobots, AI_ASSISTANT_BOTS, AI_TRAINING_BOTS } from './buildRobots.js'\nexport type { RobotsRules, RobotsOptions } from './buildRobots.js'\nexport { buildIconsMetadata } from './buildIconsMetadata.js'\nexport { buildOrganizationJsonLd } from './buildOrganizationJsonLd.js'\nexport { validateFaviconField } from './validateFavicon.js'\nexport { buildNoindexField } from './buildNoindexField.js'\nexport { buildSpeakableJsonLd } from './buildSpeakableJsonLd.js'\nexport { buildSummaryField } from './buildSummaryField.js'\nexport { buildWebSiteJsonLd } from './buildWebSiteJsonLd.js'\nexport { buildBreadcrumbJsonLd } from './buildBreadcrumbJsonLd.js'\nexport { buildSiteNavigationJsonLd } from './buildSiteNavigationJsonLd.js'\nexport { buildLocalBusinessJsonLd } from './buildLocalBusinessJsonLd.js'\nexport { buildFaqJsonLd } from './buildFaqJsonLd.js'\nexport { buildServiceJsonLd } from './buildServiceJsonLd.js'\nexport { buildArticleJsonLd } from './buildArticleJsonLd.js'\nexport { buildLlmsTxt } from './buildLlmsTxt.js'\nexport { createLlmsTxtRoute, createSitemapRouteHandler } from './routeHandlers.js'\nexport type { SitemapRouteOptions } from './routeHandlers.js'\nexport { buildSitemapCss, SITEMAP_STYLE_PARAM, DEFAULT_SITEMAP_CREDIT } from './sitemapStyle.js'\nexport type { SitemapStyleOptions } from './sitemapStyle.js'\nexport { createManifestHandler } from './buildManifest.js'\nexport { JsonLdGraph } from './JsonLdGraph.js'\n"],"names":["composeTitle","buildHreflangAlternates","buildMetadata","buildSeoPlugin","buildAutoFillMetaHook","injectAutoFillMeta","injectSeoTabs","createMetadataGenerator","createPageMetadata","readSiteMetaConfig","slugsAcrossLocales","buildSitemapEntries","buildSitemapXml","buildRobots","AI_ASSISTANT_BOTS","AI_TRAINING_BOTS","buildIconsMetadata","buildOrganizationJsonLd","validateFaviconField","buildNoindexField","buildSpeakableJsonLd","buildSummaryField","buildWebSiteJsonLd","buildBreadcrumbJsonLd","buildSiteNavigationJsonLd","buildLocalBusinessJsonLd","buildFaqJsonLd","buildServiceJsonLd","buildArticleJsonLd","buildLlmsTxt","createLlmsTxtRoute","createSitemapRouteHandler","buildSitemapCss","SITEMAP_STYLE_PARAM","DEFAULT_SITEMAP_CREDIT","createManifestHandler","JsonLdGraph"],"mappings":"AACA,SAASA,YAAY,QAAQ,oBAAmB;AAEhD,SAASC,uBAAuB,QAAQ,gBAAe;AACvD,SAASC,aAAa,QAAQ,qBAAoB;AAElD,SAASC,cAAc,QAAQ,uBAAsB;AACrD,SAASC,qBAAqB,QAAQ,oBAAmB;AACzD,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,aAAa,QAAQ,qBAAoB;AAElD,SAASC,uBAAuB,QAAQ,+BAA8B;AACtE,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,kBAAkB,QAAQ,0BAAyB;AAE5D,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,mBAAmB,QAAQ,2BAA0B;AAC9D,SAASC,eAAe,QAAQ,uBAAsB;AAEtD,SAASC,WAAW,EAAEC,iBAAiB,EAAEC,gBAAgB,QAAQ,mBAAkB;AAEnF,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,uBAAuB,QAAQ,+BAA8B;AACtE,SAASC,oBAAoB,QAAQ,uBAAsB;AAC3D,SAASC,iBAAiB,QAAQ,yBAAwB;AAC1D,SAASC,oBAAoB,QAAQ,4BAA2B;AAChE,SAASC,iBAAiB,QAAQ,yBAAwB;AAC1D,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,qBAAqB,QAAQ,6BAA4B;AAClE,SAASC,yBAAyB,QAAQ,iCAAgC;AAC1E,SAASC,wBAAwB,QAAQ,gCAA+B;AACxE,SAASC,cAAc,QAAQ,sBAAqB;AACpD,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,kBAAkB,EAAEC,yBAAyB,QAAQ,qBAAoB;AAElF,SAASC,eAAe,EAAEC,mBAAmB,EAAEC,sBAAsB,QAAQ,oBAAmB;AAEhG,SAASC,qBAAqB,QAAQ,qBAAoB;AAC1D,SAASC,WAAW,QAAQ,mBAAkB"} \ No newline at end of file diff --git a/dist/modules/seo/routeHandlers.d.ts b/dist/modules/seo/routeHandlers.d.ts index 41182a4..5f71078 100644 --- a/dist/modules/seo/routeHandlers.d.ts +++ b/dist/modules/seo/routeHandlers.d.ts @@ -1,6 +1,7 @@ import type { BasePayload } from 'payload'; import type { I18nConfig } from '../i18n/index.js'; import type { SitemapEntry } from './buildSitemapEntries.js'; +import { type SitemapStyleOptions } from './sitemapStyle.js'; /** * Ready-made Next route handler for /llms.txt. Replaces the ~60-line try/catch * every project was copying. buildLlmsTxt already handles collections without @@ -21,30 +22,38 @@ import type { SitemapEntry } from './buildSitemapEntries.js'; * baseUrl: process.env.NEXT_PUBLIC_SERVER_URL!, full: true }) */ export declare function createLlmsTxtRoute(opts: { - baseUrl: string; - config: I18nConfig; - /** Inline every page's full Markdown (llms-full.txt). Default false. */ - full?: boolean; getCachedPayload: () => Promise; + config: I18nConfig; + baseUrl: string; pagesSlug?: string; settingsSlug?: string; + /** Inline every page's full Markdown (llms-full.txt). Default false. */ + full?: boolean; /** Field holding a richer AI summary (buildSummaryField) to prefer as description. */ summaryField?: string; }): () => Promise; -/** - * 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, opts?: { +export type SitemapRouteOptions = { + /** + * Built-in browser look (default ON): the XML points at `?style` + * and the same handler serves the CSS — nothing to copy into /public. + * `false` = raw XML. Object = header/credit/accent (SitemapStyleOptions); + * `title` may be async (sitemapRoute passes the Site Settings name). + */ + style?: false | (Omit & { + title?: string | (() => Promise); + }); + /** Legacy: your own stylesheet URL (e.g. '/sitemap.css'). Overrides `style`. */ cssUrl?: string; -}): () => Promise; +}; +/** + * Ready-made Next route handler for /sitemap.xml, styled for humans out of the box. + * Usually you don't call this — `createContentHelpers` returns `sitemapRoute`: + * + * // app/sitemap.xml/route.ts — the whole file + * export { sitemapRoute as GET } from '@/lib/content' + * export const dynamic = 'force-dynamic' + * + * `GET /sitemap.xml` → XML (crawlers), `GET /sitemap.xml?style` → its CSS. + * Don't keep app/sitemap.ts next to it — two sitemaps confuse crawlers. + */ +export declare function createSitemapRouteHandler(sitemap: () => Promise, opts?: SitemapRouteOptions): (req?: Request) => Promise; diff --git a/dist/modules/seo/routeHandlers.js b/dist/modules/seo/routeHandlers.js index 614f82d..1c14fe1 100644 --- a/dist/modules/seo/routeHandlers.js +++ b/dist/modules/seo/routeHandlers.js @@ -1,5 +1,6 @@ import { buildLlmsTxt } from './buildLlmsTxt.js'; import { buildSitemapXml } from './buildSitemapXml.js'; +import { buildSitemapCss, SITEMAP_STYLE_PARAM } from './sitemapStyle.js'; /** * Ready-made Next route handler for /llms.txt. Replaces the ~60-line try/catch * every project was copying. buildLlmsTxt already handles collections without @@ -23,12 +24,12 @@ import { buildSitemapXml } from './buildSitemapXml.js'; try { const payload = await opts.getCachedPayload(); const body = await buildLlmsTxt({ - baseUrl: opts.baseUrl, - config: opts.config, - full: opts.full, - pagesSlug: opts.pagesSlug, payload, + config: opts.config, + baseUrl: opts.baseUrl, + pagesSlug: opts.pagesSlug, settingsSlug: opts.settingsSlug, + full: opts.full, summaryField: opts.summaryField }); return new Response(body, { @@ -49,24 +50,42 @@ import { buildSitemapXml } from './buildSitemapXml.js'; }; } /** - * 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. + * Ready-made Next route handler for /sitemap.xml, styled for humans out of the box. + * Usually you don't call this — `createContentHelpers` returns `sitemapRoute`: * - * // app/sitemap.xml/route.ts - * import { createSitemapRouteHandler } from '@intecion/ipal-kit' - * import { sitemap } from '@/lib/content' + * // app/sitemap.xml/route.ts — the whole file + * export { sitemapRoute as GET } 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). + * `GET /sitemap.xml` → XML (crawlers), `GET /sitemap.xml?style` → its CSS. + * Don't keep app/sitemap.ts next to it — two sitemaps confuse crawlers. */ export function createSitemapRouteHandler(sitemap, opts = {}) { - return async ()=>{ + const style = opts.cssUrl ? false : opts.style === false ? false : opts.style ?? {}; + return async (req)=>{ + const url = req ? new URL(req.url) : null; + if (style && url?.searchParams.has(SITEMAP_STYLE_PARAM)) { + let title; + try { + title = typeof style.title === 'function' ? await style.title() : style.title; + } catch { + title = undefined; // DB down → generic heading, never a broken stylesheet + } + return new Response(buildSitemapCss({ + ...style, + title + }), { + headers: { + 'Content-Type': 'text/css; charset=utf-8', + 'Cache-Control': 'public, max-age=3600', + 'X-Robots-Tag': 'noindex' + } + }); + } + const cssUrl = opts.cssUrl ?? (style ? `${url?.pathname ?? '/sitemap.xml'}?${SITEMAP_STYLE_PARAM}` : undefined); try { const entries = await sitemap(); const xml = buildSitemapXml(entries, { - cssUrl: opts.cssUrl + cssUrl }); return new Response(xml, { headers: { diff --git a/dist/modules/seo/routeHandlers.js.map b/dist/modules/seo/routeHandlers.js.map index 9dbe65f..7aedd57 100644 --- a/dist/modules/seo/routeHandlers.js.map +++ b/dist/modules/seo/routeHandlers.js.map @@ -1 +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 *\n * For the full-content variant, add a second route with `full: true`:\n *\n * // app/llms-full.txt/route.ts\n * export const GET = createLlmsTxtRoute({ getCachedPayload, config: i18nConfig,\n * baseUrl: process.env.NEXT_PUBLIC_SERVER_URL!, full: true })\n */\nexport function createLlmsTxtRoute(opts: {\n baseUrl: string\n config: I18nConfig\n /** Inline every page's full Markdown (llms-full.txt). Default false. */\n full?: boolean\n getCachedPayload: () => Promise\n pagesSlug?: string\n settingsSlug?: string\n /** Field holding a richer AI summary (buildSummaryField) to prefer as description. */\n summaryField?: string\n}): () => Promise {\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 full: opts.full,\n pagesSlug: opts.pagesSlug,\n payload,\n settingsSlug: opts.settingsSlug,\n summaryField: opts.summaryField,\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,\n opts: { cssUrl?: string } = {},\n): () => Promise {\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 '\\n' +\n ''\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","full","pagesSlug","settingsSlug","summaryField","Response","headers","err","console","warn","createSitemapRouteHandler","sitemap","entries","xml","cssUrl","empty"],"mappings":"AAKA,SAASA,YAAY,QAAQ,oBAAmB;AAChD,SAASC,eAAe,QAAQ,uBAAsB;AAEtD;;;;;;;;;;;;;;;;;;CAkBC,GACD,OAAO,SAASC,mBAAmBC,IAUlC;IACC,OAAO;QACL,IAAI;YACF,MAAMC,UAAU,MAAMD,KAAKE,gBAAgB;YAC3C,MAAMC,OAAO,MAAMN,aAAa;gBAC9BO,SAASJ,KAAKI,OAAO;gBACrBC,QAAQL,KAAKK,MAAM;gBACnBC,MAAMN,KAAKM,IAAI;gBACfC,WAAWP,KAAKO,SAAS;gBACzBN;gBACAO,cAAcR,KAAKQ,YAAY;gBAC/BC,cAAcT,KAAKS,YAAY;YACjC;YACA,OAAO,IAAIC,SAASP,MAAM;gBACxBQ,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,EACtChB,OAA4B,CAAC,CAAC;IAE9B,OAAO;QACL,IAAI;YACF,MAAMiB,UAAU,MAAMD;YACtB,MAAME,MAAMpB,gBAAgBmB,SAAS;gBAAEE,QAAQnB,KAAKmB,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"} \ No newline at end of file +{"version":3,"sources":["../../../src/modules/seo/routeHandlers.ts"],"sourcesContent":["import type { BasePayload } from 'payload'\nimport type { I18nConfig } from '../i18n/index.js'\nimport { buildLlmsTxt } from './buildLlmsTxt.js'\nimport { buildSitemapXml } from './buildSitemapXml.js'\nimport type { SitemapEntry } from './buildSitemapEntries.js'\nimport { buildSitemapCss, SITEMAP_STYLE_PARAM, type SitemapStyleOptions } from './sitemapStyle.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 *\n * For the full-content variant, add a second route with `full: true`:\n *\n * // app/llms-full.txt/route.ts\n * export const GET = createLlmsTxtRoute({ getCachedPayload, config: i18nConfig,\n * baseUrl: process.env.NEXT_PUBLIC_SERVER_URL!, full: true })\n */\nexport function createLlmsTxtRoute(opts: {\n getCachedPayload: () => Promise\n config: I18nConfig\n baseUrl: string\n pagesSlug?: string\n settingsSlug?: string\n /** Inline every page's full Markdown (llms-full.txt). Default false. */\n full?: boolean\n /** Field holding a richer AI summary (buildSummaryField) to prefer as description. */\n summaryField?: string\n}): () => Promise {\n return async () => {\n try {\n const payload = await opts.getCachedPayload()\n const body = await buildLlmsTxt({\n payload,\n config: opts.config,\n baseUrl: opts.baseUrl,\n pagesSlug: opts.pagesSlug,\n settingsSlug: opts.settingsSlug,\n full: opts.full,\n summaryField: opts.summaryField,\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\nexport type SitemapRouteOptions = {\n /**\n * Built-in browser look (default ON): the XML points at `?style`\n * and the same handler serves the CSS — nothing to copy into /public.\n * `false` = raw XML. Object = header/credit/accent (SitemapStyleOptions);\n * `title` may be async (sitemapRoute passes the Site Settings name).\n */\n style?: false | (Omit & { title?: string | (() => Promise) })\n /** Legacy: your own stylesheet URL (e.g. '/sitemap.css'). Overrides `style`. */\n cssUrl?: string\n}\n\n/**\n * Ready-made Next route handler for /sitemap.xml, styled for humans out of the box.\n * Usually you don't call this — `createContentHelpers` returns `sitemapRoute`:\n *\n * // app/sitemap.xml/route.ts — the whole file\n * export { sitemapRoute as GET } from '@/lib/content'\n * export const dynamic = 'force-dynamic'\n *\n * `GET /sitemap.xml` → XML (crawlers), `GET /sitemap.xml?style` → its CSS.\n * Don't keep app/sitemap.ts next to it — two sitemaps confuse crawlers.\n */\nexport function createSitemapRouteHandler(\n sitemap: () => Promise,\n opts: SitemapRouteOptions = {},\n): (req?: Request) => Promise {\n const style = opts.cssUrl ? false : opts.style === false ? false : (opts.style ?? {})\n\n return async (req?: Request) => {\n const url = req ? new URL(req.url) : null\n\n if (style && url?.searchParams.has(SITEMAP_STYLE_PARAM)) {\n let title: string | undefined\n try {\n title = typeof style.title === 'function' ? await style.title() : style.title\n } catch {\n title = undefined // DB down → generic heading, never a broken stylesheet\n }\n return new Response(buildSitemapCss({ ...style, title }), {\n headers: {\n 'Content-Type': 'text/css; charset=utf-8',\n 'Cache-Control': 'public, max-age=3600',\n 'X-Robots-Tag': 'noindex',\n },\n })\n }\n\n const cssUrl = opts.cssUrl ?? (style ? `${url?.pathname ?? '/sitemap.xml'}?${SITEMAP_STYLE_PARAM}` : undefined)\n try {\n const entries = await sitemap()\n const xml = buildSitemapXml(entries, { 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 '\\n' +\n ''\n return new Response(empty, {\n headers: { 'Content-Type': 'application/xml; charset=utf-8' },\n })\n }\n }\n}\n"],"names":["buildLlmsTxt","buildSitemapXml","buildSitemapCss","SITEMAP_STYLE_PARAM","createLlmsTxtRoute","opts","payload","getCachedPayload","body","config","baseUrl","pagesSlug","settingsSlug","full","summaryField","Response","headers","err","console","warn","createSitemapRouteHandler","sitemap","style","cssUrl","req","url","URL","searchParams","has","title","undefined","pathname","entries","xml","empty"],"mappings":"AAEA,SAASA,YAAY,QAAQ,oBAAmB;AAChD,SAASC,eAAe,QAAQ,uBAAsB;AAEtD,SAASC,eAAe,EAAEC,mBAAmB,QAAkC,oBAAmB;AAElG;;;;;;;;;;;;;;;;;;CAkBC,GACD,OAAO,SAASC,mBAAmBC,IAUlC;IACC,OAAO;QACL,IAAI;YACF,MAAMC,UAAU,MAAMD,KAAKE,gBAAgB;YAC3C,MAAMC,OAAO,MAAMR,aAAa;gBAC9BM;gBACAG,QAAQJ,KAAKI,MAAM;gBACnBC,SAASL,KAAKK,OAAO;gBACrBC,WAAWN,KAAKM,SAAS;gBACzBC,cAAcP,KAAKO,YAAY;gBAC/BC,MAAMR,KAAKQ,IAAI;gBACfC,cAAcT,KAAKS,YAAY;YACjC;YACA,OAAO,IAAIC,SAASP,MAAM;gBACxBQ,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;AAcA;;;;;;;;;;CAUC,GACD,OAAO,SAASI,0BACdC,OAAsC,EACtChB,OAA4B,CAAC,CAAC;IAE9B,MAAMiB,QAAQjB,KAAKkB,MAAM,GAAG,QAAQlB,KAAKiB,KAAK,KAAK,QAAQ,QAASjB,KAAKiB,KAAK,IAAI,CAAC;IAEnF,OAAO,OAAOE;QACZ,MAAMC,MAAMD,MAAM,IAAIE,IAAIF,IAAIC,GAAG,IAAI;QAErC,IAAIH,SAASG,KAAKE,aAAaC,IAAIzB,sBAAsB;YACvD,IAAI0B;YACJ,IAAI;gBACFA,QAAQ,OAAOP,MAAMO,KAAK,KAAK,aAAa,MAAMP,MAAMO,KAAK,KAAKP,MAAMO,KAAK;YAC/E,EAAE,OAAM;gBACNA,QAAQC,WAAU,uDAAuD;YAC3E;YACA,OAAO,IAAIf,SAASb,gBAAgB;gBAAE,GAAGoB,KAAK;gBAAEO;YAAM,IAAI;gBACxDb,SAAS;oBACP,gBAAgB;oBAChB,iBAAiB;oBACjB,gBAAgB;gBAClB;YACF;QACF;QAEA,MAAMO,SAASlB,KAAKkB,MAAM,IAAKD,CAAAA,QAAQ,GAAGG,KAAKM,YAAY,eAAe,CAAC,EAAE5B,qBAAqB,GAAG2B,SAAQ;QAC7G,IAAI;YACF,MAAME,UAAU,MAAMX;YACtB,MAAMY,MAAMhC,gBAAgB+B,SAAS;gBAAET;YAAO;YAC9C,OAAO,IAAIR,SAASkB,KAAK;gBACvBjB,SAAS;oBAAE,gBAAgB;gBAAiC;YAC9D;QACF,EAAE,OAAOC,KAAK;YACZC,QAAQC,IAAI,CAAC,8DAA8DF;YAC3E,sEAAsE;YACtE,MAAMiB,QACJ,6CACA;YACF,OAAO,IAAInB,SAASmB,OAAO;gBACzBlB,SAAS;oBAAE,gBAAgB;gBAAiC;YAC9D;QACF;IACF;AACF"} \ No newline at end of file diff --git a/dist/modules/seo/sitemapStyle.d.ts b/dist/modules/seo/sitemapStyle.d.ts new file mode 100644 index 0000000..fac09df --- /dev/null +++ b/dist/modules/seo/sitemapStyle.d.ts @@ -0,0 +1,21 @@ +/** + * Built-in look of /sitemap.xml in a browser — served by the sitemap route itself + * (`/sitemap.xml?style`), so projects ship NO sitemap.css and copy nothing. + * Plain CSS on XML (W3C "Associating Style Sheets with XML", type="text/css") — + * not XSLT, which browsers are removing. Crawlers ignore it. + */ +export type SitemapStyleOptions = { + /** Accent colour (card hover). Default '#027bd0'. Any plain CSS colour. */ + accent?: string; + /** + * Line under the header — the technology provider. Default + * "Technology by Intecion.com". `false` hides it. + */ + credit?: false | string; + /** Header line. Default: the site name from Site Settings (sitemapRoute), else "XML Sitemap". */ + title?: string; +}; +/** Query parameter on the sitemap URL that returns the stylesheet instead of XML. */ +export declare const SITEMAP_STYLE_PARAM = "style"; +export declare const DEFAULT_SITEMAP_CREDIT = "Technology by Intecion.com"; +export declare function buildSitemapCss({ accent, credit, title }?: SitemapStyleOptions): string; diff --git a/dist/modules/seo/sitemapStyle.js b/dist/modules/seo/sitemapStyle.js new file mode 100644 index 0000000..8e57880 --- /dev/null +++ b/dist/modules/seo/sitemapStyle.js @@ -0,0 +1,70 @@ +/** + * Built-in look of /sitemap.xml in a browser — served by the sitemap route itself + * (`/sitemap.xml?style`), so projects ship NO sitemap.css and copy nothing. + * Plain CSS on XML (W3C "Associating Style Sheets with XML", type="text/css") — + * not XSLT, which browsers are removing. Crawlers ignore it. + */ /** Query parameter on the sitemap URL that returns the stylesheet instead of XML. */ export const SITEMAP_STYLE_PARAM = 'style'; +export const DEFAULT_SITEMAP_CREDIT = 'Technology by Intecion.com'; +/** CSS `content: "…"` value — escapes backslashes, quotes and newlines. */ const cssString = (s)=>`"${s.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/[\r\n]+/g, ' ')}"`; +/** Only plain colour values — the option ends up inside a stylesheet. */ const safeColor = (c, fallback)=>c && /^(#[0-9a-f]{3,8}|[a-z]+|(rgb|hsl|oklch)a?\([\d\s.,%/-]+\))$/i.test(c.trim()) ? c.trim() : fallback; +export function buildSitemapCss({ accent, credit, title } = {}) { + const heading = title?.trim() || 'XML Sitemap'; + const note = credit === false ? '' : (credit ?? DEFAULT_SITEMAP_CREDIT).trim(); + const acc = safeColor(accent, '#027bd0'); + const divider = 'padding-bottom: 1.25rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--border);'; + return `: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: ${acc}; +} +@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; + } +} +urlset { + display: flex; flex-direction: column; box-sizing: border-box; min-height: 100vh; + max-width: 1040px; margin: 0 auto; padding: 3rem 1.5rem; line-height: 1.5; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif; + background-color: var(--bg); color: var(--text-main); +} +urlset::before { + content: ${cssString(heading)}; + display: block; order: -2; font-size: 1.35rem; font-weight: 600; letter-spacing: -0.02em; + color: var(--text-main); ${note ? 'padding-bottom: 0.4rem;' : divider} +} +${note ? `urlset::after { + content: ${cssString(note)}; + display: block; order: -1; font-size: 0.8rem; color: var(--text-muted); ${divider} +} +` : ''}url { + display: block; width: 100%; order: 0; box-sizing: border-box; + background-color: var(--card); border: 1px solid var(--border); border-radius: 8px; + padding: 1rem 1.25rem; margin-bottom: 0.65rem; + transition: border-color 0.15s ease, box-shadow 0.15s ease; +} +url:hover { border-color: var(--accent); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03); } +loc { + display: block; margin-bottom: 0.45rem; word-break: break-all; line-height: 1.45; + font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace; + font-size: 0.875rem; font-weight: 500; color: var(--url-color); +} +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); } +link { + display: inline-block; font-size: 0.7rem; font-weight: 600; text-transform: uppercase; + 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; +} +link::before { content: attr(hreflang); } +`; +} + +//# sourceMappingURL=sitemapStyle.js.map \ No newline at end of file diff --git a/dist/modules/seo/sitemapStyle.js.map b/dist/modules/seo/sitemapStyle.js.map new file mode 100644 index 0000000..66c7b25 --- /dev/null +++ b/dist/modules/seo/sitemapStyle.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../src/modules/seo/sitemapStyle.ts"],"sourcesContent":["/**\n * Built-in look of /sitemap.xml in a browser — served by the sitemap route itself\n * (`/sitemap.xml?style`), so projects ship NO sitemap.css and copy nothing.\n * Plain CSS on XML (W3C \"Associating Style Sheets with XML\", type=\"text/css\") —\n * not XSLT, which browsers are removing. Crawlers ignore it.\n */\n\nexport type SitemapStyleOptions = {\n /** Accent colour (card hover). Default '#027bd0'. Any plain CSS colour. */\n accent?: string\n /**\n * Line under the header — the technology provider. Default\n * \"Technology by Intecion.com\". `false` hides it.\n */\n credit?: false | string\n /** Header line. Default: the site name from Site Settings (sitemapRoute), else \"XML Sitemap\". */\n title?: string\n}\n\n/** Query parameter on the sitemap URL that returns the stylesheet instead of XML. */\nexport const SITEMAP_STYLE_PARAM = 'style'\nexport const DEFAULT_SITEMAP_CREDIT = 'Technology by Intecion.com'\n\n/** CSS `content: \"…\"` value — escapes backslashes, quotes and newlines. */\nconst cssString = (s: string) => `\"${s.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"').replace(/[\\r\\n]+/g, ' ')}\"`\n\n/** Only plain colour values — the option ends up inside a stylesheet. */\nconst safeColor = (c: string | undefined, fallback: string) =>\n c && /^(#[0-9a-f]{3,8}|[a-z]+|(rgb|hsl|oklch)a?\\([\\d\\s.,%/-]+\\))$/i.test(c.trim()) ? c.trim() : fallback\n\nexport function buildSitemapCss({ accent, credit, title }: SitemapStyleOptions = {}): string {\n const heading = title?.trim() || 'XML Sitemap'\n const note = credit === false ? '' : (credit ?? DEFAULT_SITEMAP_CREDIT).trim()\n const acc = safeColor(accent, '#027bd0')\n const divider = 'padding-bottom: 1.25rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--border);'\n\n return `:root {\n --bg: #fafafa; --card: #ffffff; --border: #e5e7eb; --border-hover: #d1d5db;\n --text-main: #111827; --text-secondary: #4b5563; --text-muted: #9ca3af; --url-color: #1e293b;\n --badge-bg: #f3f4f6; --badge-border: #e5e7eb; --badge-text: #4b5563; --accent: ${acc};\n}\n@media (prefers-color-scheme: dark) {\n :root {\n --bg: #090a0f; --card: #12131a; --border: #1e202e; --border-hover: #2e3247;\n --text-main: #f9fafb; --text-secondary: #9ca3af; --text-muted: #6b7280; --url-color: #f3f4f6;\n --badge-bg: #1a1c26; --badge-border: #282b3d; --badge-text: #9ca3af;\n }\n}\nurlset {\n display: flex; flex-direction: column; box-sizing: border-box; min-height: 100vh;\n max-width: 1040px; margin: 0 auto; padding: 3rem 1.5rem; line-height: 1.5;\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Inter, Helvetica, Arial, sans-serif;\n background-color: var(--bg); color: var(--text-main);\n}\nurlset::before {\n content: ${cssString(heading)};\n display: block; order: -2; font-size: 1.35rem; font-weight: 600; letter-spacing: -0.02em;\n color: var(--text-main); ${note ? 'padding-bottom: 0.4rem;' : divider}\n}\n${note ? `urlset::after {\n content: ${cssString(note)};\n display: block; order: -1; font-size: 0.8rem; color: var(--text-muted); ${divider}\n}\n` : ''}url {\n display: block; width: 100%; order: 0; box-sizing: border-box;\n background-color: var(--card); border: 1px solid var(--border); border-radius: 8px;\n padding: 1rem 1.25rem; margin-bottom: 0.65rem;\n transition: border-color 0.15s ease, box-shadow 0.15s ease;\n}\nurl:hover { border-color: var(--accent); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03); }\nloc {\n display: block; margin-bottom: 0.45rem; word-break: break-all; line-height: 1.45;\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", monospace;\n font-size: 0.875rem; font-weight: 500; color: var(--url-color);\n}\nlastmod, changefreq, priority {\n display: inline-block; font-size: 0.775rem; color: var(--text-secondary);\n margin-right: 1.25rem; margin-top: 0.15rem;\n}\nlastmod::before { content: \"Updated: \"; color: var(--text-muted); }\nchangefreq::before { content: \"Frequency: \"; color: var(--text-muted); }\npriority::before { content: \"Priority: \"; color: var(--text-muted); }\nlink {\n display: inline-block; font-size: 0.7rem; font-weight: 600; text-transform: uppercase;\n background-color: var(--badge-bg); border: 1px solid var(--badge-border); color: var(--badge-text);\n padding: 0.1rem 0.45rem; border-radius: 4px; margin-right: 0.3rem; margin-top: 0.35rem;\n}\nlink::before { content: attr(hreflang); }\n`\n}\n"],"names":["SITEMAP_STYLE_PARAM","DEFAULT_SITEMAP_CREDIT","cssString","s","replace","safeColor","c","fallback","test","trim","buildSitemapCss","accent","credit","title","heading","note","acc","divider"],"mappings":"AAAA;;;;;CAKC,GAcD,mFAAmF,GACnF,OAAO,MAAMA,sBAAsB,QAAO;AAC1C,OAAO,MAAMC,yBAAyB,6BAA4B;AAElE,yEAAyE,GACzE,MAAMC,YAAY,CAACC,IAAc,CAAC,CAAC,EAAEA,EAAEC,OAAO,CAAC,OAAO,QAAQA,OAAO,CAAC,MAAM,OAAOA,OAAO,CAAC,YAAY,KAAK,CAAC,CAAC;AAE9G,uEAAuE,GACvE,MAAMC,YAAY,CAACC,GAAuBC,WACxCD,KAAK,+DAA+DE,IAAI,CAACF,EAAEG,IAAI,MAAMH,EAAEG,IAAI,KAAKF;AAElG,OAAO,SAASG,gBAAgB,EAAEC,MAAM,EAAEC,MAAM,EAAEC,KAAK,EAAuB,GAAG,CAAC,CAAC;IACjF,MAAMC,UAAUD,OAAOJ,UAAU;IACjC,MAAMM,OAAOH,WAAW,QAAQ,KAAK,AAACA,CAAAA,UAAUX,sBAAqB,EAAGQ,IAAI;IAC5E,MAAMO,MAAMX,UAAUM,QAAQ;IAC9B,MAAMM,UAAU;IAEhB,OAAO,CAAC;;;iFAGuE,EAAED,IAAI;;;;;;;;;;;;;;;;WAgB5E,EAAEd,UAAUY,SAAS;;2BAEL,EAAEC,OAAO,4BAA4BE,QAAQ;;AAExE,EAAEF,OAAO,CAAC;WACC,EAAEb,UAAUa,MAAM;0EAC6C,EAAEE,QAAQ;;AAEpF,CAAC,GAAG,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;AAyBP,CAAC;AACD"} \ No newline at end of file diff --git a/docs/agent/AGENT.md b/docs/agent/AGENT.md index 318b6f6..5c6db07 100644 --- a/docs/agent/AGENT.md +++ b/docs/agent/AGENT.md @@ -165,7 +165,8 @@ src/ [[...slug]]/page.tsx # PODWÓJNE nawiasy; RenderBlocks (payload)/ # panel (generowany) manifest.ts # createManifestHandler + force-dynamic - sitemap.ts, robots.ts # z lib/content (+ force-dynamic na sitemap) + sitemap.xml/route.ts # sitemapRoute z lib/content + force-dynamic (wygląd z pluginu) + robots.ts # z lib/content api/health/route.ts # createHealthRoute instrumentation.ts # assertEnv(ipalEnvRules({...})) fields/ # sectionHeader.ts, sectionSettings.ts (linki: z pluginu) @@ -218,7 +219,7 @@ Bez skrótów (`HeroSection`, nie `HeroSec`). Nie twórz `lib/pages.ts`, Locale do bloków → `enhanceProps`; w `not-found.tsx` (brak `params`) → wersja na każdy język + `` (pages.md). 7. **`export const dynamic = 'force-dynamic'`** na trasach czytających bazę: - `manifest.ts`, `sitemap.ts`/`sitemap.xml`, `llms.txt`, `api/health`. Handlery + `manifest.ts`, `sitemap.xml/route.ts`, `llms.txt`, `api/health`. Handlery pluginu mają try/catch, ale `dynamic` musi być w pliku trasy. 8. **`instrumentation.ts`** z `assertEnv(ipalEnvRules({...}))` (env.md). 9. **RSC domyślnie.** `'use client'` tylko dla stanu/interakcji, w osobnym pliku; diff --git a/docs/agent/skills/ipal-audit/scripts/audit.sh b/docs/agent/skills/ipal-audit/scripts/audit.sh index f05d92d..7d8da4d 100644 --- a/docs/agent/skills/ipal-audit/scripts/audit.sh +++ b/docs/agent/skills/ipal-audit/scripts/audit.sh @@ -55,6 +55,15 @@ if [ -d .agents ] && [ -f tsconfig.json ]; then "$(grep -qE '"exclude"[^]]*\.agents' tsconfig.json || echo tsconfig.json)" fi +# --- Sitemap: one route, look from the plugin (seo.md) --- +SM_TS=$(ls src/app/sitemap.ts 2>/dev/null) +SM_ROUTE=$(ls src/app/sitemap.xml/route.ts 2>/dev/null) +if [ -n "$SM_TS" ] && [ -n "$SM_ROUTE" ]; then + report ERROR "two sitemaps" "seo.md — keep src/app/sitemap.xml/route.ts (sitemapRoute), delete src/app/sitemap.ts" "$(printf '%s\n%s' "$SM_TS" "$SM_ROUTE")" +fi +report WARNING "project copy of the sitemap stylesheet" "seo.md — sitemapRoute serves the look from the plugin; delete it (and cssUrl)" \ + "$(ls public/sitemap.css 2>/dev/null)" + # --- Architecture (AGENT.md §4) --- report ERROR "middleware.ts exists" "§4.1 Next 16 uses proxy.ts only" \ "$(ls src/middleware.ts middleware.ts 2>/dev/null)" diff --git a/docs/agent/skills/ipal-setup/SKILL.md b/docs/agent/skills/ipal-setup/SKILL.md index d572553..8cdb728 100644 --- a/docs/agent/skills/ipal-setup/SKILL.md +++ b/docs/agent/skills/ipal-setup/SKILL.md @@ -30,7 +30,7 @@ tylko, gdy użytkownik o to poprosi. Pełna budowa strony: skill **ipal-site**. 6. **Routing** — `proxy.ts` (`createProxy`), `lib/content.ts`, layout bez ``, catch-all z ISR + `generateStaticParams` + `resolveRedirect`, `not-found.tsx` z `LocaleView` — bez `headers()`, wersja na każdy język (PROGRAMISTA §2.6–2.8, pages.md). -7. **SEO i bezpieczeństwo** — sitemap, robots, manifest, llms.txt, health +7. **SEO i bezpieczeństwo** — sitemap (`sitemap.xml/route.ts` = `sitemapRoute`, bez CSS w `public/`), robots, manifest, llms.txt, health (wszystkie z `force-dynamic`), `htmlLimitedBots`, `buildSecurityHeaders`, `instrumentation.ts` z `assertEnv` (PROGRAMISTA §2.8–2.9). 8. **Nawigacja** — skill **ipal-nav**. diff --git a/docs/dev/PROGRAMISTA.md b/docs/dev/PROGRAMISTA.md index ecb2c5c..33cdda9 100644 --- a/docs/dev/PROGRAMISTA.md +++ b/docs/dev/PROGRAMISTA.md @@ -279,8 +279,8 @@ Archiwum z paginacją (`?page=`) — osobna trasa albo świadomie dynamiczna (pa (przykład w pages.md). ```ts -// src/app/sitemap.ts -export { sitemap as default } from '@/lib/content' +// src/app/sitemap.xml/route.ts — XML dla Google, wygląd dla ludzi z pluginu (nic w /public) +export { sitemapRoute as GET } from '@/lib/content' export const dynamic = 'force-dynamic' // src/app/robots.ts @@ -304,8 +304,9 @@ import { createHealthRoute } from '@intecion/ipal-kit' export const dynamic = 'force-dynamic' export const GET = createHealthRoute({ getCachedPayload }) ``` -Albo `sitemap.ts`, albo `sitemap.xml/route.ts` (`createSitemapRouteHandler`) — -nigdy oba. +Jeden sitemap: `sitemap.xml/route.ts` **albo** `sitemap.ts` — nigdy oba. Nagłówek +sitemapy = `siteName` z Site Settings, pod nim „Technology by Intecion.com”; zmiana +przez `createContentHelpers({ sitemapStyle })` (seo.md). ### 2.9 next.config.ts i instrumentation.ts ```ts @@ -470,6 +471,7 @@ Rób po jednej pozycji, buduj, sprawdzaj. Kolejność wg wagi: | 15c | `createPageMetadata(...)` w `page.tsx` | `generatePageMetadata(locale, slug)` z `lib/content` — wspólny cache z komponentem strony, mniej zapytań | seo.md | | 15d | brak limitów na za duże obrazy / wideo w Media | `buildOptimizeUploadHook()` + `buildOptimizeUploadField()`, migracja pola | storage.md | | 15e | tablice „Add Row”, wiersze „Item 01”, `cta1`/`cta2`, etykiety PL w panelu | `labels` + `rowLabel()` na tablicach, sloty → tablica (z migracją!), etykiety EN — AGENT.md §6.5a; po aktualizacji pluginu **`pnpm payload generate:importmap`** (buildLinksField używa `RowLabel`) | links.md | +| 15f | `public/sitemap.css` + własna trasa / `app/sitemap.ts` | `app/sitemap.xml/route.ts`: `export { sitemapRoute as GET } from '@/lib/content'` + `force-dynamic`; usuń `public/sitemap.css` i `app/sitemap.ts` | seo.md | | 16 | 404 na sztywno | rola 404 w System Pages + `getNotFoundPage` | pages.md | | 16a | `privacyPolicy: { label: 'Polityka prywatności', … }` w layoucie | usuń cały parametr; tekst wpisz w Cookie Settings → Privacy link label | consent.md | | 17 | Opcjonalnie — AI/GEO | Markdown per strona, llms-full, boty AI w robots, MCP, wyszukiwarka, speakable, aiSummary | content.md, seo.md, mcp.md | diff --git a/docs/dev/vibe.md b/docs/dev/vibe.md index 6c6e274..9656c9c 100644 --- a/docs/dev/vibe.md +++ b/docs/dev/vibe.md @@ -184,7 +184,7 @@ Sprawdź: `/` → `/`; `pnpm build` pokazuje strony jako `●` ``` Zrób wg PROGRAMISTA.md §2.8–2.9 i seo.md: -- app/sitemap.ts, robots.ts, manifest.ts (createManifestHandler), llms.txt/route.ts, +- app/sitemap.xml/route.ts (sitemapRoute z lib/content), robots.ts, manifest.ts (createManifestHandler), llms.txt/route.ts, api/health/route.ts — każda trasa czytająca bazę z export const dynamic = 'force-dynamic', - next.config.ts: htmlLimitedBots, buildSecurityHeaders, - metadata strony przez generatePageMetadata z lib/content (wspólny cache), favicon przez buildIconsMetadata, diff --git a/docs/seo.md b/docs/seo.md index 583af67..30e3f3b 100644 --- a/docs/seo.md +++ b/docs/seo.md @@ -1066,65 +1066,46 @@ Listy botów: `AI_ASSISTANT_BOTS`, `AI_TRAINING_BOTS` (eksportowane; nadpisujesz przez `aiAssistantAgents` / `aiTrainingAgents`). `Next` akceptuje `rules` jako tablicę — przy aktywnych botach AI zwracana jest tablica reguł. -## Sitemap czytelny w przeglądarce (czysty XML) +## Sitemap — czytelny w przeglądarce, zero plików w projekcie -Domyślny `/sitemap.xml` (Next MetadataRoute) działa dla Google, ale w przeglądarce -bywa nieczytelny. Możesz serwować go jako **czysty, sformatowany XML** przez -`buildSitemapXml` — przeglądarka pokaże wbudowane drzewo XML (wcięcia, zwijanie, -kolorowanie składni), bez żadnej transformacji. - -> **NIE używaj XSLT.** Przeglądarki (Chrome i in.) WYCOFUJĄ XSLT — arkusz -> `` pokazuje ostrzeżenie i wkrótce przestanie działać. -> Rozwiązanie: serwuj czysty XML z poprawnym Content-Type; przeglądarka -> renderuje swój natywny widok drzewa XML sama. +`createContentHelpers` zwraca `sitemapRoute`: XML dla crawlerów, a dla ludzi +gotowy wygląd (kafelki, pigułki hreflang, tryb jasny/ciemny) **serwowany przez +plugin z tej samej trasy** (`/sitemap.xml?style`). Projekt nie ma `sitemap.css`, +nic nie kopiuje z `node_modules`, nie podaje `cssUrl`. Cały plik trasy: ```ts -// app/sitemap.xml/route.ts (zamiast app/sitemap.ts) -import { buildSitemapXml } from '@intecion/ipal-kit' -import { sitemap } from '@/lib/content' - +// src/app/sitemap.xml/route.ts +export { sitemapRoute as GET } from '@/lib/content' export const dynamic = 'force-dynamic' - -export async function GET() { - const entries = await sitemap() - const xml = buildSitemapXml(entries) - return new Response(xml, { - headers: { 'Content-Type': 'application/xml; charset=utf-8' }, - }) -} ``` -`buildSitemapXml` zwraca wcięty XML. Dwa tryby wyświetlania: - -**Bez `cssUrl`** → przeglądarka pokazuje natywny widok drzewa XML (wcięcia, zwijanie). - -**Z `cssUrl`** → stylujesz XML własnym CSS (kafelki, etykiety). To W3C standard -„Associating Style Sheets with XML" — `type="text/css"`, NIE wycofywane (w -przeciwieństwie do XSLT/`text/xsl`). Zero ostrzeżenia, ładny wygląd, bezpieczne -dla Google (crawlery ignorują dyrektywę). +- **Nagłówek** = `siteName` z Site Settings (język domyślny); brak → „XML Sitemap”. +- **Linia pod nagłówkiem** = dostawca technologii: „Technology by Intecion.com”. +- To CSS na XML (``, standard W3C) — **nie XSLT**, + które przeglądarki wycofują. Google ignoruje dyrektywę; zero wpływu na SEO. +Zmiana wyglądu — raz, w `lib/content.ts`, nie w plikach: ```ts -const xml = buildSitemapXml(entries, { cssUrl: '/sitemap.css' }) +createContentHelpers({ + config, content, i18n: i18nConfig, + sitemapStyle: { accent: '#0f766e' }, // kolor akcentu + // sitemapStyle: { credit: false }, // bez linii dostawcy + // sitemapStyle: { title: 'Sitemap' }, // stały nagłówek zamiast siteName + // sitemapStyle: false, // surowy XML (natywny widok przeglądarki) + // siteNameField: 'name', // gdy pole nazwy w Site Settings ma inną nazwę +}) ``` -### Gotowy CSS z pluginu - -Plugin dostarcza dopracowany `sitemap.css` (auto dark/light, kafelki, pigułki -hreflang, monospace URL). Skopiuj do projektu: -```bash -cp node_modules/@intecion/ipal-kit/dist/modules/seo/assets/sitemap.css public/sitemap.css -``` -Dostosuj `--accent` i inne zmienne CSS do brandingu projektu. Selektory to nazwy -tagów XML (`urlset`, `url`, `loc`, `lastmod`, `link`). hreflang pokazuje się jako -pigułka przez `link::before { content: attr(hreflang) }`. - +Niższy poziom (bez `createContentHelpers`): `createSitemapRouteHandler(sitemap, { style })`, +`buildSitemapXml(entries, { cssUrl })`, `buildSitemapCss(options)`. Opcja `cssUrl` +(własny arkusz w `public/`) nadal działa, ale nie jest potrzebna. ### WAŻNE — jeden sitemap, nie dwa Jeśli używasz `app/sitemap.xml/route.ts`, USUŃ `app/sitemap.ts` (MetadataRoute). Dwa sitemapy pod różnymi ścieżkami mylą crawlery. Wybierz jeden: -- **route.ts + buildSitemapXml** — czytelny XML w przeglądarce -- **sitemap.ts** (reeksport z lib/content) — mniej kodu, mniej czytelny w przeglądarce +- **`sitemap.xml/route.ts` + `sitemapRoute`** (zalecane) — czytelny w przeglądarce, wygląd z pluginu +- **`sitemap.ts`** (`export { sitemap as default }`) — natywny widok XML przeglądarki Oba tak samo dobre dla Google — to kwestia czytelności dla człowieka, nie SEO. diff --git a/src/index.ts b/src/index.ts index f4a572d..70c2c63 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,20 +1,3 @@ -export { ipalKit } from './plugin.js' -export type { IpalOptions } from './types.js' -export type { I18nConfig, LocaleDefinition, LocalizedSlugs } 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 { PagesOption, SystemPageRole } from './modules/pages/index.js' -export { ALL_SYSTEM_PAGE_ROLES, getSystemPagePath } from './modules/pages/index.js' export type { AccessOption, Role } from './modules/access/index.js' export { adminOnly, @@ -30,58 +13,102 @@ export { requireRoleField, ROLE_HIERARCHY, } from './modules/access/index.js' -export type { GlobalQueryOptions } from './modules/payload/index.js' +export { A11Y_COOKIE, A11Y_DEFAULT, a11yAttributes, parseA11y, serializeA11y } from './modules/accessibility/index.js' +export type { A11yState } from './modules/accessibility/index.js' +export { rowLabel } from './modules/admin-ui/index.js' +export type { RowLabelProps } from './modules/admin-ui/index.js' +export type { AnalyticsConfig } from './modules/analytics/index.js' +export { getAnalyticsConfig } from './modules/analytics/index.js' export { - getGlobal, - getSiteSettings, - getSiteIntegrations, - SITE_SETTINGS_SLUG, - SITE_INTEGRATIONS_SLUG, -} from './modules/payload/index.js' -export type { SeoOption, SeoMeta, PageMetadata } from './modules/seo/index.js' + ACCEPT_ALL_CONSENT, + CONSENT_CATEGORIES, + CONSENT_COOKIE, + CONSENT_MAX_AGE, + CONSENT_VERSION, + DEFAULT_CONSENT, + getConsentTexts, + parseConsent, + REJECT_ALL_CONSENT, + serializeConsent, + setDefaultConsent, + updateConsent, +} from './modules/consent/index.js' +export type { ConsentCategory, ConsentState, ConsentTexts } from './modules/consent/index.js' +export type { ContentCollectionOption, ContentOption, ResolvedRoute } from './modules/content/index.js' export { - composeTitle, - buildHreflangAlternates, - buildMetadata, - readSiteMetaConfig, - slugsAcrossLocales, -} from './modules/seo/index.js' -export type { SiteMetaConfig } from './modules/seo/index.js' -export type { ContentOption, ContentCollectionOption, ResolvedRoute } from './modules/content/index.js' -export { createContentHelpers } from './modules/frontend/index.js' -export { - resolveRoute, - resolveRedirect, - resolveNotFoundPage, - blocksToMarkdown, - createMarkdownRenderer, - markdownResponse, - prefersMarkdown, - markdownHref, - MARKDOWN_PREFIX, - searchContent, - createSearchRoute, archiveFieldName, - getArchiveEntries, + blocksToMarkdown, buildArchivePath, buildEntryPath, + createMarkdownRenderer, + createSearchRoute, + getArchiveEntries, + MARKDOWN_PREFIX, + markdownHref, + markdownResponse, parsePageParam, + prefersMarkdown, + resolveNotFoundPage, + resolveRedirect, + resolveRoute, + searchContent, } from './modules/content/index.js' export type { ArchiveEntries } from './modules/content/index.js' export type { SearchResult } from './modules/content/index.js' -// Lexical → Markdown (pure, no React) — for AI-readable output. -export { lexicalToMarkdown } from './modules/richtext/index.js' -export type { AutoFillMapping, SitemapEntry, RobotsRules, RobotsOptions } from './modules/seo/index.js' +export { graphAdapter } from './modules/email/graphAdapter.js' +export type { GraphAdapterArgs } from './modules/email/graphAdapter.js' +export { mailAdapter } from './modules/email/mailAdapter.js' +export type { MailAdapterArgs } from './modules/email/mailAdapter.js' +// Imported straight from the file, NOT from ./modules/email/index.js — that +// barrel re-exports sendEmail, which imports 'server-only' and would crash when +// Payload loads the config (or runs generate:importmap) as a plain Node script. +export { panelSmtpAdapter } from './modules/email/panelSmtpAdapter.js' +export type { PanelSmtpAdapterArgs } from './modules/email/panelSmtpAdapter.js' +// Boot-time environment validation (fail fast on misconfigured deploys). +export { assertEnv, ipalEnvRules } from './modules/env/index.js' +export type { AssertEnvOptions, EnvKind, EnvRule, IpalEnvFeatures } from './modules/env/index.js' +// Panel-managed form analytics (config-time field builder). +export { buildFormAnalyticsFields } from './modules/forms/formAnalyticsFields.js' +export { buildFormsPlugin } from './modules/forms/formsPluginConfig.js' +export { HONEYPOT_FIELD, honeypotInputProps, isHoneypotTripped } from './modules/forms/honeypot.js' +export type { + FormsCollectionOverrides, + FormsFieldsOverride, + FormsOption, +} from './modules/forms/types.js' +export type { FormErrors, FormSubmitAction, Validator } from './modules/forms/useForm.js' +// Validation rules are pure — exported server-side too, for re-validating a +// submission inside a server action. (useForm/useContactForm are client-only → +// '@intecion/ipal-kit/client'.) export { - buildAutoFillMetaHook, - injectAutoFillMeta, - createMetadataGenerator, - createPageMetadata, - buildSitemapEntries, - buildRobots, - AI_ASSISTANT_BOTS, - AI_TRAINING_BOTS, -} from './modules/seo/index.js' + buildValidator, + checked, + custom, + email, + isEmail, + maxLength, + minLength, + pattern, + required, +} from './modules/forms/validators.js' +export type { Rule } from './modules/forms/validators.js' +export { createContentHelpers } from './modules/frontend/index.js' +// Healthcheck route (Coolify/Docker liveness with a real DB round-trip). +export { createHealthRoute } from './modules/health/index.js' +export { buildCrossLocaleFieldSync, buildPreventDeleteSystemPage, buildRevalidateHook, buildValidateUniqueRole, setPublishedAtHook, trackSlugHistoryHook } from './modules/hooks/index.js' +export type { I18nConfig, LocaleDefinition, LocalizedSlugs } 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 { createLocaleMiddleware, @@ -89,96 +116,70 @@ export { } from './modules/i18n/index.js' export { createProxy, DEFAULT_PROXY_MATCHER } from './modules/i18n/index.js' export { resolveLocalized } from './modules/i18n/index.js' -export { - CONSENT_CATEGORIES, - DEFAULT_CONSENT, - ACCEPT_ALL_CONSENT, - REJECT_ALL_CONSENT, - CONSENT_COOKIE, - CONSENT_VERSION, - CONSENT_MAX_AGE, - serializeConsent, - parseConsent, - setDefaultConsent, - updateConsent, - getConsentTexts, -} from './modules/consent/index.js' -export type { ConsentCategory, ConsentState, ConsentTexts } from './modules/consent/index.js' -// Imported straight from the file, NOT from ./modules/email/index.js — that -// barrel re-exports sendEmail, which imports 'server-only' and would crash when -// Payload loads the config (or runs generate:importmap) as a plain Node script. -export { panelSmtpAdapter } from './modules/email/panelSmtpAdapter.js' -export { graphAdapter } from './modules/email/graphAdapter.js' -export { mailAdapter } from './modules/email/mailAdapter.js' -export type { MailAdapterArgs } from './modules/email/mailAdapter.js' -export type { GraphAdapterArgs } from './modules/email/graphAdapter.js' -export type { PanelSmtpAdapterArgs } from './modules/email/panelSmtpAdapter.js' -export { buildFormsPlugin } from './modules/forms/formsPluginConfig.js' +export { buildLinkField, buildLinksField, resolveLinkHref } from './modules/links/index.js' export type { - FormsOption, - FormsCollectionOverrides, - FormsFieldsOverride, -} from './modules/forms/types.js' -// Validation rules are pure — exported server-side too, for re-validating a -// submission inside a server action. (useForm/useContactForm are client-only → -// '@intecion/ipal-kit/client'.) -export { - buildValidator, - isEmail, - required, - email, - minLength, - maxLength, - checked, - pattern, - custom, -} from './modules/forms/validators.js' -export type { Rule } from './modules/forms/validators.js' -export type { FormErrors, FormSubmitAction, Validator } from './modules/forms/useForm.js' -export { HONEYPOT_FIELD, honeypotInputProps, isHoneypotTripped } from './modules/forms/honeypot.js' -// Panel-managed form analytics (config-time field builder). -export { buildFormAnalyticsFields } from './modules/forms/formAnalyticsFields.js' -// Healthcheck route (Coolify/Docker liveness with a real DB round-trip). -export { createHealthRoute } from './modules/health/index.js' + BuildLinkFieldOptions, + BuildLinksFieldOptions, + LinkAppearance, + LinkValue, + ResolveLinkHrefOptions, +} from './modules/links/index.js' // Read-only MCP server (Claude/agents connect to the site and query it). export { createMcpRoute } from './modules/mcp/index.js' -// Boot-time environment validation (fail fast on misconfigured deploys). -export { assertEnv, ipalEnvRules } from './modules/env/index.js' -export type { EnvRule, EnvKind, AssertEnvOptions, IpalEnvFeatures } from './modules/env/index.js' -export type { AnalyticsConfig } from './modules/analytics/index.js' -export { getAnalyticsConfig } from './modules/analytics/index.js' -export { buildSlugField, toSlug } from './modules/slug/index.js' -export { createLlmsTxtRoute, createSitemapRouteHandler, createManifestHandler } from './modules/seo/index.js' +export { buildOptimizeUploadField, buildOptimizeUploadHook, normalizeFilename, normalizeFilenameHook } from './modules/media/index.js' +export type { OptimizeUploadOptions } from './modules/media/index.js' +export { getNotificationTexts, NOTIFICATION_FALLBACK, resolveFormMessage } from './modules/notifications/index.js' +export type { FormNotificationTexts, NotificationTexts } from './modules/notifications/index.js' +export type { PagesOption, SystemPageRole } from './modules/pages/index.js' +export { ALL_SYSTEM_PAGE_ROLES, getSystemPagePath } from './modules/pages/index.js' +export type { GlobalQueryOptions } from './modules/payload/index.js' -export { getNotificationTexts, resolveFormMessage, NOTIFICATION_FALLBACK } from './modules/notifications/index.js' +export { + getGlobal, + getSiteIntegrations, + getSiteSettings, + SITE_INTEGRATIONS_SLUG, + SITE_SETTINGS_SLUG, +} from './modules/payload/index.js' +// Lexical → Markdown (pure, no React) — for AI-readable output. +export { lexicalToMarkdown } from './modules/richtext/index.js' export { buildSecurityHeaders } from './modules/security/index.js' export { buildCsp } from './modules/security/index.js' export type { BuildCspArgs } from './modules/security/index.js' +export type { BuildSecurityHeadersArgs, SecurityHeader } from './modules/security/index.js' +export type { PageMetadata, SeoMeta, SeoOption } from './modules/seo/index.js' +export { + buildHreflangAlternates, + buildMetadata, + composeTitle, + readSiteMetaConfig, + slugsAcrossLocales, +} from './modules/seo/index.js' +export type { SiteMetaConfig } from './modules/seo/index.js' +export type { AutoFillMapping, RobotsOptions, RobotsRules, SitemapEntry } from './modules/seo/index.js' +export { + AI_ASSISTANT_BOTS, + AI_TRAINING_BOTS, + buildAutoFillMetaHook, + buildRobots, + buildSitemapEntries, + createMetadataGenerator, + createPageMetadata, + injectAutoFillMeta, +} from './modules/seo/index.js' +export { createLlmsTxtRoute, createManifestHandler, createSitemapRouteHandler } from './modules/seo/index.js' export { buildIconsMetadata, buildOrganizationJsonLd, validateFaviconField } from './modules/seo/index.js' export { buildNoindexField } from './modules/seo/index.js' -export { rowLabel } from './modules/admin-ui/index.js' -export type { RowLabelProps } from './modules/admin-ui/index.js' -export { buildLinkField, buildLinksField, resolveLinkHref } from './modules/links/index.js' -export type { - LinkAppearance, - LinkValue, - BuildLinkFieldOptions, - BuildLinksFieldOptions, - ResolveLinkHrefOptions, -} from './modules/links/index.js' export { buildSpeakableJsonLd } from './modules/seo/index.js' export { buildSummaryField } from './modules/seo/index.js' -export { buildWebSiteJsonLd, buildBreadcrumbJsonLd, buildSiteNavigationJsonLd } from './modules/seo/index.js' +export { buildBreadcrumbJsonLd, buildSiteNavigationJsonLd, buildWebSiteJsonLd } from './modules/seo/index.js' // Local SEO structured data — LocalBusiness (map pack), Service (offering), FAQPage. -export { buildLocalBusinessJsonLd, buildFaqJsonLd, buildServiceJsonLd } from './modules/seo/index.js' +export { buildFaqJsonLd, buildLocalBusinessJsonLd, buildServiceJsonLd } from './modules/seo/index.js' export { buildArticleJsonLd } from './modules/seo/index.js' export { buildLlmsTxt } from './modules/seo/index.js' -export { buildSitemapXml } from './modules/seo/index.js' +export { buildSitemapCss, buildSitemapXml, DEFAULT_SITEMAP_CREDIT, SITEMAP_STYLE_PARAM } from './modules/seo/index.js' +export type { SitemapRouteOptions, SitemapStyleOptions } from './modules/seo/index.js' +export { buildSlugField, toSlug } from './modules/slug/index.js' export { buildR2Storage } from './modules/storage/index.js' -export { normalizeFilename, normalizeFilenameHook, buildOptimizeUploadHook, buildOptimizeUploadField } from './modules/media/index.js' -export type { OptimizeUploadOptions } from './modules/media/index.js' -export { buildRevalidateHook, setPublishedAtHook, buildPreventDeleteSystemPage, buildValidateUniqueRole, trackSlugHistoryHook, buildCrossLocaleFieldSync } from './modules/hooks/index.js' -export { A11Y_COOKIE, A11Y_DEFAULT, a11yAttributes, parseA11y, serializeA11y } from './modules/accessibility/index.js' -export type { A11yState } from './modules/accessibility/index.js' -export type { SecurityHeader, BuildSecurityHeadersArgs } from './modules/security/index.js' -export type { NotificationTexts, FormNotificationTexts } from './modules/notifications/index.js' +export { ipalKit } from './plugin.js' +export type { IpalOptions } from './types.js' diff --git a/src/modules/frontend/createContentHelpers.ts b/src/modules/frontend/createContentHelpers.ts index 34ead02..32b92e6 100644 --- a/src/modules/frontend/createContentHelpers.ts +++ b/src/modules/frontend/createContentHelpers.ts @@ -5,10 +5,10 @@ import { cache } from 'react' import type { ArchiveEntries, ContentOption, ResolvedRoute } from '../content/index.js' import type { I18nConfig } from '../i18n/index.js' -import type { PageMetadata, RobotsOptions, RobotsRules, SitemapEntry } from '../seo/index.js' +import type { PageMetadata, RobotsOptions, RobotsRules, SitemapEntry, SitemapStyleOptions } from '../seo/index.js' import { getArchiveEntries, resolveRoute as resolveRouteRaw } from '../content/index.js' -import { buildRobots, buildSitemapEntries, createPageMetadata } from '../seo/index.js' +import { buildRobots, buildSitemapEntries, createPageMetadata, createSitemapRouteHandler } from '../seo/index.js' type CreateContentHelpersArgs = { /** @@ -39,6 +39,14 @@ type CreateContentHelpersArgs = { robots?: RobotsOptions /** SiteSettings global slug. Defaults to 'site-settings'. */ settingsSlug?: string + /** + * Browser look of `sitemapRoute` (/sitemap.xml). Default: built-in style, + * header = Site Settings `siteName` (default locale), credit "Technology by + * Intecion.com". `false` = raw XML. `{ credit: false }` hides the credit line. + */ + sitemapStyle?: { title?: string } & Omit | false + /** Site Settings field with the site name (sitemap header). Default 'siteName'. */ + siteNameField?: string } /** @@ -75,6 +83,8 @@ export function createContentHelpers({ pagesSlug = 'pages', robots: robotsOptions, settingsSlug = 'site-settings', + sitemapStyle, + siteNameField = 'siteName', }: CreateContentHelpersArgs) { const origin = baseUrl ?? process.env.NEXT_PUBLIC_SERVER_URL ?? '' const getCachedPayload = cache( @@ -384,6 +394,31 @@ export function createContentHelpers({ } } + /** + * Route handler for app/sitemap.xml/route.ts — XML for crawlers, styled for + * people (`?style` serves the CSS from the plugin; nothing in /public): + * + * export { sitemapRoute as GET } from '@/lib/content' + * export const dynamic = 'force-dynamic' + */ + const sitemapRoute = createSitemapRouteHandler(sitemap, { + style: + sitemapStyle === false + ? false + : { + ...sitemapStyle, + title: + sitemapStyle?.title ?? + (async () => { + const locale = i18n?.defaultLocale + if (!locale) {return undefined} + const s = (await getSettings(locale)) as Record + const name = s?.[siteNameField] + return typeof name === 'string' ? name : undefined + }), + }, + }) + return { generatePageMetadata, generateStaticParams, @@ -395,5 +430,6 @@ export function createContentHelpers({ resolveRoute, robots, sitemap, + sitemapRoute, } } diff --git a/src/modules/seo/index.ts b/src/modules/seo/index.ts index dcc5150..249ae4b 100644 --- a/src/modules/seo/index.ts +++ b/src/modules/seo/index.ts @@ -1,38 +1,41 @@ -export { buildAutoFillMetaHook } from './autoFillMeta.js' -export type { AutoFillMapping } from './autoFillMeta.js' -export { buildArticleJsonLd } from './buildArticleJsonLd.js' -export { buildBreadcrumbJsonLd } from './buildBreadcrumbJsonLd.js' -export { buildFaqJsonLd } from './buildFaqJsonLd.js' -export { buildIconsMetadata } from './buildIconsMetadata.js' -export { buildLlmsTxt } from './buildLlmsTxt.js' -export { buildLocalBusinessJsonLd } from './buildLocalBusinessJsonLd.js' -export { createManifestHandler } from './buildManifest.js' +export type { SeoOption, SeoMeta } from './types.js' +export { composeTitle } from './composeTitle.js' +export type { TitleOrder } from './composeTitle.js' +export { buildHreflangAlternates } from './hreflang.js' export { buildMetadata } from './buildMetadata.js' export type { PageMetadata } from './buildMetadata.js' -export { buildNoindexField } from './buildNoindexField.js' -export { buildOrganizationJsonLd } from './buildOrganizationJsonLd.js' -export { AI_ASSISTANT_BOTS, AI_TRAINING_BOTS, buildRobots } from './buildRobots.js' -export type { RobotsOptions, RobotsRules } from './buildRobots.js' -export { buildServiceJsonLd } from './buildServiceJsonLd.js' +export { buildSeoPlugin } from './seoPluginConfig.js' +export { buildAutoFillMetaHook } from './autoFillMeta.js' +export { injectAutoFillMeta } from './injectAutoFillMeta.js' +export { injectSeoTabs } from './injectSeoTabs.js' +export type { AutoFillMapping } from './autoFillMeta.js' +export { createMetadataGenerator } from './createMetadataGenerator.js' +export { createPageMetadata } from './createPageMetadata.js' +export { readSiteMetaConfig } from './readSiteMetaConfig.js' +export type { SiteMetaConfig } from './readSiteMetaConfig.js' +export { slugsAcrossLocales } from './slugsAcrossLocales.js' export { buildSitemapEntries } from './buildSitemapEntries.js' -export type { SitemapEntry } from './buildSitemapEntries.js' export { buildSitemapXml } from './buildSitemapXml.js' -export { buildSiteNavigationJsonLd } from './buildSiteNavigationJsonLd.js' +export type { SitemapEntry } from './buildSitemapEntries.js' +export { buildRobots, AI_ASSISTANT_BOTS, AI_TRAINING_BOTS } from './buildRobots.js' +export type { RobotsRules, RobotsOptions } from './buildRobots.js' +export { buildIconsMetadata } from './buildIconsMetadata.js' +export { buildOrganizationJsonLd } from './buildOrganizationJsonLd.js' +export { validateFaviconField } from './validateFavicon.js' +export { buildNoindexField } from './buildNoindexField.js' export { buildSpeakableJsonLd } from './buildSpeakableJsonLd.js' export { buildSummaryField } from './buildSummaryField.js' export { buildWebSiteJsonLd } from './buildWebSiteJsonLd.js' -export { composeTitle } from './composeTitle.js' -export type { TitleOrder } from './composeTitle.js' -export { createMetadataGenerator } from './createMetadataGenerator.js' -export { createPageMetadata } from './createPageMetadata.js' -export { buildHreflangAlternates } from './hreflang.js' -export { injectAutoFillMeta } from './injectAutoFillMeta.js' -export { injectSeoTabs } from './injectSeoTabs.js' -export { JsonLdGraph } from './JsonLdGraph.js' -export { readSiteMetaConfig } from './readSiteMetaConfig.js' -export type { SiteMetaConfig } from './readSiteMetaConfig.js' +export { buildBreadcrumbJsonLd } from './buildBreadcrumbJsonLd.js' +export { buildSiteNavigationJsonLd } from './buildSiteNavigationJsonLd.js' +export { buildLocalBusinessJsonLd } from './buildLocalBusinessJsonLd.js' +export { buildFaqJsonLd } from './buildFaqJsonLd.js' +export { buildServiceJsonLd } from './buildServiceJsonLd.js' +export { buildArticleJsonLd } from './buildArticleJsonLd.js' +export { buildLlmsTxt } from './buildLlmsTxt.js' export { createLlmsTxtRoute, createSitemapRouteHandler } from './routeHandlers.js' -export { buildSeoPlugin } from './seoPluginConfig.js' -export { slugsAcrossLocales } from './slugsAcrossLocales.js' -export type { SeoMeta, SeoOption } from './types.js' -export { validateFaviconField } from './validateFavicon.js' +export type { SitemapRouteOptions } from './routeHandlers.js' +export { buildSitemapCss, SITEMAP_STYLE_PARAM, DEFAULT_SITEMAP_CREDIT } from './sitemapStyle.js' +export type { SitemapStyleOptions } from './sitemapStyle.js' +export { createManifestHandler } from './buildManifest.js' +export { JsonLdGraph } from './JsonLdGraph.js' diff --git a/src/modules/seo/routeHandlers.ts b/src/modules/seo/routeHandlers.ts index ac205ff..50df12e 100644 --- a/src/modules/seo/routeHandlers.ts +++ b/src/modules/seo/routeHandlers.ts @@ -1,10 +1,9 @@ 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' +import type { SitemapEntry } from './buildSitemapEntries.js' +import { buildSitemapCss, SITEMAP_STYLE_PARAM, type SitemapStyleOptions } from './sitemapStyle.js' /** * Ready-made Next route handler for /llms.txt. Replaces the ~60-line try/catch @@ -26,13 +25,13 @@ import { buildSitemapXml } from './buildSitemapXml.js' * baseUrl: process.env.NEXT_PUBLIC_SERVER_URL!, full: true }) */ export function createLlmsTxtRoute(opts: { - baseUrl: string - config: I18nConfig - /** Inline every page's full Markdown (llms-full.txt). Default false. */ - full?: boolean getCachedPayload: () => Promise + config: I18nConfig + baseUrl: string pagesSlug?: string settingsSlug?: string + /** Inline every page's full Markdown (llms-full.txt). Default false. */ + full?: boolean /** Field holding a richer AI summary (buildSummaryField) to prefer as description. */ summaryField?: string }): () => Promise { @@ -40,12 +39,12 @@ export function createLlmsTxtRoute(opts: { try { const payload = await opts.getCachedPayload() const body = await buildLlmsTxt({ - baseUrl: opts.baseUrl, - config: opts.config, - full: opts.full, - pagesSlug: opts.pagesSlug, payload, + config: opts.config, + baseUrl: opts.baseUrl, + pagesSlug: opts.pagesSlug, settingsSlug: opts.settingsSlug, + full: opts.full, summaryField: opts.summaryField, }) return new Response(body, { @@ -62,28 +61,58 @@ export function createLlmsTxtRoute(opts: { } } +export type SitemapRouteOptions = { + /** + * Built-in browser look (default ON): the XML points at `?style` + * and the same handler serves the CSS — nothing to copy into /public. + * `false` = raw XML. Object = header/credit/accent (SitemapStyleOptions); + * `title` may be async (sitemapRoute passes the Site Settings name). + */ + style?: false | (Omit & { title?: string | (() => Promise) }) + /** Legacy: your own stylesheet URL (e.g. '/sitemap.css'). Overrides `style`. */ + cssUrl?: string +} + /** - * 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. + * Ready-made Next route handler for /sitemap.xml, styled for humans out of the box. + * Usually you don't call this — `createContentHelpers` returns `sitemapRoute`: * - * // app/sitemap.xml/route.ts - * import { createSitemapRouteHandler } from '@intecion/ipal-kit' - * import { sitemap } from '@/lib/content' + * // app/sitemap.xml/route.ts — the whole file + * export { sitemapRoute as GET } 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). + * `GET /sitemap.xml` → XML (crawlers), `GET /sitemap.xml?style` → its CSS. + * Don't keep app/sitemap.ts next to it — two sitemaps confuse crawlers. */ export function createSitemapRouteHandler( sitemap: () => Promise, - opts: { cssUrl?: string } = {}, -): () => Promise { - return async () => { + opts: SitemapRouteOptions = {}, +): (req?: Request) => Promise { + const style = opts.cssUrl ? false : opts.style === false ? false : (opts.style ?? {}) + + return async (req?: Request) => { + const url = req ? new URL(req.url) : null + + if (style && url?.searchParams.has(SITEMAP_STYLE_PARAM)) { + let title: string | undefined + try { + title = typeof style.title === 'function' ? await style.title() : style.title + } catch { + title = undefined // DB down → generic heading, never a broken stylesheet + } + return new Response(buildSitemapCss({ ...style, title }), { + headers: { + 'Content-Type': 'text/css; charset=utf-8', + 'Cache-Control': 'public, max-age=3600', + 'X-Robots-Tag': 'noindex', + }, + }) + } + + const cssUrl = opts.cssUrl ?? (style ? `${url?.pathname ?? '/sitemap.xml'}?${SITEMAP_STYLE_PARAM}` : undefined) try { const entries = await sitemap() - const xml = buildSitemapXml(entries, { cssUrl: opts.cssUrl }) + const xml = buildSitemapXml(entries, { cssUrl }) return new Response(xml, { headers: { 'Content-Type': 'application/xml; charset=utf-8' }, }) diff --git a/src/modules/seo/sitemapStyle.ts b/src/modules/seo/sitemapStyle.ts new file mode 100644 index 0000000..209a40d --- /dev/null +++ b/src/modules/seo/sitemapStyle.ts @@ -0,0 +1,90 @@ +/** + * Built-in look of /sitemap.xml in a browser — served by the sitemap route itself + * (`/sitemap.xml?style`), so projects ship NO sitemap.css and copy nothing. + * Plain CSS on XML (W3C "Associating Style Sheets with XML", type="text/css") — + * not XSLT, which browsers are removing. Crawlers ignore it. + */ + +export type SitemapStyleOptions = { + /** Accent colour (card hover). Default '#027bd0'. Any plain CSS colour. */ + accent?: string + /** + * Line under the header — the technology provider. Default + * "Technology by Intecion.com". `false` hides it. + */ + credit?: false | string + /** Header line. Default: the site name from Site Settings (sitemapRoute), else "XML Sitemap". */ + title?: string +} + +/** Query parameter on the sitemap URL that returns the stylesheet instead of XML. */ +export const SITEMAP_STYLE_PARAM = 'style' +export const DEFAULT_SITEMAP_CREDIT = 'Technology by Intecion.com' + +/** CSS `content: "…"` value — escapes backslashes, quotes and newlines. */ +const cssString = (s: string) => `"${s.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/[\r\n]+/g, ' ')}"` + +/** Only plain colour values — the option ends up inside a stylesheet. */ +const safeColor = (c: string | undefined, fallback: string) => + c && /^(#[0-9a-f]{3,8}|[a-z]+|(rgb|hsl|oklch)a?\([\d\s.,%/-]+\))$/i.test(c.trim()) ? c.trim() : fallback + +export function buildSitemapCss({ accent, credit, title }: SitemapStyleOptions = {}): string { + const heading = title?.trim() || 'XML Sitemap' + const note = credit === false ? '' : (credit ?? DEFAULT_SITEMAP_CREDIT).trim() + const acc = safeColor(accent, '#027bd0') + const divider = 'padding-bottom: 1.25rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--border);' + + return `: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: ${acc}; +} +@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; + } +} +urlset { + display: flex; flex-direction: column; box-sizing: border-box; min-height: 100vh; + max-width: 1040px; margin: 0 auto; padding: 3rem 1.5rem; line-height: 1.5; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif; + background-color: var(--bg); color: var(--text-main); +} +urlset::before { + content: ${cssString(heading)}; + display: block; order: -2; font-size: 1.35rem; font-weight: 600; letter-spacing: -0.02em; + color: var(--text-main); ${note ? 'padding-bottom: 0.4rem;' : divider} +} +${note ? `urlset::after { + content: ${cssString(note)}; + display: block; order: -1; font-size: 0.8rem; color: var(--text-muted); ${divider} +} +` : ''}url { + display: block; width: 100%; order: 0; box-sizing: border-box; + background-color: var(--card); border: 1px solid var(--border); border-radius: 8px; + padding: 1rem 1.25rem; margin-bottom: 0.65rem; + transition: border-color 0.15s ease, box-shadow 0.15s ease; +} +url:hover { border-color: var(--accent); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03); } +loc { + display: block; margin-bottom: 0.45rem; word-break: break-all; line-height: 1.45; + font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace; + font-size: 0.875rem; font-weight: 500; color: var(--url-color); +} +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); } +link { + display: inline-block; font-size: 0.7rem; font-weight: 600; text-transform: uppercase; + 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; +} +link::before { content: attr(hreflang); } +` +}