diff --git a/server/src/routes/seo.js b/server/src/routes/seo.js index 1ffd21f..546f097 100644 --- a/server/src/routes/seo.js +++ b/server/src/routes/seo.js @@ -64,6 +64,52 @@ router.get('/sitemap.xml', async (req, res) => { ) }) + +// ===== 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}' + +router.get('/trends', async (req, res) => { + const o = origin(req) + let items = [] + try { items = await Trend.find({}).sort({ newsDate: -1 }).limit(30).lean() } catch (e) {} + const list = items.map((t) => ` +
+

${esc(t.title)}

+ ${t.summary ? `

${esc(String(t.summary).slice(0, 120))}

` : ''} +
${esc(t.category || '资讯')}${esc(t.source || '')} · ${(t.newsDate || t.createdAt || '').toString().slice(0, 10)}
+
`).join('') + res.type('html').send(` +每日 AI 趋势速递 | 宇之然AI维度 + + + +

每日 AI 趋势速递

+
宇之然AI维度 · 自动采集更新
+${list || '

暂无内容

'} +
© ${new Date().getFullYear()} 宇之然 · 打开小程序获取完整体验
+`) +}) + +router.get('/trends/:id', async (req, res) => { + const o = origin(req) + let t = null + try { t = await Trend.findById(req.params.id).lean() } catch (e) {} + if (!t) return res.status(404).type('html').send('

内容不存在

返回趋势列表') + res.type('html').send(` +${esc(t.title)} | AI维度趋势 + + + +${esc(t.category || '资讯')} +

${esc(t.title)}

+
${esc(t.source || '')} · ${(t.newsDate || t.createdAt || '').toString().slice(0, 10)}
+${t.summary ? `

${esc(t.summary)}

` : ''} +${t.body ? `
${esc(t.body).split('\n').map((p) => `

${p}

`).join('')}
` : ''} +${t.sourceUrl ? `

阅读原文 →

` : ''} +
← 更多 AI 趋势 · © 宇之然
+`) +}) + router.get('/llms.txt', (req, res) => { const o = origin(req) res.type('text/markdown').send(