1
0
mirror of https://github.com/kremalicious/blog.git synced 2025-02-14 21:10:25 +01:00

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 // Vex modals
// //
/* global vex */ /* global vex, fetch */
/* exported krlcModals */ /* exported krlcModals */
/* eslint-disable spaced-comment */ /* eslint-disable spaced-comment */
@ -11,25 +11,42 @@
const krlcModals = (() => { // eslint-disable-line no-unused-vars const krlcModals = (() => { // eslint-disable-line no-unused-vars
const _config = { const _config = {
vexTriggers: document.querySelectorAll('.js-vex-btc'), btcVexTriggers: 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>'
} }
let btcAddress
const _private = { const _private = {
initVex() { getBtcAddress() {
_config.vexTriggers.forEach(el => { 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 => { el.addEventListener('click', e => {
e.preventDefault() e.preventDefault()
vex.defaultOptions.className = 'vex-theme-kremalicious vex-bitcoin' vex.defaultOptions.className = 'vex-theme-kremalicious vex-bitcoin'
vex.dialog.buttons.YES.text = 'Close' vex.dialog.buttons.YES.text = 'Close'
vex.open({unsafeContent: _config.modalContent}) 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>'})
}, false) })
}) })
} }
} }
return { return {
init: _private.initVex init() {
_private.getBtcAddress()
_private.vexBtc()
}
} }
})(); // eslint-disable-line semi })(); // eslint-disable-line semi

View File

@ -1,10 +1,13 @@
--- ---
layout: null
--- ---
[ [
{ {
"name" : "{{ site.name }}", "name" : "{{ site.name }}",
"description" : "{{ site.description | xml_escape }}", "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 %}
}
} }
] ]