移除旧版 HTML 模板与兼容层,并完善私信、举报、媒体存储与 SEO。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-03 16:37:11 +08:00
parent 060b7707cb
commit 48db333272
121 changed files with 11147 additions and 3225 deletions

View File

@@ -0,0 +1,18 @@
/** 从 HTML 提取纯文本摘要(供页面 description / OG */
export function excerptFromHTML(html: string, max = 160): string {
if (!html) return '';
const doc = new DOMParser().parseFromString(html, 'text/html');
const text = (doc.body.textContent || '').replace(/\s+/g, ' ').trim();
if (text.length <= max) return text;
return `${text.slice(0, Math.max(0, max - 1))}`;
}
/** 正文中第一张图片 URL */
export function firstImageFromHTML(html: string): string {
if (!html) return '';
const doc = new DOMParser().parseFromString(html, 'text/html');
const img = doc.querySelector('img[src]');
const src = img?.getAttribute('src')?.trim() || '';
if (!src || src.startsWith('data:')) return '';
return src;
}