Represents a Singleton entity returned by the API.
A Singleton’s data field can be further typed by passing an object-like
structure as the D generic type. This is useful to provide type-safety to
your application, since the data field is a generic JS object by default.
It’s recommended to use the Field types provided by this SDK to type your
Singletons. For instance:
import{ StringField, VisualField, MediaField }from'@starlightcms/js-sdk' typeHomeFields={ site_title: StringField hero_image: MediaField hero_content: VisualField } // response type will be StarlightItemResponse<Singleton<HomeFields>> on request success const response = Starlight.singletons.get<HomeFields>('home') // home type is Singleton<HomeFields> const home = response.data
You could also place all your Singleton field types in the same type
definition file used to configure Entry fields, which makes it easier to
import these types in other files on your project. See
DefaultModelDefinition for more info.
Represents a Singleton entity returned by the API.
A Singleton’s
data
field can be further typed by passing an object-like structure as the D generic type. This is useful to provide type-safety to your application, since thedata
field is a generic JS object by default.It’s recommended to use the Field types provided by this SDK to type your Singletons. For instance:
You could also place all your Singleton field types in the same type definition file used to configure Entry fields, which makes it easier to import these types in other files on your project. See DefaultModelDefinition for more info.