mirror of
https://github.com/kremalicious/blog.git
synced 2025-01-03 18:35:07 +01:00
grab author metadata from one source
This commit is contained in:
parent
069c71d09f
commit
75aa3ffb8d
@ -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
|
||||
|
@ -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 %}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user