mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-10 21:17:07 +08:00
fix: 修復開啟anchor後,瀏覽器上一頁/下一頁 跳轉會404的bug (文章頁的url hash 在pjax下變成 undefined)
fix: 修復開啟anchor後,文章頁跳轉回主頁,主頁網址的hash添加上文章頁最後一個標題的 bug improvement: 優化 button tags 標簽外掛
This commit is contained in:
@@ -12,6 +12,8 @@
|
|||||||

|

|
||||||

|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
Demo: 👍 [Butterfly](https://butterfly.js.org/) || 🤞 [MYW](https://immyw.com/)
|
Demo: 👍 [Butterfly](https://butterfly.js.org/) || 🤞 [MYW](https://immyw.com/)
|
||||||
|
|
||||||
Docs: 📖 [Butterfly Docs](https://butterfly.js.org/posts/21cfbf15/)
|
Docs: 📖 [Butterfly Docs](https://butterfly.js.org/posts/21cfbf15/)
|
||||||
@@ -97,6 +99,9 @@ npm i hexo-theme-butterfly
|
|||||||
|
|
||||||
## Screenshots
|
## Screenshots
|
||||||
|
|
||||||
|

|
||||||
|

|
||||||
|

|
||||||
|

|
||||||

|

|
||||||
|
|
||||||

|

|
||||||
@@ -12,6 +12,8 @@
|
|||||||

|

|
||||||

|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
預覽: 👍 [Butterfly](https://butterfly.js.org/) || 🤞 [MYW](https://immyw.com/)
|
預覽: 👍 [Butterfly](https://butterfly.js.org/) || 🤞 [MYW](https://immyw.com/)
|
||||||
|
|
||||||
文檔: 📖 [Butterfly Docs](https://butterfly.js.org/posts/21cfbf15/)
|
文檔: 📖 [Butterfly Docs](https://butterfly.js.org/posts/21cfbf15/)
|
||||||
@@ -96,6 +98,9 @@ theme: butterfly
|
|||||||
|
|
||||||
## 截圖
|
## 截圖
|
||||||
|
|
||||||
|

|
||||||
|

|
||||||
|

|
||||||
|

|
||||||

|

|
||||||
|
|
||||||

|

|
||||||
47
layout/includes/third-party/pjax.pug
vendored
47
layout/includes/third-party/pjax.pug
vendored
@@ -26,6 +26,29 @@ script.
|
|||||||
scrollRestoration: false
|
scrollRestoration: false
|
||||||
})
|
})
|
||||||
|
|
||||||
|
document.addEventListener('pjax:send', function () {
|
||||||
|
|
||||||
|
// removeEventListener toc scroll
|
||||||
|
window.removeEventListener('scroll', window.tocScrollFn)
|
||||||
|
|
||||||
|
typeof preloader === 'object' && preloader.initLoading()
|
||||||
|
|
||||||
|
if (window.aplayers) {
|
||||||
|
for (let i = 0; i < window.aplayers.length; i++) {
|
||||||
|
if (!window.aplayers[i].options.fixed) {
|
||||||
|
window.aplayers[i].destroy()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
typeof typed === 'object' && typed.destroy()
|
||||||
|
|
||||||
|
//reset readmode
|
||||||
|
const $bodyClassList = document.body.classList
|
||||||
|
$bodyClassList.contains('read-mode') && $bodyClassList.remove('read-mode')
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
document.addEventListener('pjax:complete', function () {
|
document.addEventListener('pjax:complete', function () {
|
||||||
window.refreshFn()
|
window.refreshFn()
|
||||||
|
|
||||||
@@ -61,28 +84,12 @@ script.
|
|||||||
typeof preloader === 'object' && preloader.endLoading()
|
typeof preloader === 'object' && preloader.endLoading()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
document.addEventListener('pjax:send', function () {
|
|
||||||
typeof preloader === 'object' && preloader.initLoading()
|
|
||||||
|
|
||||||
if (window.aplayers) {
|
|
||||||
for (let i = 0; i < window.aplayers.length; i++) {
|
|
||||||
if (!window.aplayers[i].options.fixed) {
|
|
||||||
window.aplayers[i].destroy()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
typeof typed === 'object' && typed.destroy()
|
|
||||||
|
|
||||||
//reset readmode
|
|
||||||
const $bodyClassList = document.body.classList
|
|
||||||
$bodyClassList.contains('read-mode') && $bodyClassList.remove('read-mode')
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
document.addEventListener('pjax:error', (e) => {
|
document.addEventListener('pjax:error', (e) => {
|
||||||
if (e.request.status === 404) {
|
if (e.request.status === 404) {
|
||||||
|
if (!{theme.anchor}) {
|
||||||
|
location.hash && e.request.responseURL !== location.href ? pjax.loadUrl(location.href) : pjax.loadUrl('/404.html')
|
||||||
|
return
|
||||||
|
}
|
||||||
pjax.loadUrl('/404.html')
|
pjax.loadUrl('/404.html')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hexo-theme-butterfly",
|
"name": "hexo-theme-butterfly",
|
||||||
"version": "3.7.5-b3",
|
"version": "3.7.5-b4",
|
||||||
"description": "A Simple and Card UI Design theme for Hexo",
|
"description": "A Simple and Card UI Design theme for Hexo",
|
||||||
"main": "package.json",
|
"main": "package.json",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ function btn (args) {
|
|||||||
option = option.trim()
|
option = option.trim()
|
||||||
|
|
||||||
return `<a class="btn-beautify button--animated ${option}" href="${urlFor(url)}"
|
return `<a class="btn-beautify button--animated ${option}" href="${urlFor(url)}"
|
||||||
title="${text}">${icon.length > 0 ? `<i class="${icon} fa-fw"></i>` : ''}<span>${text}</span></a>`
|
title="${text}">${icon.length ? `<i class="${icon}"></i>` : ''}${text.length ? `<span>${text}</span>` : ''}</a>`
|
||||||
}
|
}
|
||||||
|
|
||||||
hexo.extend.tag.register('btn', btn, { ends: false })
|
hexo.extend.tag.register('btn', btn, { ends: false })
|
||||||
|
|||||||
@@ -11,6 +11,9 @@
|
|||||||
color: $btn-color
|
color: $btn-color
|
||||||
line-height: 2
|
line-height: 2
|
||||||
|
|
||||||
|
i + span
|
||||||
|
margin-left: .3rem
|
||||||
|
|
||||||
&:not(.block) + .btn-beautify:not(.block)
|
&:not(.block) + .btn-beautify:not(.block)
|
||||||
margin: 0 .2rem 1rem
|
margin: 0 .2rem 1rem
|
||||||
|
|
||||||
|
|||||||
@@ -388,11 +388,14 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
const $article = document.getElementById('article-container')
|
const $article = document.getElementById('article-container')
|
||||||
|
|
||||||
// main of scroll
|
// main of scroll
|
||||||
window.addEventListener('scroll', btf.throttle(function (e) {
|
window.tocScrollFn = function () {
|
||||||
const currentTop = window.scrollY || document.documentElement.scrollTop
|
return btf.throttle(function () {
|
||||||
scrollPercent(currentTop)
|
const currentTop = window.scrollY || document.documentElement.scrollTop
|
||||||
findHeadPosition(currentTop)
|
scrollPercent(currentTop)
|
||||||
}, 100))
|
findHeadPosition(currentTop)
|
||||||
|
}, 100)()
|
||||||
|
}
|
||||||
|
window.addEventListener('scroll', tocScrollFn)
|
||||||
|
|
||||||
const scrollPercent = function (currentTop) {
|
const scrollPercent = function (currentTop) {
|
||||||
const docHeight = $article.clientHeight
|
const docHeight = $article.clientHeight
|
||||||
|
|||||||
Reference in New Issue
Block a user