Contents (SDK)
Typed client for blog posts and long-form content.
Wraps the Contents REST API.
Methods
inventra.contents.list()
Lists every published content item for the organization, newest first. The list response omits the article body — use getBySlug to load the full content.
const posts = await inventra.contents.list();Returns Promise<ContentListItem[]>
inventra.contents.getBySlug(slug)
Returns the full content detail (including markdown body) for a given slug.
const post = await inventra.contents.getBySlug('how-to-grow-with-content');
console.log(post.content); // raw markdownReturns Promise<ContentDetail>
Types
interface ContentListItem {
id: string;
title: string;
slug: string;
excerpt: string | null;
categoryName: string | null;
categorySlug: string | null;
authorName: string;
publishedAt: string;
featuredImage: { url: string; alt: string } | null;
seoMetadata: { title: string; description: string } | null;
tags: string[];
}
interface ContentDetail extends ContentListItem {
content: string; // markdown
}Example: blog index page
import { Inventra } from 'inventra';
const inventra = new Inventra({
apiKey: process.env.INVENTRA_API_KEY!,
orgId: process.env.INVENTRA_ORG_ID!
});
export default async function BlogIndex() {
const posts = await inventra.contents.list();
return (
<ul>
{posts.map((post) => (
<li key={post.id}>
<a href={`/blog/${post.slug}`}>
<h2>{post.title}</h2>
<p>{post.excerpt}</p>
</a>
</li>
))}
</ul>
);
}Example: individual blog post
import { Inventra } from 'inventra';
import { Markdown } from 'inventra/react';
const inventra = new Inventra({
apiKey: process.env.INVENTRA_API_KEY!,
orgId: process.env.INVENTRA_ORG_ID!
});
export default async function BlogPost({ params }: { params: { slug: string } }) {
const post = await inventra.contents.getBySlug(params.slug);
return (
<article>
<h1>{post.title}</h1>
<p>By {post.authorName} · {post.publishedAt}</p>
<Markdown>{post.content}</Markdown>
</article>
);
}