Skip to content

Webinars

When a Webinar is published or updated in Sanity, the system fetches type-specific fields in addition to the general variables. Webinars are the most complex resource type due to localized speakers and regional variants — each region gets its own Algolia record.

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


FieldSourceDescription
typeNamefetchEventsTaaxonomies()Localized display name from webinar_types taxonomy
is_visibleprops.draft?.is_hiddenVisibility flag (inverted: true if not hidden)
is_webinarHardcoded trueDistinguishes webinars from podcasts (which share similar logic)
audiences_slugfetchTaxonomiesSlug()Target audience slugs
languages_slugfetchTaxonomiesRepeaterSlug()Available language slugs
type_slugfetchTaxonomiesSlug()Webinar type slug
regions_slugfetchTaxonomiesRepeaterSlug()Region slugs for regional filtering
regionsfetchWebinarLanguages()Localized region names
aundiences_languagesfetchEventsTaaxonomies()Localized audience names
regions_infoprops?.draft?.repeaterRaw region repeater data (dates, configuration)
organizersGROQ query on peopleSpeakers with localized job titles

Webinars support localized speakers — different speakers can be assigned to different regions. The system checks has_localized_speakers to determine the logic:

With Localized Speakers (has_localized_speakers: true)

Section titled “With Localized Speakers (has_localized_speakers: true)”

For each region, the system finds speakers assigned to that region and groups them:

if (props?.draft?.has_localized_speakers) {
const regions = props.draft?.repeater || []
const speakers = props.draft?.speakers || []
for (const region of regions) {
const newOrganizers = []
for (const speaker of speakers) {
// Check if this speaker is assigned to this region
if (speaker?.regions?.some((r) => r?.region._ref === region?.region._ref)) {
const query = `*[_type == "people" && _id == "${speakerID}"][0]{
'title': title,
'image': asset_type.image.asset->url,
'company': company,
'job_title': text
}`
const author = await client.fetch(query)
newOrganizers.push({
title: author?.title,
image: author?.image,
company_name: author?.company,
speaker_ref: region?.region._ref,
job_title: {
en: author?.job_title?.en,
de: author?.job_title?.de,
es: author?.job_title?.es,
fr: author?.job_title?.fr,
it: author?.job_title?.it,
pt: author?.job_title?.pt,
}
})
}
}
// Get region slug and group organizers by region
const region_slug = await client.fetch(
`*[_type == "webinar_regions" && _id == "${region?.region._ref}"][0].slug`
)
organizers.push({ region: region_slug, newOrganizers })
}
}

All speakers are fetched and applied to every region:

for (let i = 0; i < props.draft?.speakers?.length; i++) {
var queryAuthor = `*[_type == "people" && _id == "${props.draft?.speakers[i]?.speaker._ref}"][0]{
'title': title,
'image': asset_type.image.asset->url,
'company': company,
'job_title': text
}`
await client.fetch(queryAuthor).then((author) => {
organizers.push({
title: author?.title,
image: author?.image,
company_name: author?.company,
job_title: {
en: author?.job_title?.en,
de: author?.job_title?.de,
es: author?.job_title?.es,
fr: author?.job_title?.fr,
it: author?.job_title?.it,
pt: author?.job_title?.pt,
}
})
})
}

A separate Algolia record is created for each region. This allows region-based filtering while keeping a unique URL per webinar.

Each record receives:

FieldValueDescription
objectID${id}-${region}Unique ID per region (e.g., webinar-123-us)
regions_slugSingle region slugThe specific region for this record
typecustomerData.type_slugWebinar type slug
dateRegional dateUses manual_date or webinar_date depending on config
organizersRegion-specific speakersSpeakers assigned to this region (or all speakers)
algolia/custom_actions/CustomCreateRecordAlgolia.jsx
customerData.regions_slug.map(async (region, index) => {
var newOrganizers = customerData.organizers.filter((o) => o.region === region)
var newData = {
...customerData,
objectID: `${id}-${region}`,
regions_slug: region,
regions: [customerData.regions[index]],
type: customerData.type_slug,
date: customerData.regions_info[index].manual_date || type == 'podcasts'
? customerData.regions_info[index].date
: customerData.regions_info[index].webinar_date,
regions_info: {
slug: region,
name: [customerData.regions[index]],
date: customerData.regions_info[index].manual_date || type == 'podcasts'
? customerData.regions_info[index].date
: customerData.regions_info[index].webinar_date,
},
organizers: newOrganizers[0]?.newOrganizers || customerData.organizers,
}
try {
await axios.post(
'https://netwrix.com/.netlify/functions/create-algolia-record',
{ data: newData }
)
} catch (error) {
console.error(error)
}
})