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 Parameter | Default type |
|---|---|
TContent | Record<string, unknown> |
Parameters
| Parameter | Type | Description |
|---|---|---|
collectionType | string | The collection type slug |
slug | string | The 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 Parameter | Default type |
|---|---|
TContent | Record<string, unknown> |
Parameters
| Parameter | Type | Description |
|---|---|---|
collectionType | string | The collection type slug |
options? | CollectionListOptions | Query 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' }
]
})

