Compare commits

...
2 Commits
Author SHA1 Message Date
radoslaw.smolinski 015092e773 1.8.10 2026-10-14 11:32:12 +02:00
radoslaw.smolinski f4d969ad29 Sitemap.xml fixed 2026-10-14 11:32:03 +02:00
10 changed files with 15 additions and 53 deletions
+3 -8
View File
@@ -33,14 +33,9 @@ type CreateContentHelpersArgs = {
settingsSlug?: string; settingsSlug?: string;
/** /**
* Browser look of `sitemapRoute` (/sitemap.xml). Default: built-in style, * Browser look of `sitemapRoute` (/sitemap.xml). Default: built-in style,
* header = Site Settings `siteName` (default locale), credit "Technology by * header "XML Sitemap", credit "Technology by Intecion.com". `false` = raw XML.
* Intecion.com". `false` = raw XML. `{ credit: false }` hides the credit line.
*/ */
sitemapStyle?: { sitemapStyle?: false | SitemapStyleOptions;
title?: string;
} & Omit<SitemapStyleOptions, 'title'> | 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 * 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 * 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. * 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<PageMetadata>; generatePageMetadata: (locale: string, segments: string[] | undefined, page?: number) => Promise<PageMetadata>;
generateStaticParams: () => Promise<Array<{ generateStaticParams: () => Promise<Array<{
locale: string; locale: string;
+2 -13
View File
@@ -27,7 +27,7 @@ import { buildRobots, buildSitemapEntries, createPageMetadata, createSitemapRout
* `resolveRoute` and `getEntries` are separate on purpose: routing decides what * `resolveRoute` and `getEntries` are separate on purpose: routing decides what
* a URL is, fetching gets the listing. Metadata generation needs the first and * 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. * 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', sitemapStyle, siteNameField = 'siteName' }) { */ export function createContentHelpers({ baseUrl, config, content, i18n, pagesSlug = 'pages', robots: robotsOptions, settingsSlug = 'site-settings', sitemapStyle }) {
const origin = baseUrl ?? process.env.NEXT_PUBLIC_SERVER_URL ?? ''; const origin = baseUrl ?? process.env.NEXT_PUBLIC_SERVER_URL ?? '';
const getCachedPayload = cache(async ()=>getPayload({ const getCachedPayload = cache(async ()=>getPayload({
config: await config config: await config
@@ -318,18 +318,7 @@ import { buildRobots, buildSitemapEntries, createPageMetadata, createSitemapRout
* export { sitemapRoute as GET } from '@/lib/content' * export { sitemapRoute as GET } from '@/lib/content'
* export const dynamic = 'force-dynamic' * export const dynamic = 'force-dynamic'
*/ const sitemapRoute = createSitemapRouteHandler(sitemap, { */ const sitemapRoute = createSitemapRouteHandler(sitemap, {
style: sitemapStyle === false ? false : { style: sitemapStyle ?? {}
...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 { return {
generatePageMetadata, generatePageMetadata,
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -12,7 +12,7 @@ export type SitemapStyleOptions = {
* "Technology by Intecion.com". `false` hides it. * "Technology by Intecion.com". `false` hides it.
*/ */
credit?: false | string; credit?: false | string;
/** Header line. Default: the site name from Site Settings (sitemapRoute), else "XML Sitemap". */ /** Header line. Default "XML Sitemap". */
title?: string; title?: string;
}; };
/** Query parameter on the sitemap URL that returns the stylesheet instead of XML. */ /** Query parameter on the sitemap URL that returns the stylesheet instead of XML. */
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -320,7 +320,7 @@ export const dynamic = 'force-dynamic'
export const GET = createHealthRoute({ getCachedPayload }) export const GET = createHealthRoute({ getCachedPayload })
``` ```
Jeden sitemap: `sitemap.xml/route.ts` **albo** `sitemap.ts` — nigdy oba. Nagłówek 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). przez `createContentHelpers({ sitemapStyle })` (seo.md).
### 2.9 next.config.ts i instrumentation.ts ### 2.9 next.config.ts i instrumentation.ts
+1 -3
View File
@@ -1079,7 +1079,7 @@ export { sitemapRoute as GET } from '@/lib/content'
export const dynamic = 'force-dynamic' 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”. - **Linia pod nagłówkiem** = dostawca technologii: „Technology by Intecion.com”.
- To CSS na XML (`<?xml-stylesheet type="text/css"?>`, standard W3C) — **nie XSLT**, - To CSS na XML (`<?xml-stylesheet type="text/css"?>`, standard W3C) — **nie XSLT**,
które przeglądarki wycofują. Google ignoruje dyrektywę; zero wpływu na SEO. które przeglądarki wycofują. Google ignoruje dyrektywę; zero wpływu na SEO.
@@ -1090,9 +1090,7 @@ createContentHelpers({
config, content, i18n: i18nConfig, config, content, i18n: i18nConfig,
sitemapStyle: { accent: '#0f766e' }, // kolor akcentu sitemapStyle: { accent: '#0f766e' }, // kolor akcentu
// sitemapStyle: { credit: false }, // bez linii dostawcy // sitemapStyle: { credit: false }, // bez linii dostawcy
// sitemapStyle: { title: 'Sitemap' }, // stały nagłówek zamiast siteName
// sitemapStyle: false, // surowy XML (natywny widok przeglądarki) // sitemapStyle: false, // surowy XML (natywny widok przeglądarki)
// siteNameField: 'name', // gdy pole nazwy w Site Settings ma inną nazwę
}) })
``` ```
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@intecion/ipal-kit", "name": "@intecion/ipal-kit",
"version": "1.8.9", "version": "1.8.10",
"description": "Intecion Payload Advanced Library — a Payload CMS 3 plugin: i18n, SEO, forms, consent, analytics, blog/archives.", "description": "Intecion Payload Advanced Library — a Payload CMS 3 plugin: i18n, SEO, forms, consent, analytics, blog/archives.",
"license": "MIT", "license": "MIT",
"repository": { "repository": {
+3 -23
View File
@@ -41,12 +41,9 @@ type CreateContentHelpersArgs = {
settingsSlug?: string settingsSlug?: string
/** /**
* Browser look of `sitemapRoute` (/sitemap.xml). Default: built-in style, * Browser look of `sitemapRoute` (/sitemap.xml). Default: built-in style,
* header = Site Settings `siteName` (default locale), credit "Technology by * header "XML Sitemap", credit "Technology by Intecion.com". `false` = raw XML.
* Intecion.com". `false` = raw XML. `{ credit: false }` hides the credit line.
*/ */
sitemapStyle?: { title?: string } & Omit<SitemapStyleOptions, 'title'> | false sitemapStyle?: false | SitemapStyleOptions
/** Site Settings field with the site name (sitemap header). Default 'siteName'. */
siteNameField?: string
} }
/** /**
@@ -84,7 +81,6 @@ export function createContentHelpers({
robots: robotsOptions, robots: robotsOptions,
settingsSlug = 'site-settings', settingsSlug = 'site-settings',
sitemapStyle, sitemapStyle,
siteNameField = 'siteName',
}: CreateContentHelpersArgs) { }: CreateContentHelpersArgs) {
const origin = baseUrl ?? process.env.NEXT_PUBLIC_SERVER_URL ?? '' const origin = baseUrl ?? process.env.NEXT_PUBLIC_SERVER_URL ?? ''
const getCachedPayload = cache( const getCachedPayload = cache(
@@ -401,23 +397,7 @@ export function createContentHelpers({
* export { sitemapRoute as GET } from '@/lib/content' * export { sitemapRoute as GET } from '@/lib/content'
* export const dynamic = 'force-dynamic' * export const dynamic = 'force-dynamic'
*/ */
const sitemapRoute = createSitemapRouteHandler(sitemap, { const sitemapRoute = createSitemapRouteHandler(sitemap, { style: sitemapStyle ?? {} })
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 { return {
generatePageMetadata, generatePageMetadata,
+1 -1
View File
@@ -13,7 +13,7 @@ export type SitemapStyleOptions = {
* "Technology by Intecion.com". `false` hides it. * "Technology by Intecion.com". `false` hides it.
*/ */
credit?: false | string credit?: false | string
/** Header line. Default: the site name from Site Settings (sitemapRoute), else "XML Sitemap". */ /** Header line. Default "XML Sitemap". */
title?: string title?: string
} }