List Posts
Retrieve published blog posts with pagination.
Updated
On this page
Overview
Fetch a paginated list of published blog posts. Supports filtering by category, tag, search, and custom fields.
SDK Usage
import dash from "@/lib/dash"
const { posts, pagination } = await dash.blog.list({
limit: 10,
offset: 0,
})
// posts = [{ id, title, slug, excerpt, featured_image, author, published_at, ... }]
Parameters
| Parameter | Type | Description |
|---|---|---|
limit | number | Posts per page (default: 20) |
offset | number | Skip N posts |
category | string | Filter by category slug |
tag | string | Filter by tag |
search | string | Search in title and content |
featured | boolean | Only featured posts |
customFields | object | Filter by custom field values |
Blog Listing Page
// app/blog/page.tsx
import dash from "@/lib/dash"
export default async function BlogPage({ searchParams }) {
const { posts, pagination } = await dash.blog.list({
limit: 12,
offset: Number(searchParams.offset) || 0,
category: searchParams.category,
})
return (
<div className="grid md:grid-cols-3 gap-6">
{posts.map(post => (
<a key={post.id} href={`/blog/${post.slug}`} className="block">
<img src={post.featured_image} alt={post.title} />
<h2>{post.title}</h2>
<p>{post.excerpt}</p>
<time>{new Date(post.published_at).toLocaleDateString()}</time>
</a>
))}
</div>
)
}
List Blog Categories
const { categories } = await dash.blog.listCategories()
// categories = [{ id, name, slug }, ...]
REST API
GET /storefront/blog/posts?limit=12&category=news&search=update
X-API-Key: pk_live_your_key
GET /storefront/blog/categories
X-API-Key: pk_live_your_key
Next Steps
- Get Post by Slug — Single post with full content
- Blog SEO — Meta tags for blog posts
- Recipe: Build a Blog — Full blog implementation