From f4d969ad297c0db6c0e029ea83a508564c469ba3 Mon Sep 17 00:00:00 2001 From: rasm-its Date: Wed, 14 Oct 2026 11:32:03 +0200 Subject: [PATCH] Sitemap.xml fixed --- .../frontend/createContentHelpers.d.ts | 11 +++----- dist/modules/frontend/createContentHelpers.js | 15 ++--------- .../frontend/createContentHelpers.js.map | 2 +- dist/modules/seo/sitemapStyle.d.ts | 2 +- dist/modules/seo/sitemapStyle.js.map | 2 +- docs/dev/PROGRAMISTA.md | 2 +- docs/seo.md | 4 +-- src/modules/frontend/createContentHelpers.ts | 26 +++---------------- src/modules/seo/sitemapStyle.ts | 2 +- 9 files changed, 14 insertions(+), 52 deletions(-) diff --git a/dist/modules/frontend/createContentHelpers.d.ts b/dist/modules/frontend/createContentHelpers.d.ts index 931a6e4..fc21045 100644 --- a/dist/modules/frontend/createContentHelpers.d.ts +++ b/dist/modules/frontend/createContentHelpers.d.ts @@ -33,14 +33,9 @@ type CreateContentHelpersArgs = { 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. + * header "XML Sitemap", credit "Technology by Intecion.com". `false` = raw XML. */ - sitemapStyle?: { - title?: string; - } & Omit | false; - /** Site Settings field with the site name (sitemap header). Default 'siteName'. */ - siteNameField?: string; + sitemapStyle?: false | SitemapStyleOptions; }; /** * Bundles the per-request data helpers a frontend needs — the same cached @@ -68,7 +63,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, sitemapStyle, siteNameField, }: CreateContentHelpersArgs): { +export declare function createContentHelpers({ baseUrl, config, content, i18n, pagesSlug, robots: robotsOptions, settingsSlug, sitemapStyle, }: CreateContentHelpersArgs): { generatePageMetadata: (locale: string, segments: string[] | undefined, page?: number) => Promise; generateStaticParams: () => PromisegetPayload({ config: await config @@ -318,18 +318,7 @@ import { buildRobots, buildSitemapEntries, createPageMetadata, createSitemapRout * 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; - }) - } + style: sitemapStyle ?? {} }); return { generatePageMetadata, diff --git a/dist/modules/frontend/createContentHelpers.js.map b/dist/modules/frontend/createContentHelpers.js.map index b685e89..e14afa6 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, 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;QAAO;IAGtE,MAAMc,uBAAuBxB,MAAM;QACjC,MAAMyB,IAAI,MAAMf;QAChB,OAAOe,EAAEC,YAAY,GAAGD,EAAEC,YAAY,CAACC,OAAO,CAACC,GAAG,CAAC,CAACC,IAAMA,EAAEC,IAAI,IAAI,EAAE;IACxE;IAEA;;;GAGC,GACD,MAAMC,cAAc/B,MAAM,OAAOgC;QAC/B,MAAMC,UAAU,MAAMV;QACtB,OAAOU,QAAQC,UAAU,CAAC;YAAEC,MAAMnB;YAAuBoB,OAAO;YAAGJ,QAAQA;QAAgB;IAC7F;IAEA,iEAAiE,GACjE,MAAM9B,eAAeF,MACnB,OACEgC,Q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AACA,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;;;;;;GAMC,GACD,MAAMC,eAAenF,0BAA0BgD,SAAS;QACtDoC,OACE1E,iBAAiB,QACb,QACA;YACE,GAAGA,YAAY;YACf2E,OACE3E,cAAc2E,SACb,CAAA;gBACC,MAAM5D,SAASpB,MAAMiF;gBACrB,IAAI,CAAC7D,QAAQ;oBAAC,OAAOW;gBAAS;gBAC9B,MAAMmD,IAAK,MAAM/D,YAAYC;gBAC7B,MAAM+D,OAAOD,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 +{"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 \"XML Sitemap\", credit \"Technology by Intecion.com\". `false` = raw XML.\n */\n sitemapStyle?: false | SitemapStyleOptions\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}: 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, { style: sitemapStyle ?? {} })\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","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"],"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;AAsCjH;;;;;;;;;;;;;;;;;;;;;;;;;CAyBC,GACD,OAAO,SAASC,qBAAqB,EACnCC,OAAO,EACPC,MAAM,EACNC,OAAO,EACPC,IAAI,EACJC,YAAY,OAAO,EACnBC,QAAQC,aAAa,EACrBC,eAAe,eAAe,EAC9BC,YAAY,EACa;IACzB,MAAMC,SAAST,WAAWU,QAAQC,GAAG,CAACC,sBAAsB,IAAI;IAChE,MAAMC,mBAAmBtB,MACvB,UAAkCD,WAAW;YAAEW,QAAQ,MAAMA;QAAO;IAGtE,MAAMa,uBAAuBvB,MAAM;QACjC,MAAMwB,IAAI,MAAMd;QAChB,OAAOc,EAAEC,YAAY,GAAGD,EAAEC,YAAY,CAACC,OAAO,CAACC,GAAG,CAAC,CAACC,IAAMA,EAAEC,IAAI,IAAI,EAAE;IACxE;IAEA;;;GAGC,GACD,MAAMC,cAAc9B,MAAM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AM;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;;;;;;GAMC,GACD,MAAMC,eAAelF,0BAA0B+C,SAAS;QAAEoC,OAAOzE,gBAAgB,CAAC;IAAE;IAEpF,OAAO;QACLuB;QACAkB;QACApC;QACAC;QACA6B;QACAH;QACAnB;QACA5B;QACAY;QACAwC;QACAmC;IACF;AACF"} \ No newline at end of file diff --git a/dist/modules/seo/sitemapStyle.d.ts b/dist/modules/seo/sitemapStyle.d.ts index fac09df..6189a24 100644 --- a/dist/modules/seo/sitemapStyle.d.ts +++ b/dist/modules/seo/sitemapStyle.d.ts @@ -12,7 +12,7 @@ export type SitemapStyleOptions = { * "Technology by Intecion.com". `false` hides it. */ credit?: false | string; - /** Header line. Default: the site name from Site Settings (sitemapRoute), else "XML Sitemap". */ + /** Header line. Default "XML Sitemap". */ title?: string; }; /** Query parameter on the sitemap URL that returns the stylesheet instead of XML. */ diff --git a/dist/modules/seo/sitemapStyle.js.map b/dist/modules/seo/sitemapStyle.js.map index 5898931..64264be 100644 --- a/dist/modules/seo/sitemapStyle.js.map +++ b/dist/modules/seo/sitemapStyle.js.map @@ -1 +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,mEAAmEE,IAAI,CAACF,EAAEG,IAAI,MAAMH,EAAEG,IAAI,KAAKF;AAEtG,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 +{"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 \"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,mEAAmEE,IAAI,CAACF,EAAEG,IAAI,MAAMH,EAAEG,IAAI,KAAKF;AAEtG,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/dev/PROGRAMISTA.md b/docs/dev/PROGRAMISTA.md index 189de94..7d5c660 100644 --- a/docs/dev/PROGRAMISTA.md +++ b/docs/dev/PROGRAMISTA.md @@ -320,7 +320,7 @@ export const dynamic = 'force-dynamic' export const GET = createHealthRoute({ getCachedPayload }) ``` 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 +sitemapy = „XML Sitemap”, pod nim „Technology by Intecion.com”; zmiana przez `createContentHelpers({ sitemapStyle })` (seo.md). ### 2.9 next.config.ts i instrumentation.ts diff --git a/docs/seo.md b/docs/seo.md index 30e3f3b..9351077 100644 --- a/docs/seo.md +++ b/docs/seo.md @@ -1079,7 +1079,7 @@ export { sitemapRoute as GET } from '@/lib/content' export const dynamic = 'force-dynamic' ``` -- **Nagłówek** = `siteName` z Site Settings (język domyślny); brak → „XML Sitemap”. +- **Nagłówek** = „XML Sitemap” (bez nazwy firmy/strony). - **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. @@ -1090,9 +1090,7 @@ 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ę }) ``` diff --git a/src/modules/frontend/createContentHelpers.ts b/src/modules/frontend/createContentHelpers.ts index 32b92e6..62fa87a 100644 --- a/src/modules/frontend/createContentHelpers.ts +++ b/src/modules/frontend/createContentHelpers.ts @@ -41,12 +41,9 @@ type CreateContentHelpersArgs = { 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. + * header "XML Sitemap", credit "Technology by Intecion.com". `false` = raw XML. */ - sitemapStyle?: { title?: string } & Omit | false - /** Site Settings field with the site name (sitemap header). Default 'siteName'. */ - siteNameField?: string + sitemapStyle?: false | SitemapStyleOptions } /** @@ -84,7 +81,6 @@ export function createContentHelpers({ robots: robotsOptions, settingsSlug = 'site-settings', sitemapStyle, - siteNameField = 'siteName', }: CreateContentHelpersArgs) { const origin = baseUrl ?? process.env.NEXT_PUBLIC_SERVER_URL ?? '' const getCachedPayload = cache( @@ -401,23 +397,7 @@ export function createContentHelpers({ * 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 - }), - }, - }) + const sitemapRoute = createSitemapRouteHandler(sitemap, { style: sitemapStyle ?? {} }) return { generatePageMetadata, diff --git a/src/modules/seo/sitemapStyle.ts b/src/modules/seo/sitemapStyle.ts index ba45b98..f3876a5 100644 --- a/src/modules/seo/sitemapStyle.ts +++ b/src/modules/seo/sitemapStyle.ts @@ -13,7 +13,7 @@ export type SitemapStyleOptions = { * "Technology by Intecion.com". `false` hides it. */ credit?: false | string - /** Header line. Default: the site name from Site Settings (sitemapRoute), else "XML Sitemap". */ + /** Header line. Default "XML Sitemap". */ title?: string }