Compare commits

...

89 Commits
4.2.0 ... 4.6.1

Author SHA1 Message Date
Jerry
062641c8ab Merge branch 'dev' 2023-01-18 20:28:07 +08:00
Jerry
08fabdc2d1 update package.json 2023-01-18 20:27:31 +08:00
Jerry
6a50b62869 remove: 移除多余的代码 2023-01-17 15:02:42 +08:00
Jerry
396fb102da feat: 可配置 typed.js 的參數 closed #1154
fix: 修復 typeJSFn 重複賦值的 bug
fix: 修復固定狀態欄後,標題有陰影的 bug
fix: 修復 gallery 標籤將圖片鏈接截斷導致404無法加載圖片的 bug closed #1160
fix: 修復開啟導航欄固定後,點擊部分滾動向上的按鈕,滾動的目標部分被導航欄遮擋的 bug closed #1158
fix: 修復固定導航欄後,toc 被遮擋的 closed #1159
fix: 切換簡繁時,會改變 html 的 lang 屬性
2023-01-17 14:46:55 +08:00
Jerry
b019a1fd33 Merge branch 'dev' 2023-01-15 01:40:13 +08:00
Jerry
929a5608d3 fix: 修復 pjax 下, waline js 會重複加載的 bug 2023-01-15 01:39:16 +08:00
Jerry
9a3b41912a feat: 不蒜子可配置 CDN closed #1132
feat: gallery 標簽外掛增加圖片懶加載,增加 lazyload rowHeight 和 limit 屬性配置
feat: 可設置固定導航欄 closed #1150
fix: 修復開啟懶加載後,再使用 flink_url 的方式引入友鏈數據,友鏈頭像有可能不顯示的 bug closed #1146
fix: 修復閲讀模式下,代碼塊的背景顏色仍顯示彩色背景的 bug (自定義代碼塊) closed #1139
improvement: 搜索結果換行時不會拆分單詞顯示
improvement: 優化搜索結果顯示滾動條位置
improvement: css/js 優化
2023-01-14 00:36:34 +08:00
Jerry
0f915f47ef breaking changes: 移除 cnzz 分析
feat: 導航欄可隱藏博客名字
feat: 導航欄可設置 logo closed #1104
2022-12-22 00:16:54 +08:00
Jerry
e2565a9f39 breaking changes: cover 的顯示優化 #1101
feature: default_cover 可配置顏色
fix: 修復使用本地搜索時,輸入特殊符號沒有顯示結果的 bug closed #1110
fix: 修復 頂部圖和 footer 配置帶有/的顏色參數時,無法顯示顏色的 bug
improvement: 鼠標移動到分頁時,文章分頁按鈕增加説明文字
improvement: 文章頁的頂部圖顯示次序為 top_img > cover > default_top_img
improvement: canonical 的鏈接根據配置生成 #1111
2022-12-13 01:23:50 +08:00
Jerry
4cd26d183c update 2022-11-18 18:35:04 +08:00
Jerry
f218a0a14a breaking changes: 移除 subtitle 一句網調用(api 已失效)
feat: 右下角按鈕增加預覽進度顯示
feat: toc可設置是否顯示預覽進度
fix: 修復 TypeError: require(...) is not a function 的報錯 #1102
improvement: 日期設置相對日期時,文章的日期格式和最新評論的日期格式統一為 年月日
2022-11-18 18:30:25 +08:00
Jerry Wong
6c7debfd24 Merge pull request #1102 from GZTimeWalker/patch-1
fix: `TypeError: require(...) is not a function` when setup
2022-11-18 13:32:47 +08:00
Jerry Wong
eb88a5bb4a Update welcome.js 2022-11-18 13:32:35 +08:00
Jerry Wong
f07823903f Update init.js 2022-11-18 13:32:03 +08:00
GZTime
4bd5edd955 chore: remove semicolons 2022-11-16 03:45:54 +08:00
GZTime
ecf4d341e6 fix: TypeError: require(...) is not a function 2022-11-16 03:36:24 +08:00
Jerry
c6c58f7620 Merge branch 'dev' 2022-10-31 00:10:50 +08:00
Jerry
5c0d578e4c fix: 修復 mathjax 行內公式 導致行距過密的 bug
fix: 修復更新mathjax 新版本後,mathjax 會溢出屏幕而不是顯示滾動條的 bug
improvement: 避免沒更新主題文件而導致 anchor 配置報錯的問題
improvement: 更新 plugins.yml
2022-10-31 00:09:13 +08:00
Jerry
859cd4938b Merge branch 'dev' 2022-10-21 18:17:12 +08:00
Jerry
21f71cd0f2 breaking changes: Open_Graph_meta 設置更改,可配置其它參數
feature: 更新 Facebook sdk 到 v15
improvement: 更新 plugins.yml
Remove: 移除 meta keywords
2022-10-21 18:10:52 +08:00
Jerry
f775e97548 Merge branch 'dev' of https://github.com/jerryc127/hexo-theme-butterfly into dev 2022-10-09 16:57:50 +08:00
Jerry
54a4fa381d improvement: update plugins.yml 2022-10-09 16:56:50 +08:00
Jerry Wong
bf3a43e62a Merge pull request #1075 from EmptyDreams/patch-1
修正`throttle`函数调用方式
2022-10-09 16:40:30 +08:00
Jerry Wong
274a499aff Update main.js 2022-10-09 16:27:24 +08:00
Jerry Wong
48781800f3 Merge pull request #1076 from wangyijin209/dev
Update tw_cn.js 增加`龍、歷、誌、製、壹、臺、臯、準、復、勐、鐘、註和範`的繁簡轉化
2022-10-09 15:08:05 +08:00
Jerry Wong
449fe2f876 Update tw_cn.js 2022-10-09 15:07:17 +08:00
wangyijin209
06ab48f607 Update tw_cn.js 2022-10-06 21:15:57 +08:00
wangyijin209
e0382c80ae Update tw_cn.js 2022-10-06 20:54:02 +08:00
wangyijin209
a1589c0212 Update tw_cn.js 2022-10-06 20:48:41 +08:00
wangyijin209
ff6fc30743 Update tw_cn.js 2022-10-06 20:43:46 +08:00
wangyijin209
fef6dcf6c6 Update tw_cn.js 2022-10-06 17:41:41 +08:00
空梦
5fd171bab0 修正throttle函数调用方式
只有在调用`throttle`返回的同一个对象时才能起到“节流”效果。
2022-10-05 21:14:11 +08:00
Jerry
0b0cb38b59 breaking changes: 增加 pace.js 加載動畫條 closed #935 2022-09-21 01:29:36 +08:00
Jerry
65b1ad32c8 Merge branch 'dev' of https://github.com/jerryc127/hexo-theme-butterfly into dev 2022-09-03 15:57:20 +08:00
Jerry
13cf15c369 breaking changes: anchor設置更改,可單獨設置按鈕和自動更新anchor是否開啟,可設置button圖標,可設置button 總是顯示 closed #1025
improvement: 本地預覽,友情鏈接頁面刷新,內容不會重複顯示
2022-09-03 15:55:18 +08:00
Jerry Wong
6b7d0d9806 Merge pull request #1032 from KiritaniAyaka/patch-2
fix: fix mixed layout when screen eq 768px
2022-08-24 00:00:20 +08:00
Ayaka
c17b0cb553 Update main.js 2022-08-23 22:34:57 +08:00
Jerry
8ee052e93b Merge branch 'dev' 2022-08-18 00:39:29 +08:00
Jerry
c866315b87 feat: update 4.4.0 2022-08-18 00:38:09 +08:00
Jerry
2404eee5c1 fix 2022-08-18 00:31:53 +08:00
Jerry
5e656b7072 feat: update plugins.yml 2022-08-18 00:27:09 +08:00
Jerry Wong
a405217462 Merge pull request #1013 from dlinedev/dev
feat: Support typewriter effect speed options of Subtitle in _config.yml
2022-08-13 13:01:00 +08:00
Jerry Wong
8cfa1665b9 Update subtitle.pug 2022-08-13 12:59:53 +08:00
Dylan Lin
d12f5be271 docs: add default Effect Speed Options of Subtitle in _config.yml 2022-08-13 02:29:20 +08:00
Dylan Lin
26f2c1b4e3 feat: Support typewriter effect speed options of Subtitle in _config.yml 2022-08-12 17:15:32 +08:00
Jerry Wong
bb7fc446fc Merge pull request #965 from KiritaniAyaka/patch-1
fix: fix a minor problem about header border-radius style
2022-07-19 16:35:24 +08:00
Jerry Wong
49e4903b34 Merge pull request #977 from kkfive/dev
fix: artalk评论option无效
2022-07-19 16:21:03 +08:00
DreamyTZK
91641646a7 fix: artalk评论option无效 2022-07-17 14:31:24 +08:00
DreamyTZK
4b8492a377 Merge pull request #13 from jerryc127/dev
[pull] dev from jerryc127:dev
2022-07-17 14:28:32 +08:00
Jerry
a36c9ca6d2 feat: 在綫聊天新增facebook洽談外掛程式 closed #918
feat: 添加artalk評論 closed #933
fix: 修復 開啟 archor 後, facebook評論加載不正確的 bug
fix: 修復 facebook 評論數無法加載的 bug
2022-07-17 01:14:41 +08:00
Ayaka
6361f28328 Update head.styl 2022-07-08 17:42:09 +08:00
Jerry
7e83095920 Merge branch 'dev' 2022-06-27 01:27:45 +08:00
Jerry
dbb31dec99 fix: 當設置 comments 為 false 時,如果設置了顯示評論提供的閲讀數,閲讀數無法顯示的 bug
fix: findArchivesTitle bug
2022-06-27 01:23:35 +08:00
Jerry
057581b955 fix merge conflict 2022-06-24 02:10:04 +08:00
Jerry
fba180afaf update 4.3.0 2022-06-24 02:08:26 +08:00
Jerry Wong
b8b728898e Merge pull request #942 from ccknbc-forked/dev
fix:侧边栏归档卡片自定义排序异常
2022-06-19 21:55:30 +08:00
CC康纳百川
91d49fe7a2 fix:侧边栏归档卡片自定义排序异常 2022-06-18 18:35:31 +08:00
Jerry
931a0ba82d breaking changes: archives 隱藏 aside 設置更改
feat: tag 和 category 頁面可設置隱藏 aside
feat: 子歸檔頁面顯示的文章數量不再顯示總文章數量,而是對應的子歸檔文章數量
feat: 為一些數據加載增加 loading 顯示
improvement: 修改 note 圖標 class 名字,避免第三方圖標覆蓋主題樣式
2022-06-17 01:01:46 +08:00
Jerry
9a33e23a9c feat: 移除 katex copy-tex.css
feat: CDN可配置 cdnjs
feat: cdn可設置 version 和 custom format
feat: 點擊歸檔日期跳轉到頁面,標題顯示日期而不是‘歸檔’二字 closed #925
fix: Algolia搜索沒有結果 closed #923
2022-06-12 01:07:09 +08:00
Jerry Wong
945ea89685 Merge branch 'dev' of https://github.com/jerryc127/hexo-theme-butterfly into dev 2022-05-22 16:22:26 +08:00
Jerry Wong
b4d3ea86bb feat: CDN 可配置為 unpkg
fix: 評論系統開啟時 busuanzi 的 page_pv 不顯示
2022-05-22 16:20:49 +08:00
Jerry Wong
ecebacad37 Merge pull request #917 from jerryc127/revert-914-dev
Revert "Feat: 添加系列文章目录"
2022-05-22 00:02:43 +08:00
Jerry Wong
e650f71086 Revert "Feat: 添加系列文章目录" 2022-05-22 00:02:14 +08:00
Jerry Wong
6d387eadcc Merge pull request #894 from pai233/dev
Feat: 添加Remark42评论系统支持
2022-05-22 00:01:59 +08:00
Jerry Wong
860f6c5ef9 Merge pull request #914 from qsgy-edge/dev
Feat: 添加系列文章目录
2022-05-21 23:59:42 +08:00
pai233
e56757ac29 Merge branch 'jerryc127:dev' into dev 2022-05-21 08:26:46 +08:00
qsgy-edge
08b7cd9dbb 添加系列文章目录 2022-05-20 16:55:51 +08:00
Jerry Wong
9a86429484 breaking changes: 適配 disqusjs 3.0
fix: 修復首頁文章 valine 評論數只顯示第一篇的 bug
fix: 修復子目錄下,第三方插件本地資源無法加載的 bug closed #908
fix: 評論系統開啟時 busuanzi 的 page_pv 不顯示的 bug closed #902
fix: 修復 pjax 下,使用 mermaid 跳轉會重新加載的 bug
2022-05-19 16:45:30 +08:00
Jerry Wong
6e58f68f0c fix: 修復首頁文章 valine 評論數只顯示第一篇的 bug
fix: 修復子目錄下,第三方插件本地資源無法加載的 bug closed #908
fix: 評論系統開啟時 busuanzi 的 page_pv 不顯示的 bug closed #902
fix: 修復 pjax 下,使用 mermaid 跳轉會重新加載的 bug
2022-05-19 16:37:01 +08:00
Jerry Wong
004a27decc Merge branch 'dev' 2022-05-19 15:39:05 +08:00
Jerry Wong
4df78b1966 fix pjax 2022-05-17 16:03:25 +08:00
Jerry Wong
b1e40b33d7 Merge pull request #897 from kkfive/patch-1
perf: 优化twikoo评论,无评论数容器时不调用API获取
2022-05-16 01:49:53 +08:00
DreamyTZK
cf38250fa9 perf: 优化twikoo评论,无评论数容器时不调用API获取 2022-05-15 14:18:10 +08:00
pai233
e3bb904e87 Merge branch 'dev' of https://github.com/pai233/hexo-theme-butterfly into dev 2022-05-13 10:22:46 +08:00
pai233
cbf52c3053 feat: Remark42支持显示最新评论 2022-05-13 10:22:16 +08:00
pai233
9351413b63 Update index.pug 2022-05-12 20:56:46 +08:00
pai233
1f3f2f471b feat: Remark42评论支持显示文章评论数 2022-05-12 08:39:56 +08:00
pai233
c68e872f0e feat: 将Remark42的可选配置归入option 2022-05-11 13:47:54 +08:00
pai233
1bc54d6eb3 Merge branch 'dev' of https://github.com/pai233/hexo-theme-butterfly into dev 2022-05-11 09:36:37 +08:00
pai233
f768d6fce0 删除不必要的空格 2022-05-11 09:35:39 +08:00
pai233
4dd146f787 Merge branch 'jerryc127:dev' into dev 2022-05-11 09:33:49 +08:00
pai233
7187a17896 feat: 添加Remark42配置说明 2022-05-11 09:31:51 +08:00
pai233
41ac7f170c feat: 增加Remark42评论系统主题色适应
feat: 增加Remark42主题评论系统自定义显示评论数
2022-05-11 09:27:21 +08:00
Jerry
fd21969278 Merge branch 'dev' 2022-05-11 00:20:35 +08:00
Jerry
9479f8a704 Merge branch 'dev' of https://github.com/jerryc127/hexo-theme-butterfly into dev 2022-05-11 00:19:37 +08:00
Jerry
793e004a3a fix: CDN配置為 local 時 mathjax 字體缺失的 bug close #893 2022-05-11 00:18:19 +08:00
Jerry Wong
b3e5b7c30d Merge pull request #888 from kkfive/dev
perf: 调整本地搜索结果间距
2022-05-07 00:06:36 +08:00
pai233
060defa475 feat: 添加Remark42评论支持 2022-05-04 12:44:39 +08:00
DreamyTZK
c2c199bd16 perf: 调整本地搜索结果间距 2022-05-03 22:19:34 +08:00
101 changed files with 1624 additions and 657 deletions

View File

@@ -16,6 +16,16 @@ body:
validations:
required: true
- type: dropdown
id: modify
attributes:
label: 是否修改过主题文件? || Has the theme files been modified?
options:
- 是 (Yes)
- 不是 (No)
validations:
required: true
- type: dropdown
id: browser
attributes:

20
.github/stale.yml vendored
View File

@@ -1,20 +0,0 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 30
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7
# Issues with these labels will never be considered stale
exemptLabels:
- pinned
- security
- bug
- enhancement
- documentation
# Label to use when marking an issue as stale
staleLabel: stale
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false

19
.github/workflows/stale.yml vendored Normal file
View File

