Sitemap.xml fixed

This commit is contained in:
2026-10-14 11:32:03 +02:00
parent fad5d778e8
commit f4d969ad29
9 changed files with 14 additions and 52 deletions
+3 -8
View File
@@ -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<SitemapStyleOptions, 'title'> | 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<PageMetadata>;
generateStaticParams: () => Promise<Array<{
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
* a URL is, fetching gets the listing. Metadata generation needs the first and
* not the second, and a page component composes them in two obvious lines.
*/ export function createContentHelpers({ baseUrl, config, content, i18n, pagesSlug = 'pages', robots: robotsOptions, settingsSlug = 'site-settings', 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 getCachedPayload = cache(async ()=>getPayload({
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,
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.
*/
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. */
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 })
```
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
+1 -3
View File
@@ -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 (`<?xml-stylesheet type="text/css"?>`, 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ę
})
```
+3 -23
View File
@@ -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<SitemapStyleOptions, 'title'> | 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<string, unknown>
const name = s?.[siteNameField]
return typeof name === 'string' ? name : undefined
}),
},
})
const sitemapRoute = createSitemapRouteHandler(sitemap, { style: sitemapStyle ?? {} })
return {
generatePageMetadata,
+1 -1
View File
@@ -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
}