diff --git a/layout/_third-party/index.njk b/layout/_third-party/index.njk index 4b7ccce..a6afcc8 100644 --- a/layout/_third-party/index.njk +++ b/layout/_third-party/index.njk @@ -18,3 +18,5 @@ {%- include 'tags/mermaid.njk' -%} {%- include 'fancybox.njk' -%} + +{%- include 'pace.njk' -%} diff --git a/layout/_third-party/pace.njk b/layout/_third-party/pace.njk new file mode 100644 index 0000000..ffbadcd --- /dev/null +++ b/layout/_third-party/pace.njk @@ -0,0 +1,3 @@ +{%- if theme.pace.enable %} + {{ next_js('third-party/pace.js') }} +{%- endif %} diff --git a/scripts/filters/minify.js b/scripts/filters/minify.js index f977816..9ac33ae 100644 --- a/scripts/filters/minify.js +++ b/scripts/filters/minify.js @@ -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'); } diff --git a/source/js/third-party/pace.js b/source/js/third-party/pace.js new file mode 100644 index 0000000..c22d59f --- /dev/null +++ b/source/js/third-party/pace.js @@ -0,0 +1,7 @@ +/* global Pace */ + +Pace.options.restartOnPushState = false; + +document.addEventListener('pjax:send', () => { + Pace.restart(); +});