mirror of
https://github.com/bigchaindb/site.git
synced 2024-11-23 02:00:18 +01:00
Matthias Kretschmann
77e10d9a8f
* add meetup link to community page * all social data as array * add next meetup link to hero, grab data from Meetup API * community bar style tweaks
34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
//require whatwg-fetch/fetch.js
|
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
|
|
const url = 'https://bigchaindb-meetups.now.sh'
|
|
|
|
function injectData(data) {
|
|
const events = data
|
|
|
|
// 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 = '<span class="hero__community__label">' + date + '</span> ' + '<strong>' + name + '</strong>'
|
|
elementTitle.style.opacity = 1
|
|
element.href = link
|
|
}
|
|
|
|
fetch(url)
|
|
.then(function(response) {
|
|
return response.json()
|
|
})
|
|
.then(function(data) {
|
|
injectData(data)
|
|
})
|
|
.catch(function(error) {
|
|
console.log(error)
|
|
})
|
|
})
|