Add pace-js (#352)

This commit is contained in:
Mimi 2021-08-30 13:19:50 +08:00 committed by GitHub
parent f1700648e2
commit 30848e9486
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 27 additions and 47 deletions

View File

@ -835,10 +835,16 @@ motion:
sidebar: fadeInUp sidebar: fadeInUp
# Progress bar in the top during page loading. # Progress bar in the top during page loading.
# For more information: https://github.com/rstacruz/nprogress # For more information: https://github.com/CodeByZach/pace
nprogress: pace:
enable: false enable: false
spinner: true # All available colors:
# black | blue | green | orange | pink | purple | red | silver | white | yellow
color: blue
# All available themes:
# big-counter | bounce | barber-shop | center-atom | center-circle | center-radar | center-simple
# corner-indicator | fill-left | flat-top | flash | loading-bar | mac-osx | material | minimal
theme: minimal
# Canvas ribbon # Canvas ribbon
# For more information: https://github.com/hustcc/ribbon.js # For more information: https://github.com/hustcc/ribbon.js

View File

@ -153,16 +153,17 @@ animate_css:
version: 3.1.1 version: 3.1.1
file: animate.min.css file: animate.min.css
integrity: sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE= integrity: sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=
nprogress_js: pace_js:
name: nprogress name: pace-js
version: 0.2.0 version: 1.2.4
file: nprogress.js file: pace.min.js
integrity: sha256-a5YRB27CcBwBFcT5EF/f3E4vzIqyHrSR878nseNYw64= alias: pace
nprogress_css: integrity: sha256-gqd7YTjg/BtfqWSwsJOvndl0Bxc8gFImLEkXQT8+qj0=
name: nprogress pace_css:
version: 0.2.0 name: pace-js
file: nprogress.css version: 1.2.4
integrity: sha256-no0c5ccDODBwp+9hSmV5VvPpKwHCpbVzXHexIkupM6U= dir: themes
alias: pace
canvas_ribbon: canvas_ribbon:
name: ribbon.js name: ribbon.js
version: 1.0.2 version: 1.0.2

View File

@ -48,9 +48,9 @@
{{ next_vendors('fancybox_css') }} {{ next_vendors('fancybox_css') }}
{%- endif %} {%- endif %}
{%- if theme.nprogress.enable %} {%- if theme.pace.enable %}
{{ next_vendors('nprogress_css') }} {{ next_vendors('pace_css') }}
{{ next_vendors('nprogress_js') }} {{ next_vendors('pace_js') }}
{%- endif %} {%- endif %}
{{ next_data('main', next_config()) }} {{ next_data('main', next_config()) }}

View File

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

View File

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

View File

@ -14,7 +14,7 @@ const vendorsFile = fs.readFileSync(path.join(__dirname, '../../../_vendors.yml'
const dependencies = yaml.load(vendorsFile); const dependencies = yaml.load(vendorsFile);
module.exports = hexo => { module.exports = hexo => {
const { vendors, creative_commons } = hexo.theme.config; const { vendors, creative_commons, pace } = hexo.theme.config;
if (typeof internal === 'function') { if (typeof internal === 'function') {
internal(hexo, dependencies); internal(hexo, dependencies);
} }
@ -30,6 +30,9 @@ module.exports = hexo => {
if (key === 'creative_commons') { if (key === 'creative_commons') {
value.file = `${value.dir}/${creative_commons.size}/${creative_commons.license.replace(/-/g, '_')}.svg`; value.file = `${value.dir}/${creative_commons.size}/${creative_commons.license.replace(/-/g, '_')}.svg`;
} }
if (key === 'pace_css') {
value.file = `${value.dir}/${pace.color}/pace-theme-${pace.theme}.css`;
}
const { name, version, file, alias, unavailable } = value; const { name, version, file, alias, unavailable } = value;
const links = { const links = {
local : url_for.call(hexo, `lib/${name}/${file}`), local : url_for.call(hexo, `lib/${name}/${file}`),

View File

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

View File

@ -1,20 +0,0 @@
/* global CONFIG, NProgress */
NProgress.configure({
showSpinner: CONFIG.nprogress.spinner
});
NProgress.start();
document.addEventListener('readystatechange', () => {
if (document.readyState === 'interactive') {
NProgress.inc(0.8);
}
if (document.readyState === 'complete') {
NProgress.done();
}
});
document.addEventListener('pjax:send', () => {
NProgress.start();
});
document.addEventListener('pjax:success', () => {
NProgress.done();
});