@@ -0,0 +1,19 @@
name: 'Close stale issues and PRs'
on:
schedule:
- cron: '30 1 * * *'
jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v5
with:
days-before-issue-stale: 30
days-before-pr-stale: -1
days-before-close: 7
stale-issue-message: 'This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.'
close-pr-message: 'This issue has not seen any activity since it was marked stale. Closing.'
stale-issue-label: 'Stale'
exempt-issue-labels: 'pinned,bug,enhancement,documentation,Plan'
operations-per-run: 1000

View File

@@ -9,7 +9,7 @@
![master version](https://img.shields.io/github/package-json/v/jerryc127/hexo-theme-butterfly/master?color=%231ab1ad&label=master)
![master version](https://img.shields.io/github/package-json/v/jerryc127/hexo-theme-butterfly/dev?label=dev)
![https://img.shields.io/npm/v/hexo-theme-butterfly?color=%09%23bf00ff](https://img.shields.io/npm/v/hexo-theme-butterfly?color=%09%23bf00ff)
![hexo version](https://img.shields.io/badge/hexo-5.0+-0e83c)
![hexo version](https://img.shields.io/badge/hexo-5.3.0+-0e83c)
![license](https://img.shields.io/github/license/jerryc127/hexo-theme-butterfly?color=FF5531)
![](https://cdn.jsdelivr.net/gh/jerryc127/CDN@m2/img/theme-butterfly-readme.png)
@@ -79,9 +79,9 @@ npm i hexo-theme-butterfly
- [x] Related articles
- [x] Displays outdated notice for a post
- [x] Share (AddThis/Sharejs/Addtoany)
- [X] Comment (Disqus/Disqusjs/Livere/Gitalk/Valine/Waline/Utterances/Facebook Comments/Twikoo/Giscus)
- [X] Comment (Disqus/Disqusjs/Livere/Gitalk/Valine/Waline/Utterances/Facebook Comments/Twikoo/Giscus/Remark42/artalk)
- [x] Multiple Comment System Support
- [x] Online Chats (Chatra/Tidio/Daovoice/Gitter/Crisp)
- [x] Online Chats (Chatra/Tidio/Daovoice/Gitter/Crisp/messenger)
- [x] Web analytics
- [x] Google AdSense
- [x] Webmaster Verification
@@ -89,7 +89,7 @@ npm i hexo-theme-butterfly
- [x] Typewriter Effect: activate_power_mode
- [x] Background effects (Canvas ribbon/canvas_ribbon_piao/canvas_nest)
- [x] Mouse click effects (Fireworks/Heart/Text)
- [x] Preloader/Loading Animation
- [x] Preloader/Loading Animation/pace.js
- [x] Busuanzi visitor counter
- [x] Medium Zoom/Fancybox
- [x] Mermaid

View File

@@ -9,7 +9,7 @@
![master version](https://img.shields.io/github/package-json/v/jerryc127/hexo-theme-butterfly/master?color=%231ab1ad&label=master)
![master version](https://img.shields.io/github/package-json/v/jerryc127/hexo-theme-butterfly/dev?label=dev)
![https://img.shields.io/npm/v/hexo-theme-butterfly?color=%09%23bf00ff](https://img.shields.io/npm/v/hexo-theme-butterfly?color=%09%23bf00ff)
![hexo version](https://img.shields.io/badge/hexo-5.0+-0e83c)
![hexo version](https://img.shields.io/badge/hexo-5.3.0+-0e83c)
![license](https://img.shields.io/github/license/jerryc127/hexo-theme-butterfly?color=FF5531)
![](https://cdn.jsdelivr.net/gh/jerryc127/CDN@m2/img/theme-butterfly-readme.png)
@@ -79,9 +79,9 @@ theme: butterfly
- [x] 顯示相關文章
- [x] 過期文章提醒
- [x] 多種分享系統AddThis/Sharejs/Addtoany
- [X] 多種評論系統Disqus/Disqusjs/Livere/Gitalk/Valine/Waline/Utterances/Facebook Comments/Twikoo/Giscus
- [X] 多種評論系統Disqus/Disqusjs/Livere/Gitalk/Valine/Waline/Utterances/Facebook Comments/Twikoo/Giscus/Remark42/artalk
- [x] 支持雙評論部署
- [x] 多種在線聊天Chatra/Tidio/Daovoice/Gitter/Crisp
- [x] 多種在線聊天Chatra/Tidio/Daovoice/Gitter/Crisp/messenger
- [x] 多種分析系統
- [x] 谷歌廣告/手動廣告位置
- [x] 各種站長驗證Google/Bing/Baidu/360/Yandex
@@ -89,7 +89,7 @@ theme: butterfly
- [x] 打字特效 activate_power_mode
- [x] 多種背景特效(靜止彩帶/動態彩帶/Canvas Nest
- [x] 多種鼠標點擊特效(煙花/文字/愛心)
- [x] 內置一種 Preloader 加載動畫
- [x] 內置一種 Preloader 加載動畫和 pace.js 加載動畫條
- [x] 不蒜子訪問統計
- [x] 兩種大圖模式Medium Zoom/Fancybox
- [x] Mermaid 圖表顯示
@@ -97,7 +97,7 @@ theme: butterfly
- [x] 圖片懶加載
- [x] Instantpage/Pangu/Snackbar彈窗/PWA......
## ✨ 贡献
## ✨ 貢獻
<a href="https://github.com/jerryc127/hexo-theme-butterfly/graphs/contributors">
<img src="https://contrib.rocks/image?repo=jerryc127/hexo-theme-butterfly" />

View File

@@ -13,6 +13,11 @@ menu:
# Link: /link/ || fas fa-link
# About: /about/ || fas fa-heart
nav:
logo: # image
display_title: true
fixed: false # fixed navigation bar
# Code Blocks (代碼相關)
# --------------------------------------
@@ -168,8 +173,12 @@ index_post_content:
length: 500 # if you set method to 2 or 3, the length need to config
# anchor
# when you scroll in post, the URL will update according to header id.
anchor: false
anchor:
button:
enable: false
always_show: false
icon: # the unicode value of Font Awesome icon, such as '\3423'
auto_update: false # when you scroll in post, the URL will update according to header id.
# Post
# --------------------------------------
@@ -181,6 +190,7 @@ toc:
number: true
expand: false
style_simple: false # for post
scroll_percent: true
post_copyright:
enable: true
@@ -259,7 +269,7 @@ addtoany:
comments:
# Up to two comments system, the first will be shown as default
# Choose: Disqus/Disqusjs/Livere/Gitalk/Valine/Waline/Utterances/Facebook Comments/Twikoo/Giscus
# Choose: Disqus/Disqusjs/Livere/Gitalk/Valine/Waline/Utterances/Facebook Comments/Twikoo/Giscus/Remark42/Artalk
use: # Valine,Disqus
text: true # Display the comment name next to the button
# lazyload: The comment system will be load when comment element enters the browser's viewport.
@@ -333,7 +343,7 @@ facebook_comments:
user_id: # optional
pageSize: 10 # The number of comments to show
order_by: social # social/time/reverse_time
lang: en_US # Language en_US/zh_CN/zh_TW and so on
lang: zh_TW # Language en_US/zh_CN/zh_TW and so on
# Twikoo
# https://github.com/imaegoo/twikoo
@@ -354,6 +364,21 @@ giscus:
dark: dark
option:
# Remark42
# https://remark42.com/docs/configuration/frontend/
remark42:
host: # Your Host URL
siteId: # Your Site ID
option:
# Artalk
# https://artalk.js.org/guide/frontend/config.html
artalk:
server:
site:
visitor: false
option:
# Chat Services
# --------------------------------------
@@ -377,7 +402,7 @@ tidio:
public_key:
# daovoice
# http://daovoice.io/
# http://dashboard.daovoice.io/app
daovoice:
enable: false
app_id:
@@ -394,6 +419,13 @@ crisp:
enable: false
website_id:
# messenger
# https://developers.facebook.com/docs/messenger-platform/discovery/facebook-chat-plugin/
messenger:
enable: false
pageID:
lang: zh_TW # Language en_US/zh_CN/zh_TW and so on
# Footer Settings
# --------------------------------------
footer:
@@ -414,10 +446,6 @@ baidu_analytics:
# https://analytics.google.com/analytics/web/
google_analytics:
# CNZZ Analytics
# https://www.umeng.com/
cnzz_analytics:
# Cloudflare Analytics
# https://www.cloudflare.com/zh-tw/web-analytics/
cloudflare_analytics:
@@ -597,12 +625,13 @@ subtitle:
enable: false
# Typewriter Effect (打字效果)
effect: true
# loop (循環打字)
loop: true
# Customize typed.js (配置typed.js)
# https://github.com/mattboldt/typed.js/#customization
typed_option:
# source 調用第三方服務
# source: false 關閉調用
# source: 1 調用一言網的一句話(簡體) https://hitokoto.cn/
# source: 2 調用一句網(簡體) http://yijuzhan.com/
# source: 2 調用一句網(簡體) https://yijuzhan.com/
# source: 3 調用今日詩詞(簡體) https://www.jinrishici.com/
# subtitle 會先顯示 source , 再顯示 sub 的內容
source: false
@@ -610,7 +639,14 @@ subtitle:
sub:
# Loading Animation (加載動畫)
preloader: false
preloader:
enable: false
# source
# 1. fullpage-loading
# 2. pace (progress bar)
source: 1
# pace theme (see https://codebyzach.github.io/pace/)
pace_css_url:
# aside (側邊欄)
# --------------------------------------
@@ -621,7 +657,10 @@ aside:
button: true
mobile: true # display on mobile
position: right # left or right
archives: true
display:
archive: true
tag: true
category: true
card_author:
enable: true
description:
@@ -713,6 +752,9 @@ darkmode:
# autoChangeMode: false
autoChangeMode: false
# show scroll percent in scroll-to-top button
rightside_scroll_percent: false
# Don't modify the following settings unless you know how they work (非必要請不要修改 )
# Choose: readmode,translate,darkmode,hideAside,toc,chat,comment
# Don't repeat 不要重複
@@ -817,7 +859,16 @@ lazyload:
# Open graph meta tags
# https://developers.facebook.com/docs/sharing/webmasters/
Open_Graph_meta: true
Open_Graph_meta:
enable: true
option:
# twitter_card:
# twitter_image:
# twitter_id:
# twitter_site:
# google_plus:
# fb_admins:
# fb_app_id:
# Add the vendor prefixes to ensure compatibility
css_prefix: true
@@ -836,13 +887,22 @@ inject:
# 非必要請不要修改
CDN:
# The CDN provider of internal scripts (主題內部 js 的 cdn 配置)
# option: local/jsdelivr
# Dev version cannot choose jsdelivr (dev版的主題能設置為 jsdelivr)
# option: local/jsdelivr/unpkg/cdnjs/custom
# Dev version can only choose. ( dev版的主題能設置為 local )
internal_provider: local
# The CDN provider of third party scripts (第三方 js 的 cdn 配置)
# option: local/jsdelivr
# option: local/jsdelivr/unpkg/cdnjs/custom
# when set it to local, you need to install hexo-butterfly-extjs
third_party_provider: jsdelivr
# Add version number to CDN, true or false
version: false
# Custom format
# For example: https://cdn.staticfile.org/${cdnjs_name}/${version}/${min_cdnjs_file}
custom_format:
option:
# main_css:
# main:
@@ -867,7 +927,6 @@ CDN:
# mathjax:
# katex:
# katex_copytex:
# katex_copytex_css:
# mermaid:
# canvas_ribbon:
# canvas_fluttering_ribbon:
@@ -893,4 +952,7 @@ CDN:
# meting_js:
# prismjs_js:
# prismjs_lineNumber_js:
# prismjs_autoloader:
# prismjs_autoloader:
# artalk_js:
# artalk_css:
# busuanzi:

View File

@@ -117,5 +117,6 @@ Snackbar:
night_to_day: Light Mode Activated Manually
loading: Loading...
load_more: Load More
error404: Page not found

View File

@@ -117,5 +117,6 @@ Snackbar:
night_to_day: Light Mode Activated Manually
loading: Loading...
load_more: Load More
error404: Page not found

View File

@@ -118,5 +118,6 @@ Snackbar:
night_to_day: 你已切换为浅色模式
loading: 加载中...
load_more: 加载更多
error404: 页面没有找到

View File

@@ -118,5 +118,6 @@ Snackbar:
night_to_day: 你已切換為淺色模式
loading: 載入中...
load_more: 載入更多
error404: 頁面沒有找到

View File

@@ -3,6 +3,7 @@ extends includes/layout.pug
block content
include ./includes/mixins/article-sort.pug
#archive
.article-sort-title= _p('page.articles') + ' - ' + site.posts.length
- const archiveLength = findArchiveLength(fragment_cache)
.article-sort-title= _p('page.articles') + ' - ' + archiveLength
+articleSort(page.posts)
include includes/pagination.pug

View File

@@ -30,9 +30,6 @@ div
else if theme.local_search.enable
script(src=url_for(theme.asset.local_search))
if theme.preloader
!= partial("includes/loading/loading-js", {}, { cache: true })
.js-pjax
if needLoadCountJs
!= partial("includes/third-party/card-post-count/index", {}, { cache: true })
@@ -69,4 +66,4 @@ div
!= partial("includes/third-party/pjax", {}, { cache: true })
if theme.busuanzi.site_uv || theme.busuanzi.site_pv || theme.busuanzi.page_pv
script(async data-pjax src='//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js')
script(async data-pjax src= theme.asset.busuanzi || '//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js')

View File

@@ -1,19 +1,12 @@
- var pageTitle
- if (is_archive()) pageTitle = fragment_cache('findArchivesTitle', function(){return findArchivesTitle(theme.menu);})
- else if (is_tag()) pageTitle = _p('page.tag') + ': ' + page.tag
- is_archive() ? page.title = findArchivesTitle(page, theme.menu, date) : ''
- if (is_tag()) pageTitle = _p('page.tag') + ': ' + page.tag
- else if (is_category()) pageTitle = _p('page.category') + ': ' + page.category
- else if (is_month()) pageTitle += ': ' + page.month + '/' + page.year
- else if (is_year()) pageTitle += ': ' + page.year
- else if (is_current('/404.html', [strict])) pageTitle = _p('error404')
- else pageTitle = page.title || config.title || ''
- var isSubtitle = config.subtitle ? ' - ' + config.subtitle : ''
- var tabTitle = is_home() || !pageTitle ? config.title + isSubtitle : pageTitle + ' | ' + config.title
- var pageKeywords
- if (page.keywords) pageKeywords = Array.isArray(page.keywords) ? (page.keywords).join(',') : ([]).join(',') || page.keywords
- else if (page.tags && page.tags.length) pageKeywords = page.tags.data.map(function(tag) {return tag.name;}).join(',')
- else pageKeywords = Array.isArray(config.keywords) ? (config.keywords).join(','): ([]).join(',') || config.keywords
- var pageAuthor = config.email ? config.author + ',' + config.email : config.author
- var pageCopyright = config.copyright || config.author
- var themeColorLight = theme.theme_color && theme.theme_color.enable && theme.theme_color.meta_theme_color_light || '#ffffff'
@@ -22,10 +15,8 @@
meta(charset='UTF-8')
meta(http-equiv="X-UA-Compatible" content="IE=edge")
meta(name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no")
meta(name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0")
title= tabTitle
if pageKeywords
meta(name="keywords" content=pageKeywords)
meta(name="author" content=pageAuthor)
meta(name="copyright" content=pageCopyright)
meta(name ="format-detection" content="telephone=no")
@@ -35,7 +26,7 @@ meta(name="theme-color" content=themeColor)
include ./head/Open_Graph.pug
!=favicon_tag(theme.favicon || config.favicon)
link(rel="canonical" href=urlNoIndex())
link(rel="canonical" href=urlNoIndex(null,config.pretty_urls.trailing_index,config.pretty_urls.trailing_html))
//- 預解析
!=partial('includes/head/preconnect', {}, {cache: true})

View File

@@ -1,11 +1,14 @@
if theme.Open_Graph_meta
- let contentType = is_post() ? 'article' : 'website'
- let metaImage = (page.cover || theme.avatar.img) ? full_url_for(page.cover || theme.avatar.img) : ''
- let fb_appId = theme.facebook_comments.app_id || ''
- let fb_admins = theme.facebook_comments.user_id || ''
!= open_graph({type: contentType, image: metaImage, fb_admins: fb_admins, fb_app_id: fb_appId})
if theme.Open_Graph_meta.enable
-
const coverVal = page.cover_type === 'img' ? page.cover : theme.avatar.img
let ogOption = Object.assign({
type: is_post() ? 'article' : 'website',
image: coverVal ? full_url_for(coverVal) : '',
fb_admins: theme.facebook_comments.user_id || '',
fb_app_id: theme.facebook_comments.app_id || '',
}, theme.Open_Graph_meta.option)
-
!= open_graph(ogOption)
else
meta(name="description" content=page_description())

View File

@@ -16,9 +16,6 @@ if theme.google_analytics
gtag('js', new Date());
gtag('config', '!{theme.google_analytics}');
if theme.cnzz_analytics
script(async data-pjax src=`https://s4.cnzz.com/z_stat.php?id=${theme.cnzz_analytics}&web_id=${theme.cnzz_analytics}`)
if theme.cloudflare_analytics
script(defer data-pjax src='https://static.cloudflareinsights.com/beacon.min.js' data-cf-beacon=`{"token": "${theme.cloudflare_analytics}"}`)

View File

@@ -120,5 +120,9 @@ script.
},
isPhotoFigcaption: !{theme.photofigcaption},
islazyload: !{theme.lazyload.enable},
isAnchor: !{theme.anchor}
isAnchor: !{theme.anchor.auto_update || false},
percent: {
toc: !{theme.toc.scroll_percent},
rightside: !{theme.rightside_scroll_percent},
}
}

View File

@@ -6,9 +6,6 @@ if theme.google_analytics
if theme.baidu_analytics
link(rel="preconnect" href="//hm.baidu.com")
if theme.cnzz_analytics
link(rel="preconnect" href="//s4.cnzz.com")
if theme.cloudflare_analytics
link(rel="preconnect" href="//static.cloudflareinsights.com")
@@ -18,5 +15,5 @@ if theme.microsoft_clarity
if theme.blog_title_font && theme.blog_title_font.font_link && theme.blog_title_font.font_link.indexOf('//fonts.googleapis.com') != -1
link(rel="preconnect" href="//fonts.googleapis.com" crossorigin='')
if theme.busuanzi.site_uv || theme.busuanzi.site_pv || theme.busuanzi.page_pv
if !theme.asset.busuanzi && (theme.busuanzi.site_uv || theme.busuanzi.site_pv || theme.busuanzi.page_pv)
link(rel="preconnect" href="//busuanzi.ibruce.info")

View File

@@ -1,6 +1,6 @@
if !theme.disable_top_img && page.top_img !== false
if is_post()
- var top_img = page.top_img || page.cover || page.randomcover
- var top_img = page.top_img || page.cover || theme.default_top_img
else if is_page()
- var top_img = page.top_img || theme.default_top_img
else if is_tag()
@@ -17,9 +17,9 @@ if !theme.disable_top_img && page.top_img !== false
- var top_img = page.top_img || theme.default_top_img
if top_img !== false
- var imgSource = top_img && top_img.indexOf('/') !== -1 ? `background-image: url('${url_for(top_img)}')` : `background: ${top_img}`
- var imgSource = top_img && isImgOrUrl(top_img) ? `background-image: url('${url_for(top_img)}')` : `background: ${top_img}`
- var bg_img = top_img ? imgSource : ''
- var site_title = is_archive() ? fragment_cache('findArchivesTitle', function(){return findArchivesTitle(theme.menu);}) : page.title || page.tag || page.category || config.title
- var site_title = page.title || page.tag || page.category || config.title
- var isHomeClass = is_home() ? 'full_page' : 'not-home-page'
- is_post() ? isHomeClass = 'post-bg' : isHomeClass
else
@@ -28,7 +28,9 @@ else
- var top_img = false
- var isHomeClass = 'not-top-img'
header#page-header(class=isHomeClass style=bg_img)
- const isFixedClass = theme.nav.fixed ? ' fixed' : ''
header#page-header(class=`${isHomeClass+isFixedClass}` style=bg_img)
!=partial('includes/header/nav', {}, {cache: true})
if top_img !== false
if is_post()

View File

@@ -1,17 +1,21 @@
nav#nav
span#blog_name
a#site-name(href=url_for('/')) #[=config.title]
span#blog-info
a(href=url_for('/') title=config.title)
if theme.nav.logo
img.site-icon(src=url_for(theme.nav.logo))
if theme.nav.display_title
span.site-name=config.title
#menus
if (theme.algolia_search.enable || theme.local_search.enable)
#search-button
a.site-page.social-icon.search
a.site-page.social-icon.search(href="javascript:void(0);")
i.fas.fa-search.fa-fw
span=' '+_p('search.title')
!=partial('includes/header/menu_item', {}, {cache: true})
#toggle-menu
a.site-page
a.site-page(href="javascript:void(0);")
i.fas.fa-bars.fa-fw

View File

@@ -62,23 +62,31 @@
block
- const commentUse = comments.use
if commentUse && !comments.lazyload
case commentUse[0]
when 'Valine'
if theme.valine.visitor
+pvBlock(url_for(page.path),'leancloud_visitors',page.title)
span.leancloud-visitors-count
when 'Waline'
if theme.waline.pageview
+pvBlock('','','')
span.waline-pageview-count(data-path=url_for(page.path))
when 'Twikoo'
if theme.twikoo.visitor
+pvBlock('','','')
span#twikoo_visitors
if page.comments !== false && commentUse && !comments.lazyload
if commentUse[0] === 'Valine' && theme.valine.visitor
+pvBlock(url_for(page.path),'leancloud_visitors',page.title)
span.leancloud-visitors-count
i.fa-solid.fa-spinner.fa-spin
else if commentUse[0] === 'Waline' && theme.waline.pageview
+pvBlock('','','')
span.waline-pageview-count(data-path=url_for(page.path))
i.fa-solid.fa-spinner.fa-spin
else if commentUse[0] === 'Twikoo' && theme.twikoo.visitor
+pvBlock('','','')
span#twikoo_visitors
i.fa-solid.fa-spinner.fa-spin
else if commentUse[0] === 'Artalk' && theme.artalk.visitor
+pvBlock('','','')
span#ArtalkPV
i.fa-solid.fa-spinner.fa-spin
else if theme.busuanzi.page_pv
+pvBlock('','post-meta-pv-cv','')
span#busuanzi_value_page_pv
i.fa-solid.fa-spinner.fa-spin
else if theme.busuanzi.page_pv
+pvBlock('','post-meta-pv-cv','')
span#busuanzi_value_page_pv
i.fa-solid.fa-spinner.fa-spin
if comments.count && !comments.lazyload && page.comments !== false && comments.use
- var whichCount = comments.use[0]
@@ -93,27 +101,46 @@
case whichCount
when 'Disqus'
when 'Disqusjs'
+countBlock
span.disqus-comment-count
a(href=full_url_for(page.path) + '#disqus_thread')
i.fa-solid.fa-spinner.fa-spin
when 'Disqusjs'
+countBlock
a(href=full_url_for(page.path) + '#disqusjs')
span.disqus-comment-count(data-disqus-url=full_url_for(page.path))
i.fa-solid.fa-spinner.fa-spin
when 'Valine'
+countBlock
a(href=url_for(page.path) + '#post-comment' itemprop="discussionUrl")
span.valine-comment-count(data-xid=url_for(page.path) itemprop="commentCount")
i.fa-solid.fa-spinner.fa-spin
when 'Waline'
+countBlock
a(href=url_for(page.path) + '#post-comment')
span.waline-comment-count(data-path=url_for(page.path))
i.fa-solid.fa-spinner.fa-spin
when 'Gitalk'
+countBlock
a(href=url_for(page.path) + '#post-comment')
span.gitalk-comment-count
i.fa-solid.fa-spinner.fa-spin
when 'Twikoo'
+countBlock
a(href=url_for(page.path) + '#post-comment')
span#twikoo-count
i.fa-solid.fa-spinner.fa-spin
when 'Facebook Comments'
+countBlock
a(href=url_for(page.path) + '#post-comment')
span.fb-comments-count(data-href=urlNoIndex())
span.fb-comments-count(data-href=urlNoIndex())
when 'Remark42'
+countBlock
a(href=url_for(page.path) + '#post-comment')
span.remark42__counter(data-url=urlNoIndex())
i.fa-solid.fa-spinner.fa-spin
when 'Artalk'
+countBlock
a(href=url_for(page.path) + '#post-comment')
span.artalk-count
i.fa-solid.fa-spinner.fa-spin

View File

@@ -1,5 +1,5 @@
- var htmlClassHideAside = theme.aside.enable && theme.aside.hide ? 'hide-aside' : ''
- page.aside = is_archive() ? theme.aside.archives : page.aside
- page.aside = is_archive() ? theme.aside.display.archive: is_category() ? theme.aside.display.category : is_tag() ? theme.aside.display.tag : page.aside
- var hideAside = !theme.aside.enable || page.aside === false ? 'hide-aside' : ''
- var pageType = is_post() ? 'post' : 'page'
@@ -8,8 +8,8 @@ html(lang=config.language data-theme=theme.display_mode class=htmlClassHideAside
head
include ./head.pug
body
if theme.preloader
!=partial('includes/loading/loading', {}, {cache: true})
if theme.preloader.enable
!=partial('includes/loading/index', {}, {cache: true})
if theme.background
#web_bg
@@ -33,7 +33,7 @@ html(lang=config.language data-theme=theme.display_mode class=htmlClassHideAside
if (footerBg === true)
- var footer_bg = bg_img
else
- var footer_bg = theme.footer_bg.indexOf('/') !== -1 ? `background-image: url('${url_for(footerBg)}')` : `background: ${footerBg}`
- var footer_bg = isImgOrUrl(theme.footer_bg) ? `background-image: url('${url_for(footerBg)}')` : `background: ${footerBg}`
else
- var footer_bg = ''

View File

@@ -0,0 +1,28 @@
#loading-box
.loading-left-bg
.loading-right-bg
.spinner-box
.configure-border-1
.configure-core
.configure-border-2
.configure-core
.loading-word= _p('loading')
script.
const preloader = {
endLoading: () => {
document.body.style.overflow = 'auto';
document.getElementById('loading-box').classList.add("loaded")
},
initLoading: () => {
document.body.style.overflow = '';
document.getElementById('loading-box').classList.remove("loaded")
}
}
window.addEventListener('load',()=> { preloader.endLoading() })
if (!{theme.pjax && theme.pjax.enable}) {
document.addEventListener('pjax:send', () => { preloader.initLoading() })
document.addEventListener('pjax:complete', () => { preloader.endLoading() })
}

View File

@@ -0,0 +1,4 @@
if theme.preloader.source === 1
include ./fullpage-loading.pug
else
include ./pace.pug

View File

@@ -1,13 +0,0 @@
script.
var preloader = {
endLoading: () => {
document.body.style.overflow = 'auto';
document.getElementById('loading-box').classList.add("loaded")
},
initLoading: () => {
document.body.style.overflow = '';
document.getElementById('loading-box').classList.remove("loaded")
}
}
window.addEventListener('load',preloader.endLoading())

View File

@@ -1,9 +0,0 @@
#loading-box
.loading-left-bg
.loading-right-bg
.spinner-box
.configure-border-1
.configure-core
.configure-border-2
.configure-core
.loading-word= _p('loading')

View File

@@ -0,0 +1,2 @@
link(rel="stylesheet", href=url_for(theme.preloader.pace_css_url || theme.asset.pace_default_css))
script(src=url_for(theme.asset.pace_js))

View File

@@ -11,7 +11,10 @@ mixin articleSort(posts)
.article-sort-item(class=no_cover)
if article.cover && theme.cover.archives_enable
a.article-sort-item-img(href=url_for(article.path) title=title)
img(src=url_for(article.cover) alt=title onerror=`this.onerror=null;this.src='${url_for(theme.error_img.post_page)}'`)
if article.cover_type === 'img'
img(src=url_for(article.cover) alt=title onerror=`this.onerror=null;this.src='${url_for(theme.error_img.post_page)}'`)
else
div(style=`background: ${article.cover}`)
.article-sort-item-info
.article-sort-item-time
i.far.fa-calendar-alt

View File

@@ -5,7 +5,7 @@ mixin postUI(posts)
let link = article.link || article.path
let title = article.title || _p('no_title')
const position = theme.cover.position
let leftOrRight = position === 'both'
let leftOrRight = position === 'both'
? index%2 == 0 ? 'left' : 'right'
: position === 'left' ? 'left' : 'right'
let post_cover = article.cover
@@ -14,7 +14,10 @@ mixin postUI(posts)
if post_cover && theme.cover.index_enable
.post_cover(class=leftOrRight)
a(href=url_for(link) title=title)
img.post_bg(src=url_for(post_cover) onerror=`this.onerror=null;this.src='`+ url_for(theme.error_img.post_page) + `'` alt=title)
if article.cover_type === 'img'
img.post-bg(src=url_for(post_cover) onerror=`this.onerror=null;this.src='${url_for(theme.error_img.post_page)}'` alt=title)
else
div.post-bg(style=`background: ${post_cover}`)
.recent-post-info(class=no_cover)
a.article-title(href=url_for(link) title=title)= title
.article-meta-wrap
@@ -70,24 +73,42 @@ mixin postUI(posts)
if theme.comments.card_post_count
case theme.comments.use[0]
when 'Disqus'
when 'Disqusjs'
+countBlockInIndex
a(href=full_url_for(link) + '#disqus_thread')
i.fa-solid.fa-spinner.fa-spin
when 'Disqusjs'
+countBlockInIndex
a(href=full_url_for(link) + '#disqusjs')
span.disqus-comment-count(data-disqus-url=full_url_for(link))
i.fa-solid.fa-spinner.fa-spin
when 'Valine'
+countBlockInIndex
a(href=url_for(link) + '#post-comment' itemprop="discussionUrl")
span.valine-comment-count(data-xid=url_for(link) itemprop="commentCount")
a(href=url_for(link) + '#post-comment')
span.valine-comment-count(data-xid=url_for(link))
i.fa-solid.fa-spinner.fa-spin
when 'Waline'
+countBlockInIndex
a(href=url_for(link) + '#post-comment')
span.waline-comment-count(id=url_for(link))
i.fa-solid.fa-spinner.fa-spin
when 'Twikoo'
+countBlockInIndex
a.twikoo-count(href=url_for(link) + '#post-comment')
i.fa-solid.fa-spinner.fa-spin
when 'Facebook Comments'
+countBlockInIndex
a(href=url_for(link) + '#post-comment')
span.fb-comments-count(data-href=urlNoIndex(article.permalink))
when 'Remark42'
+countBlockInIndex
a(href=url_for(link) + '#post-comment')
span.remark42__counter(data-url=urlNoIndex(article.permalink))
i.fa-solid.fa-spinner.fa-spin
when 'Artalk'
+countBlockInIndex
a(href=url_for(link) + '#post-comment')
span.artalk-count(data-page-key=url_for(link))
i.fa-solid.fa-spinner.fa-spin
//- Display the article introduction on homepage
case theme.index_post_content.method

View File

@@ -1,5 +1,6 @@
#article-container
.flink
- let pageContent = page.content
if page.flink_url
script.
(()=>{
@@ -35,6 +36,7 @@
}
document.querySelector(".flink").insertAdjacentHTML("afterbegin", result)
window.lazyLoadInstance && window.lazyLoadInstance.update()
})
})()
@@ -63,6 +65,6 @@
- result += `${className}${classDesc} <div class="flink-list">${listResult}</div>`
- page.content = result + page.content
!= page.content
- pageContent = result + pageContent
!= pageContent

View File

@@ -13,19 +13,23 @@ if is_post()
if(prev)
- var hasPageNext = next ? 'pull-left' : 'pull-full'
.prev-post(class=hasPageNext)
- var pagination_cover = prev.cover === false ? prev.randomcover : prev.cover
a(href=url_for(prev.path))
img.prev-cover(src=url_for(pagination_cover) onerror=`onerror=null;src='${url_for(theme.error_img.post_page)}'` alt='cover of previous post')
a(href=url_for(prev.path) title=prev.title)
if prev.cover_type === 'img'
img.cover(src=url_for(prev.cover) onerror=`onerror=null;src='${url_for(theme.error_img.post_page)}'` alt='cover of previous post')
else
.cover(style=`background: ${prev.cover || 'var(--default-bg-color)'}`)
.pagination-info
.label=_p('pagination.prev')
.prev_info=prev.title
if(next)
- var hasPagePrev = prev ? 'pull-right' : 'pull-full'
- var pagination_cover = next.cover == false ? next.randomcover : next.cover
.next-post(class=hasPagePrev)
a(href=url_for(next.path))
img.next-cover(src=url_for(pagination_cover) onerror=`onerror=null;src='${url_for(theme.error_img.post_page)}'` alt='cover of next post')
a(href=url_for(next.path) title=next.title)
if next.cover_type === 'img'
img.cover(src=url_for(next.cover) onerror=`onerror=null;src='${url_for(theme.error_img.post_page)}'` alt='cover of next post')
else
.cover(style=`background: ${next.cover || 'var(--default-bg-color)'}`)
.pagination-info
.label=_p('pagination.next')
.next_info=next.title

View File

@@ -57,4 +57,5 @@ mixin rightsideItem(array)
+rightsideItem(showArray)
button#go-up(type="button" title=_p("rightside.back_to_top"))
span.scroll-percent
i.fas.fa-arrow-up

View File

@@ -0,0 +1,20 @@
- const { server, site } = theme.artalk
script.
(() => {
const getArtalkCount = () => {
const runWidget = () => {
Artalk.LoadCountWidget({
server: '!{server}',
site: '!{site}',
countEl: '.artalk-count'
})
}
if (typeof Artalk === 'function') runWidget()
else getScript('!{theme.asset.artalk_js}').then(runWidget)
}
window.pjax ? getArtalkCount() : window.addEventListener('load', getArtalkCount)
})()

View File

@@ -1,10 +1,13 @@
- const fbSDKVer = 'v15.0'
- const fbSDK = theme.messenger.enable ? `https://connect.facebook.net/${theme.facebook_comments.lang}/sdk/xfbml.customerchat.js#xfbml=1&version=${fbSDKVer}` : `https://connect.facebook.net/${theme.facebook_comments.lang}/sdk.js#xfbml=1&version=${fbSDKVer}`
script.
(()=>{
function loadFBComment () {
if (typeof FB === 'object') FB.XFBML.parse()
if (typeof FB === 'object') FB.XFBML.parse(document.getElementById('recent-posts'))
else {
let ele = document.createElement('script')
ele.setAttribute('src','https://connect.facebook.net/!{theme.facebook_comments.lang}/sdk.js#xfbml=1&version=v9.0')
ele.setAttribute('src','!{fbSDK}')
ele.setAttribute('async', 'true')
ele.setAttribute('defer', 'true')
ele.setAttribute('crossorigin', 'anonymous')

View File

@@ -9,4 +9,8 @@ case theme.comments.use[0]
when 'Waline'
include ./waline.pug
when 'Facebook Comments'
include ./fb.pug
include ./fb.pug
when 'Remark42'
include ./remark42.pug
when 'Artalk'
include ./artalk.pug

View File

@@ -0,0 +1,18 @@
- const { host, siteId, option } = theme.remark42
script.
(()=>{
window.remark_config = Object.assign({
host: '!{host}',
site_id: '!{siteId}',
},!{JSON.stringify(option)})
function getCount () {
const s = document.createElement('script')
s.src = remark_config.host + '/web/counter.js'
s.defer = true
document.head.appendChild(s)
}
window.pjax ? getCount() : window.addEventListener('load', getCount)
})()

View File

@@ -28,7 +28,7 @@ script.
if (typeof twikoo === 'object') {
runTwikoo()
} else {
getScript('!{theme.asset.twikoo}').then(runTwikoo)
getScript('!{url_for(theme.asset.twikoo)}').then(runTwikoo)
}
}

View File

@@ -6,6 +6,7 @@ script.
el: '#vcomment',
appId: '#{theme.valine.appId}',
appKey: '#{theme.valine.appKey}',
serverURLs: '#{theme.valine.serverURLs}'
}
const valine = new Valine(initData)

View File

@@ -10,7 +10,7 @@ script.
const waline = Waline.init(initData)
}
if (typeof Waline === 'function') initWaline()
if (typeof Waline === 'object') initWaline()
else getScript('!{url_for(theme.asset.waline_js)}').then(initWaline)
}

View File

@@ -7,4 +7,6 @@ else if theme.daovoice && theme.daovoice.enable
else if theme.gitter && theme.gitter.enable
include ./gitter.pug
else if theme.crisp && theme.crisp.enable
include ./crisp.pug
include ./crisp.pug
else if theme.messenger && theme.messenger.enable
include ./messenger.pug

View File

@@ -0,0 +1,42 @@
- let { pageID, lang } = theme.messenger
- lang = theme.comments.use && theme.comments.use.includes('Facebook Comments') ? theme.facebook_comments.lang : lang
#fb-customer-chat.fb-customerchat(page_id=pageID attribution='biz_inbox')
script.
document.getElementById('fb-root') ? '' : document.body.insertAdjacentHTML('afterend', '<div id="fb-root"></div>')
window.fbAsyncInit = function() {
FB.init({
xfbml: true,
version: 'v15.0'
});
};
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = 'https://connect.facebook.net/!{lang}/sdk/xfbml.customerchat.js';
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
if (!{theme.chat_btn}) {
var chatBtnFn = () => {
var chatBtn = document.getElementById("chat_btn")
chatBtn.addEventListener("click", function(){
FB.CustomerChat.show();
});
}
chatBtnFn()
} else {
if (!{theme.chat_hide_show}) {
function chatBtnHide () {
FB.CustomerChat.hide()
}
function chatBtnShow () {
FB.CustomerChat.show(false)
}
}
}

View File

@@ -0,0 +1,38 @@
- const { server, site, option } = theme.artalk
script.
function loadArtalk () {
function initArtalk () {
window.artalkItem = new Artalk(Object.assign({
el: '#artalk-wrap',
server: '!{server}',
site: '!{site}',
pageKey: location.pathname,
darkMode: document.documentElement.getAttribute('data-theme') === 'dark',
countEl: '.artalk-count'
},!{JSON.stringify(option)}))
}
if (typeof window.artalkItem === 'object') setTimeout(()=>{initArtalk()},200)
else {
getCSS('!{theme.asset.artalk_css}')
typeof Artalk !== 'function' ? getScript('!{theme.asset.artalk_js}').then(initArtalk)
: setTimeout(()=>{initArtalk()},200)
}
}
document.getElementById('darkmode').addEventListener('click',()=> {
if (typeof window.artalkItem !== 'object') return
let isDark = document.documentElement.getAttribute('data-theme') === 'dark'
window.artalkItem.setDarkMode(!isDark)
})
if ('!{theme.comments.use[0]}' === 'Artalk' || !!{theme.comments.lazyload}) {
if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('artalk-wrap'), loadArtalk)
else loadArtalk()
} else {
function loadOtherComment () {
loadArtalk()
}
}

View File

@@ -4,7 +4,7 @@ script.
function loadDisqus () {
var disqus_config = function () {
this.page.url = '!{ page.permalink }'
this.page.identifier = '!{ page.path }'
this.page.identifier = '!{ url_for(page.path) }'
this.page.title = '!{ disqusPageTitle }'
};
@@ -24,6 +24,10 @@ script.
(d.head || d.body).appendChild(s);
})();
}
document.getElementById('darkmode').addEventListener('click', () => {
setTimeout(() => window.disqusReset(), 200)
})
}
if ('!{theme.comments.use[0]}' === 'Disqus' || !!{theme.comments.lazyload}) {

View File

@@ -2,37 +2,39 @@
script.
function loadDisqusjs () {
function addDisqusjsCSS () {
const ele = document.createElement('link')
ele.rel = 'stylesheet'
ele.href= '!{url_for(theme.asset.disqusjs_css)}'
document.getElementsByTagName('head')[0].appendChild(ele)
}
function initDisqusjs () {
window.DISQUS = null
new DisqusJS(Object.assign({
window.disqusjs = null
disqusjs = new DisqusJS(Object.assign({
shortname: '!{theme.disqusjs.shortname}',
identifier: '!{ page.path }',
identifier: '!{ url_for(page.path) }',
url: '!{ page.permalink }',
title: '!{ disqusjsPageTitle }',
apikey: '!{theme.disqusjs.apikey}',
},!{JSON.stringify(theme.disqusjs.option)}))
disqusjs.render(document.getElementById('disqusjs'))
}
const themeChange = () => {
const ele = document.getElementById('disqus_thread')
if(!ele) return
disqusjs.destroy()
initDisqusjs()
}
window.disqusReset = initDisqusjs
document.getElementById('darkmode').addEventListener('click', themeChange)
if (window.disqusJsLoad) initDisqusjs()
else {
addDisqusjsCSS()
getCSS('!{url_for(theme.asset.disqusjs_css)}')
getScript('!{url_for(theme.asset.disqusjs)}').then(initDisqusjs)
window.disqusJsLoad = true
}
}
if ('!{theme.comments.use[0]}' === 'Disqusjs' || !!{theme.comments.lazyload}) {
if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('disqus_thread'), loadDisqusjs)
if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('disqusjs'), loadDisqusjs)
else loadDisqusjs()
}
else {

View File

@@ -1,16 +1,26 @@
#fb-root
- const fbSDKVer = 'v15.0'
- const fbSDK = theme.messenger.enable ? `https://connect.facebook.net/${theme.facebook_comments.lang}/sdk/xfbml.customerchat.js#xfbml=1&version=${fbSDKVer}` : `https://connect.facebook.net/${theme.facebook_comments.lang}/sdk.js#xfbml=1&version=${fbSDKVer}`
script.
function loadFBComment () {
var themeNow = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'light'
document.getElementsByClassName('fb-comments')[0].setAttribute('data-colorscheme',themeNow)
document.getElementById('fb-root') ? '' : document.body.insertAdjacentHTML('afterend', '<div id="fb-root"></div>')
if (typeof FB === 'object') FB.XFBML.parse()
const themeNow = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'light'
const $fbComment = document.getElementsByClassName('fb-comments')[0]
$fbComment.setAttribute('data-colorscheme',themeNow)
$fbComment.setAttribute('data-href', '!{urlNoIndex(page.permalink)}')
if (typeof FB === 'object') {
FB.XFBML.parse(document.getElementsByClassName('post-meta-commentcount')[0])
FB.XFBML.parse(document.getElementById('post-comment'))
}
else {
let ele = document.createElement('script')
ele.setAttribute('src','https://connect.facebook.net/!{theme.facebook_comments.lang}/sdk.js#xfbml=1&version=v13.0&appId=!{theme.facebook_comments.app_id}&autoLogAppEvents=1')
ele.setAttribute('src','!{fbSDK}')
ele.setAttribute('async', 'true')
ele.setAttribute('defer', 'true')
ele.setAttribute('crossorigin', 'anonymous')
ele.setAttribute('id', 'facebook-jssdk')
document.getElementById('fb-root').insertAdjacentElement('afterbegin',ele)
}
}

View File

@@ -1,11 +1,4 @@
script.
function addGitalkSource () {
const ele = document.createElement('link')
ele.rel = 'stylesheet'
ele.href= '!{url_for(theme.asset.gitalk_css)}'
document.getElementsByTagName('head')[0].appendChild(ele)
}
function loadGitalk () {
function initGitalk () {
var gitalk = new Gitalk(Object.assign({
@@ -23,7 +16,7 @@ script.
if (typeof Gitalk === 'function') initGitalk()
else {
addGitalkSource()
getCSS('!{url_for(theme.asset.gitalk_css)}')
getScript('!{url_for(theme.asset.gitalk)}').then(initGitalk)
}
}

View File

@@ -22,7 +22,7 @@ hr
when 'Valine'
#vcomment.vcomment
when 'Disqusjs'
#disqus_thread
#disqusjs
when 'Livere'
#lv-container(data-id="city" data-uid=theme.livere.uid)
when 'Gitalk'
@@ -40,3 +40,7 @@ hr
data-numposts= theme.facebook_comments.pageSize || 10
data-order-by= theme.facebook_comments.order_by || 'social'
data-width="100%")
when 'Remark42'
#remark42
when 'Artalk'
#artalk-wrap

View File

@@ -19,4 +19,8 @@ each name in theme.comments.use
when 'Giscus'
!=partial('includes/third-party/comments/giscus', {}, {cache: true})
when 'Facebook Comments'
!=partial('includes/third-party/comments/facebook_comments', {}, {cache: true})
include ./facebook_comments.pug
when 'Remark42'
!=partial('includes/third-party/comments/remark42', {}, {cache: true})
when 'Artalk'
!=partial('includes/third-party/comments/artalk', {}, {cache: true})

View File

@@ -0,0 +1,67 @@
- const { host, siteId, option } = theme.remark42
script.
var remark_config = Object.assign({
host: '!{host}',
site_id: '!{siteId}',
components: ['embed'],
theme: document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'light'
},!{JSON.stringify(option)})
function addRemark42(){
for (let i = 0; i < remark_config.components.length; i++) {
const s = document.createElement('script')
s.src = remark_config.host + '/web/' + remark_config.components[i] + '.js'
s.defer = true
document.head.appendChild(s)
}
}
function initRemark42() {
if (window.REMARK42) {
if (this.remark42Instance) {
this.remark42Instance.destroy()
}
this.remark42Instance = window.REMARK42.createInstance({
...remark_config
})
}
}
function getCount () {
const ele = document.querySelector('.remark42__counter')
if (ele) {
const s = document.createElement('script')
s.src = remark_config.host + '/web/counter.js'
s.defer = true
document.head.appendChild(s)
}
}
function loadRemark42 () {
if (window.REMARK42) {
this.initRemark42()
getCount()
} else {
addRemark42()
window.addEventListener('REMARK42::ready', () => {
this.initRemark42()
getCount()
})
}
}
document.getElementById('darkmode').addEventListener('click',()=>{
if (!window.REMARK42) return
let theme = document.documentElement.getAttribute('data-theme') === 'dark' ? 'light' : 'dark'
window.REMARK42.changeTheme(theme)
})
if ('!{theme.comments.use[0]}' === 'Remark42' || !!{theme.comments.lazyload}) {
if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('remark42'), loadRemark42)
else loadRemark42()
} else {
function loadOtherComment () {
loadRemark42()
}
}

View File

@@ -15,13 +15,15 @@ script.
}
const getCount = () => {
const countELement = document.getElementById('twikoo-count')
if(!countELement) return
twikoo.getCommentsCount({
envId: '!{envId}',
region: '!{region}',
urls: [window.location.pathname],
includeReply: false
}).then(function (res) {
document.getElementById('twikoo-count').innerText = res[0].count
countELement.innerText = res[0].count
}).catch(function (err) {
console.error(err);
});
@@ -37,7 +39,7 @@ script.
setTimeout(runFn,0)
return
}
getScript('!{theme.asset.twikoo}').then(runFn)
getScript('!{url_for(theme.asset.twikoo)}').then(runFn)
}
if ('!{use[0]}' === 'Twikoo' || !!{lazyload}) {

View File

@@ -3,13 +3,6 @@
script.
function loadWaline () {
function insertCSS () {
const link = document.createElement("link")
link.rel = "stylesheet"
link.href = "!{url_for(theme.asset.waline_css)}"
document.head.appendChild(link)
}
function initWaline () {
const waline = Waline.init(Object.assign({
el: '#waline-wrap',
@@ -21,10 +14,11 @@ script.
}, !{JSON.stringify(option)}))
}
if (typeof Waline === 'function') initWaline()
if (typeof Waline === 'object') initWaline()
else {
insertCSS()
getScript('!{url_for(theme.asset.waline_js)}').then(initWaline)
getCSS('!{url_for(theme.asset.waline_css)}').then(() => {
getScript('!{url_for(theme.asset.waline_js)}').then(initWaline)
})
}
}

View File

@@ -1,6 +1,5 @@
link(rel="stylesheet" type="text/css" href=theme.asset.katex)
link(rel="stylesheet" type="text/css" href=url_for(theme.asset.katex))
script(src=url_for(theme.asset.katex_copytex))
link(rel="stylesheet" type="text/css" href=theme.asset.katex_copytex_css)
script.
(() => {
document.querySelectorAll('#article-container span.katex-display').forEach(item => {

View File

@@ -7,7 +7,7 @@ script.
tags: 'ams'
},
chtml: {
scale: 1.2
scale: 1.1
},
options: {
renderActions: {
@@ -23,12 +23,11 @@ script.
}
}, ''],
insertScript: [200, () => {
document.querySelectorAll('mjx-container:not\([display]\)').forEach(node => {
const target = node.parentNode
if (target.nodeName.toLowerCase() === 'li') {
target.parentNode.classList.add('has-jax')
document.querySelectorAll('mjx-container').forEach(node => {
if (node.hasAttribute('display')) {
btf.wrap(node, 'div', { class: 'mathjax-overflow' })
} else {
target.classList.add('has-jax')
btf.wrap(node, 'span', { class: 'mathjax-overflow' })
}
});
}, '', false]
@@ -37,7 +36,7 @@ script.
}
const script = document.createElement('script')
script.src = '!{theme.asset.mathjax}'
script.src = '!{url_for(theme.asset.mathjax)}'
script.id = 'MathJax-script'
script.async = true
document.head.appendChild(script)

View File

@@ -18,7 +18,7 @@ script.
}
const loadMermaid = () => {
window.loadMermaid ? runMermaid() : getScript('!{theme.asset.mermaid}').then(runMermaid)
window.loadMermaid ? runMermaid() : getScript('!{url_for(theme.asset.mermaid)}').then(runMermaid)
}
window.pjax ? loadMermaid() : document.addEventListener('DOMContentLoaded', loadMermaid)

View File

@@ -0,0 +1,82 @@
- const { server, option } = theme.artalk
- const avatarCdn = option !== null && option.gravatar ? option.gravatar.mirror : 'https://sdn.geekzu.org/avatar/'
- const avatarDefault = option !== null && option.gravatar ? option.gravatar.default : 'mp'
script.
window.addEventListener('load', () => {
const changeContent = (content) => {
if (content === '') return content
content = content.replace(/<img.*?src="(.*?)"?[^\>]+>/ig, '[!{_p("aside.card_newest_comments.image")}]') // replace image link
content = content.replace(/<a[^>]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi, '[!{_p("aside.card_newest_comments.link")}]') // replace url
content = content.replace(/<pre><code>.*?<\/pre>/gi, '[!{_p("aside.card_newest_comments.code")}]') // replace code
content = content.replace(/<[^>]+>/g,"") // remove html tag
if (content.length > 150) {
content = content.substring(0,150) + '...'
}
return content
}
const generateHtml = array => {
let result = ''
if (array.length) {
for (let i = 0; i < array.length; i++) {
result += '<div class=\'aside-list-item\'>'
if (!{theme.newest_comments.avatar}) {
const name = '!{theme.lazyload.enable ? "data-lazy-src" : "src"}'
result += `<a href='${array[i].url}' class='thumbnail'><img ${name}='${array[i].avatar}' alt='${array[i].nick}'></a>`
}
result += `<div class='content'>
<a class='comment' href='${array[i].url}' title='${array[i].content}'>${array[i].content}</a>
<div class='name'><span>${array[i].nick} / </span><time datetime="${array[i].date}">${btf.diffDate(array[i].date, true)}</time></div>
</div></div>`
}
} else {
result += '!{_p("aside.card_newest_comments.zero")}'
}
let $dom = document.querySelector('#card-newest-comments .aside-list')
$dom.innerHTML= result
window.lazyLoadInstance && window.lazyLoadInstance.update()
window.pjax && window.pjax.refresh($dom)
}
const getComment = () => {
fetch('!{server}/api/stat?type=latest_comments&limit=!{theme.newest_comments.limit}',{method: "POST"})
.then(response => response.json())
.then(d => {
const artalk = d.data.map(function (e) {
return {
'avatar': '!{avatarCdn}' + e.email_encrypted + '?d=!{avatarDefault}',
'content': changeContent(e.content_marked),
'nick': e.nick,
'url': e.page_url,
'date': e.date,
}
})
saveToLocal.set('artalk-newest-comments', JSON.stringify(artalk), !{theme.newest_comments.storage}/(60*24))
generateHtml(artalk)
}).catch(e => {
const $dom = document.querySelector('#card-newest-comments .aside-list')
$dom.innerHTML= "!{_p('aside.card_newest_comments.error')}"
})
}
const newestCommentInit = () => {
if (document.querySelector('#card-newest-comments .aside-list')) {
const data = saveToLocal.get('artalk-newest-comments')
if (data) {
generateHtml(JSON.parse(data))
} else {
getComment()
}
}
}
newestCommentInit()
document.addEventListener('pjax:complete', newestCommentInit)
})

View File

@@ -23,4 +23,8 @@ if use
include ./github-issues.pug
when 'Utterances'
- userRepo = theme.utterances.repo
include ./github-issues.pug
include ./github-issues.pug
when 'Remark42'
include ./remark42.pug
when 'Artalk'
include ./artalk.pug

View File

@@ -0,0 +1,80 @@
- const { host, siteId } = theme.remark42
script.
window.addEventListener('load', () => {
const changeContent = (content) => {
if (content === '') return content
content = content.replace(/<img.*?src="(.*?)"?[^\>]+>/ig, '[!{_p("aside.card_newest_comments.image")}]') // replace image link
content = content.replace(/<a[^>]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi, '[!{_p("aside.card_newest_comments.link")}]') // replace url
content = content.replace(/<pre><code>.*?<\/pre>/gi, '[!{_p("aside.card_newest_comments.code")}]') // replace code
content = content.replace(/<[^>]+>/g,"") // remove html tag
if (content.length > 150) {
content = content.substring(0,150) + '...'
}
return content
}
const generateHtml = array => {
let result = ''
if (array.length) {
for (let i = 0; i < array.length; i++) {
result += '<div class=\'aside-list-item\'>'
if (!{theme.newest_comments.avatar}) {
const name = '!{theme.lazyload.enable ? "data-lazy-src" : "src"}'
result += `<a href='${array[i].url}' class='thumbnail'><img ${name}='${array[i].avatar}' alt='${array[i].nick}'></a>`
}
result += `<div class='content'>
<a class='comment' href='${array[i].url}' title='${array[i].content}'>${array[i].content}</a>
<div class='name'><span>${array[i].nick} / </span><time datetime="${array[i].date}">${btf.diffDate(array[i].date, true)}</time></div>
</div></div>`
}
} else {
result += '!{_p("aside.card_newest_comments.zero")}'
}
let $dom = document.querySelector('#card-newest-comments .aside-list')
$dom.innerHTML= result
window.lazyLoadInstance && window.lazyLoadInstance.update()
window.pjax && window.pjax.refresh($dom)
}
const getComment = () => {
fetch('!{host}/api/v1/last/!{theme.newest_comments.limit}?site=!{siteId}')
.then(response => response.json())
.then(data => {
const remark42 = data.map(function (e) {
return {
'avatar': e.user.picture,
'content': changeContent(e.text),
'nick': e.user.name,
'url': e.locator.url,
'date': e.time,
}
})
saveToLocal.set('remark42-newest-comments', JSON.stringify(remark42), !{theme.newest_comments.storage}/(60*24))
generateHtml(remark42)
}).catch(e => {
const $dom = document.querySelector('#card-newest-comments .aside-list')
$dom.innerHTML= "!{_p('aside.card_newest_comments.error')}"
})
}
const newestCommentInit = () => {
if (document.querySelector('#card-newest-comments .aside-list')) {
const data = saveToLocal.get('remark42-newest-comments')
if (data) {
generateHtml(JSON.parse(data))
} else {
getComment()
}
}
}
newestCommentInit()
document.addEventListener('pjax:complete', newestCommentInit)
})

View File

@@ -43,7 +43,7 @@ script.
if (typeof twikoo === 'object') {
runTwikoo()
} else {
getScript('!{theme.asset.twikoo}').then(runTwikoo)
getScript('!{url_for(theme.asset.twikoo)}').then(runTwikoo)
}
}

View File

@@ -64,7 +64,7 @@ script.
})
}
if (typeof Waline === 'function') loadWaline()
if (typeof Waline === 'object') loadWaline()
else getScript('!{url_for(theme.asset.waline_js)}').then(loadWaline)
}

View File

@@ -3,11 +3,11 @@ if theme.pjax.exclude
each val in theme.pjax.exclude
- pjaxExclude = pjaxExclude + `:not([href="${val}"])`
- let pjaxSelectors = ['title','#config-diff','#body-wrap','#rightside-config-hide','#rightside-config-show','.js-pjax']
- let pjaxSelectors = ['head > title','#config-diff','#body-wrap','#rightside-config-hide','#rightside-config-show','.js-pjax']
- let choose = theme.comments.use
if choose
if theme.Open_Graph_meta && (choose.includes('Livere') || choose.includes('Utterances') || choose.includes('Giscus'))
if theme.Open_Graph_meta.enable && (choose.includes('Livere') || choose.includes('Utterances') || choose.includes('Giscus'))
- pjaxSelectors.unshift('meta[property="og:image"]', 'meta[property="og:title"]', 'meta[property="og:url"]')
if choose.includes('Utterances') || choose.includes('Giscus')
- pjaxSelectors.unshift('link[rel="canonical"]')
@@ -30,7 +30,6 @@ script.
window.tocScrollFn && window.removeEventListener('scroll', window.tocScrollFn)
window.scrollCollect && window.removeEventListener('scroll', scrollCollect)
typeof preloader === 'object' && preloader.initLoading()
document.getElementById('rightside').style.cssText = "opacity: ''; transform: ''"
if (window.aplayers) {
@@ -47,6 +46,7 @@ script.
const $bodyClassList = document.body.classList
$bodyClassList.contains('read-mode') && $bodyClassList.remove('read-mode')
typeof disqusjs === 'object' && disqusjs.destroy()
})
document.addEventListener('pjax:complete', function () {
@@ -75,8 +75,6 @@ script.
// prismjs
typeof Prism === 'object' && Prism.highlightAll()
typeof preloader === 'object' && preloader.endLoading()
})
document.addEventListener('pjax:error', (e) => {

View File

@@ -1,3 +1,4 @@
.social-share(data-image=url_for(page.cover|| theme.avatar.img) data-sites= theme.sharejs.sites)
- const coverVal = page.cover_type === 'img' ? page.cover : theme.avatar.img
.social-share(data-image=url_for(coverVal) data-sites= theme.sharejs.sites)
link(rel='stylesheet' href=url_for(theme.asset.sharejs_css) media="print" onload="this.media='all'")
script(src=url_for(theme.asset.sharejs) defer)

View File

@@ -1,6 +1,30 @@
- const { effect,loop,source,sub } = theme.subtitle
- const { effect,source,sub,typed_option } = theme.subtitle
- let subContent = sub || new Array()
script.
window.typedJSFn = {
init: (str) => {
window.typed = new Typed('#subtitle', Object.assign({
strings: str,
startDelay: 300,
typeSpeed: 150,
loop: true,
backSpeed: 50,
}, !{JSON.stringify(typed_option)}))
},
run: (subtitleType) => {
if (!{effect}) {
if (typeof Typed === 'function') {
subtitleType()
} else {
getScript('!{url_for(theme.asset.typed)}').then(subtitleType)
}
} else {
subtitleType()
}
}
}
case source
when 1
script.
@@ -12,28 +36,13 @@ case source
const from = '出自 ' + data.from
const sub = !{JSON.stringify(subContent)}
sub.unshift(data.hitokoto, from)
window.typed = new Typed('#subtitle', {
strings: sub,
startDelay: 300,
typeSpeed: 150,
loop: !{loop},
backSpeed: 50,
})
typedJSFn.init(sub)
} else {
document.getElementById('subtitle').innerHTML = data.hitokoto
}
})
}
if (!{effect}) {
if (typeof Typed === 'function') {
subtitleType()
} else {
getScript('!{url_for(theme.asset.typed)}').then(subtitleType)
}
} else {
subtitleType()
}
typedJSFn.run(subtitleType)
when 2
script.
@@ -44,28 +53,13 @@ case source
const from = '出自 ' + str[1]
const sub = !{JSON.stringify(subContent)}
sub.unshift(con, from)
window.typed = new Typed('#subtitle', {
strings: sub,
startDelay: 300,
typeSpeed: 150,
loop: !{loop},
backSpeed: 50,
})
typedJSFn.init(sub)
} else {
document.getElementById('subtitle').innerHTML = con
}
})
}
if (!{effect}) {
if (typeof Typed === 'function') {
subtitleType()
} else {
getScript('!{url_for(theme.asset.typed)}').then(subtitleType)
}
} else {
subtitleType()
}
typedJSFn.run(subtitleType)
when 3
script.
@@ -76,53 +70,23 @@ case source
const sub = !{JSON.stringify(subContent)}
const content = result.data.content
sub.unshift(content)
window.typed = new Typed('#subtitle', {
strings: sub,
startDelay: 300,
typeSpeed: 150,
loop: !{loop},
backSpeed: 50,
})
typedJSFn.init(sub)
} else {
document.getElementById('subtitle').innerHTML = result.data.content
}
})
})
}
if (!{effect}) {
if (typeof Typed === 'function') {
subtitleType()
} else {
getScript('!{url_for(theme.asset.typed)}').then(subtitleType)
}
} else {
subtitleType()
}
typedJSFn.run(subtitleType)
default
- subContent = subContent.length ? subContent : new Array(config.subtitle)
script.
function subtitleType () {
if (!{effect}) {
window.typed = new Typed("#subtitle", {
strings: !{JSON.stringify(subContent)},
startDelay: 300,
typeSpeed: 150,
loop: !{loop},
backSpeed: 50
})
if (!{effect}) {
typedJSFn.init(!{JSON.stringify(subContent)})
} else {
document.getElementById("subtitle").innerHTML = '!{subContent[0]}'
}
}
if (!{effect}) {
if (typeof Typed === 'function') {
subtitleType()
} else {
getScript('!{url_for(theme.asset.typed)}').then(subtitleType)
}
} else {
subtitleType()
}
typedJSFn.run(subtitleType)

View File

@@ -14,7 +14,10 @@ if theme.aside.card_recent_post.enable
.aside-list-item(class=no_cover)
if post_cover && theme.cover.aside_enable
a.thumbnail(href=url_for(link) title=title)
img(src=url_for(post_cover) onerror=`this.onerror=null;this.src='${url_for(theme.error_img.post_page)}'` alt=title)
if article.cover_type === 'img'
img(src=url_for(post_cover) onerror=`this.onerror=null;this.src='${url_for(theme.error_img.post_page)}'` alt=title)
else
div(style=`background: ${post_cover}`)
.content
a.title(href=url_for(link) title=title)= title
if theme.aside.card_recent_post.sort === 'updated'

View File

@@ -12,20 +12,24 @@ if theme.aside.card_webinfo.enable
.webinfo-item
.item-name= _p('aside.card_webinfo.runtime.name') + " :"
.item-count#runtimeshow(data-publishDate=date_xml(theme.runtimeshow.publish_date))
i.fa-solid.fa-spinner.fa-spin
if theme.wordcount.enable && theme.wordcount.total_wordcount
.webinfo-item
.item-name=_p('aside.card_webinfo.site_wordcount') + " :"
.item-count=totalcount(site)
if theme.busuanzi.site_uv
if theme.busuanzi.site_uv
.webinfo-item
.item-name= _p('aside.card_webinfo.site_uv_name') + " :"
.item-count#busuanzi_value_site_uv
i.fa-solid.fa-spinner.fa-spin
if theme.busuanzi.site_pv
.webinfo-item
.item-name= _p('aside.card_webinfo.site_pv_name') + " :"
.item-count#busuanzi_value_site_pv
i.fa-solid.fa-spinner.fa-spin
if theme.aside.card_webinfo.last_push_date
.webinfo-item
.item-name= _p('aside.card_webinfo.last_push_date.name') + " :"
.item-count#last-push-date(data-lastPushDate=date_xml(Date.now()))
i.fa-solid.fa-spinner.fa-spin

View File

@@ -1,6 +1,6 @@
{
"name": "hexo-theme-butterfly",
"version": "4.2.0",
"version": "4.6.1",
"description": "A Simple and Card UI Design theme for Hexo",
"main": "package.json",
"scripts": {
@@ -23,7 +23,7 @@
"email": "my@crazywong.com"
},
"dependencies": {
"hexo-renderer-stylus": "^2.0.1",
"hexo-renderer-stylus": "^2.1.0",
"hexo-renderer-pug": "^3.0.0"
},
"homepage": "https://butterfly.js.org/",

200
plugins.yml Normal file
View File

@@ -0,0 +1,200 @@
algolia_search_v4:
name: algoliasearch
file: dist/algoliasearch-lite.umd.js
version: 4.14.3
instantsearch_v4:
name: instantsearch.js
file: dist/instantsearch.production.min.js
version: 4.49.4
pjax:
name: pjax
file: pjax.min.js
version: 0.2.8
gitalk:
name: gitalk
file: dist/gitalk.min.js
version: 1.8.0
gitalk_css:
name: gitalk
file: dist/gitalk.css
version: 1.8.0
blueimp_md5:
name: blueimp-md5
file: js/md5.min.js
version: 2.19.0
valine:
name: valine
file: dist/Valine.min.js
version: 1.5.1
disqusjs:
name: disqusjs
file: dist/browser/disqusjs.es2015.umd.min.js
version: 3.0.2
disqusjs_css:
name: disqusjs
file: dist/browser/styles/disqusjs.css
version: 3.0.2
twikoo:
name: twikoo
file: dist/twikoo.all.min.js
version: 1.6.8
waline_js:
name: '@waline/client'
file: dist/waline.js
other_name: waline
version: 2.14.7
waline_css:
name: '@waline/client'
file: dist/waline.css
other_name: waline
version: 2.14.7
sharejs:
name: butterfly-extsrc
file: sharejs/dist/js/social-share.min.js
version: 1.1.3
sharejs_css:
name: butterfly-extsrc
file: sharejs/dist/css/share.min.css
version: 1.1.3
mathjax:
name: mathjax
file: es5/tex-mml-chtml.js
version: 3.2.2
katex:
name: katex
file: dist/katex.min.css
other_name: KaTeX
version: 0.16.4
katex_copytex:
name: katex
file: dist/contrib/copy-tex.min.js
other_name: KaTeX
version: 0.16.4
mermaid:
name: mermaid
file: dist/mermaid.min.js
version: 9.3.0
canvas_ribbon:
name: butterfly-extsrc
file: dist/canvas-ribbon.min.js
version: 1.1.3
canvas_fluttering_ribbon:
name: butterfly-extsrc
file: dist/canvas-fluttering-ribbon.min.js
version: 1.1.3
canvas_nest:
name: butterfly-extsrc
file: dist/canvas-nest.min.js
version: 1.1.3
activate_power_mode:
name: butterfly-extsrc
file: dist/activate-power-mode.min.js
version: 1.1.3
fireworks:
name: butterfly-extsrc
file: dist/fireworks.min.js
version: 1.1.3
click_heart:
name: butterfly-extsrc
file: dist/click-heart.min.js
version: 1.1.3
ClickShowText:
name: butterfly-extsrc
file: dist/click-show-text.min.js
version: 1.1.3
lazyload:
name: vanilla-lazyload
file: dist/lazyload.iife.min.js
version: 17.8.3
instantpage:
name: instant.page
file: instantpage.js
version: 5.1.1
typed:
name: typed.js
file: lib/typed.min.js
version: 2.0.12
pangu:
name: pangu
file: dist/browser/pangu.min.js
version: 4.0.7
fancybox_css_v4:
name: '@fancyapps/ui'
file: dist/fancybox.css
version: 4.0.31
other_name: fancyapps-ui
fancybox_v4:
name: '@fancyapps/ui'
file: dist/fancybox.umd.js
version: 4.0.31
other_name: fancyapps-ui
medium_zoom:
name: medium-zoom
file: dist/medium-zoom.min.js
version: 1.0.8
snackbar_css:
name: node-snackbar
file: dist/snackbar.min.css
version: 0.1.16
snackbar:
name: node-snackbar
file: dist/snackbar.min.js
version: 0.1.16
fontawesomeV6:
name: '@fortawesome/fontawesome-free'
file: css/all.min.css
other_name: font-awesome
version: 6.2.1
flickr_justified_gallery_js:
name: flickr-justified-gallery
file: dist/fjGallery.min.js
version: 2.1.2
flickr_justified_gallery_css:
name: flickr-justified-gallery
file: dist/fjGallery.css
version: 2.1.2
aplayer_css:
name: aplayer
file: dist/APlayer.min.css
version: 1.10.1
aplayer_js:
name: aplayer
file: dist/APlayer.min.js
version: 1.10.1
meting_js:
name: butterfly-extsrc
file: metingjs/dist/Meting.min.js
version: 1.1.3
prismjs_js:
name: prismjs
file: prism.js
other_name: prism
version: 1.29.0
prismjs_lineNumber_js:
name: prismjs
file: plugins/line-numbers/prism-line-numbers.min.js
other_name: prism
version: 1.29.0
prismjs_autoloader:
name: prismjs
file: plugins/autoloader/prism-autoloader.min.js
other_name: prism
version: 1.29.0
artalk_js:
name: artalk
file: dist/Artalk.js
version: 2.4.4
artalk_css:
name: artalk
file: dist/Artalk.css
version: 2.4.4
pace_js:
name: pace-js
other_name: pace
file: pace.min.js
version: 1.2.4
pace_default_css:
name: pace-js
other_name: pace
file: themes/blue/pace-theme-minimal.css
version: 1.2.4

95
scripts/events/cdn.js Normal file
View File

@@ -0,0 +1,95 @@
/**
* Butterfly
* Merge CDN
*/
'use strict'
const { version } = require('../../package.json')
const path = require('path')
hexo.extend.filter.register('before_generate', () => {
const themeConfig = hexo.theme.config
const { CDN } = themeConfig
const thirdPartySrc = hexo.render.renderSync({ path: path.join(hexo.theme_dir, '/plugins.yml'), engine: 'yaml' })
const internalSrc = {
main: {
name: 'hexo-theme-butterfly',
file: 'js/main.js',
version
},
utils: {
name: 'hexo-theme-butterfly',
file: 'js/utils.js',
version
},
translate: {
name: 'hexo-theme-butterfly',
file: 'js/tw_cn.js',
version
},
local_search: {
name: 'hexo-theme-butterfly',
file: 'js/search/local-search.js',
version
},
algolia_js: {
name: 'hexo-theme-butterfly',
file: 'js/search/algolia.js',
version
}
}
const minFile = (file) => {
return file.replace(/(?<!\.min)\.(js|css)$/g, ext => '.min' + ext)
}
const createCDNLink = (data, type, cond = '') => {
Object.keys(data).forEach(key => {
let { name, version, file, other_name } = data[key]
const min_file = minFile(file)
const cdnjs_name = other_name || name
const cdnjs_file = file.replace(/^[lib|dist]*\/|browser\//g, '')
const min_cdnjs_file = minFile(cdnjs_file)
if (cond === 'internal') file = `source/${file}`
const verType = CDN.version ? `@${version}` : ''
const value = {
version,
name,
file,
cdnjs_file,
min_file,
min_cdnjs_file,
cdnjs_name
}
const cdnSource = {
local: cond === 'internal' ? cdnjs_file : `/pluginsSrc/${name}/${file}`,
jsdelivr: `https://cdn.jsdelivr.net/npm/${name}${verType}/${min_file}`,
unpkg: `https://unpkg.com/${name}${verType}/${file}`,
cdnjs: `https://cdnjs.cloudflare.com/ajax/libs/${cdnjs_name}/${version}/${min_cdnjs_file}`,
custom: (CDN.custom_format || '').replace(/\$\{(.+?)\}/g, (match, $1) => value[$1])
}
data[key] = cdnSource[type]
})
if (cond === 'internal') data.main_css = 'css/index.css'
return data
}
// delete null value
const deleteNullValue = obj => {
if (!obj) return
for (const i in obj) {
obj[i] === null && delete obj[i]
}
return obj
}
themeConfig.asset = Object.assign(createCDNLink(internalSrc, CDN.internal_provider, 'internal'),
createCDNLink(thirdPartySrc, CDN.third_party_provider), deleteNullValue(CDN.option))
})

14
scripts/events/comment.js Normal file
View File

@@ -0,0 +1,14 @@
/**
* Capitalize the first letter of comment name
*/
hexo.extend.filter.register('before_generate', () => {
const themeConfig = hexo.theme.config
let { use } = themeConfig.comments
if (!use) return
if (typeof use === 'string') {
use = use.split(',')
}
const newArray = use.map(item => item.toLowerCase().replace(/\b[a-z]/g, s => s.toUpperCase()))
themeConfig.comments.use = newArray
})

View File

@@ -1,133 +0,0 @@
/**
* Butterfly
* 1. Merge CDN
* 2. Capitalize the first letter of comment name
*/
'use strict'
const { version } = require('../../package.json')
const path = require('path')
hexo.extend.filter.register('before_generate', () => {
const themeConfig = hexo.theme.config
const { CDN, comments } = themeConfig
/**
* Merge CDN
*/
const internalSrcCDN = {
main_css: '/css/index.css',
main: `https://cdn.jsdelivr.net/npm/hexo-theme-butterfly@${version}/source/js/main.min.js`,
utils: `https://cdn.jsdelivr.net/npm/hexo-theme-butterfly@${version}/source/js/utils.min.js`,
translate: `https://cdn.jsdelivr.net/npm/hexo-theme-butterfly@${version}/source/js/tw_cn.min.js`,
local_search: `https://cdn.jsdelivr.net/npm/hexo-theme-butterfly@${version}/source/js/search/local-search.min.js`,
algolia_js: `https://cdn.jsdelivr.net/npm/hexo-theme-butterfly@${version}/source/js/search/algolia.min.js`,
}
const internalSrcLocal = {
main_css: '/css/index.css',
main: '/js/main.js',
utils: '/js/utils.js',
translate: '/js/tw_cn.js',
local_search: '/js/search/local-search.js',
algolia_js: '/js/search/algolia.js',
}
const thirdPartySrcCDN = {
algolia_search_v4: 'https://cdn.jsdelivr.net/npm/algoliasearch@4/dist/algoliasearch-lite.umd.js',
instantsearch_v4: 'https://cdn.jsdelivr.net/npm/instantsearch.js@4/dist/instantsearch.production.min.js',
pjax: 'https://cdn.jsdelivr.net/npm/pjax/pjax.min.js',
gitalk: 'https://cdn.jsdelivr.net/npm/gitalk@latest/dist/gitalk.min.js',
gitalk_css: 'https://cdn.jsdelivr.net/npm/gitalk/dist/gitalk.min.css',
blueimp_md5: 'https://cdn.jsdelivr.net/npm/blueimp-md5/js/md5.min.js',
valine: 'https://cdn.jsdelivr.net/npm/valine/dist/Valine.min.js',
disqusjs: 'https://cdn.jsdelivr.net/npm/disqusjs@1/dist/disqus.js',
disqusjs_css: 'https://cdn.jsdelivr.net/npm/disqusjs@1/dist/disqusjs.css',
twikoo: 'https://cdn.jsdelivr.net/npm/twikoo@1/dist/twikoo.all.min.js',
waline_js: 'https://cdn.jsdelivr.net/npm/@waline/client/dist/waline.js',
waline_css: 'https://cdn.jsdelivr.net/npm/@waline/client/dist/waline.css',
sharejs: 'https://cdn.jsdelivr.net/gh/overtrue/share.js@master/dist/js/social-share.min.js',
sharejs_css: 'https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css',
mathjax: 'https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js',
katex: 'https://cdn.jsdelivr.net/npm/katex@latest/dist/katex.min.css',
katex_copytex: 'https://cdn.jsdelivr.net/npm/katex@latest/dist/contrib/copy-tex.min.js',
katex_copytex_css: 'https://cdn.jsdelivr.net/npm/katex@latest/dist/contrib/copy-tex.css',
mermaid: 'https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js',
canvas_ribbon: 'https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-ribbon.min.js',
canvas_fluttering_ribbon: 'https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-fluttering-ribbon.min.js',
canvas_nest: 'https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-nest.min.js',
activate_power_mode: 'https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/activate-power-mode.min.js',
fireworks: 'https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/fireworks.min.js',
click_heart: 'https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/click-heart.min.js',
ClickShowText: 'https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/click-show-text.min.js',
lazyload: 'https://cdn.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.iife.min.js',
instantpage: 'https://cdn.jsdelivr.net/npm/instant.page@5/instantpage.min.js',
typed: 'https://cdn.jsdelivr.net/npm/typed.js/lib/typed.min.js',
pangu: 'https://cdn.jsdelivr.net/npm/pangu@4/dist/browser/pangu.min.js',
fancybox_css_v4: 'https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.css',
fancybox_v4: 'https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.js',
medium_zoom: 'https://cdn.jsdelivr.net/npm/medium-zoom/dist/medium-zoom.min.js',
snackbar_css: 'https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.css',
snackbar: 'https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.js',
fontawesomeV6: 'https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6/css/all.min.css',
flickr_justified_gallery_js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery@2/dist/fjGallery.min.js',
flickr_justified_gallery_css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery@2/dist/fjGallery.min.css',
aplayer_css: 'https://cdn.jsdelivr.net/npm/aplayer@1/dist/APlayer.min.css',
aplayer_js: 'https://cdn.jsdelivr.net/npm/aplayer@1/dist/APlayer.min.js',
meting_js: 'https://cdn.jsdelivr.net/gh/metowolf/MetingJS@1.2/dist/Meting.min.js',
prismjs_js: 'https://cdn.jsdelivr.net/npm/prismjs@1/prism.min.js',
prismjs_lineNumber_js: 'https://cdn.jsdelivr.net/npm/prismjs@1/plugins/line-numbers/prism-line-numbers.min.js',
prismjs_autoloader: 'https://cdn.jsdelivr.net/npm/prismjs@1/plugins/autoloader/prism-autoloader.min.js',
}
// delete null value
const deleteNullValue = obj => {
if (!obj) return
for (const i in obj) {
obj[i] === null && delete obj[i]
}
return obj
}
const defaultVal = (obj, choose) => {
if (obj === 'internal') {
if (choose === 'local') return internalSrcLocal
else return internalSrcCDN
}
if (obj === 'external') {
if (choose === 'local') {
let result = {}
try {
const data = path.join(hexo.plugin_dir,'hexo-butterfly-extjs/plugins.yml')
result = hexo.render.renderSync({ path: data, engine: 'yaml'})
Object.keys(result).map(key => {
result[key] = 'pluginsSrc/' + result[key]
})
} catch (e) {}
return result
} else return thirdPartySrcCDN
}
}
themeConfig.asset = Object.assign(defaultVal('internal', CDN.internal_provider),
defaultVal('external', CDN.third_party_provider), deleteNullValue(CDN.option))
/**
* Capitalize the first letter of comment name
*/
let { use } = comments
if (!use) return
if (typeof use === 'string') {
use = use.split(',')
}
const newArray = use.map(item => item.toLowerCase().replace(/\b[a-z]/g, s => s.toUpperCase()))
themeConfig.comments.use = newArray
})

View File

@@ -1,19 +1,20 @@
const logger = require('hexo-log')()
hexo.extend.filter.register('before_generate', () => {
// Get first two digits of the Hexo version number
const hexoVer = hexo.version.replace(/(^.*\..*)\..*/, '$1')
const logger = hexo.log
if (hexoVer < 5) {
logger.error('Please update Hexo to V5.0.0 or higher!')
logger.error('請把 Hexo 升級到 V5.0.0 或更高的版本!')
if (hexoVer < 5.3) {
logger.error('Please update Hexo to V5.3.0 or higher!')
logger.error('請把 Hexo 升級到 V5.3.0 或更高的版本!')
process.exit(-1)
}
if (hexo.locals.get) {
const data = hexo.locals.get('data')
if (data && data.butterfly) {
logger.error(" 'butterfly.yml' is deprecated. Please use '_config.butterfly.yml' ")
logger.error(
" 'butterfly.yml' is deprecated. Please use '_config.butterfly.yml' "
)
logger.error(" 'butterfly.yml' 已經棄用,請使用 '_config.butterfly.yml' ")
process.exit(-1)
}

View File

@@ -1,17 +1,13 @@
const logger = require('hexo-log')()
hexo.on('ready', () => {
const { version } = require('../../package.json')
logger.info(`
hexo.log.info(`
===================================================================
##### # # ##### ##### ###### ##### ###### # # #
# # # # # # # # # # # # #
##### # # # # ##### # # ##### # #
# # # # # # # ##### # # #
# # # # # # # # # # # #
##### #### # # ###### # # # ###### #
##### # # ##### ##### ###### ##### ###### # # #
# # # # # # # # # # # # #
##### # # # # ##### # # ##### # #
# # # # # # # ##### # # #
# # # # # # # # # # # #
##### #### # # ###### # # # ###### #
${version}
===================================================================`)
})

View File

@@ -6,40 +6,40 @@
'use strict'
hexo.extend.filter.register('before_post_render', function (data) {
const { config } = this
if (config.post_asset_folder) {
const imgTestReg = /\.(png|jpe?g|gif|svg|webp)(\?.*)?$/
const imgTestReg = /\.(png|jpe?g|gif|svg|webp)(\?.*)?$/
let randomCover
let coverVal = data.cover
// Add path to top_img and cover if post_asset_folder is enabled
if (hexo.config.post_asset_folder) {
const topImg = data.top_img
const cover = data.cover
if (topImg && topImg.indexOf('/') === -1 && imgTestReg.test(topImg)) data.top_img = data.path + topImg
if (cover && cover.indexOf('/') === -1) data.cover = data.path + cover
if (coverVal && coverVal.indexOf('/') === -1 && imgTestReg.test(coverVal)) data.cover = data.path + coverVal
}
if (data.cover === false) {
data.randomcover = randomCover()
return data
const randomCoverFn = () => {
const theme = hexo.theme.config
if (!(theme.cover && theme.cover.default_cover)) return false
if (!Array.isArray(theme.cover.default_cover)) return theme.cover.default_cover
const num = Math.floor(Math.random() * theme.cover.default_cover.length)
return theme.cover.default_cover[num]
}
if (coverVal === false) return data
// If cover is not set, use random cover
if (!coverVal) {
randomCover = randomCoverFn()
data.cover = randomCover
coverVal = randomCover // update coverVal
}
if (coverVal) {
if (coverVal.indexOf('//') !== -1 || imgTestReg.test(coverVal)) {
data.cover_type = 'img'
return data
}
}
data.cover = data.cover || randomCover()
return data
})
function randomCover () {
const theme = hexo.theme.config
let cover
let num
if (theme.cover && theme.cover.default_cover) {
if (!Array.isArray(theme.cover.default_cover)) {
cover = theme.cover.default_cover
return cover
} else {
num = Math.floor(Math.random() * theme.cover.default_cover.length)
cover = theme.cover.default_cover[num]
return cover
}
} else {
cover = theme.default_top_img || 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'
return cover
}
}

View File

@@ -0,0 +1,58 @@
hexo.extend.helper.register('findArchiveLength', function (func) {
const allPostsLength = this.site.posts.length
if (hexo.config.archive_generator && hexo.config.archive_generator.enable === false) return allPostsLength
const { yearly, monthly, daily } = hexo.config.archive_generator
const { year, month, day } = this.page
if (yearly === false || !year) return allPostsLength
const posts = this.site.posts.sort('date')
const compareFunc = (type, y1, m1, d1, y2, m2, d2) => {
if (type === 'year') {
return y1 === y2
} else if (type === 'month') {
return y1 === y2 && m1 === m2
} else if (type === 'day') {
return y1 === y2 && m1 === m2 && d1 === d2
}
}
const generateDateObj = (type) => {
const dateObj = []
let length = 0
posts.forEach(post => {
const date = post.date.clone()
const year = date.year()
const month = date.month() + 1
const day = date.date()
const lastData = dateObj[length - 1]
if (!lastData || !compareFunc(type, lastData.year, lastData.month, lastData.day, year, month, day)) {
const name = type === 'year' ? year : type === 'month' ? `${year}-${month}` : `${year}-${month}-${day}`
length = dateObj.push({
name,
year,
month,
day,
count: 1
})
} else {
lastData.count++
}
})
return dateObj
}
const data = func('createArchiveObj', () => {
const yearObj = yearly ? generateDateObj('year') : []
const monthObj = monthly ? generateDateObj('month') : []
const dayObj = daily ? generateDateObj('day') : []
const fullObj = [...yearObj, ...monthObj, ...dayObj]
return fullObj
})
const name = month ? day ? `${year}-${month}-${day}` : `${year}-${month}` : year
return data.find(item => item.name === name).count
})

View File

@@ -9,8 +9,8 @@ hexo.extend.helper.register('inject_head_js', function () {
const { darkmode, aside } = this.theme
const { theme_color } = hexo.theme.config
const themeColorLight = theme_color && theme_color.enable && theme_color.meta_theme_color_light || '#ffffff'
const themeColorDark = theme_color && theme_color.enable && theme_color.meta_theme_color_dark || '#0d0d0d'
const themeColorLight = (theme_color && theme_color.enable && theme_color.meta_theme_color_light) || '#ffffff'
const themeColorDark = (theme_color && theme_color.enable && theme_color.meta_theme_color_dark) || '#0d0d0d'
const localStore = `
win.saveToLocal = {
@@ -60,6 +60,17 @@ hexo.extend.helper.register('inject_head_js', function () {
})
`
const getCSS = `
win.getCSS = url => new Promise((resolve, reject) => {
const link = document.createElement('link')
link.rel = 'stylesheet'
link.href = url
link.onload = () => resolve()
link.onerror = () => reject()
document.head.appendChild(link)
})
`
let darkmodeJs = ''
if (darkmode.enable) {
darkmodeJs = `
@@ -144,5 +155,5 @@ hexo.extend.helper.register('inject_head_js', function () {
detectApple()
`
return `<script>(win=>{${localStore + getScript + darkmodeJs + asideStatus + detectApple}})(window)</script>`
return `<script>(win=>{${localStore + getScript + getCSS + darkmodeJs + asideStatus + detectApple}})(window)</script>`
})

View File

@@ -54,8 +54,8 @@ hexo.extend.helper.register('cloudTags', function (options = {}) {
return result
})
hexo.extend.helper.register('urlNoIndex', function (url = null) {
return prettyUrls(url || this.url, { trailing_index: false, trailing_html: false })
hexo.extend.helper.register('urlNoIndex', function (url = null, trailingIndex = false, trailingHtml = false) {
return prettyUrls(url || this.url, { trailing_index: trailingIndex, trailing_html: trailingHtml })
})
hexo.extend.helper.register('md5', function (path) {
@@ -71,7 +71,13 @@ hexo.extend.helper.register('injectHtml', function (data) {
return result
})
hexo.extend.helper.register('findArchivesTitle', function (menu) {
hexo.extend.helper.register('findArchivesTitle', function (page, menu, date) {
if (page.year) {
const dateStr = page.month ? `${page.year}-${page.month}` : `${page.year}`
const dateFormat = page.month ? hexo.theme.config.aside.card_archives.format : 'YYYY'
return date(dateStr, dateFormat)
}
const defaultTitle = this._p('page.archives')
if (!menu) return defaultTitle
@@ -89,3 +95,11 @@ hexo.extend.helper.register('findArchivesTitle', function (menu) {
return loop(menu) || defaultTitle
})
hexo.extend.helper.register('isImgOrUrl', function (path) {
const imgTestReg = /\.(png|jpe?g|gif|svg|webp)(\?.*)?$/
if (path.indexOf('//') !== -1 || imgTestReg.test(path)) {
return true
}
return false
})

View File

@@ -15,7 +15,7 @@ hexo.extend.helper.register('related_posts', function (currentPost, allPosts) {
title: post.title,
path: post.path,
cover: post.cover,
randomcover: post.randomcover,
cover_type: post.cover_type,
weight: 1,
updated: post.updated,
created: post.date
@@ -50,13 +50,14 @@ hexo.extend.helper.register('related_posts', function (currentPost, allPosts) {
result += '<div class="relatedPosts-list">'
for (let i = 0; i < Math.min(relatedPosts.length, limitNum); i++) {
const cover =
relatedPosts[i].cover === false
? relatedPosts[i].randomcover
: relatedPosts[i].cover
const cover = relatedPosts[i].cover || 'var(--default-bg-color)'
const title = this.escape_html(relatedPosts[i].title)
result += `<div><a href="${this.url_for(relatedPosts[i].path)}" title="${title}">`
result += `<img class="cover" src="${this.url_for(cover)}" alt="cover">`
if (relatedPosts[i].cover_type === 'img') {
result += `<img class="cover" src="${this.url_for(cover)}" alt="cover">`
} else {
result += `<div class="cover" style="background: ${cover}"></div>`
}
if (dateType === 'created') {
result += `<div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> ${this.date(relatedPosts[i].created, hexoConfig.date_format)}</div>`
} else {

View File

@@ -1,6 +1,8 @@
/**
* Butterfly
* galleryGroup and allery
* galleryGroup and gallery
* {% galleryGroup [name] [descr] [url] [img] %}
* {% gallery [lazyload],[rowHeight],[limit] %}
*/
'use strict'
@@ -8,13 +10,38 @@
const urlFor = require('hexo-util').url_for.bind(hexo)
function gallery (args, content) {
return `<div class="fj-gallery">${hexo.render.renderSync({ text: content, engine: 'markdown' }).split('\n').join('')}
</div>`
const { data, languages } = hexo.theme.i18n
args = args.join(' ').split(',')
const rowHeight = args[1] || 220
const limit = args[2] || 10
const lazyload = args[0] === 'true'
const regex = /!\[(.*?)\]\(([^\s]*)\s*(?:["'](.*?)["']?)?\s*\)/g
const lazyloadClass = lazyload ? 'lazyload' : ''
let m
const arr = []
while ((m = regex.exec(content)) !== null) {
if (m.index === regex.lastIndex) {
regex.lastIndex++
}
arr.push({
url: m[2],
alt: m[1],
title: m[3]
})
}
return `<div class="gallery">
<div class="fj-gallery ${lazyloadClass}" data-rowHeight="${rowHeight}" data-limit="${limit}">
<span class="gallery-data">${JSON.stringify(arr)}</span>
</div>
<button class="gallery-load-more"><span>${data[languages[0]].load_more}</span><i class="fa-solid fa-arrow-down"></i></button>
</div>`
}
function galleryGroup (args) {
const name = args[0]
const desrc = args[1]
const descr = args[1]
const url = urlFor(args[2])
const img = urlFor(args[3])
@@ -23,7 +50,7 @@ function galleryGroup (args) {
<img class="gallery-group-img no-lightbox" src='${img}' alt="Group Image Gallery">
<figcaption>
<div class="gallery-group-name">${name}</div>
<p>${desrc}</p>
<p>${descr}</p>
<a href='${url}'></a>
</figcaption>
</figure>

View File

@@ -17,7 +17,7 @@ function postNote (args, content) {
const iconArray = args[args.length - 2]
if (iconArray && iconArray.startsWith('fa')) {
icon = `<i class="note-icon ${iconArray}"></i>`
args[args.length - 2] = 'icon'
args[args.length - 2] = 'icon-padding'
}
return `<div class="note ${args.join(' ')}">${icon + hexo.render.renderSync({ text: content, engine: 'markdown' })}</div>`

View File

@@ -36,11 +36,11 @@
.postImgHover
&:hover
img
.cover
opacity: .8
transform: scale(1.1)
img
.cover
position: absolute
width: 100%
height: 100%

View File

@@ -33,6 +33,7 @@
--pseudo-hover: $pseudo-hover
--headline-presudo: #a0a0a0
--scrollbar-color: $scrollbar-color
--default-bg-color: $theme-color
body
position: relative
@@ -165,7 +166,7 @@ a
if $site-name-font
#site-title,
#site-subtitle,
#site-name,
.site-name,
#aside-content .author-info__name,
#aside-content .author-info__description
font-family: $site-name-font

View File

@@ -115,7 +115,7 @@
width: w = 4.2em
height: w
& > img
:first-child
@extend .imgHover
.content
@@ -403,7 +403,7 @@
if hexo-config('aside.card_archives.sort_order')
.card-archives
order: hexo-config('aside.card-archives.sort_order')
order: hexo-config('aside.card_archives.sort_order')
if hexo-config('aside.card_webinfo.sort_order')
.card-webinfo

View File

@@ -6,3 +6,12 @@ if hexo-config('chat_btn') == true && hexo-config('chatra.enable')
height: 1px !important
opacity: 0 !important
pointer-events: none
if hexo-config('chat_btn') == true && hexo-config('messenger.enable')
.fb_dialog,
.fb-customerchat
visibility: hidden !important
width: 1px !important
height: 1px !important
opacity: 0 !important
pointer-events: none

View File

@@ -1,6 +1,6 @@
#footer
position: relative
background: $light-blue
background-color: $light-blue
background-attachment: scroll
background-position: bottom
background-size: cover

View File

@@ -124,7 +124,8 @@
background: rgba(255, 255, 255, .8)
box-shadow: 0 5px 6px -5px rgba(133, 133, 133, .6)
a
a,
.site-name
color: var(--font-color)
text-shadow: none
@@ -137,8 +138,16 @@
box-shadow: 0 5px 6px -5px alpha($grey, .6)
transition: transform .2s ease-in-out, opacity .2s ease-in-out
#blog-info
color: var(--font-color)
&:hover
color: $light-blue
.site-name
text-shadow: none
a,
#site-name,
#toggle-menu
color: var(--font-color)
text-shadow: none
@@ -146,7 +155,12 @@
&:hover
color: $light-blue
&.nav-visible
&.fixed
#nav
top: 0
transition: all .5s
&.nav-visible:not(.fixed)
#nav
transition: all .5s
transform: translate3d(0, 100%, 0)
@@ -156,6 +170,19 @@
top: 70px
transition: top .5s
&.fixed
#nav
position: fixed
& + .layout
& > .aside-content > .sticky_layout
top: 70px
transition: top .5s
#card-toc
.toc-content
max-height: calc(100vh - 170px)
#page
h1.page-title
margin: 8px 0 20px
@@ -253,8 +280,15 @@
&.show
opacity: 1
#blog_name
#blog-info
flex: 1
color: var(--light-grey)
@extend .limit-one-line
.site-icon
margin-right: 6px
height: 36px
vertical-align: middle
#toggle-menu
display: none
@@ -270,10 +304,9 @@
&:hover
color: var(--white)
#site-name
.site-name
text-shadow: 2px 2px 4px rgba($dark-black, .15)
font-weight: bold
cursor: pointer
.menus_items
display: inline
@@ -301,10 +334,10 @@
margin-top: 8px
padding: 0
width: max-content
border-radius: 5px
background-color: var(--sidebar-bg)
box-shadow: 0 5px 20px -4px rgba($dark-black, .5)
animation: sub_menus .3s .1s ease both
border-radius: 5px
&:before
position: absolute
@@ -321,9 +354,13 @@
background: var(--text-bg-hover)
&:first-child
border-radius: 5px 5px 0 0
border-top-left-radius: 5px
border-top-right-radius: 5px
&:last-child
border-radius: 0 0 5px 5px
border-bottom-right-radius: 5px
border-bottom-left-radius: 5px
a
display: inline-block
padding: 8px 16px
@@ -369,4 +406,4 @@
&:hover
&:after
width: 100%
width: 100%

View File

@@ -1,4 +1,4 @@
if hexo-config('preloader')
if hexo-config('preloader.enable') && hexo-config('preloader.source') == 1
.loading-bg
position: fixed
z-index: 1000

View File

@@ -102,31 +102,35 @@ beautify()
font-family: Monaco, 'Ubuntu Mono', monospace
line-height: 1em
if hexo-config('anchor')
if hexo-config('anchor.button.enable')
a.headerlink
&:after
@extend .fontawesomeIcon
float: right
color: var(--headline-presudo)
content: '\f0c1'
content: $archor-button-icon
font-size: .95em
opacity: 0
transition: all .3s
&:hover
&:after
color: var(--pseudo-hover)
h1,
h2,
h3,
h4,
h5,
h6
&:hover
a.headerlink
&:after
opacity: 1
if !hexo-config('anchor.button.always_show')
a.headerlink
&:after
opacity: 0
h1,
h2,
h3,
h4,
h5,
h6
&:hover
a.headerlink
&:after
opacity: 1
ol,
ul

View File

@@ -47,3 +47,22 @@
+maxWidth900()
#hide-aside-btn
display: none
if hexo-config('rightside_scroll_percent')
#go-up
.scroll-percent
display: none
&.show-percent
.scroll-percent
display: block
& + i
display: none
&:hover
.scroll-percent
display: none
& + i
display: block

View File

@@ -25,11 +25,8 @@
--waline-theme-color: $button-bg
--waline-active-color: $button-hover-color
.vuser
transition: all .5s
&:hover
transform: rotate(360deg)
.wl-comment-actions > button:not(last-child)
padding-right: 4px
if hexo-config('valine.bg')
#vcomment
@@ -84,12 +81,16 @@ if hexo-config('waline.bg')
&::-webkit-scrollbar
display: none
// mathjax
mjx-container[display],
.has-jax
// Mathjax
.mathjax-overflow
overflow-x: auto
overflow-y: hidden
line-height: normal !important
span.mathjax-overflow
display: inline-block
padding: 0 2px
max-width: 100%
vertical-align: bottom
.aplayer
color: $font-black

View File

@@ -118,8 +118,10 @@ if hexo-config('darkmode.enable') || hexo-config('display_mode') == 'dark'
fill: alpha(#FFFFFF, .9) !important
// Disqusjs
#disqus_thread
#disqusjs
#dsqjs
&:hover,
&:focus,
.dsqjs-tab-active,
.dsqjs-no-comment
color: alpha(#FFFFFF, .7)

View File

@@ -106,7 +106,7 @@ if hexo-config('readmode')
color: var(--font-color) !important
.hljs
background: var(-highlight-bg) !important
background: var(--highlight-bg) !important
h1,
h2,

View File

@@ -101,7 +101,7 @@
width: 80px
height: 80px
img
:first-child
@extend .imgHover
&-info

View File

@@ -15,7 +15,7 @@
height: auto
&:hover
img.post_bg
img.post-bg
transform: scale(1.1)
&.ads-wrap
@@ -31,7 +31,7 @@
width: 100%
height: 230px
img.post_bg
.post-bg
@extend .imgHover
&.right
@@ -82,6 +82,9 @@
i
margin: 0 4px 0 0
.fa-spinner
margin: 0
.article-meta-label
if hexo-config('post_meta.page.label')
padding-right: 4px

View File

@@ -28,7 +28,7 @@
.algolia-hit-item-content
margin: 0 0 8px
word-break: break-all
word-break: break-word
.ais-Pagination
margin: 20px 0 0
@@ -69,6 +69,8 @@
#algolia-hits
> div
overflow-y: scroll
margin: 0 -20px
padding: 0 22px
+minWidth768()
max-height: calc(80vh - 240px)

View File

@@ -52,14 +52,16 @@
.search-result
margin: 0 0 8px
word-break: break-all
word-break: break-word
.search-keyword
color: $search-keyword-highlight
font-weight: bold
.search-result-list
overflow-y: auto
overflow-y: overlay
margin: 0 -20px
padding: 0 22px
max-height: calc(80vh - 130px)
+maxWidth768()

View File

@@ -94,9 +94,46 @@
overflow: auto
padding: 0 0 16px
.fj-gallery
.gallery
margin: 0 0 16px
opacity: 0
text-align: center
.img-alt
display: none
.fj-gallery
opacity: 0
.img-alt
display: none
&.lazyload
+ button
display: inline-block
.gallery-data
display: none
button
display: none
margin-top: 25px
padding: 10px
width: 9em
border-radius: 5px
background: var(--btn-bg)
color: var(--btn-color)
font-weight: bold
font-size: 1.1em
transition: all .3s
& > *
transition: all .4s
i
width: 0
opacity: 0
&:hover
background: var(--btn-hover-color)
i
margin-left: 2px
width: 20px
opacity: 1

View File

@@ -7,7 +7,7 @@
if hexo-config('note.border_radius') is a 'unit'
border-radius: unit(hexo-config('note.border_radius'), px)
&.icon
&.icon-padding
padding-left: 3em
& > .note-icon

View File

@@ -71,7 +71,7 @@ $button-hover-color = $themeColorEnable && hexo-config('theme_color.button_hover
$button-bg = $theme-color
$pseudo-hover = $button-hover-color
// scrollbar
$scrollbar-color= $themeColorEnable && hexo-config('theme_color.scrollbar_color') ? convert(hexo-config('theme_color.scrollbar_color')) : $theme-color
$scrollbar-color = $themeColorEnable && hexo-config('theme_color.scrollbar_color') ? convert(hexo-config('theme_color.scrollbar_color')) : $theme-color
// table
$table-thead-bg = #99a9bf
// reward
@@ -180,4 +180,6 @@ $tab-active-border-color = $theme-color
$tab-button-active-bg = $card-bg
$tab-to-top-color = #99a9bf
// Tag Plugins - timeline
$timeline-default-color = $theme-color
$timeline-default-color = $theme-color
// archor
$archor-button-icon = hexo-config('anchor.button.icon') ? hexo-config('anchor.button.icon') : '\f0c1'

View File

@@ -1,21 +1,24 @@
document.addEventListener('DOMContentLoaded', function () {
let blogNameWidth, menusWidth, searchWidth, $nav
let headerContentWidth, $nav
let mobileSidebarOpen = false
const adjustMenu = (init) => {
const adjustMenu = init => {
const getAllWidth = ele => {
let width = 0
ele.length && Array.from(ele).forEach(i => { width += i.offsetWidth })
return width
}
if (init) {
blogNameWidth = document.getElementById('site-name').offsetWidth
const $menusEle = document.querySelectorAll('#menus .menus_item')
menusWidth = 0
$menusEle.length && $menusEle.forEach(i => { menusWidth += i.offsetWidth })
const $searchEle = document.querySelector('#search-button')
searchWidth = $searchEle ? $searchEle.offsetWidth : 0
const blogInfoWidth = getAllWidth(document.querySelector('#blog-info > a').children)
const menusWidth = getAllWidth(document.getElementById('menus').children)
headerContentWidth = blogInfoWidth + menusWidth
$nav = document.getElementById('nav')
}
let hideMenuIndex = ''
if (window.innerWidth < 768) hideMenuIndex = true
else hideMenuIndex = blogNameWidth + menusWidth + searchWidth > $nav.offsetWidth - 120
if (window.innerWidth <= 768) hideMenuIndex = true
else hideMenuIndex = headerContentWidth > $nav.offsetWidth - 120
if (hideMenuIndex) {
$nav.classList.add('hide-menu')
@@ -229,14 +232,42 @@ document.addEventListener('DOMContentLoaded', function () {
* justified-gallery 圖庫排版
*/
const runJustifiedGallery = function (ele) {
ele.forEach(item => {
const $imgList = item.querySelectorAll('img')
$imgList.forEach(i => {
const dataLazySrc = i.getAttribute('data-lazy-src')
if (dataLazySrc) i.src = dataLazySrc
btf.wrap(i, 'div', { class: 'fj-gallery-item' })
const htmlStr = arr => {
let str = ''
const replaceDq = str => str.replace(/"/g, '&quot;') // replace double quotes to &quot;
arr.forEach(i => {
const alt = i.alt ? `alt="${replaceDq(i.alt)}"` : ''
const title = i.title ? `title="${replaceDq(i.title)}"` : ''
str += `<div class="fj-gallery-item"><img src="${i.url}" ${alt + title}"></div>`
})
return str
}
const lazyloadFn = (i, arr) => {
const loadItem = i.getAttribute('data-limit')
const arrLength = arr.length
if (arrLength > loadItem) i.insertAdjacentHTML('beforeend', htmlStr(arr.splice(0, loadItem)))
else {
i.insertAdjacentHTML('beforeend', htmlStr(arr))
i.classList.remove('lazyload')
}
return arrLength > loadItem ? loadItem : arrLength
}
ele.forEach(item => {
const arr = JSON.parse(item.querySelector('.gallery-data').textContent)
if (!item.classList.contains('lazyload')) item.innerHTML = htmlStr(arr)
else {
lazyloadFn(item, arr)
const limit = item.getAttribute('data-limit')
const clickBtnFn = () => {
const lastItemLength = lazyloadFn(item, arr)
fjGallery(item, 'appendImages', item.querySelectorAll(`.fj-gallery-item:nth-last-child(-n+${lastItemLength})`))
btf.loadLightbox(item.querySelectorAll('img'))
lastItemLength < limit && item.nextElementSibling.removeEventListener('click', clickBtnFn)
}
item.nextElementSibling.addEventListener('click', clickBtnFn)
}
})
if (window.fjGallery) {
@@ -244,13 +275,24 @@ document.addEventListener('DOMContentLoaded', function () {
return
}
const newEle = document.createElement('link')
newEle.rel = 'stylesheet'
newEle.href = GLOBAL_CONFIG.source.justifiedGallery.css
document.body.appendChild(newEle)
getCSS(`${GLOBAL_CONFIG.source.justifiedGallery.css}`)
getScript(`${GLOBAL_CONFIG.source.justifiedGallery.js}`).then(() => { btf.initJustifiedGallery(ele) })
}
/**
* rightside scroll percent
*/
const rightsideScrollPercent = currentTop => {
const perNum = btf.getScrollPercent(currentTop, document.body)
const $goUp = document.getElementById('go-up')
if (perNum < 95) {
$goUp.classList.add('show-percent')
$goUp.querySelector('.scroll-percent').textContent = perNum
} else {
$goUp.classList.remove('show-percent')
}
}
/**
* 滾動處理
*/
@@ -276,41 +318,44 @@ document.addEventListener('DOMContentLoaded', function () {
const $header = document.getElementById('page-header')
const isChatBtnHide = typeof chatBtnHide === 'function'
const isChatBtnShow = typeof chatBtnShow === 'function'
const isShowPercent = GLOBAL_CONFIG.percent.rightside
window.scrollCollect = () => {
return btf.throttle(function (e) {
const currentTop = window.scrollY || document.documentElement.scrollTop
const isDown = scrollDirection(currentTop)
if (currentTop > 56) {
if (isDown) {
if ($header.classList.contains('nav-visible')) $header.classList.remove('nav-visible')
if (isChatBtnShow && isChatShow === true) {
chatBtnHide()
isChatShow = false
}
} else {
if (!$header.classList.contains('nav-visible')) $header.classList.add('nav-visible')
if (isChatBtnHide && isChatShow === false) {
chatBtnShow()
isChatShow = true
}
}
$header.classList.add('nav-fixed')
if (window.getComputedStyle($rightside).getPropertyValue('opacity') === '0') {
$rightside.style.cssText = 'opacity: 0.8; transform: translateX(-58px)'
const scrollTask = btf.throttle(() => {
const currentTop = window.scrollY || document.documentElement.scrollTop
const isDown = scrollDirection(currentTop)
if (currentTop > 56) {
if (isDown) {
if ($header.classList.contains('nav-visible')) $header.classList.remove('nav-visible')
if (isChatBtnShow && isChatShow === true) {
chatBtnHide()
isChatShow = false
}
} else {
if (currentTop === 0) {
$header.classList.remove('nav-fixed', 'nav-visible')
if (!$header.classList.contains('nav-visible')) $header.classList.add('nav-visible')
if (isChatBtnHide && isChatShow === false) {
chatBtnShow()
isChatShow = true
}
$rightside.style.cssText = "opacity: ''; transform: ''"
}
if (document.body.scrollHeight <= innerHeight) {
$header.classList.add('nav-fixed')
if (window.getComputedStyle($rightside).getPropertyValue('opacity') === '0') {
$rightside.style.cssText = 'opacity: 0.8; transform: translateX(-58px)'
}
}, 200)()
}
} else {
if (currentTop === 0) {
$header.classList.remove('nav-fixed', 'nav-visible')
}
$rightside.style.cssText = "opacity: ''; transform: ''"
}
isShowPercent && rightsideScrollPercent(currentTop)
if (document.body.scrollHeight <= innerHeight) {
$rightside.style.cssText = 'opacity: 0.8; transform: translateX(-58px)'
}
}, 200)
window.scrollCollect = scrollTask
window.addEventListener('scroll', scrollCollect)
}
@@ -325,26 +370,15 @@ document.addEventListener('DOMContentLoaded', function () {
if (!($article && (isToc || isAnchor))) return
let $tocLink, $cardToc, scrollPercent, autoScrollToc, isExpand
let $tocLink, $cardToc, autoScrollToc, $tocPercentage, isExpand
if (isToc) {
const $cardTocLayout = document.getElementById('card-toc')
$cardToc = $cardTocLayout.getElementsByClassName('toc-content')[0]
$tocLink = $cardToc.querySelectorAll('.toc-link')
const $tocPercentage = $cardTocLayout.querySelector('.toc-percentage')
$tocPercentage = $cardTocLayout.querySelector('.toc-percentage')
isExpand = $cardToc.classList.contains('is-expand')
scrollPercent = currentTop => {
const docHeight = $article.clientHeight
const winHeight = document.documentElement.clientHeight
const headerHeight = $article.offsetTop
const contentMath = (docHeight > winHeight) ? (docHeight - winHeight) : (document.documentElement.scrollHeight - winHeight)
const scrollPercent = (currentTop - headerHeight) / (contentMath)
const scrollPercentRounded = Math.round(scrollPercent * 100)
const percentage = (scrollPercentRounded > 100) ? 100 : (scrollPercentRounded <= 0) ? 0 : scrollPercentRounded
$tocPercentage.textContent = percentage
}
window.mobileToc = {
open: () => {
$cardTocLayout.style.cssText = 'animation: toc-open .3s; opacity: 1; right: 55px'
@@ -433,13 +467,14 @@ document.addEventListener('DOMContentLoaded', function () {
}
// main of scroll
window.tocScrollFn = function () {
return btf.throttle(function () {
const currentTop = window.scrollY || document.documentElement.scrollTop
isToc && scrollPercent(currentTop)
findHeadPosition(currentTop)
}, 100)()
}
window.tocScrollFn = btf.throttle(() => {
const currentTop = window.scrollY || document.documentElement.scrollTop
if (isToc && GLOBAL_CONFIG.percent.toc) {
$tocPercentage.textContent = btf.getScrollPercent(currentTop, $article)
}
findHeadPosition(currentTop)
}, 100)
window.addEventListener('scroll', tocScrollFn)
}
@@ -477,8 +512,7 @@ document.addEventListener('DOMContentLoaded', function () {
// handle some cases
typeof utterancesTheme === 'function' && utterancesTheme()
typeof changeGiscusTheme === 'function' && changeGiscusTheme()
typeof FB === 'object' && window.loadFBComment()
window.DISQUS && document.getElementById('disqus_thread').children.length && setTimeout(() => window.disqusReset(), 200)
typeof FB === 'object' && window.loadFBComment && window.loadFBComment()
typeof runMermaid === 'function' && window.runMermaid()
},
showOrHideBtn: (e) => { // rightside 點擊設置 按鈕 展開

View File

@@ -56,7 +56,7 @@ window.addEventListener('load', () => {
post = '...'
}
let matchContent = pre + content.substring(start, end) + post
const matchContent = pre + content.substring(start, end) + post
return matchContent
}
@@ -68,10 +68,11 @@ window.addEventListener('load', () => {
const search = instantsearch({
indexName: algolia.indexName,
/* global algoliasearch */
searchClient: algoliasearch(algolia.appId, algolia.apiKey),
searchFunction(helper) {
searchFunction (helper) {
helper.state.query && helper.search()
},
}
})
const configure = instantsearch.widgets.configure({
@@ -89,13 +90,21 @@ window.addEventListener('load', () => {
const hits = instantsearch.widgets.hits({
container: '#algolia-hits',
templates: {
item(data) {
item (data) {
const link = data.permalink ? data.permalink : (GLOBAL_CONFIG.root + data.path)
const result = data._highlightResult
const content = result.contentStripTruncate
? cutContent(result.contentStripTruncate.value)
: result.contentStrip
? cutContent(result.contentStrip.value)
: result.content
? cutContent(result.content.value)
: ''
return `
<a href="${link}" class="algolia-hit-item-link">
${data._highlightResult.title.value || 'no-title'}
${result.title.value || 'no-title'}
</a>
<p class="algolia-hit-item-content">${cutContent(data._highlightResult.contentStripTruncate.value)}</p>`
<p class="algolia-hit-item-content">${content}</p>`
},
empty: function (data) {
return (
@@ -122,7 +131,7 @@ window.addEventListener('load', () => {
})
const powerBy = instantsearch.widgets.poweredBy({
container: '#algolia-info > .algolia-poweredBy',
container: '#algolia-info > .algolia-poweredBy'
})
const pagination = instantsearch.widgets.pagination({
@@ -136,8 +145,7 @@ window.addEventListener('load', () => {
}
})
search.addWidgets([configure,searchBox,hits,stats,powerBy,pagination]) // add the widgets to the instantsearch instance
search.addWidgets([configure, searchBox, hits, stats, powerBy, pagination]) // add the widgets to the instantsearch instance
search.start()

View File

@@ -56,7 +56,7 @@ window.addEventListener('load', () => {
const res = await response.text()
const t = await new window.DOMParser().parseFromString(res, 'text/xml')
const a = await t
data = [...a.querySelectorAll('entry')].map(item =>{
data = [...a.querySelectorAll('entry')].map(item => {
return {
title: item.querySelector('title').textContent,
content: item.querySelector('content') && item.querySelector('content').textContent,
@@ -84,8 +84,11 @@ window.addEventListener('load', () => {
$input.addEventListener('input', function () {
const keywords = this.value.trim().toLowerCase().split(/[\s]+/)
if (keywords[0] !== '') $loadingStatus.innerHTML = '<i class="fas fa-spinner fa-pulse"></i>'
else {
$resultContent.innerHTML = ''
return
}
$resultContent.innerHTML = ''
let str = '<div class="search-result-list">'
if (keywords.length <= 0) return
let count = 0
@@ -150,7 +153,12 @@ window.addEventListener('load', () => {
// highlight all keywords
keywords.forEach(keyword => {
const regS = new RegExp(keyword, 'gi')
let regexStr = keyword
const specialRegex = /[^\w\s]+/ // match special characters
if (keyword.length === 1 && specialRegex.test(keyword)) {
regexStr = `\\${keyword}`
}
const regS = new RegExp(regexStr, 'gi')
matchContent = matchContent.replace(regS, '<span class="search-keyword">' + keyword + '</span>')
dataTitle = dataTitle.replace(regS, '<span class="search-keyword">' + keyword + '</span>')
})

File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show More