GetTypedField
cartographer / getTypedField
Function: getTypedField()
Section titled “Function: 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.
Type Parameters
Section titled “Type Parameters”T
Expected return type of the field
Parameters
Section titled “Parameters”The CatalogItem to read from
fieldKey
Section titled “fieldKey”string
The field key to retrieve
settings
Section titled “settings”Plugin settings (contains the schema)
Returns
Section titled “Returns”T | null
- The typed field value, or null if field not found or not set
Example
Section titled “Example”const title = getTypedField<string>(item, 'title', settings);const wordCount = getTypedField<number>(item, 'word-count', settings);const authors = getTypedField<string[]>(item, 'authors', settings);