Skip to content

GetTypedField

cartographer


cartographer / getTypedField

getTypedField<T>(item, fieldKey, settings): T | null

Defined in: types/types.ts:80

Helper to get typed field from CatalogItem based on schema. Looks up the field definition in the schema and returns the typed value.

T

Expected return type of the field

CatalogItem

The CatalogItem to read from

string

The field key to retrieve

DatacoreSettings

Plugin settings (contains the schema)

T | null

  • The typed field value, or null if field not found or not set
const title = getTypedField<string>(item, 'title', settings);
const wordCount = getTypedField<number>(item, 'word-count', settings);
const authors = getTypedField<string[]>(item, 'authors', settings);