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 ? '📷 图片' : '短文'
+}
diff --git a/frontend/src/views/ArchiveView.vue b/frontend/src/views/ArchiveView.vue
index 38c32ce..2742dcb 100644
--- a/frontend/src/views/ArchiveView.vue
+++ b/frontend/src/views/ArchiveView.vue
@@ -5,7 +5,7 @@ import RightRail from '../components/RightRail.vue'
import { publicApi } from '../api'
import YohakuArchive from '../ui/yohaku/YohakuArchive.vue'
import { applyDocTitle, site } from '../site'
-import { formatDateShort } from '../utils'
+import { formatDateShort, stripTags } from '../utils'
const years = ref([])
// vivid(余白)是另一套 DOM,数据来源不变,只在视图层分叉
@@ -29,6 +29,21 @@ const total = computed(() =>
years.value.reduce((n, y) => n + (y.count || 0), 0)
)
+// 短文摘录:与「最近更新」同一套规则——贴链接的短文开头是 URL 本身,
+// 先剥 ;剥完没字(纯链接贴)退到链接卡标题
+const EXCERPT_LEN = 48
+function excerpt(p) {
+ if (p.kind !== 'short') return p.title || '无题'
+ const noLinks = (p.content_html || '').replace(/]*>[\s\S]*?<\/a>/gi, ' ')
+ const text = stripTags(noLinks).replace(/\s+/g, ' ').trim()
+ if (text) return text.length > EXCERPT_LEN ? text.slice(0, EXCERPT_LEN) + '…' : text
+ if (p.link_card && p.link_card.title) {
+ const t = p.link_card.title
+ return t.length > EXCERPT_LEN ? t.slice(0, EXCERPT_LEN) + '…' : t
+ }
+ return p.images && p.images.length ? '📷 图片' : '短文'
+}
+
applyDocTitle('归档')
@@ -59,7 +74,7 @@ applyDocTitle('归档')
{{ formatDateShort(p.published_at).slice(5) }}
- {{ p.kind === 'short' ? '短文' : p.title || '无题' }}
+ {{ excerpt(p) }}
短