Skip to content

Events

When an Event is published or updated in Sanity, the system fetches type-specific fields in addition to the general variables. Events have unique fields for multi-day scheduling, sponsor logos, and timestamp-based sorting.

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


FieldSourceDescription
dateprops.draft?.dateEvent start date
date_timestampComputed from dateUnix timestamp for date-based sorting
is_multidayprops.draft?.is_multidayWhether the event spans multiple days
end_dateprops.draft?.end_dateEnd date (only if is_multiday is true)
regions_slugfetchEvents()Event region slugs (uses fetchEvents, not fetchTaxRepeaterSlug)
imageGROQ queryEvent featured image from attributes
typeNameGROQ query on event_typesLocalized event type display name
organizersSet to falseEvents don’t have author-style organizers
logosGROQ query on repeaterSponsor/partner logos with titles

Events display sponsor/partner logos instead of author organizers. The logos are fetched from the repeater field:

for (let i = 0; i < props.draft?.repeater?.length; i++) {
let id = props.draft?._id?.replace(/^drafts\./, '')
var queryAuthor = `*[_type == "events" && (_id == "${id}" || _id == "${props.draft?._id}")][0]{
'images': repeater[]{'image': asset_type.image.asset->url, 'title': title}
}`
await client.fetch(queryAuthor).then((author) => {
organizers = false
logos = author?.images
})
}

A Unix timestamp is computed for sorting purposes:

date = props.draft?.date;
date_timestamp = Math.floor(new Date(date).getTime() / 1000)

If the event spans multiple days, the end date is also stored:

is_multiday = props.draft?.is_multiday
if (is_multiday) {
end_date = props.draft?.end_date
}

Events use a different fetch method for regions than other resource types:

regions_slug = await fetchEvents('region', 'events_regions_tax', props, client)

This uses fetchEvents() instead of the standard fetchTaxRepeaterSlug() used by other types.

var queryImage = `*[_type == "events" && (_id == "drafts.${id}" || _id == "${id}")][0]{
'image': attributes.asset_type.image.asset->url,
}`
await client.fetch(queryImage).then((imageUrl) => {
image = imageUrl?.image
})
var queryTypeName = `*[_type == 'event_types' && _id == "${props.draft?.reference._ref}"][0].title`
typeName = await client.fetch(queryTypeName)