From 233876fdbe0ec5d2db1f5bafcaf289927ce98779 Mon Sep 17 00:00:00 2001 From: Dave Nichols Date: Wed, 17 Jul 2024 16:24:28 +0100 Subject: [PATCH] Updating to check for options --- blocks/event-summary/event-summary.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/blocks/event-summary/event-summary.js b/blocks/event-summary/event-summary.js index c1a7163..1c399e6 100644 --- a/blocks/event-summary/event-summary.js +++ b/blocks/event-summary/event-summary.js @@ -23,9 +23,11 @@ export default async function decorate(block) { const image = getMetadata('og:image'); const registerButton = getMetadata('register-button'); const title = getMetadata('og:title'); + const description = getMetadata('og:description'); const type = getMetadata('type'); const region = getMetadata('region'); const address = getMetadata('address'); + const eventTitle = document.querySelector('.eventtitle.block'); const eventSummary = document.querySelector('.eventsummary.block'); const outerBlock = document.querySelector('.section'); @@ -41,7 +43,7 @@ export default async function decorate(block) { { class: 'event-date' }, `${date} ${eventTime}`, ) : p({ class: 'event-date' }, date)); - const eventSubtitle = h1({ class: 'event-subtitle' }, title); + const eventSubtitle = h1({ class: 'event-subtitle' }, eventTitle.textContent ? eventTitle : title); const keywordList = ul( { class: 'keyword-list' }, li({ class: 'item type' }, type), @@ -59,7 +61,7 @@ export default async function decorate(block) { // Append elements to block block.appendChild(imageContainer); - block.appendChild(div({ class: 'event-details' }, eventDate, eventSubtitle, div({ class: 'event-keywords' }, keywordList), div({ class: 'event-description' }, eventSummary, registerButtonContainer, talkButtonContainer))); + block.appendChild(div({ class: 'event-details' }, eventDate, eventSubtitle, div({ class: 'event-keywords' }, keywordList), div({ class: 'event-description' }, eventSummary.textContent ? eventSummary : description, registerButtonContainer, talkButtonContainer))); // Add event listener to the 'Register Today' button registerButtonLink.addEventListener('click', (event) => {