Webinars
Webinar Records in Algolia
Section titled “Webinar Records in Algolia”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
Type-Specific Fields
Section titled “Type-Specific Fields”| Field | Source | Description |
|---|---|---|
typeName | fetchEventsTaaxonomies() | Localized display name from webinar_types taxonomy |
is_visible | props.draft?.is_hidden | Visibility flag (inverted: true if not hidden) |
is_webinar | Hardcoded true | Distinguishes webinars from podcasts (which share similar logic) |
audiences_slug | fetchTaxonomiesSlug() | Target audience slugs |
languages_slug | fetchTaxonomiesRepeaterSlug() | Available language slugs |
type_slug | fetchTaxonomiesSlug() | Webinar type slug |
regions_slug | fetchTaxonomiesRepeaterSlug() | Region slugs for regional filtering |
regions | fetchWebinarLanguages() | Localized region names |
aundiences_languages | fetchEventsTaaxonomies() | Localized audience names |
regions_info | props?.draft?.repeater | Raw region repeater data (dates, configuration) |
organizers | GROQ query on people | Speakers with localized job titles |
Localized Speakers
Section titled “Localized Speakers”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 }) }}Without Localized Speakers
Section titled “Without Localized Speakers”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, } }) })}Regional Record Creation
Section titled “Regional Record Creation”A separate Algolia record is created for each region. This allows region-based filtering while keeping a unique URL per webinar.
Each record receives:
| Field | Value | Description |
|---|---|---|
objectID | ${id}-${region} | Unique ID per region (e.g., webinar-123-us) |
regions_slug | Single region slug | The specific region for this record |
type | customerData.type_slug | Webinar type slug |
date | Regional date | Uses manual_date or webinar_date depending on config |
organizers | Region-specific speakers | Speakers assigned to this region (or all speakers) |
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) }})