API Reference

getBlogBySlug()

Fetches a single blog by its URL slug, including the full rich-text content block array.

Code
const blog = await client.getBlogBySlug(slug: string)
// returns: Blog

Parameters

ParamTypeDescription
slugstringExact slug value stored in blogjs. No partial matching.

Return value

Returns the first matching Blog object, or null if not found.

Code
// Blog object, types mentioned in types page
Blog

Example

For Relevant TypeScript types.

Code
const blog: Blog | null = await client.getBlogBySlug("my-first-post");

if (!blog) {
  notFound();
}

const blocks: ContentBlock[] = JSON.parse(blog.content ?? "[]");
// or use normalizeContent() helper from the detail page template