Pular para o conteúdo principal

externalCollectionInstance <C>

An Instance that provide methods to request information and items from a specific Collection.

You can access a CollectionInstance using StarlightClient.collection.

To list all workspace collections, use a CollectionSelector.

Index

Methods

Methods

externalget

  • Returns a StarlightItemResponse with a single Collection.

    @example

    Requesting information from a collection of slug featured-news.

    import Starlight from '@starlightcms/js-sdk'

    const response = await Starlight.collection('featured-news').get()

    Returns Promise<StarlightItemResponse<Collection<CollectionTypeMapper<C>>>>

externalitems

  • Returns a StarlightListResponse with the list of items of this Collection. The returned list type depends on the collection type: a list of Entries for a collection of type entry, a list of MediaObjects for a collection o type media, and so on.

    If the given Collection is not typed, this method will return a response of StarlightListResponse<unknown>.

    @example

    Requesting all items from an Entry collection of slug featured-news.

    import Starlight from '@starlightcms/js-sdk'

    const response = await Starlight.collection('featured-news').items()
    @example

    Explicitly typing the returned items. Only possible in TypeScript.

    import Starlight from '@starlightcms/js-sdk'
    import { NewsPostType } from '../types'

    // response will be StarlightListResponse<Entry<NewsPostType>>
    const response = await Starlight.collection<Entry<NewsPostType>>('featured-news').items()

    Parameters

    Returns Promise<StarlightListResponse<C>>