pjax官网

https://github.com/MoOx/pjax

单页跳过pjax

一般主题里会有exclude,这是整个页面跳过pjax

1
2
3
4
pjax:
enable: false
exclude:
# - xxxx

举例:跳过 test 页面

1
2
3
4
pjax:
enable: true
exclude:
- \test\

div跳过pjax

butterfly 3.4.1找到blog/node_modules/hexo-theme-butterfly/layout/includes/third-party/pjax.pug

selectorspjaxSelectors,下面这些class、id,都是能跳过pjax。

1
2
3
4
5
6
7
8
9
script.
let pjaxSelectors = [
'title',
'#config_change',
'#body-wrap',
'#rightside-config-hide',
'#rightside-config-show',
'.js-pjax'
]

Next 8.1.0找到blog/node_modules/hexo-theme-next/layout/_scripts/pjax.njk

selectors下的class都能跳过

1
2
3
4
5
6
7
8
selectors: [
'head title',
'.page-configurations',
'.main-inner',
'.post-toc-wrap',
'.languages',
'.pjax'
]

举例

butterfly<div class="js-pjax"></div>

Next<div class="pjax"></div>

JavaScript跳过pjax

butterfly 3.4.1找到blog/node_modules/hexo-theme-butterfly/layout/includes/third-party/pjax.pug

document.querySelectorAll('script[data-pjax]')data-pjax

Next 8.1.0找到blog/node_modules/hexo-theme-next/layout/_scripts/pjax.njk

document.querySelectorAll('script[data-pjax], .pjax script')data-pjax

举例

butterfly<script defer data-pjax src="/js/wow.js"></script>

next<script defer data-pjax src="/js/wow.js"></script>

参考

https://akilar.top/posts/3b78b69a/