Do not restart Pace on every pushState event

* See: https://github.com/next-theme/hexo-theme-next/issues/362
This commit is contained in:
Mimi 2021-09-08 11:16:31 +08:00
parent d1bf101cc1
commit 0005c0367f
4 changed files with 16 additions and 0 deletions

View File

@ -18,3 +18,5 @@
{%- include 'tags/mermaid.njk' -%}
{%- include 'fancybox.njk' -%}
{%- include 'pace.njk' -%}

3
layout/_third-party/pace.njk vendored Normal file
View File

@ -0,0 +1,3 @@
{%- if theme.pace.enable %}
{{ next_js('third-party/pace.js') }}
{%- endif %}

View File

@ -137,6 +137,10 @@ hexo.extend.filter.register('after_generate', () => {
hexo.route.remove('js/third-party/fancybox.js');
}
if (!theme.pace.enable) {
hexo.route.remove('js/third-party/pace.js');
}
if (!theme.quicklink.enable) {
hexo.route.remove('js/third-party/quicklink.js');
}

7
source/js/third-party/pace.js vendored Normal file
View File

@ -0,0 +1,7 @@
/* global Pace */
Pace.options.restartOnPushState = false;
document.addEventListener('pjax:send', () => {
Pace.restart();
});