XML Style

This commit is contained in:
2026-05-09 13:16:52 -03:00
parent 290cbd5bcb
commit 908084c394
4 changed files with 34 additions and 17 deletions
+18 -14
View File
@@ -87,7 +87,7 @@ export function llmsTxt(baseUrl) {
'Crawler guidance:',
'- Public approved meme images are available under /media/<sha256>.',
'- Admin, review, upload, and API mutation routes are not public knowledge sources.',
'- The site is intentionally visual and sparse; use metadata, sitemap image entries, and JSON feed for machine summaries.',
'- The site is intentionally visual and sparse; use metadata, sitemap URLs, and JSON feed for machine summaries.',
''
].join('\n');
}
@@ -132,22 +132,26 @@ export function feedJson(baseUrl, memes) {
}
export function sitemapXml(baseUrl, memes) {
const images = memes.slice(0, 1000).map((meme) => [
' <image:image>',
` <image:loc>${xmlEscape(`${baseUrl}/media/${meme.id}`)}</image:loc>`,
` <image:caption>${xmlEscape(`Meme ${shortId(meme.id)} with MEME_CONSENSUS_SCORE ${meme.moderationScore}/100`)}</image:caption>`,
' </image:image>'
].join('\n')).join('\n');
const latest = memes[0]?.createdAt || new Date().toISOString();
const urls = [
[
' <url>',
` <loc>${xmlEscape(`${baseUrl}/`)}</loc>`,
` <lastmod>${xmlEscape(latest)}</lastmod>`,
' </url>'
].join('\n'),
...memes.slice(0, 1000).map((meme) => [
' <url>',
` <loc>${xmlEscape(`${baseUrl}/media/${meme.id}`)}</loc>`,
` <lastmod>${xmlEscape(meme.createdAt)}</lastmod>`,
' </url>'
].join('\n'))
].join('\n');
return [
'<?xml version="1.0" encoding="UTF-8"?>',
'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">',
' <url>',
` <loc>${xmlEscape(`${baseUrl}/`)}</loc>`,
' <changefreq>hourly</changefreq>',
' <priority>1.0</priority>',
images,
' </url>',
'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">',
urls,
'</urlset>',
''
].join('\n');