Behio Storefront SDK
Catalog & Products

Blog

Several blogs per site, published posts with tags, pagination and sanitised HTML

A site (a website or an e-shop) can have several blogs: news, recipes, customer stories. Each blog has its own handle and lives at /blog/{handle}; a post lives at /blog/{handle}/{slug}. Merchants write posts in the Behio admin (or let the AI write a draft); the API only ever returns published posts.

Blog endpoints work with both e-shop keys and website keys, so a company website without a shop can run a blog too.

List blogs

const { data, error } = await client.blog.list('cs');
// data.blogs: [{ handle, name, description, postCount, settings, updatedAt }]

Hide blogs with postCount === 0 from navigation. settings.layout (grid, list, magazine) and settings.postsPerPage are the merchant's presentation hints.

Posts of a blog

const { data: page } = await client.blog.posts('novinky', {
  locale: 'cs',
  page: 1,
  limit: 12,
  tag: 'tipy', // optional, tag slug
});
// page.items: BlogPostListItem[] (featured first, then newest)
// page.total, page.totalPages, page.tags (all tags of the blog for a filter)

One post

import { RichText } from '@behio/storefront-sdk/react';

const { data: post, error } = await client.blog.post('novinky', 'otevreli-jsme-novou-pobocku', 'cs');

if (error || !post) {
  // 404 for a draft, scheduled, archived or unknown post
}

// post.content = { format: "html", html: "<p>...</p>" } sanitised by the API
<RichText html={post.content.html ?? ''} />
// post.related: other posts of the same blog

Render coverUrl as the hero, publishedAt (epoch ms) as a date, readingTimeMin when present, and the related list under the article. Use seoTitle / seoDescription / ogImage for metadata.

React hooks

import { useBlogs, useBlogPosts, useBlogPost } from '@behio/storefront-sdk/react';

const { data: blogs } = useBlogs('cs');
const { data: page } = useBlogPosts('novinky', { locale: 'cs', page: 1 });
const { data: post } = useBlogPost('novinky', 'otevreli-jsme-novou-pobocku', 'cs');

Sitemap

Blog.updatedAt is the latest publish time of the blog; use it as lastmod for /blog/{handle}. For post URLs iterate client.blog.posts(handle, { limit: 50 }) page by page and use publishedAt.

On this page