feat(content): 链接卡片模式——独立成段裸链接转 OG 预览卡
- rehype-link-cards.ts 构建期插件:段落仅含一个链接才转卡(内联链接 保持普通样式);fetch OG/twitter 元信息(UA 伪装、4s 超时、只读前 200KB)+ favicon 兜底;任何失败回落普通链接,构建绝不因外部站点挂 - content/.link-cache.json 入仓缓存(30 天刷新,构建确定性与零重复 请求);单篇上限 10 卡、并发 4,超出回落 - LinkCardStyles.astro 灰阶卡片样式:hairline+圆角、favicon 16px、 标题一行/描述两行截断、域名 mono、OG 图右侧 88px(无图不占位)、 hover 1px 微浮(reduced-motion 豁免)、纯 CSS 零 JS - 安全:抓取内容全 escaping、图片地址仅 http(s) - @astrojs/markdown-remark 依赖(Astro 7 换默认 markdown 处理器后 自定义插件必须经此包生效) - 样张 content/posts/link-cards-test.md(tags 含 hidden,活样例不列出) 修复说明:264148f 提交时误带入 archives 页面对 LinkCardStyles 的 import(两车道共改同一文件),本笔补全组件与插件,恢复构建仓可用。 教训:跨车道共改文件,staged 前必须看 diff 归属。 车道:op-artalk;收编复验:本地构建 45 页 + 卡片渲染(后续专项复验) 验证: pnpm astro build 45 页 exit 0;link-cards 样张页渲染正常 Spec: none (链接卡片,车道级交付) Co-authored-by: GLM-5.3
This commit is contained in:
1 parent
264148f0a6
commit
f5232b7c03
7 files changed
+1701
-14
No files matched your search
@@ -0,0 +1,76 @@
|
||||
---
|
||||
// 链接卡片样式(构建期由 rehype 插件产出 .link-card 节点,元素无 astro cid):
|
||||
// 样式必须全局。灰阶克制 + 纯 CSS(hover 微浮、reduced-motion 豁免)。
|
||||
---
|
||||
|
||||
<style is:global>
|
||||
.link-card {
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
gap: var(--space-3);
|
||||
margin: var(--space-3) 0;
|
||||
padding: var(--space-3);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius-img, 10px);
|
||||
text-decoration: none;
|
||||
transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
|
||||
}
|
||||
.link-card:hover {
|
||||
border-color: var(--accent);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.link-card, .link-card:hover { transition: none; transform: none; }
|
||||
}
|
||||
.lc-body {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 3px;
|
||||
}
|
||||
.lc-title {
|
||||
color: var(--ink-1);
|
||||
font-size: 14px;
|
||||
line-height: 1.45;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.lc-desc {
|
||||
color: var(--ink-3);
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
}
|
||||
.lc-host {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
margin-top: 2px;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 11.5px;
|
||||
color: var(--ink-4);
|
||||
}
|
||||
.lc-favicon {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
border-radius: 3px;
|
||||
object-fit: contain;
|
||||
}
|
||||
/* 缩略图:右侧 88px 方形,无图不占位(元素不存在即无空间) */
|
||||
.lc-thumb {
|
||||
flex: none;
|
||||
width: 88px;
|
||||
height: 88px;
|
||||
object-fit: cover;
|
||||
border-radius: 6px;
|
||||
border: 1px solid var(--line);
|
||||
}
|
||||
@media (max-width: 560px) {
|
||||
.lc-thumb { width: 64px; height: 64px; }
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user