diff --git a/_src/_assets/js/_modals.js b/_src/_assets/js/_modals.js index 04274e95..67ffbb96 100644 --- a/_src/_assets/js/_modals.js +++ b/_src/_assets/js/_modals.js @@ -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: '
171qDmKEXm9YBgBLXyGjjPvopP5o9htQ1V
'
+ 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: '' + btcAddress + '
'})
+ })
})
}
}
return {
- init: _private.initVex
+ init() {
+ _private.getBtcAddress()
+ _private.vexBtc()
+ }
}
})(); // eslint-disable-line semi
diff --git a/_src/api/site.json b/_src/api/site.json
index e95267d3..b9015cfb 100644
--- a/_src/api/site.json
+++ b/_src/api/site.json
@@ -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 %}
+ }
}
]