From 267ce5ab5f5c41d1fa53f450bca94399ced15bc3 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Thu, 3 May 2018 17:00:40 +0200 Subject: [PATCH] check for existing next meetup --- _src/_assets/javascripts/bigchain/meetup.js | 22 ++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/_src/_assets/javascripts/bigchain/meetup.js b/_src/_assets/javascripts/bigchain/meetup.js index 4a4b154..4e9376a 100644 --- a/_src/_assets/javascripts/bigchain/meetup.js +++ b/_src/_assets/javascripts/bigchain/meetup.js @@ -7,15 +7,23 @@ document.addEventListener('DOMContentLoaded', function() { // just grab the first item of array const nextEvent = events[0] - const name = nextEvent.name - const link = nextEvent.link - const date = new Date(nextEvent.time).toLocaleDateString('en-us', { month: 'short', day: 'numeric' }) const element = document.getElementsByClassName('js-social-link--meetup')[0] - const elementTitle = document.getElementsByClassName('meetup-title')[0] - elementTitle.innerHTML = '' + date + ' ' + '' + name + '' - elementTitle.style.opacity = 1 - element.href = link + if (nextEvent) { + const name = nextEvent.name + const link = nextEvent.link + const date = new Date(nextEvent.time).toLocaleDateString('en-us', { + month: 'short', + day: 'numeric' + }) + const elementTitle = document.getElementsByClassName('meetup-title')[0] + + elementTitle.innerHTML = `${date}${name}` + elementTitle.style.opacity = 1 + element.href = link + } else { + element.classList.add('hide') + } } fetch(url)