SEO/GEO/GSC: sitemap index + caching, Search & AI settings, getRobots
- Sitemap: batched reads (500), published-only where, field select; sitemap index over maxUrls (default 10k) with ?part=N; Cache-Control; in-process memo; runtime errors → 503 Retry-After (empty urlset only during next build) - Site Settings → Search & AI tab (seo.searchSettings: false removes it): Google/Bing/Yandex verification (paste code or whole meta tag) added to page metadata; AI crawler policy + per-bot exceptions; llms.txt note - buildRobots aiBotRules; getRobots helper reads the panel; more AI agents - Under construction: sitemap and llms.txt list only open pages - collectSiteIndex: no silent 1000 cap; llms routes send Cache-Control - IndexNow: nothing sent with IPAL_NOINDEX - Unknown route metadata is noindex - Tests (unit + SQLite integration) and docs/seo.md Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
12fbd424a5
commit
94e563055f
@@ -43,27 +43,53 @@ type BuildSitemapXmlOptions = {
|
||||
* NOTE: if you use this custom route, DON'T also keep app/sitemap.ts — pick one.
|
||||
* Two sitemaps confuse crawlers.
|
||||
*/
|
||||
const esc = (s: string): string =>
|
||||
s
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''')
|
||||
|
||||
const isoOf = (d: Date | string): string => (d instanceof Date ? d.toISOString() : String(d))
|
||||
|
||||
/** One child sitemap listed in a sitemap index. */
|
||||
export type SitemapIndexItem = { lastModified?: Date | string; url: string }
|
||||
|
||||
/**
|
||||
* Sitemap index (`<sitemapindex>`) — what /sitemap.xml returns once a site has
|
||||
* more URLs than one file should hold. Each child carries the newest lastmod
|
||||
* of its URLs, so crawlers re-read only the parts that changed.
|
||||
*/
|
||||
export function buildSitemapIndexXml(items: SitemapIndexItem[], opts: BuildSitemapXmlOptions = {}): string {
|
||||
const stylesheet = opts.cssUrl ? `<?xml-stylesheet type="text/css" href="${esc(opts.cssUrl)}"?>\n` : ''
|
||||
const body = items
|
||||
.map((i) => {
|
||||
const parts = [` <loc>${esc(i.url)}</loc>`]
|
||||
if (i.lastModified) {parts.push(` <lastmod>${esc(isoOf(i.lastModified))}</lastmod>`)}
|
||||
return ` <sitemap>\n${parts.join('\n')}\n </sitemap>`
|
||||
})
|
||||
.join('\n')
|
||||
return (
|
||||
`<?xml version="1.0" encoding="UTF-8"?>\n` +
|
||||
stylesheet +
|
||||
`<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n` +
|
||||
body +
|
||||
`\n</sitemapindex>`
|
||||
)
|
||||
}
|
||||
|
||||
export function buildSitemapXml(
|
||||
entries: SitemapEntry[],
|
||||
opts: BuildSitemapXmlOptions = {},
|
||||
): string {
|
||||
const { cssUrl } = opts
|
||||
|
||||
const esc = (s: string): string =>
|
||||
s
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''')
|
||||
|
||||
const urls = entries
|
||||
.map((e) => {
|
||||
const parts = [` <loc>${esc(e.url)}</loc>`]
|
||||
if (e.lastModified) {
|
||||
const iso =
|
||||
e.lastModified instanceof Date ? e.lastModified.toISOString() : String(e.lastModified)
|
||||
parts.push(` <lastmod>${esc(iso)}</lastmod>`)
|
||||
parts.push(` <lastmod>${esc(isoOf(e.lastModified))}</lastmod>`)
|
||||
}
|
||||
if (e.changeFrequency) {parts.push(` <changefreq>${e.changeFrequency}</changefreq>`)}
|
||||
if (typeof e.priority === 'number') {parts.push(` <priority>${e.priority}</priority>`)}
|
||||
|
||||
Reference in New Issue
Block a user