Skip to content

Blogs

When a Blog is published or updated in Sanity, the system fetches type-specific fields in addition to the general variables. These fields provide the data needed for card display and filtering in the Resource Center.

Source file: algolia/custom_actions/types/getResourcesData.js


FieldSourceDescription
dateprops.draft?.update_date or props.draft?.datePublish date; prefers update_date if available
card_imageGROQ query on featured_imageFeatured image URL for the Resource Center card
organizersGROQ query on people documentAuthor name and avatar image

The blog date uses the update_date field if available, falling back to the original date:

date = props.draft?.update_date ? props.draft?.update_date : props.draft?.date

The system queries Sanity for the blog’s image assets. It prioritizes the featured_image for the card:

var queryImage = `*[_type == "blogs" && _id == "${id}"][0]{
'index_image': attributes.asset_type.image.asset->url,
'featured_image': attributes.featured_image.image.asset->url
}`
await client.fetch(queryImage).then((imageUrl) => {
card_image = imageUrl?.featured_image ? imageUrl?.featured_image : ''
})

The author is fetched from the people document type using the author reference:

var queryAuthor = `*[_type == "people" && _id == "${props.draft?.author?._ref}"][0]{
'title': title,
'image': asset_type.image.asset->url
}`
await client.fetch(queryAuthor).then((author) => {
organizers = [{ title: author?.title, image: author?.image }]
})

The organizers field is an array with a single object containing the author’s title and image.