fix(books): 泥潭策展语与回退契约实现;自托管仓星标语义
- BooksPage 实现 schema 注释承诺的 description 回退(正文首段去记号
取 60 字)——视觉复核抓到的"文档说了代码没做"缺口
- 泥潭补人工策展语(回退之上);自托管仓星标改 self-hosted 徽标
(gitea 无 star 真值,★0 语义突兀——视觉复核次要备注)
验证: build 28 页 exit 0;dist/books 含泥潭策展语;dist/opensource
self-hosted 徽标与 ★57 并存实测
Spec: 2026-10-25_add-terminal-books-admin
Co-authored-by: GLM-5.3
This commit is contained in:
1 parent
ce587236e2
commit
40346c3f21
4 files changed
+13
-3
No files matched your search
@@ -39,7 +39,7 @@ try {
|
||||
{p.language}
|
||||
</span>
|
||||
)}
|
||||
<span class="stars">★ {p.stars}</span>
|
||||
<span class="stars">{p.source === 'gitea' ? 'self-hosted' : `★ ${p.stars}`}</span>
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
@@ -12,6 +12,12 @@ const { locale = 'zh' } = Astro.props;
|
||||
const books = (await getCollection('posts', ({ data }) => !data.draft && data.category === 'reading' && !data.tags.includes('hidden')))
|
||||
.sort((a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf());
|
||||
|
||||
// 回退契约(schema 注释声称而此前未实现——视觉复核抓到的缺口):
|
||||
// description 缺省取正文第一个非空段落(去 markdown 记号)前 60 字
|
||||
const firstPara = (body: string | undefined): string => {
|
||||
const line = (body ?? '').split(/\n\s*\n/).map((l) => l.trim()).find((l) => l && !l.startsWith('#') && !l.startsWith('---')) ?? '';
|
||||
return line.replace(/[*_>`\[\]]/g, '').slice(0, 60);
|
||||
};
|
||||
const years = [...new Set(books.map((b) => b.data.pubDate.getFullYear()))].sort((a, b) => b - a);
|
||||
const L = {
|
||||
shelf: locale === 'zh' ? '书架' : 'Books',
|
||||
@@ -36,7 +42,9 @@ const L = {
|
||||
<div class="bk-body">
|
||||
<strong class="bk-title">{b.data.title}</strong>
|
||||
{b.data.bookAuthor && <span class="bk-author">{b.data.bookAuthor}</span>}
|
||||
{b.data.description && <span class="bk-desc">{b.data.description}</span>}
|
||||
{(b.data.description || firstPara(b.body)) && (
|
||||
<span class="bk-desc">{b.data.description ?? firstPara(b.body)}</span>
|
||||
)}
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
Reference in new issue
Block a user