diff --git a/layout/includes/additional-js.pug b/layout/includes/additional-js.pug index f33be48..9d76da4 100644 --- a/layout/includes/additional-js.pug +++ b/layout/includes/additional-js.pug @@ -12,6 +12,12 @@ div if theme.fancybox script(src=url_for(theme.CDN.fancybox)) + if theme.instantpage + script(src=url_for(theme.CDN.instantpage) type="module" defer) + + if theme.lazyload.enable + script(src=url_for(theme.CDN.lazyload) async) + if theme.fireworks && theme.fireworks.enable script(src=url_for(theme.CDN.anime)) script(src=url_for(theme.CDN.fireworks)) @@ -19,6 +25,9 @@ div if (theme.snackbar && theme.snackbar.enable) script(src=url_for(theme.CDN.snackbar)) + if theme.pangu && theme.pangu.enable + include ./third-party/pangu.pug + if (theme.canvas_ribbon && theme.canvas_ribbon.enable) include ./third-party/canvas-ribbon.pug @@ -35,12 +44,6 @@ div POWERMODE.shake = #{theme.activate_power_mode.shake}; document.body.addEventListener('input', POWERMODE); - if theme.instantpage - script(src=url_for(theme.CDN.instantpage) type="module" defer) - - if theme.lazyload.enable - script(src=url_for(theme.CDN.lazyload) async) - //- 鼠標特效 if theme.click_heart script(src=url_for(theme.CDN.click_heart) async) @@ -48,9 +51,6 @@ div if theme.ClickShowText && theme.ClickShowText.enable script(src=url_for(theme.CDN.ClickShowText) async) - if theme.pangu && theme.pangu.enable - include ./third-party/pangu.pug - //- search if theme.algolia_search && theme.algolia_search.enable script(src=url_for(theme.CDN.algolia_js)) @@ -76,15 +76,15 @@ div if theme.busuanzi.site_uv || theme.busuanzi.site_pv || theme.busuanzi.page_pv script(async src=url_for(theme.CDN.busuanzi)) + !=fragment_cache('injectBottom', function(){return injectHtml(theme.inject.bottom)}) + !=partial('includes/chat/index', {}, {cache:theme.fragment_cache}) + if theme.aplayerInject && !config.aplayer.asset_inject if theme.pjax include ./head/aplayer.pug else if page.aplayer include ./head/aplayer.pug - !=fragment_cache('injectBottom', function(){return injectHtml(theme.inject.bottom)}) - !=partial('includes/chat/index', {}, {cache:theme.fragment_cache}) - if theme.pjax !=partial('includes/third-party/pjax', {}, {cache:theme.fragment_cache}) diff --git a/layout/includes/header/menu_item.pug b/layout/includes/header/menu_item.pug index bb0d3d1..fdcec60 100644 --- a/layout/includes/header/menu_item.pug +++ b/layout/includes/header/menu_item.pug @@ -8,7 +8,7 @@ span=' '+label else .menus_item - a.site-page + a.site-page(href='javascript:void(0);') if label.split('||')[1] i.fa-fw(class=trim(label.split('||')[1])) span=' '+ trim(label.split('||')[0]) diff --git a/layout/includes/post/reward.pug b/layout/includes/post/reward.pug index c3c1ac5..1bf9381 100644 --- a/layout/includes/post/reward.pug +++ b/layout/includes/post/reward.pug @@ -7,9 +7,10 @@ each item in theme.reward.QR_code - var clickTo = (item.itemlist||item).link ? (item.itemlist||item).link : (item.itemlist||item).img li.reward-item - if theme.lazyload.enable - img.post-qr-code-img(data-lazy-src=url_for((item.itemlist||item).img) alt=(item.itemlist||item).text onclick=`window.open('${url_for(clickTo)}')`) - else - img.post-qr-code-img(src=url_for((item.itemlist||item).img) alt=(item.itemlist||item).text onclick=`window.open('${url_for(clickTo)}')`) + a(href=clickTo target='_blank') + if theme.lazyload.enable + img.post-qr-code-img(data-lazy-src=url_for((item.itemlist||item).img) alt=(item.itemlist||item).text) + else + img.post-qr-code-img(src=url_for((item.itemlist||item).img) alt=(item.itemlist||item).text) .post-qr-code-desc=(item.itemlist||item).text diff --git a/layout/includes/third-party/pjax.pug b/layout/includes/third-party/pjax.pug index 067519b..b15b058 100644 --- a/layout/includes/third-party/pjax.pug +++ b/layout/includes/third-party/pjax.pug @@ -1,58 +1,56 @@ script(src=url_for(theme.CDN.pjax)) script. - $(function () { - var pjax = new Pjax({ - selectors: [ - 'title', - 'meta[name=description]', - '#config_change', - '#body-wrap', - '#rightside-config-hide', - '#rightside-config-show', - '.js-pjax' - ], - cacheBust: false, - }) - - document.addEventListener('pjax:complete', function () { - refreshFn() - - $('script[data-pjax]').each(function () { - $(this).parent().append($(this).remove()) - }) - - GLOBAL_CONFIG.islazyload && lazyLoadInstance.update() - - typeof chatBtnFn === 'function' && chatBtnFn() - typeof panguInit === 'function' && panguInit() - - if (typeof gtag === 'function') { - gtag('config', '!{theme.google_analytics}', {'page_path': window.location.pathname}); - } - - if (document.getElementsByClassName('aplayer').length){ - typeof loadMeting === 'function' && loadMeting() - } - }) - - document.addEventListener('pjax:send', function () { - if (window.aplayers) { - for (let i = 0; i < window.aplayers.length; i++) { - if (!window.aplayers[i].options.fixed) { - window.aplayers[i].destroy() - } - } - } - - typeof typed === 'object' && typed.destroy() - - $(window).off('scroll') - - //reset readmode - $('body').hasClass('read-mode') && $('body').removeClass('read-mode') - - //reset font-size - $('body').css('font-size') !== originFontSize && $('body').css('font-size', parseFloat(originFontSize)) - }) + var pjax = new Pjax({ + elements: 'a:not([target="_blank"])', + selectors: [ + 'title', + 'meta[name=description]', + '#config_change', + '#body-wrap', + '#rightside-config-hide', + '#rightside-config-show', + '.js-pjax' + ], + cacheBust: false, + }) + + document.addEventListener('pjax:complete', function () { + refreshFn() + + $('script[data-pjax]').each(function () { + $(this).parent().append($(this).remove()) + }) + + GLOBAL_CONFIG.islazyload && lazyLoadInstance.update() + + typeof chatBtnFn === 'function' && chatBtnFn() + typeof panguInit === 'function' && panguInit() + + if (typeof gtag === 'function') { + gtag('config', '!{theme.google_analytics}', {'page_path': window.location.pathname}); + } + + typeof loadMeting === 'function' && document.getElementsByClassName('aplayer').length && loadMeting() + + }) + + document.addEventListener('pjax:send', function () { + if (window.aplayers) { + for (let i = 0; i < window.aplayers.length; i++) { + if (!window.aplayers[i].options.fixed) { + window.aplayers[i].destroy() + } + } + } + + typeof typed === 'object' && typed.destroy() + + $(window).off('scroll') + + //reset readmode + $('body').hasClass('read-mode') && $('body').removeClass('read-mode') + + //reset font-size + $('body').css('font-size') !== originFontSize && $('body').css('font-size', parseFloat(originFontSize)) }) diff --git a/package.json b/package.json index 0825952..62cb05d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hexo-theme-butterfly", - "version": "3.0.0-pjax", + "version": "3.0.0-rc2-dev", "private": true, "engines": { "node": ">=8.10.0" diff --git a/scripts/filters/post_lazyload.js b/scripts/filters/post_lazyload.js index 92857cc..b5cb3b1 100644 --- a/scripts/filters/post_lazyload.js +++ b/scripts/filters/post_lazyload.js @@ -8,15 +8,8 @@ const urlFor = require('hexo-util').url_for.bind(hexo) -function lazyProcess (htmlContent) { - const bg = hexo.theme.config.lazyload.post ? urlFor(hexo.theme.config.lazyload.post) : 'data:image/gif;base64,R0lGODdhAQABAPAAAMPDwwAAACwAAAAAAQABAAACAkQBADs=' - return htmlContent.replace(/( { if (!hexo.theme.config.lazyload.enable) return - data.content = lazyProcess.call(this, data.content) - return data -} - -hexo.extend.filter.register('after_post_render', processPost) + const bg = hexo.theme.config.lazyload.post ? urlFor(hexo.theme.config.lazyload.post) : 'data:image/gif;base64,R0lGODdhAQABAPAAAMPDwwAAACwAAAAAAQABAAACAkQBADs=' + return data.content.replace(/(