Usage
import { BlogPosts } from './BlogPosts.jsx'
// Without callbacks it filters and pages the posts it is given. Wire it to your posts:
<BlogPosts
locale="en"
topics={[{ id: 'bread', name: 'Bread' }]}
posts={posts} // [{ id, topic, title, excerpt, date: '2026-11-20', minutes, likes }]
liked={likedIds}
postHref={(post) => '/posts/' + post.id}
loading={!posts}
error={postsError}
onRetry={reloadPosts}
onLike={(id, liked) => fetch('/api/likes', { method: 'POST', body: JSON.stringify({ id, liked }) })}
/>Props
| Prop | Type | Default | What it does |
|---|---|---|---|
locale | 'en' | 'zh-CN' | 'es' | 'ja' | 'en' | Language of the built-in text, the dates and the sample posts. |
posts | Array<{ id, topic, title, excerpt?, date, minutes, likes? }> | sample posts | The posts, newest first; `date` is an ISO day. An empty array shows the empty state. |
topics | Array<{ id, name }> | sample topics | The topics shown as filter chips, after “All”. |
pageSize | number | 4 | Posts per page. |
liked | string[] | [] | Ids of the posts this visitor already liked. |
loading / error | boolean / boolean | string | false | Shows the skeleton rows, or the error banner with a retry; a string replaces its sentence. |
onLike / onOpen / postHref | (id, liked) => void / (post) => void / (post) => string | — | A like was given or taken back; a title was opened (instead of following its link); the link of a post. |
onTopicChange / onPageChange / onRetry | (id) => Promise | void / (page) => Promise | void / () => Promise | void | — | Called on a new topic or page (the list waits for a returned promise), or on retry. |
labels | object | — | Replaces any built-in text (keys as in copy.js). |
Add it to your project
Copy the prompt into Codex or Claude Code. The agent reads the published source, shows you what it will write and adds the block together with the components it is built from.
BlogPosts.jsxblog-posts.csscopy.jskit.jsxkit.cssui/base-button/ui/like-button/ui/empty-state/ui/alert-banner/ui/chip-group/ui/scroll-reveal/ui/skeleton-shimmer/ui/spinner/ui/pagination/tokens.cssREADME.md
The block, its stylesheet and text, the shared kit, the components it uses and tokens.css install together into one folder.