diff --git a/frontend/src/ui/yohaku/YohakuArchive.vue b/frontend/src/ui/yohaku/YohakuArchive.vue index 742f57e..6b525e3 100644 --- a/frontend/src/ui/yohaku/YohakuArchive.vue +++ b/frontend/src/ui/yohaku/YohakuArchive.vue @@ -2,20 +2,31 @@ import { RouterLink } from 'vue-router' // 余白归档。对应设计稿 viewArchive():page-head + 年块(年 + 篇数)+ 月分组。 -// 短文没有标题,列表里用正文开头(后端对 short 返回全文 content_html,够用)。 +// 短文没有标题,列表里用正文开头当标识——与侧栏「最近更新」同一套摘录规则: +// 先剥 (贴链接的短文开头是 URL 本身,没有信息量),剥完没字退到链接卡标题。 const props = defineProps({ years: { type: Array, default: () => [] } }) const fmt = new Intl.DateTimeFormat('zh-CN', { year: 'numeric', month: '2-digit', day: '2-digit' }) const fmtDate = (iso) => fmt.format(new Date(iso)).replace(/\//g, '-') -const kindLabel = (k) => (k === 'long' ? '长文' : '短文') +const kindLabel = (k) => (k === 'long' ? '长' : '短') const plain = (html) => { if (!html) return '' const el = document.createElement('div') el.innerHTML = html return (el.textContent || '').trim() } -const titleOf = (p) => (p.kind === 'long' ? p.title : plain(p.content_html).slice(0, 48)) +const titleOf = (p) => { + if (p.kind === 'long') return p.title || '无题' + const noLinks = (p.content_html || '').replace(/]*>[\s\S]*?<\/a>/gi, ' ') + const text = plain(noLinks) + if (text) return text.length > 48 ? text.slice(0, 48) + '…' : text + if (p.link_card && p.link_card.title) { + const t = p.link_card.title + return t.length > 48 ? t.slice(0, 48) + '…' : t + } + return p.images && p.images.length ? '📷 图片' : '短文' +}