示例工程 04-head-metadata
04-head-metadata/demo-02-social/index.html
点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>分享卡片</title>
<meta name="description" content="用 OG 标签生成分享预览。" />
<meta property="og:title" content="分享卡片" />
<meta property="og:description" content="标题、描述与类型决定预览卡内容。" />
<meta property="og:type" content="website" />
<meta name="twitter:card" content="summary" />
<style>
body { margin: 0; padding: 32px; background: #f8fafc; color: #0f172a; font-family: system-ui, sans-serif; line-height: 1.75; }
h1 { margin: 0 0 8px; font-size: 28px; }
p { margin: 0 0 18px; color: #334155; }
.card { max-width: 420px; overflow: hidden; border: 1px solid #e2e8f0; border-radius: 12px; background: #fff; }
.media { height: 130px; background: linear-gradient(135deg, #0ea5e9, #2563eb); }
.body { padding: 14px 16px; }
.site { color: #64748b; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
.title { margin: 4px 0; font-size: 17px; font-weight: 700; }
.desc { margin: 0; color: #64748b; font-size: 13px; }
</style>
</head>
<body>
<h1>分享卡片</h1>
<p>下面是社交平台可能生成的预览样式。</p>
<div class="card">
<div class="media" aria-hidden="true"></div>
<div class="body">
<span class="site">example.com</span>
<p class="title">分享卡片</p>
<p class="desc">标题、描述与类型决定预览卡内容。</p>
</div>
</div>
</body>
</html>