seo: 新增/sitemap-baidu.xml纯净站点地图(去llms.txt,规避百度索引型判定)

This commit is contained in:
Hermes Agent
2026-09-17 18:25:34 +08:00
parent 1fc358d47c
commit bcb239c51b
+19
View File
@@ -71,6 +71,25 @@ router.get('/sitemap.xml', async (req, res) => {
})
// 面向百度的纯净 sitemap(不含 llms.txt 等非页面资源,避免被判为索引型)
router.get('/sitemap-baidu.xml', async (req, res) => {
const o = origin(req)
const today = new Date().toISOString().slice(0, 10)
let trendUrls = ''
try {
const items = await Trend.find({}).sort({ newsDate: -1 }).limit(20).lean()
trendUrls = items.map((t) => ` <url><loc>${o}/trends/${t._id}</loc><lastmod>${(t.newsDate || t.createdAt || new Date()).toISOString().slice(0, 10)}</lastmod><changefreq>daily</changefreq></url>`).join('\n')
} catch (e) {}
res.type('application/xml').send(
`<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n` +
[` <url><loc>${o}/</loc><lastmod>${today}</lastmod><changefreq>daily</changefreq></url>`,
` <url><loc>${o}/trends</loc><lastmod>${today}</lastmod><changefreq>daily</changefreq></url>`,
` <url><loc>${o}/about</loc><changefreq>monthly</changefreq></url>`].join('\n') +
(trendUrls ? '\n' + trendUrls : '') +
`\n</urlset>`
)
})
// ===== SSR 趋势页(SEO/GEO:真实内容直出,搜索引擎可收录) =====
const TREND_PAGE_CSS = 'body{font-family:-apple-system,"PingFang SC",sans-serif;color:#1f2333;max-width:720px;margin:0 auto;padding:24px 18px;line-height:1.7}h1{font-size:22px}.meta{color:#9aa0b4;font-size:12px;margin:4px 0 20px}a{color:#5b5ff8;text-decoration:none}.item{padding:14px 0;border-bottom:1px solid #eef0f6}.item h2{font-size:16px;margin:0 0 6px}.item p{margin:0;font-size:13px;color:#6b7080}.item .m{font-size:11px;color:#a6abbb;margin-top:4px}.tag{display:inline-block;background:rgba(91,95,248,.1);color:#5b5ff8;border-radius:99px;padding:1px 8px;font-size:11px;margin-right:6px}.foot{margin-top:28px;color:#b6bac9;font-size:12px}.plain{background:#f5f5ff;border-left:3px solid #5b5ff8;padding:8px 12px;margin:8px 0;font-size:14px;color:#3a3f55}.plainbox{background:#f5f5ff;border-left:3px solid #5b5ff8;padding:10px 14px;border-radius:0 8px 8px 0;margin:14px 0}.plainbox p{margin:4px 0;font-size:14px;color:#3a3f55}'