1
0
Fork 0

grab author metadata from one source

This commit is contained in:
Matthias Kretschmann 2017-09-09 21:20:59 +02:00
parent 069c71d09f
commit 75aa3ffb8d
Signed by: m
GPG Key ID: 606EEEF3C479A91F
2 changed files with 30 additions and 10 deletions

View File

@ -2,7 +2,7 @@
// Vex modals
//
/* global vex */
/* global vex, fetch */
/* exported krlcModals */
/* eslint-disable spaced-comment */
@ -11,25 +11,42 @@
const krlcModals = (() => { // eslint-disable-line no-unused-vars
const _config = {
vexTriggers: document.querySelectorAll('.js-vex-btc'),
modalContent: '<h3 class="vex__title">My Bitcoin Address</h3>\n <img src="/assets/img/btc-qr.png" />\n <pre class="highlight"><code class="nt">171qDmKEXm9YBgBLXyGjjPvopP5o9htQ1V</code></pre>'
btcVexTriggers: document.querySelectorAll('.js-vex-btc')
}
let btcAddress
const _private = {
initVex() {
_config.vexTriggers.forEach(el => {
getBtcAddress() {
const url = '/api/site.json'
fetch(url)
.then(res => res.json())
.then(data_ => {
btcAddress = data_[0].author.bitcoin
})
.catch(err => console.error(err))
return btcAddress
},
vexBtc() {
_config.btcVexTriggers.forEach(el => {
el.addEventListener('click', e => {
e.preventDefault()
vex.defaultOptions.className = 'vex-theme-kremalicious vex-bitcoin'
vex.dialog.buttons.YES.text = 'Close'
vex.open({unsafeContent: _config.modalContent})
}, false)
vex.open({unsafeContent: '<h3 class="vex__title">My Bitcoin Address</h3>\n <img src="/assets/img/btc-qr.png" />\n <pre class="highlight"><a href="bitcoin:' + btcAddress + '"><code class="btcAddress nt">' + btcAddress + '</code></a></pre>'})
})
})
}
}
return {
init: _private.initVex
init() {
_private.getBtcAddress()
_private.vexBtc()
}
}
})(); // eslint-disable-line semi

View File

@ -1,10 +1,13 @@
---
layout: null
---
[
{
"name" : "{{ site.name }}",
"description" : "{{ site.description | xml_escape }}",
"url" : "{{ site.url }}"
"url" : "{{ site.url }}",
"author" : {
{% for item in site.author %}"{{ item[0] }}": "{{ item[1] }}"{% unless forloop.last %},{% endunless %}
{% endfor %}
}
}
]