Sitemap.xml fixed
This commit is contained in:
+3
-8
@@ -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
@@ -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,
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
@@ -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. */
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -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
@@ -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ę
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user