SEO: project overrides (sitemapEntries, sitemapOptions, underConstructionSeo, searchSettings fn); seo-check follows sitemap index
- createContentHelpers: sitemapEntries transform has the last word, sitemapOptions passes maxUrls/cacheControl/memoSeconds to sitemapRoute, underConstructionSeo: false turns the construction filter off - seo.searchSettings accepts a function over the default fields - ipal-seo-check: reads sitemap index parts, reports 503 sitemap, warns on missing Google/Bing verification (skip key: verification) - docs/seo.md updated Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
94e563055f
commit
dc761164d9
@@ -11,7 +11,7 @@ import type { I18nConfig } from '../i18n/index.js'
|
||||
import type { LinkValue, NavItem, ResolvedLink, ResolveLinkHrefOptions, SystemLink } from '../links/index.js'
|
||||
import type { CreateMcpRouteArgs } from '../mcp/createMcpRoute.js'
|
||||
import type { FormNotificationTexts } from '../notifications/types.js'
|
||||
import type { PageMetadata, RobotsOptions, RobotsRules, SitemapEntry, SitemapStyleOptions } from '../seo/index.js'
|
||||
import type { PageMetadata, RobotsOptions, RobotsRules, SitemapEntry, SitemapRouteOptions, SitemapStyleOptions } from '../seo/index.js'
|
||||
|
||||
import { getAnalyticsConfig } from '../analytics/getAnalyticsConfig.js'
|
||||
import { getConsentTexts } from '../consent/getConsentTexts.js'
|
||||
@@ -96,8 +96,19 @@ type CreateContentHelpersArgs = {
|
||||
* LocalBusiness from the Company global); `false` = none.
|
||||
*/
|
||||
siteJsonLd?: ((ctx: { baseUrl: string; locale: string; settings: Record<string, unknown> }) => Promise<Record<string, unknown>[]> | Record<string, unknown>[]) | false
|
||||
/**
|
||||
* Last word on the sitemap: gets the plugin's entries (after the construction
|
||||
* filter) and returns the list to publish — add URLs from your own routes,
|
||||
* drop or reorder some, set priority. Used by `sitemap` and `sitemapRoute`.
|
||||
*/
|
||||
sitemapEntries?: (entries: SitemapEntry[]) => Promise<SitemapEntry[]> | SitemapEntry[]
|
||||
/** Image URLs of a document for the sitemap (Google Images). Default: its SEO share image. */
|
||||
sitemapImages?: (doc: Record<string, unknown>) => (null | string | undefined)[]
|
||||
/**
|
||||
* `sitemapRoute` behaviour: `maxUrls` (split into an index, default 10 000),
|
||||
* `cacheControl` (string or false), `memoSeconds` (default 300, 0 = off).
|
||||
*/
|
||||
sitemapOptions?: Pick<SitemapRouteOptions, 'cacheControl' | 'maxUrls' | 'memoSeconds'>
|
||||
/**
|
||||
* Browser look of `sitemapRoute` (/sitemap.xml). Default: built-in style,
|
||||
* header "XML Sitemap", credit "Technology by Intecion.com". `false` = raw XML.
|
||||
@@ -105,6 +116,11 @@ type CreateContentHelpersArgs = {
|
||||
sitemapStyle?: false | SitemapStyleOptions
|
||||
/** Field with the AI summary (buildSummaryField) — llms.txt and MCP prefer it. */
|
||||
summaryField?: string
|
||||
/**
|
||||
* While Site Settings → Under construction is on, the sitemap and llms.txt
|
||||
* list only the pages still open. Default true; false lists everything.
|
||||
*/
|
||||
underConstructionSeo?: boolean
|
||||
}
|
||||
|
||||
/** What an entry's own JSON-LD builder gets (PageJsonLdOptions.entries). */
|
||||
@@ -182,9 +198,12 @@ export function createContentHelpers({
|
||||
robots: robotsOptions,
|
||||
settingsSlug = 'site-settings',
|
||||
siteJsonLd,
|
||||
sitemapEntries: transformSitemap,
|
||||
sitemapImages,
|
||||
sitemapOptions,
|
||||
sitemapStyle,
|
||||
summaryField,
|
||||
underConstructionSeo = true,
|
||||
}: CreateContentHelpersArgs) {
|
||||
const origin = baseUrl ?? process.env.NEXT_PUBLIC_SERVER_URL ?? ''
|
||||
const getCachedPayload = cache(
|
||||
@@ -447,9 +466,9 @@ export function createContentHelpers({
|
||||
// Under construction: list only the pages visitors can still open — the
|
||||
// rest redirect to the homepage notice, which crawlers would index.
|
||||
const open = await constructionPaths()
|
||||
if (!open) {return entries}
|
||||
const allowed = new Set(open.map(normalizePath))
|
||||
return entries.filter((e) => allowed.has(normalizePath(pathOf(e.url))))
|
||||
const allowed = open ? new Set(open.map(normalizePath)) : null
|
||||
const visible = allowed ? entries.filter((e) => allowed.has(normalizePath(pathOf(e.url)))) : entries
|
||||
return transformSitemap ? await transformSitemap(visible) : visible
|
||||
} catch (error) {
|
||||
// At runtime a failure is an error (the sitemap route answers 503, so
|
||||
// crawlers retry) — an empty sitemap would read as "no pages".
|
||||
@@ -636,7 +655,7 @@ export function createContentHelpers({
|
||||
* export { sitemapRoute as GET } from '@/lib/content'
|
||||
* export const dynamic = 'force-dynamic'
|
||||
*/
|
||||
const sitemapRoute = createSitemapRouteHandler(sitemap, { style: sitemapStyle ?? {} })
|
||||
const sitemapRoute = createSitemapRouteHandler(sitemap, { ...sitemapOptions, style: sitemapStyle ?? {} })
|
||||
|
||||
const needI18n = (what: string): I18nConfig => {
|
||||
if (!i18n) {throw new Error(`[ipal] createContentHelpers: pass \`i18n\` to use ${what}.`)}
|
||||
@@ -737,7 +756,7 @@ export function createContentHelpers({
|
||||
* null when the site is open or the setting can't be read.
|
||||
*/
|
||||
const constructionPaths = async (): Promise<null | string[]> => {
|
||||
if (!i18n) {return null}
|
||||
if (!i18n || !underConstructionSeo) {return null}
|
||||
try {
|
||||
const mode = await getConstructionMode(i18n.defaultLocale)
|
||||
return mode.enabled ? mode.allowedPaths : null
|
||||
|
||||
@@ -39,9 +39,12 @@ export type SeoOption = {
|
||||
/**
|
||||
* Site Settings → "Search & AI" tab: Search Console / Bing / Yandex
|
||||
* verification, AI crawler policy for robots.txt (getRobots), llms.txt note.
|
||||
* On by default (empty fields change nothing); false removes the tab.
|
||||
* On by default (empty fields change nothing); false removes the tab; a
|
||||
* function gets the plugin's fields and returns the tab's fields (add, drop,
|
||||
* relabel). Keep the field names the readers use (searchVerification,
|
||||
* aiCrawlers, llmsIntro) or read your own fields in your routes.
|
||||
*/
|
||||
searchSettings?: false
|
||||
searchSettings?: ((defaults: Field[]) => Field[]) | false
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user