Add NProgress (#79)

This commit is contained in:
Alfred 2020-09-07 10:24:31 +08:00 committed by GitHub
parent 96c68a9321
commit edefcdae9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 44 additions and 25 deletions

View File

@ -825,13 +825,10 @@ 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/HubSpot/pace # For more information: https://github.com/rstacruz/nprogress
pace: nprogress:
enable: false enable: false
# Themes list: spinner: true
# 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
@ -889,7 +886,7 @@ vendors:
# FancyBox # FancyBox
jquery: jquery:
fancybox: fancybox_js:
fancybox_css: fancybox_css:
# Medium-zoom # Medium-zoom
@ -930,9 +927,9 @@ vendors:
# Warning: motion won't work with animate.css version 3.2.0 or later # Warning: motion won't work with animate.css version 3.2.0 or later
animate_css: animate_css:
# Pace.js # NProgress.js
pace: nprogress_js:
pace_css: nprogress_css:
# Canvas ribbon # Canvas ribbon
canvas_ribbon: canvas_ribbon:

View File

@ -53,7 +53,7 @@ jquery:
name: jquery name: jquery
version: 3.5.1 version: 3.5.1
file: dist/jquery.min.js file: dist/jquery.min.js
fancybox: fancybox_js:
name: '@fancyapps/fancybox' name: '@fancyapps/fancybox'
version: 3.5.7 version: 3.5.7
file: dist/jquery.fancybox.min.js file: dist/jquery.fancybox.min.js
@ -126,16 +126,14 @@ animate_css:
name: animate.css name: animate.css
version: 3.1.1 version: 3.1.1
file: animate.min.css file: animate.min.css
pace: nprogress_js:
name: pace-js name: nprogress
version: 1.0.2 version: 0.2.0
file: pace.min.js file: nprogress.js
alias: pace nprogress_css:
pace_css: name: nprogress
name: pace-js version: 0.2.0
version: 1.0.2 file: nprogress.css
file: themes/blue/pace-theme-minimal.css
alias: pace
canvas_ribbon: canvas_ribbon:
name: ribbon.js name: ribbon.js
version: 1.0.2 version: 1.0.2

View File

@ -53,9 +53,9 @@
<link rel="stylesheet" href="{{ theme.vendors.fancybox_css }}"> <link rel="stylesheet" href="{{ theme.vendors.fancybox_css }}">
{%- endif %} {%- endif %}
{%- if theme.pace.enable %} {%- if theme.nprogress.enable %}
<link rel="stylesheet" href="{{ theme.vendors.pace_css }}"> <link rel="stylesheet" href="{{ theme.vendors.nprogress_css }}">
<script src="{{ theme.vendors.pace }}"></script> <script src="{{ theme.vendors.nprogress_js }}"></script>
{%- endif %} {%- endif %}
{{ next_config() }} {{ next_config() }}

View File

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

22
layout/_third-party/nprogress.njk vendored Normal file
View File

@ -0,0 +1,22 @@
{%- if theme.nprogress.enable %}
<script>
NProgress.configure({
showSpinner: {{ theme.nprogress.spinner | safedump }}
});
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();
});
</script>
{%- endif %}

View File

@ -15,7 +15,7 @@ hexo.extend.helper.register('js_vendors', function() {
vendors.push('pjax'); vendors.push('pjax');
} }
if (theme.fancybox) { if (theme.fancybox) {
vendors.push('jquery', 'fancybox'); vendors.push('jquery', 'fancybox_js');
} }
if (theme.mediumzoom) { if (theme.mediumzoom) {
vendors.push('mediumzoom'); vendors.push('mediumzoom');