Pular para o conteúdo principal

externalSingletonSelector

A Selector that provide methods to list and request information on Singletons.

You can use an SingletonSelector by accessing ModelInstance.singletons.

Index

Methods

Methods

externalget

  • Returns a StarlightItemResponse with a single Singleton. This methods supports typing the returned Singleton by passing its data type as the generic type <D>.

    @example

    Requesting information from a singleton of slug “home”.

    import Starlight from '@starlightcms/js-sdk'

    const response = await Starlight.singletons.get('home')
    @example

    Typing last example’s response.

    import Starlight, { StringField, MediaField, VisualField } from '@starlightcms/js-sdk'

    type HomeFields = {
    title: StringField
    subtitle: StringField
    hero_image: MediaField
    hero_content: VisualField
    }

    // `response.data` will be of type Singleton<HomeFields>
    const response = await Starlight.singletons.get<HomeFields>('home')

    Type parameters

    • D: SerializedData

      The type of the returned Singleton’s data property.

    Parameters

    • externalslug: string

      The singleton slug.

    Returns Promise<StarlightItemResponse<Singleton<D>>>

externallist