mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-17 04:40:53 +08:00
feat: 點擊文字特效增加隨機配置 feat: 可配置是否添加css前綴 fix: 修復子目錄下,配置justifiedGallery CDN(相對鏈接)後,連接會無法訪問的bugs fix: 修復 pangu 配置post 後,仍在全站生效的bugs improvement: 夜間模式下,廣告降低亮度 improvement: 手機端toc邊距微調 improvement: html格式優化 improvement: 搜索優化 improvement: 刪除不必要的語言文件
81 lines
2.4 KiB
Plaintext
81 lines
2.4 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()
|
|
|
|
document.querySelectorAll('script[data-pjax]').forEach(item => {
|
|
const newScript = document.createElement('script')
|
|
const content = item.text || item.textContent || item.innerHTML || ""
|
|
Array.from(item.attributes).forEach(attr => newScript.setAttribute(attr.name, attr.value))
|
|
newScript.appendChild(document.createTextNode(content))
|
|
item.parentNode.replaceChild(newScript, item)
|
|
})
|
|
|
|
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()
|
|
|
|
//reset readmode
|
|
const $bodyClassList = document.body.classList
|
|
$bodyClassList.contains('read-mode') && $bodyClassList.remove('read-mode')
|
|
|
|
})
|