UNPKG

hexo-theme-sukax

Version:

Modern, powerful and simple theme for Hexo

25 lines (22 loc) 630 B
const qrImage = require('qr-image'); module.exports = function (hexo) { hexo.extend.helper.register('qrcode', (url, option) => { const qrConfig = Object.assign( { size: 6, margin: 0 }, option || {} ); const qrUrl = url.replace('index.html', ''); const buffer = qrImage.imageSync( qrUrl, { type: 'png', size: qrConfig.size, margin: qrConfig.margin } ); return `data:image/png;base64,${buffer.toString('base64')}`; }); };