mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-10 21:17:07 +08:00
refactor: 移除 代碼default主題 fix: 修復夜間模式下代碼塊有背景的bugs(沒開啟渲染的情況下) feat: 增加 code font-size配置 close #322 refactor: 更改配置中 code-font 為 code-font-family feat: Pjax下,刷新頁面時,會滾動到上次瀏覽的位置 fix: 修復mathjax溢出屏幕的Bugs close #321
76 lines
1.9 KiB
Plaintext
76 lines
1.9 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',
|
|
'meta[name=description]',
|
|
'#config_change',
|
|
'#body-wrap',
|
|
'#rightside-config-hide',
|
|
'#rightside-config-show',
|
|
'.js-pjax'
|
|
]
|
|
|
|
if (!{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 () {
|
|
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()
|
|
|
|
// Analytics
|
|
if (!{theme.tencent_analytics ? true : false}) {
|
|
MtaH5.pgv()
|
|
}
|
|
|
|
// prismjs
|
|
typeof Prism === 'object' && Prism.highlightAll()
|
|
})
|
|
|
|
|
|
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')
|
|
|
|
})
|
|
|