API Reference

getBlogs()

Returns a paginated list of blogs, optionally filtered by a search query across title, description, and slug. Results can also be filtered by category and tag.

Code
const result = await client.getBlogs(pagination?: PaginationOptions)
// returns: PaginatedResult<Blog>

Parameters

ParamTypeDefaultDescription
pagenumber11-indexed page number. Clamped to min 1.
limitnumber10Items per page. Clamped to 1-100.
querystring""Search string. Matched case-insensitively against title, description, and slug.
categorystring""Category name or slug. Matched case-insensitively.
tagstring""Tag name or slug. Matched case-insensitively.

Return value

For Relevant TypeScript types.

Code
{
  data: Blog[],
  pagination: {
    page:       number,   // current page
    limit:      number,   // items per page
    total:      number,   // total matching blogs
    totalPages: number,   // Math.ceil(total / limit)
    hasMore:    boolean,  // page < totalPages
  }
}

Example

Code
const result = await client.getBlogs({
  page: 2,
  limit: 6,
  query: "react",
  category: "technology",
  tag: "typescript",
});

console.log(result.pagination.total);  // e.g. 14
console.log(result.pagination.hasMore); // true
result.data.forEach((b) => console.log(b.title));

Taxonomy Filters

Use getCategories() and getTags() to populate filter controls with taxonomy values used by published blogs in the current project.

Code
const categories = await client.getCategories();
const tags = await client.getTags();

const categoryOptions = categories.map((category) => ({
  label: category.name,
  value: category.slug,
}));
Info
The query, category, and tag values are trimmed before they are sent to client methods.