Logo

Contents

The contents module provides methods to interact with the contents API.

GetContents

Get all contents from the workspace.

import { postivaClient } from "@/libs/postiva";
 
async function getContents() {
  try {
    const contents = await postivaClient.contents.getContents();
    console.log(contents);
  } catch (error) {
    console.error('Error fetching contents:', error);
  }
}

Parameters

PropTypeDefault
query
string
-
categories
string[]
-
tags
string[]
-
type
ContentStatusEnum
-
pagination
IPaginatinoOptions
-

searchContents

Search for contents in the workspace.

import { postivaClient } from "@/libs/postiva";
 
async function searchContents(query: string) {
  try {
    const content = await postivaClient.contents.searchContents(query);
    console.log(content);
  } catch (error) {
    console.error('Error fetching content:', error);
  }
}

getContentById

Get a content by its ID.

import { postivaClient } from "@/libs/postiva";
 
async function getContentById(id: string) {
  try {
    const content = await postivaClient.contents.getContentById(id);
    console.log(content);
  } catch (error) {
    console.error('Error fetching content:', error);
  }
}

getContentBySlug

Get a content by its slug.

import { postivaClient } from "@/libs/postiva";
 
async function getContentBySlug(slug: string) {
  try {
    const content = await postivaClient.contents.getContentBySlug(slug);
    console.log(content);
  } catch (error) {
    console.error('Error fetching content:', error);
  }
}

On this page