AI Rules
Paste this into your AI builder or IDE to help it write the integration for zenblog.
text
This is the documentation to integrate zenblog into your website.
Zenblog is a headless CMS that allows you to create and manage your blog. It will host images and videos for you.
You can install the zenblog package with npm i zenblog to use the typed http client for the API. Make sure the package version is 1.2.0 or higher.
To integrate zenblog into your website, you just need to make an HTTP request to the API with the Blog ID which you can find in the Zenblog dashboard. The content is returned as an html string. You have to render it to the dom. You can parse it however you want and change the styles and dom elements for your website as you need.
Here is the schema for the API and typescript/javascript client:
[
{
"id": "posts",
"path": "/blogs/:blogId/posts",
"method": "GET",
"title": "Post list",
"description": "Get posts for a blog",
"examples": {
"typescript": [
{
"description": "Get posts for a blog",
"code": "const { data: posts } = await zenblog.posts.list()"
},
{
"description": "Get posts for a blog filtered by a category",
"code": "const { data: posts } = await zenblog.posts.list({
category: "news",
})"
},
{
"description": "Get posts limit results to 10",
"code": "const { data: posts } = await zenblog.posts.list({
limit: 10,
})"
},
{
"description": "Get posts filtered by tag slugs",
"code": "const { data: posts } = await zenblog.posts.list({
tags: ["tag1", "tag2"],
})"
},
{
"description": "Get posts filtered by author slug",
"code": "const { data: posts } = await zenblog.posts.list({
author: "author-slug",
})"
}
]
},
"query": [
{
"key": "offset",
"required": false,
"description": "The offset for the posts"
},
{
"key": "limit",
"required": false,
"description": "The limit for the posts"
},
{
"key": "category",
"required": false,
"description": "The category slug to filter posts by. Ex: &category=news"
},
{
"key": "tags",
"required": false,
"description": "The tags to filter posts by. Ex: &tags=random,test. Multiple tags are possible."
},
{
"key": "author",
"required": false,
"description": "The author slug to filter posts by. Ex: &author=carpincho"
}
],
"response": {
"200": {
"description": "The posts",
"type": "object",
"example": "{
data: [{
title: "string",
html_content: "string",
slug: "string",
category?: {
name: "string",
slug: "string",
},
tags?: [{
name: "string",
slug: "string",
}],
excerpt?: "string",
published_at: "string",
authors?: [{
slug: "string",
name: "string",
image_url?: "string",
website?: "string",
twitter?: "string",
}],
}],
total?: number,
offset?: number,
limit?: number,
}"
}
}
},
{
"id": "postBySlug",
"path": "/blogs/:blogId/posts/:slug",
"method": "GET",
"title": "Post detail",
"description": "Get a post by its slug",
"response": {
"200": {
"description": "The post",
"type": "object",
"example": "{
title: "string",
html_content: "string",
slug: "string",
category?: {
name: "string",
slug: "string",
},
tags?: [{
name: "string",
slug: "string",
}],
authors?: [{
slug: "string",
name: "string",
image_url?: "string",
website?: "string",
twitter?: "string",
}],
excerpt: "string",
published_at: "string",
}"
}
},
"examples": {
"typescript": [
{
"description": "Get a post by its slug",
"code": "const { data: post } = await zenblog.posts.get({
slug: "post-slug",
})"
}
]
}
},
{
"id": "categories",
"path": "/blogs/:blogId/categories",
"method": "GET",
"title": "Categories list",
"description": "Get the categories for a blog",
"response": {
"200": {
"description": "The categories",
"type": "object",
"example": "{
data: [
{
name: "string",
slug: "string",
}
],
total?: number,
offset?: number,
limit?: number,
}"
}
},
"examples": {
"typescript": [
{
"description": "Get the categories for a blog",
"code": "const { data: categories } = await zenblog.categories.list()"
}
]
}
},
{
"id": "tags",
"path": "/blogs/:blogId/tags",
"method": "GET",
"title": "Tags list",
"description": "Get the tags for a blog",
"response": {
"200": {
"description": "The tags",
"type": "object",
"example": "{
data: [
{
name: "string",
slug: "string",
}
],
total?: number,
offset?: number,
limit?: number,
}"
}
},
"examples": {
"typescript": [
{
"description": "Get the tags for a blog",
"code": "const { data: tags } = await zenblog.tags.list()"
}
]
}
},
{
"id": "authors",
"path": "/blogs/:blogId/authors",
"method": "GET",
"title": "Authors list",
"description": "Get the authors for a blog",
"examples": {
"typescript": [
{
"description": "Get the authors for a blog",
"code": "const { data: authors } = await zenblog.authors.list()"
}
]
},
"response": {
"200": {
"description": "The authors",
"type": "object",
"example": "{ data: [
{
name: "string",
slug: "string",
image_url?: "string",
twitter?: "string",
website?: "string",
bio?: "string",
}
],
total?: number,
offset?: number,
limit?: number,
}"
}
}
},
{
"id": "authorBySlug",
"path": "/blogs/:blogId/authors/:slug",
"method": "GET",
"title": "Author detail",
"description": "Get an author by their slug",
"response": {
"200": {
"description": "The author",
"type": "object",
"example": "{
data: {
name: "string",
slug: "string",
image_url?: "string",
twitter?: "string",
website?: "string",
bio?: "string",
}
}"
}
},
"examples": {
"typescript": [
{
"description": "Get an author by their slug",
"code": "const { data: author } = await zenblog.authors.get({
slug: "author-slug",
})"
}
]
}
}
]