Sitemap.css is now builded in plugin
This commit is contained in:
+138
-137
@@ -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'
|
||||
|
||||
@@ -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<SitemapStyleOptions, 'title'> | 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<string, unknown>
|
||||
const name = s?.[siteNameField]
|
||||
return typeof name === 'string' ? name : undefined
|
||||
}),
|
||||
},
|
||||
})
|
||||
|
||||
return {
|
||||
generatePageMetadata,
|
||||
generateStaticParams,
|
||||
@@ -395,5 +430,6 @@ export function createContentHelpers({
|
||||
resolveRoute,
|
||||
robots,
|
||||
sitemap,
|
||||
sitemapRoute,
|
||||
}
|
||||
}
|
||||
|
||||
+33
-30
@@ -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'
|
||||
|
||||
@@ -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<BasePayload>
|
||||
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<Response> {
|
||||
@@ -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 `<this route>?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<SitemapStyleOptions, 'title'> & { title?: string | (() => Promise<string | undefined>) })
|
||||
/** 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<SitemapEntry[]>,
|
||||
opts: { cssUrl?: string } = {},
|
||||
): () => Promise<Response> {
|
||||
return async () => {
|
||||
opts: SitemapRouteOptions = {},
|
||||
): (req?: Request) => Promise<Response> {
|
||||
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' },
|
||||
})
|
||||
|
||||
@@ -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); }
|
||||
`
|
||||
}
|
||||
Reference in New Issue
Block a user