From 7d7fc67f0e2cf0f2e745fd99d9d5346065f564d5 Mon Sep 17 00:00:00 2001 From: Chris Zheng Date: Sun, 6 Aug 2017 15:19:32 +0800 Subject: [PATCH] Add support for QR code generation. You must have hexo-helper-qrcode installed. --- layout/post.jade | 2 +- source/css/style.scss | 10 +++++----- source/js/share.js | 11 ++++++----- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/layout/post.jade b/layout/post.jade index ba980fa43..f0403bbd0 100644 --- a/layout/post.jade +++ b/layout/post.jade @@ -39,7 +39,7 @@ block content != page.content if theme.shareto == true script(type='text/javascript', src=url_for(theme.js) + '/share.js' + '?v=' + theme.version, async) - a.article-share-link(data-url='#{page.permalink}', data-id='#{page._id}')= __('shareto') + a.article-share-link(data-url='#{page.permalink}', data-id='#{page._id}', data-qrcode=qrcode(page.permalink))= __('shareto') include _partial/tag include _partial/post_nav if theme.duoshuo diff --git a/source/css/style.scss b/source/css/style.scss index 960059028..372f7a323 100644 --- a/source/css/style.scss +++ b/source/css/style.scss @@ -1803,21 +1803,21 @@ table { } } -.article-share-wechat { +.article-share-qrcode { @extend .article-share-element; &:before { - content: "\f1d7"; + content: "\f029"; } - &:hover { + &:hover, &:active { background: #38ad5a; - &~ .wechat-qrcode { + &~ .qrcode { display: block; text-align: center; } } } -.wechat-qrcode { +.qrcode { display: none; } diff --git a/source/js/share.js b/source/js/share.js index a459d6753..f358213d5 100644 --- a/source/js/share.js +++ b/source/js/share.js @@ -8,6 +8,7 @@ var $this = $(this), url = $this.attr('data-url'), + qrcode_img = $this.attr('data-qrcode'), encodedUrl = encodeURIComponent(url), id = 'article-share-box-' + $this.attr('data-id'), title = document.title, @@ -25,11 +26,11 @@ '
', '', '
', - '', - '', - '', - '', - '
', + '', + '', + '', + '', + '
', '
', '
' ].join('');