TentoCMS
Classes

Class: CollectionsResource

Collections resource for interacting with the TentoCMS Collections API

Collections resource for interacting with the TentoCMS Collections API

Methods

getBySlug()

getBySlug<TContent>(
   collectionType, 
   slug, 
options?): Promise<CollectionItemResponse<CollectionItem<TContent>>>;

Get a single collection item by its slug

Type Parameters

Type ParameterDefault type
TContentRecord<string, unknown>

Parameters

ParameterTypeDescription
collectionTypestringThe collection type slug
slugstringThe item slug
options?PreviewOption & MediaOption & RefTypesOption-

Returns

Promise<CollectionItemResponse<CollectionItem<TContent>>>

The collection item object with content fields merged into root

Throws

If the item is not found

Example

const result = await client.collections.getBySlug('products', 'awesome-product')
console.log(result.data._sortOrder)    // Sort order
console.log(result.data._publishedAt)  // Publish date

list()

list<TContent>(collectionType, options?): Promise<CollectionListResponse<CollectionItem<TContent>>>;

List all items in a collection

Type Parameters

Type ParameterDefault type
TContentRecord<string, unknown>

Parameters

ParameterTypeDescription
collectionTypestringThe collection type slug
options?CollectionListOptionsQuery options for filtering, pagination, and sorting

Returns

Promise<CollectionListResponse<CollectionItem<TContent>>>

Paginated list of collection items with content fields merged into root

Example

// Basic list — alphabetical ascending
const result = await client.collections.list('products', {
  page: 1,
  limit: 20,
  sort: 'name',
})

// Newest first (descending publishedAt)
const latest = await client.collections.list('products', {
  sort: '-publishedAt',
})

// Manual authored order
const ordered = await client.collections.list('nav-items', {
  sort: '_sortOrder',
})

// With filters
const filtered = await client.collections.list('products', {
  filters: [
    { field: 'slug', operator: 'contains', value: 'premium' }
  ]
})
Copyright © 2026