mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-16 19:10:53 +08:00
fix: 修復當hexo的_config沒有設置description時,會導致pjax在頁面與文章間切換會無效 close #381 improvement: 當隱藏部分沒配置時,左下角設置按鈕會消失 #353 improvement: 網站背景可配置 (顏色(HEX值/RGB值/顔色單詞/漸變色)/漸變色/圖片鏈接) improvement: 夜間模式下,背景顔色/top-img/footer-bg 設置為顔色時,不再強制顯示黑色,而是改為遮罩降低亮度
79 lines
2.1 KiB
Plaintext
79 lines
2.1 KiB
Plaintext
- var pjaxExclude = 'a:not([target="_blank"])'
|
|
if theme.pjax.exclude
|
|
each val in theme.pjax.exclude
|
|
- pjaxExclude = pjaxExclude + `:not([href="${val}"])`
|
|
|
|
script(src=url_for(theme.CDN.pjax))
|
|
script.
|
|
let pjaxSelectors = [
|
|
'title',
|
|
'#config_change',
|
|
'#body-wrap',
|
|
'#rightside-config-hide',
|
|
'#rightside-config-show',
|
|
'.js-pjax'
|
|
]
|
|
|
|
if (!{Boolean(theme.Open_Graph_meta && theme.comments.use && theme.comments.use.includes('Livere'))}) {
|
|
pjaxSelectors.unshift('meta[property="og:image"]', 'meta[property="og:title"]', 'meta[property="og:url"]')
|
|
}
|
|
|
|
var pjax = new Pjax({
|
|
elements: '!{pjaxExclude}',
|
|
selectors: pjaxSelectors,
|
|
cacheBust: false,
|
|
analytics: !{theme.google_analytics ? true : false},
|
|
scrollRestoration: false
|
|
})
|
|
|
|
document.addEventListener('pjax:complete', function () {
|
|
window.refreshFn()
|
|
|
|
$('script[data-pjax]').each(function () {
|
|
$(this).parent().append($(this).remove())
|
|
})
|
|
|
|
GLOBAL_CONFIG.islazyload && window.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()
|
|
|
|
// Analytics
|
|
if (!{theme.tencent_analytics ? true : false}) {
|
|
MtaH5.pgv()
|
|
}
|
|
|
|
// prismjs
|
|
typeof Prism === 'object' && Prism.highlightAll()
|
|
|
|
typeof preloader === 'object' && preloader.endLoading()
|
|
})
|
|
|
|
|
|
document.addEventListener('pjax:send', function () {
|
|
typeof preloader === 'object' && preloader.initLoading()
|
|
|
|
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')
|
|
|
|
})
|
|
|