Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
jerryc127 committed Jun 6, 2023
1 parent 28d1744 commit 5d52302
Show file tree
Hide file tree
Showing 43 changed files with 426 additions and 382 deletions.
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<div align="right">
Language:
🇺🇸
<a title="Chinese" href="/README_CN.md">🇨🇳</a>
<a title="Chinese" href="/README_CN.md">中文</a>
</div>

# hexo-theme-butterfly
Expand All @@ -14,7 +12,7 @@

![](https://cdn.jsdelivr.net/gh/jerryc127/CDN@m2/img/theme-butterfly-readme.png)

Demo: 👍 [Butterfly](https://butterfly.js.org/) || 🤞 [CrazyWong](https://crazywong.com/)
Demo: 👍 [Butterfly](https://butterfly.js.org/) || 🤞 [CrazyWong](https://blog.crazywong.com/)

Docs: 📖 [Butterfly Docs](https://butterfly.js.org/posts/21cfbf15/)

Expand Down Expand Up @@ -62,17 +60,17 @@ npm i hexo-theme-butterfly

- [x] Card UI Design
- [X] Support sub-menu
- [x] Two Column designs
- [x] Two-column layout
- [x] Responsive Web Design
- [x] Dark Mode
- [x] Pjax
- [x] Read Mode
- [x] Conversion between Traditional and Simplified Chinese
- [X] TOC catalog is available for both computers and mobile phones
- [X] Color themes (darker/pale night/light/ocean/mac/mac light), support custom colors
- [X] Built-in Syntax Highlighting Themes (darker/pale night/light/ocean/mac/mac light), also support customization
- [X] Code Blocks (Display code language/close or expand Code Blocks/Copy Button/word wrap)
- [X] Disable copy/Add a Copyright Notice to the Copied Text
- [X] Search (Algolia SearchZ/Local Search)
- [X] Search (Algolia Search/Local Search)
- [x] Mathjax and Katex
- [x] Built-in 404 page
- [x] WordCount
Expand Down
8 changes: 3 additions & 5 deletions README_CN.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<div align="right">
語言:
中文
<a title="English" href="/README.md">英文</a>
<a title="English" href="/README.md">English</a>
</div>

# hexo-theme-butterfly
Expand All @@ -14,7 +12,7 @@

![](https://cdn.jsdelivr.net/gh/jerryc127/CDN@m2/img/theme-butterfly-readme.png)

預覽: 👍 [Butterfly](https://butterfly.js.org/) || 🤞 [CrazyWong](https://crazywong.com/)
預覽: 👍 [Butterfly](https://butterfly.js.org/) || 🤞 [CrazyWong](https://blog.crazywong.com/)

文檔: 📖 [Butterfly Docs](https://butterfly.js.org/posts/21cfbf15/)

Expand Down Expand Up @@ -72,7 +70,7 @@ theme: butterfly
- [X] 內置多種代碼配色(darker/pale night/light/ocean/mac/mac light),可自定義代碼配色
- [X] 代碼塊顯示代碼語言/關閉或展開代碼塊/代碼複製/代碼自動換行
- [X] 可關閉文字複製/可開啟內容複製增加版權信息)
- [X] 兩種搜索(Algolia搜索和本地搜索
- [X] 兩種搜索( Algolia 搜索和本地搜索
- [x] Mathjax 和 Katex
- [x] 內置404頁面
- [x] 顯示字數統計
Expand Down
5 changes: 5 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,11 @@ background:
# Footer Background
footer_bg: false

# Add mask to header or footer (为 header 或 footer 添加黑色半透遮罩)
mask:
header: true
footer: true

# the position of bottom right button/default unit: px (右下角按鈕距離底部的距離/默認單位為px)
rightside-bottom:

Expand Down
2 changes: 1 addition & 1 deletion layout/includes/header/index.pug
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ header#page-header(class=`${isHomeClass+isFixedClass}` style=bg_img)
span#subtitle
if(theme.social)
#site_social_icons
!=fragment_cache('social', function(){return partial('includes/header/social')})
!=partial('includes/header/social', {}, {cache: true})
#scroll-down
i.fas.fa-angle-down.scroll-down-effects
else
Expand Down
34 changes: 19 additions & 15 deletions layout/includes/loading/fullpage-loading.pug
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,25 @@
.loading-word= _p('loading')

script.
const preloader = {
endLoading: () => {
document.body.style.overflow = '';
document.getElementById('loading-box').classList.add("loaded")
},
initLoading: () => {
document.body.style.overflow = 'hidden';
document.getElementById('loading-box').classList.remove("loaded")
(()=>{
const $loadingBox = document.getElementById('loading-box')
const $body = document.body
const preloader = {
endLoading: () => {
$body.style.overflow = ''
$loadingBox.classList.add('loaded')
},
initLoading: () => {
$body.style.overflow = 'hidden'
$loadingBox.classList.remove('loaded')
}
}
}

preloader.initLoading()
window.addEventListener('load',()=> { preloader.endLoading() })
preloader.initLoading()
window.addEventListener('load',() => { preloader.endLoading() })

if (!{theme.pjax && theme.pjax.enable}) {
document.addEventListener('pjax:send', () => { preloader.initLoading() })
document.addEventListener('pjax:complete', () => { preloader.endLoading() })
}
if (!{theme.pjax && theme.pjax.enable}) {
document.addEventListener('pjax:send', () => { preloader.initLoading() })
document.addEventListener('pjax:complete', () => { preloader.endLoading() })
}
})()
4 changes: 2 additions & 2 deletions layout/includes/mixins/post-ui.pug
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ mixin postUI(posts)
block
span.article-meta-label= ' ' + _p('card_post_count')

if theme.comments.card_post_count
if theme.comments.card_post_count && theme.comments.use
case theme.comments.use[0]
when 'Disqus'
+countBlockInIndex
Expand All @@ -89,7 +89,7 @@ mixin postUI(posts)
when 'Waline'
+countBlockInIndex
a(href=url_for(link) + '#post-comment')
span.waline-comment-count(id=url_for(link))
span.waline-comment-count(data-path=url_for(link))
i.fa-solid.fa-spinner.fa-spin
when 'Twikoo'
+countBlockInIndex
Expand Down
2 changes: 1 addition & 1 deletion layout/includes/rightside.pug
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ mixin rightsideItem(array)
i.fas.fa-list-ul
when 'chat'
if chat_btn
button#chat_btn(type="button" title=_p("rightside.chat"))
button#chat-btn(type="button" title=_p("rightside.chat"))
i.fas.fa-sms
when 'comment'
if commentsJsLoad
Expand Down
2 changes: 1 addition & 1 deletion layout/includes/sidebar.pug
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
.headline= _p('aside.categories')
.length-num= site.categories.length

hr
hr.custom-hr
!=partial('includes/header/menu_item', {}, {cache: true})
35 changes: 25 additions & 10 deletions layout/includes/third-party/card-post-count/artalk.pug
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,34 @@

script.
(() => {
const getArtalkCount = () => {
const runWidget = () => {
Artalk.loadCountWidget({
server: '!{server}',
site: '!{site}',
countEl: '.artalk-count'
const getArtalkCount = async() => {
try {
const eleGroup = document.querySelectorAll('#recent-posts .artalk-count')
const keyArray = Array.from(eleGroup).map(i => i.getAttribute('data-page-key'))

const headerList = {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Origin': window.location.origin
},
body: new URLSearchParams({
'site_name': '!{site}',
'type':'page_comment',
'page_keys': keyArray
})
}

const res = await fetch('!{server}/api/stat', headerList)
const result = await res.json()

keyArray.forEach((key, index) => {
eleGroup[index].textContent = result.data[key] || 0
})
} catch (err) {
console.error(err)
}

if (typeof Artalk === 'function') runWidget()
else getScript('!{theme.asset.artalk_js}').then(runWidget)
}


window.pjax ? getArtalkCount() : window.addEventListener('load', getArtalkCount)
})()
24 changes: 13 additions & 11 deletions layout/includes/third-party/card-post-count/waline.pug
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
script.
(() => {
function loadWaline () {
function initWaline () {
let initData = {
el: null,
serverURL: '!{theme.waline.serverURL}',
comment: true
}
const waline = Waline.init(initData)
}
async function loadWaline () {
try {
const eleGroup = document.querySelectorAll('#recent-posts .waline-comment-count')
const keyArray = Array.from(eleGroup).map(i => i.getAttribute('data-path'))

if (typeof Waline === 'object') initWaline()
else getScript('!{url_for(theme.asset.waline_js)}').then(initWaline)
const res = await fetch(`!{theme.waline.serverURL}/api/comment?type=count&url=${keyArray}`, { method: 'GET' })
const result = await res.json()

result.data.forEach((count, index) => {
eleGroup[index].textContent = count
})
} catch (err) {
console.error(err)
}
}

window.pjax ? loadWaline() : window.addEventListener('load', loadWaline)
Expand Down
63 changes: 40 additions & 23 deletions layout/includes/third-party/chat/chatra.pug
Original file line number Diff line number Diff line change
@@ -1,33 +1,50 @@
//- https://chatra.io/help/api/
script.
(function(d, w, c) {
w.ChatraID = '#{theme.chatra.id}';
var s = d.createElement('script');
w[c] = w[c] || function() {
(w[c].q = w[c].q || []).push(arguments);
};
s.async = true;
s.src = 'https://call.chatra.io/chatra.js';
if (d.head) d.head.appendChild(s);
})(document, window, 'Chatra');
(() => {
const isChatBtn = !{theme.chat_btn}
const isChatHideShow = !{theme.chat_hide_show}

if (!{theme.chat_btn}) {
var chatBtnFn = () => {
var chatBtn = document.getElementById("chat_btn")
chatBtn.addEventListener("click", function(){
Chatra('openChat')
});
}
chatBtnFn()
} else {
if (!{theme.chat_hide_show}) {
function chatBtnHide () {
if (isChatBtn) {
const close = () => {
Chatra('minimizeWidget')
Chatra('hide')
}
function chatBtnShow () {

const open = () => {
Chatra('openChat', true)
Chatra('show')
}

window.ChatraSetup = {
startHidden: true
}

window.chatBtnFn = () => {
const isShow = document.getElementById('chatra').classList.contains('chatra--expanded')
isShow ? close() : open()
}
} else if (isChatHideShow) {
window.chatBtn = {
hide: () => {
Chatra('hide')
},
show: () => {
Chatra('show')
}
}
}
}

(function(d, w, c) {
w.ChatraID = '#{theme.chatra.id}'
var s = d.createElement('script')
w[c] = w[c] || function() {
(w[c].q = w[c].q || []).push(arguments)
}
s.async = true
s.src = 'https://call.chatra.io/chatra.js'
if (d.head) d.head.appendChild(s)
})(document, window, 'Chatra')

})()


63 changes: 36 additions & 27 deletions layout/includes/third-party/chat/crisp.pug
Original file line number Diff line number Diff line change
@@ -1,36 +1,45 @@
script.
window.$crisp = [];
window.CRISP_WEBSITE_ID = "!{theme.crisp.website_id}";
(function () {
d = document;
s = d.createElement("script");
s.src = "https://client.crisp.chat/l.js";
s.async = 1;
d.getElementsByTagName("head")[0].appendChild(s);
})();
$crisp.push(["safe", true])
(() => {
window.$crisp = [];
window.CRISP_WEBSITE_ID = "!{theme.crisp.website_id}";
(function () {
d = document;
s = d.createElement("script");
s.src = "https://client.crisp.chat/l.js";
s.async = 1;
d.getElementsByTagName("head")[0].appendChild(s);
})();
$crisp.push(["safe", true])

if (!{theme.chat_btn}) {
$crisp.push(["do", "chat:hide"])
$crisp.push(["on", "chat:closed", function() {
$crisp.push(["do", "chat:hide"])
}])
var chatBtnFn = () => {
var chatBtn = document.getElementById("chat_btn")
chatBtn.addEventListener("click", function(){
const isChatBtn = !{theme.chat_btn}
const isChatHideShow = !{theme.chat_hide_show}

if (isChatBtn) {
const open = () => {
$crisp.push(["do", "chat:show"])
$crisp.push(["do", "chat:open"])
}

});
}
chatBtnFn()
} else {
if (!{theme.chat_hide_show}) {
function chatBtnHide () {
const close = () => {
$crisp.push(["do", "chat:hide"])
}
function chatBtnShow () {
$crisp.push(["do", "chat:show"])

close()
$crisp.push(["on", "chat:closed", function() {
close()
}])

window.chatBtnFn = () => {
$crisp.is("chat:visible") ? close() : open()
}
} else if (isChatHideShow) {
window.chatBtn = {
hide: () => {
$crisp.push(["do", "chat:hide"])
},
show: () => {
$crisp.push(["do", "chat:show"])
}
}
}
}
})()
Loading

0 comments on commit 5d52302

Please sign in to comment.