CMS

Overview

Manage your content in TurboStarter.

TurboStarter implements a CMS interface that abstracts the implementation from where you store your data. It provides a simple API to interact with your data, and it's easy to extend and customize.

By default, the starter kit ships with these implementations in place:

  1. Content Collections - a headless CMS that uses MDX files to store your content.

The implementation is available under @turbostarter/cms package, here we'll go over how to use it.

API

The CMS package provides a simple, unified API to interact with the content. It's the same for all the providers, so you can easily use it with any of the implementations without changing the code.

Fetching content items

To fetch items from your colletions, you can use the getContentItems function.

import { getContentItems } from "@turbostarter/cms";
 
const { items, count } = getContentItems({
  collection: CollectionType.BLOG,
  tags: [ContentTag.SKILLS],
  sortBy: "publishedAt",
  sortOrder: SortOrder.DESCENDING,
  status: ContentStatus.PUBLISHED,
});

It accepts an object with the following properties:

  • collection: The collection to fetch the items from.
  • tags: The tags to filter the items by.
  • sortBy: The field to sort the items by.
  • sortOrder: The order to sort the items in.
  • status: The status of the items to fetch. It can be published or draft. By default, only published items are fetched.

Fetching a single content item

To fetch a single content item, you can use the getContentItemBySlug function.

import { getContentItemBySlug } from "@turbostarter/cms";
 
const item = getContentItemBySlug({
  collection: CollectionType.BLOG,
  slug: "my-first-blog-post",
  status: ContentStatus.PUBLISHED,
});

It accepts an object with the following properties:

  • collection: The collection to fetch the item from.
  • slug: The slug of the item to fetch.
  • status: The status of the item to fetch. It can be published or draft. By default, only published items are fetched.

Last updated on

On this page

Ship your startup everywhere. In minutes.Get TurboStarter