XML Style
This commit is contained in:
@@ -19,6 +19,8 @@ export function withSecurityHeaders(res, options = {}) {
|
||||
res.setHeader('X-Content-Type-Options', 'nosniff');
|
||||
res.setHeader('X-Frame-Options', 'DENY');
|
||||
res.setHeader('Permissions-Policy', 'camera=(), microphone=(), geolocation=()');
|
||||
if (options.contentSecurityPolicy === false) return;
|
||||
|
||||
const scriptSrc = options.scriptNonce ? `script-src 'self' 'nonce-${options.scriptNonce}'; ` : '';
|
||||
res.setHeader(
|
||||
'Content-Security-Policy',
|
||||
|
||||
+18
-14
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user