mirror of
https://github.com/next-theme/hexo-theme-next.git
synced 2026-01-17 18:22:33 +00:00
Add pace-js (#352)
This commit is contained in:
parent
f1700648e2
commit
30848e9486
12
_config.yml
12
_config.yml
@ -835,10 +835,16 @@ motion:
|
||||
sidebar: fadeInUp
|
||||
|
||||
# Progress bar in the top during page loading.
|
||||
# For more information: https://github.com/rstacruz/nprogress
|
||||
nprogress:
|
||||
# For more information: https://github.com/CodeByZach/pace
|
||||
pace:
|
||||
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
|
||||
# For more information: https://github.com/hustcc/ribbon.js
|
||||
|
||||
21
_vendors.yml
21
_vendors.yml
@ -153,16 +153,17 @@ animate_css:
|
||||
version: 3.1.1
|
||||
file: animate.min.css
|
||||
integrity: sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=
|
||||
nprogress_js:
|
||||
name: nprogress
|
||||
version: 0.2.0
|
||||
file: nprogress.js
|
||||
integrity: sha256-a5YRB27CcBwBFcT5EF/f3E4vzIqyHrSR878nseNYw64=
|
||||
nprogress_css:
|
||||
name: nprogress
|
||||
version: 0.2.0
|
||||
file: nprogress.css
|
||||
integrity: sha256-no0c5ccDODBwp+9hSmV5VvPpKwHCpbVzXHexIkupM6U=
|
||||
pace_js:
|
||||
name: pace-js
|
||||
version: 1.2.4
|
||||
file: pace.min.js
|
||||
alias: pace
|
||||
integrity: sha256-gqd7YTjg/BtfqWSwsJOvndl0Bxc8gFImLEkXQT8+qj0=
|
||||
pace_css:
|
||||
name: pace-js
|
||||
version: 1.2.4
|
||||
dir: themes
|
||||
alias: pace
|
||||
canvas_ribbon:
|
||||
name: ribbon.js
|
||||
version: 1.0.2
|
||||
|
||||
@ -48,9 +48,9 @@
|
||||
{{ next_vendors('fancybox_css') }}
|
||||
{%- endif %}
|
||||
|
||||
{%- if theme.nprogress.enable %}
|
||||
{{ next_vendors('nprogress_css') }}
|
||||
{{ next_vendors('nprogress_js') }}
|
||||
{%- if theme.pace.enable %}
|
||||
{{ next_vendors('pace_css') }}
|
||||
{{ next_vendors('pace_js') }}
|
||||
{%- endif %}
|
||||
|
||||
{{ next_data('main', next_config()) }}
|
||||
|
||||
2
layout/_third-party/index.njk
vendored
2
layout/_third-party/index.njk
vendored
@ -18,5 +18,3 @@
|
||||
{%- include 'tags/mermaid.njk' -%}
|
||||
|
||||
{%- include 'fancybox.njk' -%}
|
||||
|
||||
{%- include 'nprogress.njk' -%}
|
||||
|
||||
4
layout/_third-party/nprogress.njk
vendored
4
layout/_third-party/nprogress.njk
vendored
@ -1,4 +0,0 @@
|
||||
{%- if theme.nprogress.enable %}
|
||||
{{ next_data('nprogress', theme.nprogress) }}
|
||||
{{ next_js('third-party/nprogress.js') }}
|
||||
{%- endif %}
|
||||
@ -14,7 +14,7 @@ const vendorsFile = fs.readFileSync(path.join(__dirname, '../../../_vendors.yml'
|
||||
const dependencies = yaml.load(vendorsFile);
|
||||
|
||||
module.exports = hexo => {
|
||||
const { vendors, creative_commons } = hexo.theme.config;
|
||||
const { vendors, creative_commons, pace } = hexo.theme.config;
|
||||
if (typeof internal === 'function') {
|
||||
internal(hexo, dependencies);
|
||||
}
|
||||
@ -30,6 +30,9 @@ module.exports = hexo => {
|
||||
if (key === 'creative_commons') {
|
||||
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 links = {
|
||||
local : url_for.call(hexo, `lib/${name}/${file}`),
|
||||
|
||||
@ -137,10 +137,6 @@ hexo.extend.filter.register('after_generate', () => {
|
||||
hexo.route.remove('js/third-party/fancybox.js');
|
||||
}
|
||||
|
||||
if (!theme.nprogress.enable) {
|
||||
hexo.route.remove('js/third-party/nprogress.js');
|
||||
}
|
||||
|
||||
if (!theme.quicklink.enable) {
|
||||
hexo.route.remove('js/third-party/quicklink.js');
|
||||
}
|
||||
|
||||
20
source/js/third-party/nprogress.js
vendored
20
source/js/third-party/nprogress.js
vendored
@ -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();
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user