「文章正文」包含在 Pro 里,开通会员后显示预览。
用法
import { BlogArticle } from './BlogArticle.jsx'
// It reads its scroll from the nearest scrolling box, so it works in the page or in a panel.
<BlogArticle
locale="en"
article={post} // { topic, title, dek, date: '2026-11-24', minutes, author: { name }, sections: [{ id, heading, body: [...], quote? }] }
likes={post.likes}
liked={visitor.liked.includes(post.id)}
url={'https://example.com/posts/' + post.slug}
onLike={(liked) => fetch('/api/likes', { method: 'POST', body: JSON.stringify({ id: post.id, liked }) })}
/>属性
| 属性 | 类型 | 默认值 | 作用 |
|---|---|---|---|
locale | 'en' | 'zh-CN' | 'es' | 'ja' | 'en' | 内置文字、日期格式和示例文章的语言。 |
article | { topic, title, dek?, cover?, date, minutes, author: { name }, sections: Array<{ id, heading, body: string[], quote? }> } | null | sample essay | 文章内容,小标题会生成目录;cover 是封面图片地址(不传时显示一幅手绘的锅);传 null 或没有段落时显示空状态。 |
likes / liked / onLike | number / boolean / (liked) => void | 214 / false | 喜欢数、这位访客是否点过,以及点或取消时的回调。 |
url / onCopy | string / (url) => void | the page address | 复制按钮复制的链接,以及复制成功后的回调。 |
loading / error / onRetry | boolean / boolean | string / () => void | false | 显示骨架,或带重试的出错提示;传字符串可替换说明。 |
labels | object | — | 替换任意内置文字(键名见 copy.js)。 |
装进你的项目
Pro 包含这个区块的完整源码。复制指令,让你的 Agent 把它安装到项目中。
BlogArticle.jsxblog-article.csscopy.jskit.jsxkit.cssui/base-button/ui/copy-button/ui/like-button/ui/avatar-group/ui/empty-state/ui/alert-banner/ui/skeleton-shimmer/tokens.cssREADME.md
区块本身、样式和文案、共用的 kit、用到的组件和 tokens.css 会一起装进同一个文件夹。
