Skip to content

Commit

Permalink
feat: 添加 pacejs
Browse files Browse the repository at this point in the history
An automatic web page progress bar.
https://github.com/CodeByZach/pace

BREAKING CHANGE: 移除 nprogress
MHuiG committed Sep 8, 2022

Verified

This commit was signed with the committer’s verified signature.
1 parent 3384dea commit 3ce85d9
Showing 9 changed files with 45 additions and 208 deletions.
25 changes: 16 additions & 9 deletions _cdn.yml
Original file line number Diff line number Diff line change
@@ -253,13 +253,6 @@ pjax:
npm: true
static: true
cdnjs: true
nprogress:
name: nprogress
file: nprogress.min.js
version: 0.2.0
npm: true
static: true
cdnjs: true
font-awesome-animation:
name: font-awesome-animation
file: css/font-awesome-animation.min.css
@@ -427,8 +420,22 @@ artitalk:
npm: true
static: false
cdnjs: false


pace_js:
name: pace-js
cdnjs_name: pace
file: pace.min.js
version: 1.2.4
npm: true
static: false
cdnjs: true
pace_css:
name: pace-js
cdnjs_name: pace
file: themes/${pace_color}/pace-theme-${pace_theme}.css
version: 1.2.4
npm: true
static: false
cdnjs: true



9 changes: 8 additions & 1 deletion _config.yml
Original file line number Diff line number Diff line change
@@ -838,11 +838,18 @@ plugins:
cover: true # 封面是否pjax处理 false:每次切换页面封面都重载,适合封面较少的情况 true:封面经过Pjax处理,适合封面较多的情况
timeout: 5000 # The timeout in milliseconds for the XHR requests. Set to 0 to disable the timeout.
cacheBust: false # When set to true, Pjax appends a timestamp to skip the browser cache.
animation: false # false, nprogress, circle
exclude: # 被屏蔽的 url 地址将不启用 pjax 跳转,可以在控制台下使用 window.location.pathname 获取
# - '/artitalk/' # artitalk 不支持 pjax
# - '/bbtalk/' # bbtalk 不支持 pjax

# pace
# An automatic web page progress bar.
# https://github.com/CodeByZach/pace
pace:
enable: true
color: blue # black, blue, green, orange, pink, purple, red, silver, white, yellow
theme: minimal # 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

# 暗黑模式 darkmode
# 开关按钮:在 navbar.menu 中添加:
# - name: 暗黑模式 # 可自定义
4 changes: 4 additions & 0 deletions layout/_partial/scripts/index.ejs
Original file line number Diff line number Diff line change
@@ -119,6 +119,10 @@
<%- partial('../../_plugins/swiper/script') %>
<% } %>

<% if (theme.plugins.pace.enable) { %>
<%- partial('../../_plugins/pace/script') %>
<% } %>

<!-- pjax 标签必须存在于所有页面 否则 pjax error -->
<pjax>
<% if (page.plugins) { %>
7 changes: 7 additions & 0 deletions layout/_plugins/pace/script.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<script>
volantis.js("<%- theme.cdn.pace_js %>").then(() => {
Pace.options.restartOnPushState = false;
volantis.pjax.send(Pace.restart);
})
volantis.css("<%- theme.cdn.pace_css %>");
</script>
31 changes: 0 additions & 31 deletions layout/_plugins/pjax/animate.ejs

This file was deleted.

3 changes: 0 additions & 3 deletions layout/_plugins/pjax/index.ejs
Original file line number Diff line number Diff line change
@@ -10,9 +10,6 @@
%>

<%- js(theme.cdn.pjax) %>
<% if (theme.plugins.pjax.animation){ %>
<%- partial('animate') %>
<% } %>
<script>
var pjax;
document.addEventListener('DOMContentLoaded', function () {
10 changes: 9 additions & 1 deletion scripts/events/lib/cdn.js
Original file line number Diff line number Diff line change
@@ -143,15 +143,23 @@ function match_cdn_source(key) {
version = theme_version
}
const timestamp = hexo.theme.config.getStartTime;
const pace_color = hexo.theme.config?.plugins?.pace?.color;
const pace_theme = hexo.theme.config?.plugins?.pace?.theme;
const value = {
version,
name,
file,
min_file,
prefix,
timestamp,
pace_color,
pace_theme,
}
return format?.replace(/\$\{(.+?)\}/g, (match, $1) => value[$1]) || null
let res = format;
while (/\$\{(.+?)\}/g.test(res)) {
res = res?.replace(/\$\{(.+?)\}/g, (match, $1) => value[$1]) || null
}
return res
}
}
}
4 changes: 1 addition & 3 deletions source/css/_style/_plugins/index.styl
Original file line number Diff line number Diff line change
@@ -8,13 +8,11 @@ if hexo-config('plugins.message.enable')
@import 'message'
if hexo-config('plugins.aplayer.enable')
@import 'aplayer'
if hexo-config('plugins.pjax.enable') and hexo-config('plugins.pjax.animation')
@import 'pjaxanimate'
if hexo-config('comments.service')=='gitalk'
@import 'gitalk'
if hexo-config('custom_css.cursor.enable')
@import 'cursor'
if hexo-config('rightmenu.enable') or hexo-config('rightmenus.enable')
if hexo-config('rightmenus.enable')
@import '_rightmenu/*'


160 changes: 0 additions & 160 deletions source/css/_style/_plugins/pjaxanimate.styl

This file was deleted.

0 comments on commit 3ce85d9

Please sign in to comment.