Compare commits

...

79 Commits
4.4.0 ... 4.8.5

105 changed files with 1774 additions and 1151 deletions

View File

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

View File

@@ -81,7 +81,7 @@ npm i hexo-theme-butterfly
- [x] Share (AddThis/Sharejs/Addtoany) - [x] Share (AddThis/Sharejs/Addtoany)
- [X] Comment (Disqus/Disqusjs/Livere/Gitalk/Valine/Waline/Utterances/Facebook Comments/Twikoo/Giscus/Remark42/artalk) - [X] Comment (Disqus/Disqusjs/Livere/Gitalk/Valine/Waline/Utterances/Facebook Comments/Twikoo/Giscus/Remark42/artalk)
- [x] Multiple Comment System Support - [x] Multiple Comment System Support
- [x] Online Chats (Chatra/Tidio/Daovoice/Gitter/Crisp/messenger) - [x] Online Chats (Chatra/Tidio/Daovoice/Crisp/messenger)
- [x] Web analytics - [x] Web analytics
- [x] Google AdSense - [x] Google AdSense
- [x] Webmaster Verification - [x] Webmaster Verification
@@ -89,7 +89,7 @@ npm i hexo-theme-butterfly
- [x] Typewriter Effect: activate_power_mode - [x] Typewriter Effect: activate_power_mode
- [x] Background effects (Canvas ribbon/canvas_ribbon_piao/canvas_nest) - [x] Background effects (Canvas ribbon/canvas_ribbon_piao/canvas_nest)
- [x] Mouse click effects (Fireworks/Heart/Text) - [x] Mouse click effects (Fireworks/Heart/Text)
- [x] Preloader/Loading Animation - [x] Preloader/Loading Animation/pace.js
- [x] Busuanzi visitor counter - [x] Busuanzi visitor counter
- [x] Medium Zoom/Fancybox - [x] Medium Zoom/Fancybox
- [x] Mermaid - [x] Mermaid

View File

@@ -81,7 +81,7 @@ theme: butterfly
- [x] 多種分享系統AddThis/Sharejs/Addtoany - [x] 多種分享系統AddThis/Sharejs/Addtoany
- [X] 多種評論系統Disqus/Disqusjs/Livere/Gitalk/Valine/Waline/Utterances/Facebook Comments/Twikoo/Giscus/Remark42/artalk - [X] 多種評論系統Disqus/Disqusjs/Livere/Gitalk/Valine/Waline/Utterances/Facebook Comments/Twikoo/Giscus/Remark42/artalk
- [x] 支持雙評論部署 - [x] 支持雙評論部署
- [x] 多種在線聊天Chatra/Tidio/Daovoice/Gitter/Crisp/messenger - [x] 多種在線聊天Chatra/Tidio/Daovoice/Crisp/messenger
- [x] 多種分析系統 - [x] 多種分析系統
- [x] 谷歌廣告/手動廣告位置 - [x] 谷歌廣告/手動廣告位置
- [x] 各種站長驗證Google/Bing/Baidu/360/Yandex - [x] 各種站長驗證Google/Bing/Baidu/360/Yandex
@@ -89,7 +89,7 @@ theme: butterfly
- [x] 打字特效 activate_power_mode - [x] 打字特效 activate_power_mode
- [x] 多種背景特效(靜止彩帶/動態彩帶/Canvas Nest - [x] 多種背景特效(靜止彩帶/動態彩帶/Canvas Nest
- [x] 多種鼠標點擊特效(煙花/文字/愛心) - [x] 多種鼠標點擊特效(煙花/文字/愛心)
- [x] 內置一種 Preloader 加載動畫 - [x] 內置一種 Preloader 加載動畫和 pace.js 加載動畫條
- [x] 不蒜子訪問統計 - [x] 不蒜子訪問統計
- [x] 兩種大圖模式Medium Zoom/Fancybox - [x] 兩種大圖模式Medium Zoom/Fancybox
- [x] Mermaid 圖表顯示 - [x] Mermaid 圖表顯示
@@ -97,7 +97,7 @@ theme: butterfly
- [x] 圖片懶加載 - [x] 圖片懶加載
- [x] Instantpage/Pangu/Snackbar彈窗/PWA...... - [x] Instantpage/Pangu/Snackbar彈窗/PWA......
## ✨ 贡献 ## ✨ 貢獻
<a href="https://github.com/jerryc127/hexo-theme-butterfly/graphs/contributors"> <a href="https://github.com/jerryc127/hexo-theme-butterfly/graphs/contributors">
<img src="https://contrib.rocks/image?repo=jerryc127/hexo-theme-butterfly" /> <img src="https://contrib.rocks/image?repo=jerryc127/hexo-theme-butterfly" />

View File

@@ -1,7 +1,13 @@
# Main menu navigation (導航目錄) # Navigation bar settings (導航欄設置)
# see https://butterfly.js.org/posts/4aa8abbe/#導航菜單 # see https://butterfly.js.org/posts/4aa8abbe/##導航欄設置-Navigation-bar-settings
# -------------------------------------- # --------------------------------------
nav:
logo: # image
display_title: true
fixed: false # fixed navigation bar
# Menu 目錄
menu: menu:
# Home: / || fas fa-home # Home: / || fas fa-home
# Archives: /archives/ || fas fa-archive # Archives: /archives/ || fas fa-archive
@@ -23,54 +29,12 @@ highlight_shrink: false # true: shrink the code blocks / false: expand the code
highlight_height_limit: false # unit: px highlight_height_limit: false # unit: px
code_word_wrap: false code_word_wrap: false
# copy settings # Social Settings (社交圖標設置)
# copyright: Add the copyright information after copied content (複製的內容後面加上版權信息)
copy:
enable: true
copyright:
enable: false
limit_count: 50
# social settings (社交圖標設置)
# formal: # formal:
# icon: link || the description # icon: link || the description || color
social: social:
# fab fa-github: https://github.com/xxxxx || Github # fab fa-github: https://github.com/xxxxx || Github || '#24292e'
# fas fa-envelope: mailto:xxxxxx@gmail.com || Email # fas fa-envelope: mailto:xxxxxx@gmail.com || Email || '#4a7dbe'
# search (搜索)
# see https://butterfly.js.org/posts/ceeb73f/#搜索系統
# --------------------------------------
# Algolia search
algolia_search:
enable: false
hits:
per_page: 6
# Local search
local_search:
enable: false
preload: false
CDN:
# Math (數學)
# --------------------------------------
# About the per_page
# if you set it to true, it will load mathjax/katex script in each page (true 表示每一頁都加載js)
# if you set it to false, it will load mathjax/katex script according to your setting (add the 'mathjax: true' in page's front-matter)
# (false 需要時加載,須在使用的 Markdown Front-matter 加上 mathjax: true)
# MathJax
mathjax:
enable: false
per_page: false
# KaTeX
katex:
enable: false
per_page: false
hide_scrollbar: true
# Image (圖片設置) # Image (圖片設置)
# -------------------------------------- # --------------------------------------
@@ -150,14 +114,6 @@ post_meta:
tags: true # true or false 文章頁是否顯示標籤 tags: true # true or false 文章頁是否顯示標籤
label: true # true or false 顯示描述性文字 label: true # true or false 顯示描述性文字
# wordcount (字數統計)
# see https://butterfly.js.org/posts/ceeb73f/#字數統計
wordcount:
enable: false
post_wordcount: true
min2read: true
total_wordcount: true
# Display the article introduction on homepage # Display the article introduction on homepage
# 1: description # 1: description
# 2: both (if the description exists, it will show description, or show the auto_excerpt) # 2: both (if the description exists, it will show description, or show the auto_excerpt)
@@ -168,8 +124,23 @@ index_post_content:
length: 500 # if you set method to 2 or 3, the length need to config length: 500 # if you set method to 2 or 3, the length need to config
# anchor # anchor
# when you scroll in post, the URL will update according to header id. anchor:
anchor: false 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.
# figcaption (圖片描述文字)
photofigcaption: false
# copy settings
# copyright: Add the copyright information after copied content (複製的內容後面加上版權信息)
copy:
enable: true
copyright:
enable: false
limit_count: 50
# Post # Post
# -------------------------------------- # --------------------------------------
@@ -181,6 +152,7 @@ toc:
number: true number: true
expand: false expand: false
style_simple: false # for post style_simple: false # for post
scroll_percent: true
post_copyright: post_copyright:
enable: true enable: true
@@ -214,9 +186,6 @@ related_post:
limit: 6 # Number of posts displayed limit: 6 # Number of posts displayed
date_type: created # or created or updated 文章日期顯示創建日或者更新日 date_type: created # or created or updated 文章日期顯示創建日或者更新日
# figcaption (圖片描述文字)
photofigcaption: false
# post_pagination (分頁) # post_pagination (分頁)
# value: 1 || 2 || false # value: 1 || 2 || false
# 1: The 'next post' will link to old post # 1: The 'next post' will link to old post
@@ -233,7 +202,183 @@ noticeOutdate:
message_prev: It has been message_prev: It has been
message_next: days since the last update, the content of the article may be outdated. message_next: days since the last update, the content of the article may be outdated.
# Share System (分享功能) # Footer Settings
# --------------------------------------
footer:
owner:
enable: true
since: 2020
custom_text:
copyright: true # Copyright of theme and framework
# aside (側邊欄)
# --------------------------------------
aside:
enable: true
hide: false
button: true
mobile: true # display on mobile
position: right # left or right
display:
archive: true
tag: true
category: true
card_author:
enable: true
description:
button:
enable: true
icon: fab fa-github
text: Follow Me
link: https://github.com/xxxxxx
card_announcement:
enable: true
content: This is my Blog
card_recent_post:
enable: true
limit: 5 # if set 0 will show all
sort: date # date or updated
sort_order: # Don't modify the setting unless you know how it works
card_categories:
enable: true
limit: 8 # if set 0 will show all
expand: none # none/true/false
sort_order: # Don't modify the setting unless you know how it works
card_tags:
enable: true
limit: 40 # if set 0 will show all
color: false
orderby: random # Order of tags, random/name/length
order: 1 # Sort of order. 1, asc for ascending; -1, desc for descending
sort_order: # Don't modify the setting unless you know how it works
card_archives:
enable: true
type: monthly # yearly or monthly
format: MMMM YYYY # eg: YYYY年MM月
order: -1 # Sort of order. 1, asc for ascending; -1, desc for descending
limit: 8 # if set 0 will show all
sort_order: # Don't modify the setting unless you know how it works
card_webinfo:
enable: true
post_count: true
last_push_date: true
sort_order: # Don't modify the setting unless you know how it works
# busuanzi count for PV / UV in site
# 訪問人數
busuanzi:
site_uv: true
site_pv: true
page_pv: true
# Time difference between publish date and now (網頁運行時間)
# Formal: Month/Day/Year Time or Year/Month/Day Time
runtimeshow:
enable: false
publish_date:
# Aside widget - Newest Comments
newest_comments:
enable: false
sort_order: # Don't modify the setting unless you know how it works
limit: 6
storage: 10 # unit: mins, save data to localStorage
avatar: true
# Bottom right button (右下角按鈕)
# --------------------------------------
# Conversion between Traditional and Simplified Chinese (簡繁轉換)
translate:
enable: false
# The text of a button
default:
# the language of website (1 - Traditional Chinese/ 2 - Simplified Chinese
defaultEncoding: 2
# Time delay
translateDelay: 0
# The text of the button when the language is Simplified Chinese
msgToTraditionalChinese: '繁'
# The text of the button when the language is Traditional Chinese
msgToSimplifiedChinese: '簡'
# Read Mode (閲讀模式)
readmode: true
# dark mode
darkmode:
enable: true
# Toggle Button to switch dark/light mode
button: true
# Switch dark/light mode automatically (自動切換 dark mode和 light mode)
# autoChangeMode: 1 Following System Settings, if the system doesn't support dark mode, it will switch dark mode between 6 pm to 6 am
# autoChangeMode: 2 Switch dark mode between 6 pm to 6 am
# autoChangeMode: false
autoChangeMode: false
# Set the light mode time. The value is between 0 and 24. If not set, the default value is 6 and 18
start: # 8
end: # 22
# 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 不要重複
rightside_item_order:
enable: false
hide: # readmode,translate,darkmode,hideAside
show: # toc,chat,comment
# Math (數學)
# --------------------------------------
# About the per_page
# if you set it to true, it will load mathjax/katex script in each page (true 表示每一頁都加載js)
# if you set it to false, it will load mathjax/katex script according to your setting (add the 'mathjax: true' in page's front-matter)
# (false 需要時加載,須在使用的 Markdown Front-matter 加上 mathjax: true)
# MathJax
mathjax:
enable: false
per_page: false
# KaTeX
katex:
enable: false
per_page: false
hide_scrollbar: true
# search (搜索)
# see https://butterfly.js.org/posts/ceeb73f/#搜索系統
# --------------------------------------
# Algolia search
algolia_search:
enable: false
hits:
per_page: 6
# Local search
local_search:
enable: false
# Preload the search data when the page loads.
preload: false
# Show top n results per article, show all results by setting to -1
top_n_per_article: 1
# Unescape html strings to the readable one.
unescape: false
CDN:
# Docsearch
docsearch:
enable: false
appId:
apiKey:
indexName:
option:
# Share System (分享)
# -------------------------------------- # --------------------------------------
# AddThis # AddThis
@@ -392,17 +537,11 @@ tidio:
public_key: public_key:
# daovoice # daovoice
# http://daovoice.io/ # http://dashboard.daovoice.io/app
daovoice: daovoice:
enable: false enable: false
app_id: app_id:
# gitter
# https://gitter.im/
gitter:
enable: false
room:
# crisp # crisp
# https://crisp.chat/en/ # https://crisp.chat/en/
crisp: crisp:
@@ -416,15 +555,6 @@ messenger:
pageID: pageID:
lang: zh_TW # Language en_US/zh_CN/zh_TW and so on lang: zh_TW # Language en_US/zh_CN/zh_TW and so on
# Footer Settings
# --------------------------------------
footer:
owner:
enable: true
since: 2020
custom_text:
copyright: true # Copyright of theme and framework
# Analysis # Analysis
# -------------------------------------- # --------------------------------------
@@ -436,10 +566,6 @@ baidu_analytics:
# https://analytics.google.com/analytics/web/ # https://analytics.google.com/analytics/web/
google_analytics: google_analytics:
# CNZZ Analytics
# https://www.umeng.com/
cnzz_analytics:
# Cloudflare Analytics # Cloudflare Analytics
# https://www.cloudflare.com/zh-tw/web-analytics/ # https://www.cloudflare.com/zh-tw/web-analytics/
cloudflare_analytics: cloudflare_analytics:
@@ -525,6 +651,14 @@ rightside-bottom:
# Enter transitions (開啓網頁進入效果) # Enter transitions (開啓網頁進入效果)
enter_transitions: true enter_transitions: true
# Typewriter Effect (打字效果)
# https://github.com/disjukr/activate-power-mode
activate_power_mode:
enable: false
colorful: true # open particle animation (冒光特效)
shake: true # open shake (抖動特效)
mobile: false
# Background effects (背景特效) # Background effects (背景特效)
# -------------------------------------- # --------------------------------------
@@ -553,14 +687,6 @@ canvas_nest:
count: 99 # the number of lines, default: 99. count: 99 # the number of lines, default: 99.
mobile: false mobile: false
# Typewriter Effect (打字效果)
# https://github.com/disjukr/activate-power-mode
activate_power_mode:
enable: false
colorful: true # open particle animation (冒光特效)
shake: true # open shake (抖動特效)
mobile: false
# Mouse click effects: fireworks (鼠標點擊效果: 煙火特效) # Mouse click effects: fireworks (鼠標點擊效果: 煙火特效)
fireworks: fireworks:
enable: false enable: false
@@ -619,16 +745,13 @@ subtitle:
enable: false enable: false
# Typewriter Effect (打字效果) # Typewriter Effect (打字效果)
effect: true effect: true
# Effect Speed Options (打字效果速度參數) # Customize typed.js (配置typed.js)
startDelay: 300 # time before typing starts in milliseconds # https://github.com/mattboldt/typed.js/#customization
typeSpeed: 150 # type speed in milliseconds typed_option:
backSpeed: 50 # backspacing speed in milliseconds
# loop (循環打字)
loop: true
# source 調用第三方服務 # source 調用第三方服務
# source: false 關閉調用 # source: false 關閉調用
# source: 1 調用一言網的一句話(簡體) https://hitokoto.cn/ # source: 1 調用一言網的一句話(簡體) https://hitokoto.cn/
# source: 2 調用一句網(簡體) http://yijuzhan.com/ # source: 2 調用一句網(簡體) https://yijuzhan.com/
# source: 3 調用今日詩詞(簡體) https://www.jinrishici.com/ # source: 3 調用今日詩詞(簡體) https://www.jinrishici.com/
# subtitle 會先顯示 source , 再顯示 sub 的內容 # subtitle 會先顯示 source , 再顯示 sub 的內容
source: false source: false
@@ -636,119 +759,22 @@ subtitle:
sub: sub:
# Loading Animation (加載動畫) # Loading Animation (加載動畫)
preloader: false preloader:
# aside (側邊欄)
# --------------------------------------
aside:
enable: true
hide: false
button: true
mobile: true # display on mobile
position: right # left or right
display:
archive: true
tag: true
category: true
card_author:
enable: true
description:
button:
enable: true
icon: fab fa-github
text: Follow Me
link: https://github.com/xxxxxx
card_announcement:
enable: true
content: This is my Blog
card_recent_post:
enable: true
limit: 5 # if set 0 will show all
sort: date # date or updated
sort_order: # Don't modify the setting unless you know how it works
card_categories:
enable: true
limit: 8 # if set 0 will show all
expand: none # none/true/false
sort_order: # Don't modify the setting unless you know how it works
card_tags:
enable: true
limit: 40 # if set 0 will show all
color: false
sort_order: # Don't modify the setting unless you know how it works
card_archives:
enable: true
type: monthly # yearly or monthly
format: MMMM YYYY # eg: YYYY年MM月
order: -1 # Sort of order. 1, asc for ascending; -1, desc for descending
limit: 8 # if set 0 will show all
sort_order: # Don't modify the setting unless you know how it works
card_webinfo:
enable: true
post_count: true
last_push_date: true
sort_order: # Don't modify the setting unless you know how it works
# busuanzi count for PV / UV in site
# 訪問人數
busuanzi:
site_uv: true
site_pv: true
page_pv: true
# Time difference between publish date and now (網頁運行時間)
# Formal: Month/Day/Year Time or Year/Month/Day Time
runtimeshow:
enable: false enable: false
publish_date: # source
# 1. fullpage-loading
# 2. pace (progress bar)
source: 1
# pace theme (see https://codebyzach.github.io/pace/)
pace_css_url:
# Aside widget - Newest Comments # wordcount (字數統計)
newest_comments: # see https://butterfly.js.org/posts/ceeb73f/#字數統計
wordcount:
enable: false enable: false
sort_order: # Don't modify the setting unless you know how it works post_wordcount: true
limit: 6 min2read: true
storage: 10 # unit: mins, save data to localStorage total_wordcount: true
avatar: true
# Bottom right button (右下角按鈕)
# --------------------------------------
# Conversion between Traditional and Simplified Chinese (簡繁轉換)
translate:
enable: false
# The text of a button
default:
# the language of website (1 - Traditional Chinese/ 2 - Simplified Chinese
defaultEncoding: 2
# Time delay
translateDelay: 0
# The text of the button when the language is Simplified Chinese
msgToTraditionalChinese: '繁'
# The text of the button when the language is Traditional Chinese
msgToSimplifiedChinese: '簡'
# Read Mode (閲讀模式)
readmode: true
# dark mode
darkmode:
enable: true
# Toggle Button to switch dark/light mode
button: true
# Switch dark/light mode automatically (自動切換 dark mode和 light mode)
# autoChangeMode: 1 Following System Settings, if the system doesn't support dark mode, it will switch dark mode between 6 pm to 6 am
# autoChangeMode: 2 Switch dark mode between 6 pm to 6 am
# autoChangeMode: false
autoChangeMode: false
# Don't modify the following settings unless you know how they work (非必要請不要修改 )
# Choose: readmode,translate,darkmode,hideAside,toc,chat,comment
# Don't repeat 不要重複
rightside_item_order:
enable: false
hide: # readmode,translate,darkmode,hideAside
show: # toc,chat,comment
# Lightbox (圖片大圖查看模式) # Lightbox (圖片大圖查看模式)
# -------------------------------------- # --------------------------------------
@@ -759,12 +785,18 @@ rightside_item_order:
medium_zoom: false medium_zoom: false
# fancybox # fancybox
# http://fancyapps.com/fancybox/3/ # https://fancyapps.com/fancybox/
fancybox: true fancybox: true
# Tag Plugins settings (標籤外掛) # Tag Plugins settings (標籤外掛)
# -------------------------------------- # --------------------------------------
# abcjs (樂譜渲染)
# See https://github.com/paulrosen/abcjs
abcjs:
enable: false
per_page: true
# mermaid # mermaid
# see https://github.com/mermaid-js/mermaid # see https://github.com/mermaid-js/mermaid
mermaid: mermaid:
@@ -846,7 +878,16 @@ lazyload:
# Open graph meta tags # Open graph meta tags
# https://developers.facebook.com/docs/sharing/webmasters/ # 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 # Add the vendor prefixes to ensure compatibility
css_prefix: true css_prefix: true
@@ -874,7 +915,7 @@ CDN:
# when set it to local, you need to install hexo-butterfly-extjs # when set it to local, you need to install hexo-butterfly-extjs
third_party_provider: jsdelivr third_party_provider: jsdelivr
# Add version number to CDN, true or false # Add version number to url, true or false
version: false version: false
# Custom format # Custom format
@@ -888,8 +929,10 @@ CDN:
# translate: # translate:
# local_search: # local_search:
# algolia_js: # algolia_js:
# algolia_search_v4: # algolia_search:
# instantsearch_v4: # instantsearch:
# docsearch_js:
# docsearch_css:
# pjax: # pjax:
# gitalk: # gitalk:
# gitalk_css: # gitalk_css:
@@ -900,6 +943,7 @@ CDN:
# twikoo: # twikoo:
# waline_js: # waline_js:
# waline_css: # waline_css:
# giscus:
# sharejs: # sharejs:
# sharejs_css: # sharejs_css:
# mathjax: # mathjax:
@@ -913,8 +957,8 @@ CDN:
# instantpage: # instantpage:
# typed: # typed:
# pangu: # pangu:
# fancybox_css_v4: # fancybox_css:
# fancybox_v4: # fancybox:
# medium_zoom: # medium_zoom:
# snackbar_css: # snackbar_css:
# snackbar: # snackbar:
@@ -922,7 +966,7 @@ CDN:
# fireworks: # fireworks:
# click_heart: # click_heart:
# ClickShowText: # ClickShowText:
# fontawesomeV6: # fontawesome:
# flickr_justified_gallery_js: # flickr_justified_gallery_js:
# flickr_justified_gallery_css: # flickr_justified_gallery_css:
# aplayer_css: # aplayer_css:
@@ -933,3 +977,5 @@ CDN:
# prismjs_autoloader: # prismjs_autoloader:
# artalk_js: # artalk_js:
# artalk_css: # artalk_css:
# busuanzi:
# abcjs_basic_js:

View File

@@ -45,6 +45,7 @@ search:
local_search: local_search:
input_placeholder: Search for Posts input_placeholder: Search for Posts
hits_empty: "We didn't find any results for the search: ${query}" hits_empty: "We didn't find any results for the search: ${query}"
hits_stats: '${hits} results found'
pagination: pagination:
prev: Previous Post prev: Previous Post
@@ -117,5 +118,6 @@ Snackbar:
night_to_day: Light Mode Activated Manually night_to_day: Light Mode Activated Manually
loading: Loading... loading: Loading...
load_more: Load More
error404: Page not found error404: Page not found

View File

@@ -45,6 +45,7 @@ search:
local_search: local_search:
input_placeholder: Search for Posts input_placeholder: Search for Posts
hits_empty: "We didn't find any results for the search: ${query}" hits_empty: "We didn't find any results for the search: ${query}"
hits_stats: '${hits} results found'
pagination: pagination:
prev: Previous Post prev: Previous Post
@@ -117,5 +118,6 @@ Snackbar:
night_to_day: Light Mode Activated Manually night_to_day: Light Mode Activated Manually
loading: Loading... loading: Loading...
load_more: Load More
error404: Page not found error404: Page not found

View File

@@ -46,6 +46,7 @@ search:
local_search: local_search:
input_placeholder: 搜索文章 input_placeholder: 搜索文章
hits_empty: '找不到您查询的内容:${query}' hits_empty: '找不到您查询的内容:${query}'
hits_stats: '共找到 ${hits} 篇文章'
pagination: pagination:
prev: 上一篇 prev: 上一篇
@@ -118,5 +119,6 @@ Snackbar:
night_to_day: 你已切换为浅色模式 night_to_day: 你已切换为浅色模式
loading: 加载中... loading: 加载中...
load_more: 加载更多
error404: 页面没有找到 error404: 页面没有找到

View File

@@ -46,6 +46,7 @@ search:
local_search: local_search:
input_placeholder: 搜尋文章 input_placeholder: 搜尋文章
hits_empty: '找不到您查詢的內容:${query}' hits_empty: '找不到您查詢的內容:${query}'
hits_stats: '共找到 ${hits} 篇文章'
pagination: pagination:
prev: 上一篇 prev: 上一篇
@@ -118,5 +119,6 @@ Snackbar:
night_to_day: 你已切換為淺色模式 night_to_day: 你已切換為淺色模式
loading: 載入中... loading: 載入中...
load_more: 載入更多
error404: 頁面沒有找到 error404: 頁面沒有找到

View File

@@ -8,7 +8,7 @@ div
if theme.medium_zoom if theme.medium_zoom
script(src=url_for(theme.asset.medium_zoom)) script(src=url_for(theme.asset.medium_zoom))
else if theme.fancybox else if theme.fancybox
script(src=url_for(theme.asset.fancybox_v4)) script(src=url_for(theme.asset.fancybox))
if theme.instantpage if theme.instantpage
script(src=url_for(theme.asset.instantpage), type='module') script(src=url_for(theme.asset.instantpage), type='module')
@@ -22,17 +22,6 @@ div
if theme.pangu.enable if theme.pangu.enable
!= partial("includes/third-party/pangu.pug", {}, { cache: true }) != partial("includes/third-party/pangu.pug", {}, { cache: true })
//- search
if theme.algolia_search.enable
script(src=url_for(theme.asset.algolia_search_v4))
script(src=url_for(theme.asset.instantsearch_v4))
script(src=url_for(theme.asset.algolia_js))
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 .js-pjax
if needLoadCountJs if needLoadCountJs
!= partial("includes/third-party/card-post-count/index", {}, { cache: true }) != partial("includes/third-party/card-post-count/index", {}, { cache: true })
@@ -42,6 +31,8 @@ div
include ./third-party/math/index.pug include ./third-party/math/index.pug
include ./third-party/abcjs/index.pug
if commentsJsLoad if commentsJsLoad
include ./third-party/comments/js.pug include ./third-party/comments/js.pug
@@ -69,4 +60,6 @@ div
!= partial("includes/third-party/pjax", {}, { cache: true }) != partial("includes/third-party/pjax", {}, { cache: true })
if theme.busuanzi.site_uv || theme.busuanzi.site_pv || theme.busuanzi.page_pv 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')
!=partial('includes/third-party/search/index', {}, {cache: true})

View File

@@ -7,11 +7,6 @@
- var isSubtitle = config.subtitle ? ' - ' + config.subtitle : '' - var isSubtitle = config.subtitle ? ' - ' + config.subtitle : ''
- var tabTitle = is_home() || !pageTitle ? config.title + isSubtitle : pageTitle + ' | ' + config.title - 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 pageAuthor = config.email ? config.author + ',' + config.email : config.author
- var pageCopyright = config.copyright || 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' - var themeColorLight = theme.theme_color && theme.theme_color.enable && theme.theme_color.meta_theme_color_light || '#ffffff'
@@ -20,10 +15,8 @@
meta(charset='UTF-8') meta(charset='UTF-8')
meta(http-equiv="X-UA-Compatible" content="IE=edge") 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,viewport-fit=cover")
title= tabTitle title= tabTitle
if pageKeywords
meta(name="keywords" content=pageKeywords)
meta(name="author" content=pageAuthor) meta(name="author" content=pageAuthor)
meta(name="copyright" content=pageCopyright) meta(name="copyright" content=pageCopyright)
meta(name ="format-detection" content="telephone=no") meta(name ="format-detection" content="telephone=no")
@@ -33,7 +26,7 @@ meta(name="theme-color" content=themeColor)
include ./head/Open_Graph.pug include ./head/Open_Graph.pug
!=favicon_tag(theme.favicon || config.favicon) !=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}) !=partial('includes/head/preconnect', {}, {cache: true})
@@ -47,13 +40,13 @@ if (theme.pwa && theme.pwa.enable)
//- main css //- main css
link(rel='stylesheet', href=url_for(theme.asset.main_css)) link(rel='stylesheet', href=url_for(theme.asset.main_css))
link(rel='stylesheet', href=url_for(theme.asset.fontawesomeV6) media="print" onload="this.media='all'") link(rel='stylesheet', href=url_for(theme.asset.fontawesome) media="print" onload="this.media='all'")
if (theme.snackbar && theme.snackbar.enable) if (theme.snackbar && theme.snackbar.enable)
link(rel='stylesheet', href=url_for(theme.asset.snackbar_css) media="print" onload="this.media='all'") link(rel='stylesheet', href=url_for(theme.asset.snackbar_css) media="print" onload="this.media='all'")
if theme.fancybox if theme.fancybox
link(rel='stylesheet' href=url_for(theme.asset.fancybox_css_v4) media="print" onload="this.media='all'") link(rel='stylesheet' href=url_for(theme.asset.fancybox_css) media="print" onload="this.media='all'")
//- google_adsense //- google_adsense
!=partial('includes/head/google_adsense', {}, {cache: true}) !=partial('includes/head/google_adsense', {}, {cache: true})

View File

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

View File

@@ -16,9 +16,6 @@ if theme.google_analytics
gtag('js', new Date()); gtag('js', new Date());
gtag('config', '!{theme.google_analytics}'); 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 if theme.cloudflare_analytics
script(defer data-pjax src='https://static.cloudflareinsights.com/beacon.min.js' data-cf-beacon=`{"token": "${theme.cloudflare_analytics}"}`) script(defer data-pjax src='https://static.cloudflareinsights.com/beacon.min.js' data-cf-beacon=`{"token": "${theme.cloudflare_analytics}"}`)

View File

@@ -21,9 +21,12 @@
localSearch = JSON.stringify({ localSearch = JSON.stringify({
path: theme.local_search.CDN ? theme.local_search.CDN : config.root + config.search.path, path: theme.local_search.CDN ? theme.local_search.CDN : config.root + config.search.path,
preload: theme.local_search.preload, preload: theme.local_search.preload,
top_n_per_article: theme.local_search.top_n_per_article,
unescape: theme.local_search.unescape,
languages: { languages: {
// search languages // search languages
hits_empty: _p("search.local_search.hits_empty"), hits_empty: _p("search.local_search.hits_empty"),
hits_stats: _p("search.local_search.hits_stats"),
} }
}) })
} }
@@ -102,7 +105,7 @@ script.
post: !{theme.post_meta.post.date_format === 'relative'} post: !{theme.post_meta.post.date_format === 'relative'}
}, },
runtime: '!{theme.runtimeshow.enable ? _p("aside.card_webinfo.runtime.unit") : ""}', runtime: '!{theme.runtimeshow.enable ? _p("aside.card_webinfo.runtime.unit") : ""}',
date_suffix: { dateSuffix: {
just: '!{_p("date_suffix.just")}', just: '!{_p("date_suffix.just")}',
min: '!{_p("date_suffix.min")}', min: '!{_p("date_suffix.min")}',
hour: '!{_p("date_suffix.hour")}', hour: '!{_p("date_suffix.hour")}',
@@ -120,5 +123,10 @@ script.
}, },
isPhotoFigcaption: !{theme.photofigcaption}, isPhotoFigcaption: !{theme.photofigcaption},
islazyload: !{theme.lazyload.enable}, islazyload: !{theme.lazyload.enable},
isAnchor: !{theme.anchor} isAnchor: !{theme.anchor.auto_update || false},
percent: {
toc: !{theme.toc.scroll_percent},
rightside: !{theme.rightside_scroll_percent},
},
autoDarkmode: !{theme.darkmode.enable && theme.darkmode.autoChangeMode === 1}
} }

View File

@@ -6,9 +6,6 @@ if theme.google_analytics
if theme.baidu_analytics if theme.baidu_analytics
link(rel="preconnect" href="//hm.baidu.com") link(rel="preconnect" href="//hm.baidu.com")
if theme.cnzz_analytics
link(rel="preconnect" href="//s4.cnzz.com")
if theme.cloudflare_analytics if theme.cloudflare_analytics
link(rel="preconnect" href="//static.cloudflareinsights.com") 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 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='') 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") link(rel="preconnect" href="//busuanzi.ibruce.info")

View File

@@ -1,6 +1,6 @@
if !theme.disable_top_img && page.top_img !== false if !theme.disable_top_img && page.top_img !== false
if is_post() 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() else if is_page()
- var top_img = page.top_img || theme.default_top_img - var top_img = page.top_img || theme.default_top_img
else if is_tag() else if is_tag()
@@ -17,7 +17,7 @@ if !theme.disable_top_img && page.top_img !== false
- var top_img = page.top_img || theme.default_top_img - var top_img = page.top_img || theme.default_top_img
if top_img !== false 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 bg_img = top_img ? imgSource : ''
- var site_title = 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' - var isHomeClass = is_home() ? 'full_page' : 'not-home-page'
@@ -28,7 +28,9 @@ else
- var top_img = false - var top_img = false
- var isHomeClass = 'not-top-img' - 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}) !=partial('includes/header/nav', {}, {cache: true})
if top_img !== false if top_img !== false
if is_post() if is_post()

View File

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

View File

@@ -1,4 +1,4 @@
each url, icon in theme.social each url, icon in theme.social
a.social-icon(href=url_for(trim(url.split('||')[0])) target="_blank" a.social-icon(href=url_for(trim(url.split('||')[0])) target="_blank"
title=url.split('||')[1] === undefined ? '' : trim(url.split('||')[1])) title=url.split('||')[1] === undefined ? '' : trim(url.split('||')[1]))
i(class=icon) i(class=icon style=url.split('||')[2] === undefined ? '' : `color: ${trim(url.split('||')[2]).replace(/[\'\"]/g, '')};`)

View File

@@ -8,8 +8,8 @@ html(lang=config.language data-theme=theme.display_mode class=htmlClassHideAside
head head
include ./head.pug include ./head.pug
body body
if theme.preloader if theme.preloader.enable
!=partial('includes/loading/loading', {}, {cache: true}) !=partial('includes/loading/index', {}, {cache: true})
if theme.background if theme.background
#web_bg #web_bg
@@ -33,7 +33,7 @@ html(lang=config.language data-theme=theme.display_mode class=htmlClassHideAside
if (footerBg === true) if (footerBg === true)
- var footer_bg = bg_img - var footer_bg = bg_img
else 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 else
- var footer_bg = '' - var footer_bg = ''
@@ -44,5 +44,4 @@ html(lang=config.language data-theme=theme.display_mode class=htmlClassHideAside
include ./404.pug include ./404.pug
include ./rightside.pug include ./rightside.pug
!=partial('includes/third-party/search/index', {}, {cache: true})
include ./additional-js.pug include ./additional-js.pug

View File

@@ -0,0 +1,29 @@
#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 = '';
document.getElementById('loading-box').classList.add("loaded")
},
initLoading: () => {
document.body.style.overflow = 'hidden';
document.getElementById('loading-box').classList.remove("loaded")
}
}
preloader.initLoading()
window.addEventListener('load',()=> { preloader.endLoading() })
if (!{theme.pjax && theme.pjax.enable}) {
document.addEventListener('pjax:send', () => { preloader.initLoading() })
document.addEventListener('pjax:complete', () => { preloader.endLoading() })
}

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,11 @@
script.
window.paceOptions = {
restartOnPushState: false
}
document.addEventListener('pjax:send', () => {
Pace.restart()
})
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) .article-sort-item(class=no_cover)
if article.cover && theme.cover.archives_enable if article.cover && theme.cover.archives_enable
a.article-sort-item-img(href=url_for(article.path) title=title) 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-info
.article-sort-item-time .article-sort-item-time
i.far.fa-calendar-alt i.far.fa-calendar-alt

View File

@@ -14,7 +14,10 @@ mixin postUI(posts)
if post_cover && theme.cover.index_enable if post_cover && theme.cover.index_enable
.post_cover(class=leftOrRight) .post_cover(class=leftOrRight)
a(href=url_for(link) title=title) 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) .recent-post-info(class=no_cover)
a.article-title(href=url_for(link) title=title)= title a.article-title(href=url_for(link) title=title)= title
.article-meta-wrap .article-meta-wrap

View File

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

View File

@@ -1,2 +1,2 @@
.tag-cloud-list.is-center .tag-cloud-list.is-center
!=cloudTags({source: site.tags, minfontsize: 1.2, maxfontsize: 2.1, limit: 0, unit: 'em'}) !=cloudTags({source: site.tags, orderby: page.orderby || 'random', order: page.order || 1, minfontsize: 1.2, maxfontsize: 2.1, limit: 0, unit: 'em'})

View File

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

View File

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

View File

@@ -0,0 +1,15 @@
script.
(() => {
function abcjsInit() {
function abcjsFn() {
for (let abcContainer of document.getElementsByClassName("abc-music-sheet")) {
ABCJS.renderAbc(abcContainer, abcContainer.innerHTML, {responsive: 'resize'})
}
}
typeof ABCJS === 'object' ? abcjsFn()
: getScript('!{url_for(theme.asset.abcjs_basic_js)}').then(abcjsFn)
}
window.pjax ? abcjsInit() : document.addEventListener('DOMContentLoaded', abcjsInit)
})()

View File

@@ -0,0 +1,6 @@
if theme.abcjs && theme.abcjs.enable
if theme.abcjs.per_page
if is_post() || is_page()
include ./abcjs.pug
else if page.abcjs
include ./abcjs.pug

View File

@@ -4,7 +4,7 @@ script.
(() => { (() => {
const getArtalkCount = () => { const getArtalkCount = () => {
const runWidget = () => { const runWidget = () => {
Artalk.LoadCountWidget({ Artalk.loadCountWidget({
server: '!{server}', server: '!{server}',
site: '!{site}', site: '!{site}',
countEl: '.artalk-count' countEl: '.artalk-count'

View File

@@ -1,4 +1,4 @@
- const fbSDKVer = 'v14.0' - const fbSDKVer = 'v16.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}` - 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. script.

View File

@@ -18,7 +18,7 @@ script.
includeReply: false includeReply: false
}).then(function (res) { }).then(function (res) {
document.querySelectorAll('#recent-posts .twikoo-count').forEach((item,index) => { document.querySelectorAll('#recent-posts .twikoo-count').forEach((item,index) => {
item.innerText = res[index].count item.textContent = res[index].count
}) })
}).catch(function (err) { }).catch(function (err) {
console.log(err) console.log(err)

View File

@@ -10,7 +10,7 @@ script.
const waline = Waline.init(initData) 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) else getScript('!{url_for(theme.asset.waline_js)}').then(initWaline)
} }

View File

@@ -1,43 +0,0 @@
if theme.chat_btn
script.
((window.gitter = {}).chat = {}).options = {
disableDefaultChat: true,
};
document.addEventListener('gitter-sidecar-ready', (e) => {
const GitterChat = e.detail.Chat
let chat
function initGitter () {
chat = new GitterChat({
room: '#{theme.gitter.room}',
activationElement: '#chat_btn'
});
}
initGitter()
if (!{theme.pjax.enable}) {
document.addEventListener('pjax:complete', () => {
chat.destroy()
initGitter()
})
}
})
else
script.
((window.gitter = {}).chat = {}).options = {
room: '#{theme.gitter.room}',
};
if (!{theme.chat_hide_show}) {
function chatBtnHide () {
document.getElementsByClassName('gitter-open-chat-button')[0].style.display= 'none'
}
function chatBtnShow () {
document.getElementsByClassName('gitter-open-chat-button')[0].style.display= 'block'
}
}
script(src="https://sidecar.gitter.im/dist/sidecar.v1.js" async defer)

View File

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

View File

@@ -9,7 +9,7 @@ script.
window.fbAsyncInit = function() { window.fbAsyncInit = function() {
FB.init({ FB.init({
xfbml: true, xfbml: true,
version: 'v14.0' version: 'v16.0'
}); });
}; };

View File

@@ -1,13 +1,6 @@
- const { server, site, option } = theme.artalk - const { server, site, option } = theme.artalk
script. script.
function addArtalkSource () {
const ele = document.createElement('link')
ele.rel = 'stylesheet'
ele.href= '!{theme.asset.artalk_css}'
document.getElementsByTagName('head')[0].appendChild(ele)
}
function loadArtalk () { function loadArtalk () {
function initArtalk () { function initArtalk () {
window.artalkItem = new Artalk(Object.assign({ window.artalkItem = new Artalk(Object.assign({
@@ -18,22 +11,35 @@ script.
darkMode: document.documentElement.getAttribute('data-theme') === 'dark', darkMode: document.documentElement.getAttribute('data-theme') === 'dark',
countEl: '.artalk-count' countEl: '.artalk-count'
},!{JSON.stringify(option)})) },!{JSON.stringify(option)}))
if (GLOBAL_CONFIG.lightbox === 'null') return
window.artalkItem.use(ctx => {
ctx.on('list-loaded', () => {
ctx.getCommentList().forEach(comment => {
const $content = comment.getRender().$content
btf.loadLightbox($content.querySelectorAll('img:not([atk-emoticon])'))
})
})
})
} }
if (typeof window.artalkItem === 'object') setTimeout(()=>{initArtalk()},200) if (typeof window.artalkItem === 'object') setTimeout(()=>{initArtalk()},200)
else { else {
addArtalkSource() getCSS('!{theme.asset.artalk_css}').then(()=>{
typeof Artalk !== 'function' ? getScript('!{theme.asset.artalk_js}').then(initArtalk) typeof Artalk !== 'function' ? getScript('!{theme.asset.artalk_js}').then(initArtalk)
: setTimeout(()=>{initArtalk()},200) : setTimeout(()=>{initArtalk()},200)
})
} }
} }
document.getElementById('darkmode').addEventListener('click',()=> { function artalkChangeMode (theme) {
if (typeof window.artalkItem !== 'object') return const artalkWrap = document.getElementById('artalk-wrap')
let isDark = document.documentElement.getAttribute('data-theme') === 'dark' if (!(artalkWrap && artalkWrap.children.length)) return
window.artalkItem.setDarkMode(!isDark) const isDark = theme === 'dark'
}) window.artalkItem.setDarkMode(isDark)
}
btf.addModeChange('artalk', artalkChangeMode)
if ('!{theme.comments.use[0]}' === 'Artalk' || !!{theme.comments.lazyload}) { if ('!{theme.comments.use[0]}' === 'Artalk' || !!{theme.comments.lazyload}) {
if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('artalk-wrap'), loadArtalk) if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('artalk-wrap'), loadArtalk)

View File

@@ -2,19 +2,21 @@
script. script.
function loadDisqus () { function loadDisqus () {
var disqus_config = function () { const disqus_config = function () {
this.page.url = '!{ page.permalink }' this.page.url = '!{ page.permalink }'
this.page.identifier = '!{ url_for(page.path) }' this.page.identifier = '!{ url_for(page.path) }'
this.page.title = '!{ disqusPageTitle }' this.page.title = '!{ disqusPageTitle }'
}; }
window.disqusReset = () => { const disqusReset = () => {
DISQUS.reset({ DISQUS.reset({
reload: true, reload: true,
config: disqus_config config: disqus_config
}) })
} }
btf.addModeChange('disqus', disqusReset)
if (window.DISQUS) disqusReset() if (window.DISQUS) disqusReset()
else { else {
(function() { (function() {
@@ -24,10 +26,6 @@ script.
(d.head || d.body).appendChild(s); (d.head || d.body).appendChild(s);
})(); })();
} }
document.getElementById('darkmode').addEventListener('click', () => {
setTimeout(() => window.disqusReset(), 200)
})
} }
if ('!{theme.comments.use[0]}' === 'Disqus' || !!{theme.comments.lazyload}) { if ('!{theme.comments.use[0]}' === 'Disqus' || !!{theme.comments.lazyload}) {

View File

@@ -2,13 +2,6 @@
script. script.
function loadDisqusjs () { 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 () { function initDisqusjs () {
window.disqusjs = null window.disqusjs = null
disqusjs = new DisqusJS(Object.assign({ disqusjs = new DisqusJS(Object.assign({
@@ -30,11 +23,11 @@ script.
} }
document.getElementById('darkmode').addEventListener('click', themeChange) btf.addModeChange('disqusjs', themeChange)
if (window.disqusJsLoad) initDisqusjs() if (window.disqusJsLoad) initDisqusjs()
else { else {
addDisqusjsCSS() getCSS('!{url_for(theme.asset.disqusjs_css)}')
getScript('!{url_for(theme.asset.disqusjs)}').then(initDisqusjs) getScript('!{url_for(theme.asset.disqusjs)}').then(initDisqusjs)
window.disqusJsLoad = true window.disqusJsLoad = true
} }

View File

@@ -1,4 +1,4 @@
- const fbSDKVer = 'v14.0' - const fbSDKVer = 'v16.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}` - 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. script.
@@ -25,6 +25,16 @@ script.
} }
} }
function fbModeChange (theme) {
const $fbComment = document.getElementsByClassName('fb-comments')[0]
if ($fbComment && typeof FB === 'object') {
$fbComment.setAttribute('data-colorscheme',theme)
FB.XFBML.parse(document.getElementById('post-comment'))
}
}
btf.addModeChange('facebook_comments', fbModeChange)
if ('!{theme.comments.use[0]}' === 'Facebook Comments' || !!{theme.comments.lazyload}) { if ('!{theme.comments.use[0]}' === 'Facebook Comments' || !!{theme.comments.lazyload}) {
if (!{theme.comments.lazyload}) btf.loadComment(document.querySelector('#post-comment .fb-comments'), loadFBComment) if (!{theme.comments.lazyload}) btf.loadComment(document.querySelector('#post-comment .fb-comments'), loadFBComment)
else loadFBComment() else loadFBComment()

View File

@@ -1,16 +1,20 @@
- const { repo, repo_id, category_id, option } = theme.giscus - const { repo, repo_id, category_id, theme:themes, option } = theme.giscus
- const themes = theme.giscus.theme - const giscusUrl = theme.asset.giscus || 'https://giscus.app/client.js'
script. - const giscusOriginUrl = new URL(giscusUrl).origin
function loadGiscus () {
let nowTheme = document.documentElement.getAttribute('data-theme') === 'dark' ? '!{themes.dark}' : '!{themes.light}'
script.
function getGiscusTheme (theme) {
return theme === 'dark' ? '!{themes.dark}' : '!{themes.light}'
}
function loadGiscus () {
const config = Object.assign({ const config = Object.assign({
src: 'https://giscus.app/client.js', src: '!{giscusUrl}',
'data-repo': '!{repo}', 'data-repo': '!{repo}',
'data-repo-id': '!{repo_id}', 'data-repo-id': '!{repo_id}',
'data-category-id': '!{category_id}', 'data-category-id': '!{category_id}',
'data-mapping': 'pathname', 'data-mapping': 'pathname',
'data-theme': nowTheme, 'data-theme': getGiscusTheme(document.documentElement.getAttribute('data-theme')),
'data-reactions-enabled': '1', 'data-reactions-enabled': '1',
crossorigin: 'anonymous', crossorigin: 'anonymous',
async: true async: true
@@ -23,22 +27,22 @@ script.
document.getElementById('giscus-wrap').insertAdjacentElement('afterbegin',ele) document.getElementById('giscus-wrap').insertAdjacentElement('afterbegin',ele)
} }
function changeGiscusTheme () { function changeGiscusTheme (theme) {
const theme = document.documentElement.getAttribute('data-theme') === 'dark' ? '!{themes.dark}' : '!{themes.light}'
function sendMessage(message) { function sendMessage(message) {
const iframe = document.querySelector('iframe.giscus-frame'); const iframe = document.querySelector('iframe.giscus-frame')
if (!iframe) return; if (!iframe) return
iframe.contentWindow.postMessage({ giscus: message }, 'https://giscus.app'); iframe.contentWindow.postMessage({ giscus: message }, '!{giscusOriginUrl}')
} }
sendMessage({ sendMessage({
setConfig: { setConfig: {
theme: theme theme: getGiscusTheme(theme)
} }
}); });
} }
btf.addModeChange('giscus', changeGiscusTheme)
if ('!{theme.comments.use[0]}' === 'Giscus' || !!{theme.comments.lazyload}) { if ('!{theme.comments.use[0]}' === 'Giscus' || !!{theme.comments.lazyload}) {
if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('giscus-wrap'), loadGiscus) if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('giscus-wrap'), loadGiscus)
else loadGiscus() else loadGiscus()

View File

@@ -1,11 +1,4 @@
script. 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 loadGitalk () {
function initGitalk () { function initGitalk () {
var gitalk = new Gitalk(Object.assign({ var gitalk = new Gitalk(Object.assign({
@@ -23,7 +16,7 @@ script.
if (typeof Gitalk === 'function') initGitalk() if (typeof Gitalk === 'function') initGitalk()
else { else {
addGitalkSource() getCSS('!{url_for(theme.asset.gitalk_css)}')
getScript('!{url_for(theme.asset.gitalk)}').then(initGitalk) getScript('!{url_for(theme.asset.gitalk)}').then(initGitalk)
} }
} }
@@ -31,7 +24,7 @@ script.
function commentCount(n){ function commentCount(n){
let isCommentCount = document.querySelector('#post-meta .gitalk-comment-count') let isCommentCount = document.querySelector('#post-meta .gitalk-comment-count')
if (isCommentCount) { if (isCommentCount) {
isCommentCount.innerHTML= n isCommentCount.textContent= n
} }
} }

View File

@@ -51,11 +51,12 @@ script.
} }
} }
document.getElementById('darkmode').addEventListener('click',()=>{ function remarkChangeMode (theme) {
if (!window.REMARK42) return if (!window.REMARK42) return
let theme = document.documentElement.getAttribute('data-theme') === 'dark' ? 'light' : 'dark'
window.REMARK42.changeTheme(theme) window.REMARK42.changeTheme(theme)
}) }
btf.addModeChange('remark42', remarkChangeMode)
if ('!{theme.comments.use[0]}' === 'Remark42' || !!{theme.comments.lazyload}) { if ('!{theme.comments.use[0]}' === 'Remark42' || !!{theme.comments.lazyload}) {
if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('remark42'), loadRemark42) if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('remark42'), loadRemark42)

View File

@@ -23,7 +23,7 @@ script.
urls: [window.location.pathname], urls: [window.location.pathname],
includeReply: false includeReply: false
}).then(function (res) { }).then(function (res) {
countELement.innerText = res[0].count countELement.textContent = res[0].count
}).catch(function (err) { }).catch(function (err) {
console.error(err); console.error(err);
}); });

View File

@@ -12,10 +12,10 @@ script.
document.getElementById('utterances-wrap').insertAdjacentElement('afterbegin',ele) document.getElementById('utterances-wrap').insertAdjacentElement('afterbegin',ele)
} }
function utterancesTheme () { function utterancesTheme (theme) {
const iframe = document.querySelector('.utterances-frame') const iframe = document.querySelector('.utterances-frame')
if (iframe) { if (iframe) {
const theme = document.documentElement.getAttribute('data-theme') === 'dark' ? '#{theme.utterances.dark_theme}' : '#{theme.utterances.light_theme}' const theme = theme === 'dark' ? '#{theme.utterances.dark_theme}' : '#{theme.utterances.light_theme}'
const message = { const message = {
type: 'set-theme', type: 'set-theme',
theme: theme theme: theme
@@ -24,6 +24,8 @@ script.
} }
} }
btf.addModeChange('utterances', utterancesTheme)
if ('!{theme.comments.use[0]}' === 'Utterances' || !!{theme.comments.lazyload}) { if ('!{theme.comments.use[0]}' === 'Utterances' || !!{theme.comments.lazyload}) {
if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('utterances-wrap'), loadUtterances) if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('utterances-wrap'), loadUtterances)
else loadUtterances() else loadUtterances()

View File

@@ -3,13 +3,6 @@
script. script.
function loadWaline () { 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 () { function initWaline () {
const waline = Waline.init(Object.assign({ const waline = Waline.init(Object.assign({
el: '#waline-wrap', el: '#waline-wrap',
@@ -21,10 +14,15 @@ script.
}, !{JSON.stringify(option)})) }, !{JSON.stringify(option)}))
} }
if (typeof Waline === 'function') initWaline() const walineCSSLoad = document.getElementById('waline-css')
if (typeof Waline === 'object') {
walineCSSLoad ? initWaline() : getCSS('!{url_for(theme.asset.waline_css)}','waline-css').then(initWaline)
}
else { else {
insertCSS() getCSS('!{url_for(theme.asset.waline_css)}','waline-css').then(() => {
getScript('!{url_for(theme.asset.waline_js)}').then(initWaline) getScript('!{url_for(theme.asset.waline_js)}').then(initWaline)
})
} }
} }

View File

@@ -7,7 +7,7 @@ script.
tags: 'ams' tags: 'ams'
}, },
chtml: { chtml: {
scale: 1.2 scale: 1.1
}, },
options: { options: {
renderActions: { renderActions: {
@@ -23,12 +23,11 @@ script.
} }
}, ''], }, ''],
insertScript: [200, () => { insertScript: [200, () => {
document.querySelectorAll('mjx-container:not\([display]\)').forEach(node => { document.querySelectorAll('mjx-container').forEach(node => {
const target = node.parentNode if (node.hasAttribute('display')) {
if (target.nodeName.toLowerCase() === 'li') { btf.wrap(node, 'div', { class: 'mathjax-overflow' })
target.parentNode.classList.add('has-jax')
} else { } else {
target.classList.add('has-jax') btf.wrap(node, 'span', { class: 'mathjax-overflow' })
} }
}); });
}, '', false] }, '', false]
@@ -44,5 +43,5 @@ script.
} else { } else {
MathJax.startup.document.state(0) MathJax.startup.document.state(0)
MathJax.texReset() MathJax.texReset()
MathJax.typeset() MathJax.typesetPromise()
} }

View File

@@ -21,6 +21,10 @@ script.
window.loadMermaid ? runMermaid() : getScript('!{url_for(theme.asset.mermaid)}').then(runMermaid) window.loadMermaid ? runMermaid() : getScript('!{url_for(theme.asset.mermaid)}').then(runMermaid)
} }
btf.addModeChange('mermaid', () => {
window.runMermaid()
})
window.pjax ? loadMermaid() : document.addEventListener('DOMContentLoaded', loadMermaid) window.pjax ? loadMermaid() : document.addEventListener('DOMContentLoaded', loadMermaid)
} }
})() })()

View File

@@ -1,6 +1,6 @@
- const { server, option } = theme.artalk - const { server, site, option } = theme.artalk
- const avatarCdn = option !== null && option.gravatar ? option.gravatar.mirror : 'https://sdn.geekzu.org/avatar/' - const avatarCdn = option !== null && option.gravatar && option.gravatar.mirror
- const avatarDefault = option !== null && option.gravatar ? option.gravatar.default : 'mp' - const avatarDefault = option !== null && option.gravatar && option.gravatar.default
script. script.
window.addEventListener('load', () => { window.addEventListener('load', () => {
@@ -45,25 +45,51 @@ script.
window.pjax && window.pjax.refresh($dom) window.pjax && window.pjax.refresh($dom)
} }
const getComment = () => { const getSetting = async () => {
fetch('!{server}/api/stat?type=latest_comments&limit=!{theme.newest_comments.limit}',{method: "POST"}) try {
.then(response => response.json()) const res = await fetch('!{server}/api/conf', { method: 'GET' })
.then(d => { return await res.json()
const artalk = d.data.map(function (e) { } catch (e) {
return { console.log(e)
'avatar': '!{avatarCdn}' + e.email_encrypted + '?d=!{avatarDefault}', }
'content': changeContent(e.content_marked), }
'nick': e.nick,
'url': e.page_url, const headerList = {
'date': e.date, method: 'POST',
} headers: {
}) 'Content-Type': 'application/x-www-form-urlencoded',
saveToLocal.set('artalk-newest-comments', JSON.stringify(artalk), !{theme.newest_comments.storage}/(60*24)) 'Origin': window.location.origin
generateHtml(artalk) },
}).catch(e => { body: new URLSearchParams({
const $dom = document.querySelector('#card-newest-comments .aside-list') 'site_name': '!{site}',
$dom.innerHTML= "!{_p('aside.card_newest_comments.error')}" 'limit': '!{theme.newest_comments.limit}',
'type':'latest_comments'
})
}
const getComment = async () => {
try {
const res = await fetch('!{server}/api/stat', headerList)
const result = await res.json()
const avatarStr = await getSetting()
const avatarCdn = !{avatarCdn} || avatarStr.data.frontend_conf.gravatar.mirror
const avatarDefault = !{avatarDefault} || avatarStr.data.frontend_conf.gravatar.default
const artalk = result.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) {
console.log(e)
const $dom = document.querySelector('#card-newest-comments .aside-list')
$dom.innerHTML= "!{_p('aside.card_newest_comments.error')}"
}
} }
const newestCommentInit = () => { const newestCommentInit = () => {

View File

@@ -32,7 +32,7 @@ script.
generateHtml(disqusArray) generateHtml(disqusArray)
}).catch(e => { }).catch(e => {
const $dom = document.querySelector('#card-newest-comments .aside-list') const $dom = document.querySelector('#card-newest-comments .aside-list')
$dom.innerHTML= "!{_p('aside.card_newest_comments.error')}" $dom.textContent= "!{_p('aside.card_newest_comments.error')}"
}) })
} }

View File

@@ -58,7 +58,7 @@ script.
findTrueUrl(githubArray) findTrueUrl(githubArray)
}).catch(e => { }).catch(e => {
const $dom = document.querySelector('#card-newest-comments .aside-list') const $dom = document.querySelector('#card-newest-comments .aside-list')
$dom.innerHTML= "!{_p('aside.card_newest_comments.error')}" $dom.textContent= "!{_p('aside.card_newest_comments.error')}"
}) })
} }

View File

@@ -60,7 +60,7 @@ script.
generateHtml(remark42) generateHtml(remark42)
}).catch(e => { }).catch(e => {
const $dom = document.querySelector('#card-newest-comments .aside-list') const $dom = document.querySelector('#card-newest-comments .aside-list')
$dom.innerHTML= "!{_p('aside.card_newest_comments.error')}" $dom.textContent= "!{_p('aside.card_newest_comments.error')}"
}) })
} }

View File

@@ -36,7 +36,7 @@ script.
generateHtml(twikooArray) generateHtml(twikooArray)
}).catch(function (err) { }).catch(function (err) {
const $dom = document.querySelector('#card-newest-comments .aside-list') const $dom = document.querySelector('#card-newest-comments .aside-list')
$dom.innerHTML= "!{_p('aside.card_newest_comments.error')}" $dom.textContent= "!{_p('aside.card_newest_comments.error')}"
}) })
} }

View File

@@ -79,7 +79,7 @@ script.
generateHtml(valineArray) generateHtml(valineArray)
}).catch(e => { }).catch(e => {
const $dom = document.querySelector('#card-newest-comments .aside-list') const $dom = document.querySelector('#card-newest-comments .aside-list')
$dom.innerHTML= "!{_p('aside.card_newest_comments.error')}" $dom.textContent= "!{_p('aside.card_newest_comments.error')}"
}) })
} }

View File

@@ -60,11 +60,11 @@ script.
generateHtml(walineArray) generateHtml(walineArray)
}).catch(e => { }).catch(e => {
const $dom = document.querySelector('#card-newest-comments .aside-list') const $dom = document.querySelector('#card-newest-comments .aside-list')
$dom.innerHTML= "!{_p('aside.card_newest_comments.error')}" $dom.textContent= "!{_p('aside.card_newest_comments.error')}"
}) })
} }
if (typeof Waline === 'function') loadWaline() if (typeof Waline === 'object') loadWaline()
else getScript('!{url_for(theme.asset.waline_js)}').then(loadWaline) else getScript('!{url_for(theme.asset.waline_js)}').then(loadWaline)
} }

View File

@@ -7,7 +7,7 @@ if theme.pjax.exclude
- let choose = theme.comments.use - let choose = theme.comments.use
if choose 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"]') - pjaxSelectors.unshift('meta[property="og:image"]', 'meta[property="og:title"]', 'meta[property="og:url"]')
if choose.includes('Utterances') || choose.includes('Giscus') if choose.includes('Utterances') || choose.includes('Giscus')
- pjaxSelectors.unshift('link[rel="canonical"]') - pjaxSelectors.unshift('link[rel="canonical"]')
@@ -30,7 +30,6 @@ script.
window.tocScrollFn && window.removeEventListener('scroll', window.tocScrollFn) window.tocScrollFn && window.removeEventListener('scroll', window.tocScrollFn)
window.scrollCollect && window.removeEventListener('scroll', scrollCollect) window.scrollCollect && window.removeEventListener('scroll', scrollCollect)
typeof preloader === 'object' && preloader.initLoading()
document.getElementById('rightside').style.cssText = "opacity: ''; transform: ''" document.getElementById('rightside').style.cssText = "opacity: ''; transform: ''"
if (window.aplayers) { if (window.aplayers) {
@@ -76,8 +75,6 @@ script.
// prismjs // prismjs
typeof Prism === 'object' && Prism.highlightAll() typeof Prism === 'object' && Prism.highlightAll()
typeof preloader === 'object' && preloader.endLoading()
}) })
document.addEventListener('pjax:error', (e) => { document.addEventListener('pjax:error', (e) => {

View File

@@ -16,3 +16,7 @@
.algolia-poweredBy .algolia-poweredBy
#search-mask #search-mask
script(src=url_for(theme.asset.algolia_search))
script(src=url_for(theme.asset.instantsearch))
script(src=url_for(theme.asset.algolia_js))

View File

@@ -0,0 +1,27 @@
- const { appId, apiKey, indexName, option } = theme.docsearch
.docsearch-wrap
#docsearch(style="display:none")
link(rel="stylesheet" href=url_for(theme.asset.docsearch_css))
script(src=url_for(theme.asset.docsearch_js))
script.
(() => {
docsearch(Object.assign({
appId: '!{appId}',
apiKey: '!{apiKey}',
indexName: '!{indexName}',
container: '#docsearch',
}, !{JSON.stringify(option)}))
const searchClickFn = () => {
document.querySelector('#search-button > .search').addEventListener('click', () => {
document.querySelector('.DocSearch-Button').click()
})
}
searchClickFn()
window.addEventListener('pjax:complete', searchClickFn)
})()

View File

@@ -2,3 +2,5 @@ if theme.algolia_search.enable
include ./algolia.pug include ./algolia.pug
else if theme.local_search.enable else if theme.local_search.enable
include ./local-search.pug include ./local-search.pug
else if theme.docsearch.enable
include ./docsearch.pug

View File

@@ -15,6 +15,8 @@
.local-search-box .local-search-box
input(placeholder=_p("search.local_search.input_placeholder") type="text").local-search-box--input input(placeholder=_p("search.local_search.input_placeholder") type="text").local-search-box--input
hr hr
#local-search-results #local-search-results.no-result
#local-search-stats-wrap
#search-mask #search-mask
script(src=url_for(theme.asset.local_search))

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'") link(rel='stylesheet' href=url_for(theme.asset.sharejs_css) media="print" onload="this.media='all'")
script(src=url_for(theme.asset.sharejs) defer) script(src=url_for(theme.asset.sharejs) defer)

View File

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

View File

@@ -14,7 +14,10 @@ if theme.aside.card_recent_post.enable
.aside-list-item(class=no_cover) .aside-list-item(class=no_cover)
if post_cover && theme.cover.aside_enable if post_cover && theme.cover.aside_enable
a.thumbnail(href=url_for(link) title=title) 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 .content
a.title(href=url_for(link) title=title)= title a.title(href=url_for(link) title=title)= title
if theme.aside.card_recent_post.sort === 'updated' if theme.aside.card_recent_post.sort === 'updated'

View File

@@ -5,8 +5,10 @@ if theme.aside.card_tags.enable
i.fas.fa-tags i.fas.fa-tags
span= _p('aside.card_tags') span= _p('aside.card_tags')
- let tagLimit = theme.aside.card_tags.limit === 0 ? 0 : theme.aside.card_tags.limit || 40 - let { limit, orderby, order } = theme.aside.card_tags
- limit = limit === 0 ? 0 : limit || 40
if theme.aside.card_tags.color if theme.aside.card_tags.color
.card-tag-cloud!= cloudTags({source: site.tags, minfontsize: 1.15, maxfontsize: 1.45, limit: tagLimit, unit: 'em'}) .card-tag-cloud!= cloudTags({source: site.tags, orderby: orderby, order: order, minfontsize: 1.15, maxfontsize: 1.45, limit: limit, unit: 'em'})
else else
.card-tag-cloud!= tagcloud({min_font: 1.1, max_font: 1.5, amount: tagLimit , color: true, start_color: '#999', end_color: '#99a9bf', unit: 'em'}) .card-tag-cloud!= tagcloud({orderby: orderby, order: order, min_font: 1.1, max_font: 1.5, amount: limit , color: true, start_color: '#999', end_color: '#99a9bf', unit: 'em'})

View File

@@ -1,6 +1,6 @@
{ {
"name": "hexo-theme-butterfly", "name": "hexo-theme-butterfly",
"version": "4.4.0", "version": "4.8.5",
"description": "A Simple and Card UI Design theme for Hexo", "description": "A Simple and Card UI Design theme for Hexo",
"main": "package.json", "main": "package.json",
"scripts": { "scripts": {

View File

@@ -1,11 +1,11 @@
algolia_search_v4: algolia_search:
name: algoliasearch name: algoliasearch
file: dist/algoliasearch-lite.umd.js file: dist/algoliasearch-lite.umd.js
version: 4.14.2 version: 4.17.0
instantsearch_v4: instantsearch:
name: instantsearch.js name: instantsearch.js
file: dist/instantsearch.production.min.js file: dist/instantsearch.production.min.js
version: 4.44.0 version: 4.55.0
pjax: pjax:
name: pjax name: pjax
file: pjax.min.js file: pjax.min.js
@@ -13,11 +13,11 @@ pjax:
gitalk: gitalk:
name: gitalk name: gitalk
file: dist/gitalk.min.js file: dist/gitalk.min.js
version: 1.7.2 version: 1.8.0
gitalk_css: gitalk_css:
name: gitalk name: gitalk
file: dist/gitalk.css file: dist/gitalk.css
version: 1.7.2 version: 1.8.0
blueimp_md5: blueimp_md5:
name: blueimp-md5 name: blueimp-md5
file: js/md5.min.js file: js/md5.min.js
@@ -29,25 +29,25 @@ valine:
disqusjs: disqusjs:
name: disqusjs name: disqusjs
file: dist/browser/disqusjs.es2015.umd.min.js file: dist/browser/disqusjs.es2015.umd.min.js
version: 3.0.1 version: 3.0.2
disqusjs_css: disqusjs_css:
name: disqusjs name: disqusjs
file: dist/browser/styles/disqusjs.css file: dist/browser/styles/disqusjs.css
version: 3.0.1 version: 3.0.2
twikoo: twikoo:
name: twikoo name: twikoo
file: dist/twikoo.all.min.js file: dist/twikoo.all.min.js
version: 1.6.5 version: 1.6.16
waline_js: waline_js:
name: '@waline/client' name: '@waline/client'
file: dist/waline.js file: dist/waline.js
other_name: waline other_name: waline
version: 2.6.3 version: 2.15.4
waline_css: waline_css:
name: '@waline/client' name: '@waline/client'
file: dist/waline.css file: dist/waline.css
other_name: waline other_name: waline
version: 2.6.3 version: 2.15.4
sharejs: sharejs:
name: butterfly-extsrc name: butterfly-extsrc
file: sharejs/dist/js/social-share.min.js file: sharejs/dist/js/social-share.min.js
@@ -64,16 +64,16 @@ katex:
name: katex name: katex
file: dist/katex.min.css file: dist/katex.min.css
other_name: KaTeX other_name: KaTeX
version: 0.16.0 version: 0.16.7
katex_copytex: katex_copytex:
name: katex name: katex
file: dist/contrib/copy-tex.min.js file: dist/contrib/copy-tex.min.js
other_name: KaTeX other_name: KaTeX
version: 0.16.0 version: 0.16.7
mermaid: mermaid:
name: mermaid name: mermaid
file: dist/mermaid.min.js file: dist/mermaid.min.js
version: 9.1.5 version: 9.4.3
canvas_ribbon: canvas_ribbon:
name: butterfly-extsrc name: butterfly-extsrc
file: dist/canvas-ribbon.min.js file: dist/canvas-ribbon.min.js
@@ -105,33 +105,33 @@ ClickShowText:
lazyload: lazyload:
name: vanilla-lazyload name: vanilla-lazyload
file: dist/lazyload.iife.min.js file: dist/lazyload.iife.min.js
version: 17.3.1 version: 17.8.3
instantpage: instantpage:
name: instant.page name: instant.page
file: instantpage.js file: instantpage.js
version: 5.1.1 version: 5.2.0
typed: typed:
name: typed.js name: typed.js
file: lib/typed.min.js file: dist/typed.umd.js
version: 2.0.12 version: 2.0.16
pangu: pangu:
name: pangu name: pangu
file: dist/browser/pangu.min.js file: dist/browser/pangu.min.js
version: 4.0.7 version: 4.0.7
fancybox_css_v4: fancybox_css:
name: '@fancyapps/ui' name: '@fancyapps/ui'
file: dist/fancybox.css file: dist/fancybox/fancybox.css
version: 4.0.31 version: 5.0.17
other_name: fancyapps-ui other_name: fancyapps-ui
fancybox_v4: fancybox:
name: '@fancyapps/ui' name: '@fancyapps/ui'
file: dist/fancybox.umd.js file: dist/fancybox/fancybox.umd.js
version: 4.0.31 version: 5.0.17
other_name: fancyapps-ui other_name: fancyapps-ui
medium_zoom: medium_zoom:
name: medium-zoom name: medium-zoom
file: dist/medium-zoom.min.js file: dist/medium-zoom.min.js
version: 1.0.6 version: 1.0.8
snackbar_css: snackbar_css:
name: node-snackbar name: node-snackbar
file: dist/snackbar.min.css file: dist/snackbar.min.css
@@ -140,11 +140,11 @@ snackbar:
name: node-snackbar name: node-snackbar
file: dist/snackbar.min.js file: dist/snackbar.min.js
version: 0.1.16 version: 0.1.16
fontawesomeV6: fontawesome:
name: '@fortawesome/fontawesome-free' name: '@fortawesome/fontawesome-free'
file: css/all.min.css file: css/all.min.css
other_name: font-awesome other_name: font-awesome
version: 6.1.2 version: 6.4.0
flickr_justified_gallery_js: flickr_justified_gallery_js:
name: flickr-justified-gallery name: flickr-justified-gallery
file: dist/fjGallery.min.js file: dist/fjGallery.min.js
@@ -169,22 +169,46 @@ prismjs_js:
name: prismjs name: prismjs
file: prism.js file: prism.js
other_name: prism other_name: prism
version: 1.28.0 version: 1.29.0
prismjs_lineNumber_js: prismjs_lineNumber_js:
name: prismjs name: prismjs
file: plugins/line-numbers/prism-line-numbers.min.js file: plugins/line-numbers/prism-line-numbers.min.js
other_name: prism other_name: prism
version: 1.28.0 version: 1.29.0
prismjs_autoloader: prismjs_autoloader:
name: prismjs name: prismjs
file: plugins/autoloader/prism-autoloader.min.js file: plugins/autoloader/prism-autoloader.min.js
other_name: prism other_name: prism
version: 1.28.0 version: 1.29.0
artalk_js: artalk_js:
name: artalk name: artalk
file: dist/Artalk.js file: dist/Artalk.js
version: 2.3.4 version: 2.5.4
artalk_css: artalk_css:
name: artalk name: artalk
file: dist/Artalk.css file: dist/Artalk.css
version: 2.3.4 version: 2.5.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
docsearch_js:
name: '@docsearch/js'
other_name: docsearch-js
file: dist/umd/index.js
version: 3.3.4
docsearch_css:
name: '@docsearch/css'
other_name: docsearch-css
file: dist/style.css
version: 3.3.4
abcjs_basic_js:
name: abcjs
file: dist/abcjs-basic-min.js
version: 6.2.2

View File

@@ -12,7 +12,7 @@ hexo.extend.filter.register('before_generate', () => {
const themeConfig = hexo.theme.config const themeConfig = hexo.theme.config
const { CDN } = themeConfig const { CDN } = themeConfig
const thirdPartySrc = hexo.render.renderSync({ path: path.join(hexo.theme_dir,'/plugins.yml'), engine: 'yaml'}) const thirdPartySrc = hexo.render.renderSync({ path: path.join(hexo.theme_dir, '/plugins.yml'), engine: 'yaml' })
const internalSrc = { const internalSrc = {
main: { main: {
name: 'hexo-theme-butterfly', name: 'hexo-theme-butterfly',
@@ -41,20 +41,19 @@ hexo.extend.filter.register('before_generate', () => {
} }
} }
const minFile = (file) => { const minFile = file => {
return file.replace(/(?<!\.min)\.(js|css)$/g, ext => '.min' + ext) return file.replace(/(?<!\.min)\.(js|css)$/g, ext => '.min' + ext)
} }
const createCDNLink = (data, type, cond = '') => { const createCDNLink = (data, type, cond = '') => {
Object.keys(data).map(key => { Object.keys(data).forEach(key => {
let { name, version, file, other_name } = data[key] let { name, version, file, other_name } = data[key]
const min_file = minFile(file)
const cdnjs_name = other_name || name const cdnjs_name = other_name || name
const cdnjs_file = file.replace(/^[lib|dist]*\/|browser\//g, '') const cdnjs_file = file.replace(/^[lib|dist]*\/|browser\//g, '')
const min_cdnjs_file = minFile(cdnjs_file) const min_cdnjs_file = minFile(cdnjs_file)
if (cond === 'internal') file = `source/${file}` if (cond === 'internal') file = `source/${file}`
const verType = CDN.version ? `@${version}` : '' const min_file = minFile(file)
const verType = CDN.version ? (type === 'local' ? `?v=${version}` : `@${version}`) : ''
const value = { const value = {
version, version,
@@ -65,8 +64,9 @@ hexo.extend.filter.register('before_generate', () => {
min_cdnjs_file, min_cdnjs_file,
cdnjs_name cdnjs_name
} }
const cdnSource = { const cdnSource = {
local: cond === 'internal' ? cdnjs_file : `/pluginsSrc/${name}/${file}`, local: cond === 'internal' ? `${cdnjs_file + verType}` : `/pluginsSrc/${name}/${file + verType}`,
jsdelivr: `https://cdn.jsdelivr.net/npm/${name}${verType}/${min_file}`, jsdelivr: `https://cdn.jsdelivr.net/npm/${name}${verType}/${min_file}`,
unpkg: `https://unpkg.com/${name}${verType}/${file}`, unpkg: `https://unpkg.com/${name}${verType}/${file}`,
cdnjs: `https://cdnjs.cloudflare.com/ajax/libs/${cdnjs_name}/${version}/${min_cdnjs_file}`, cdnjs: `https://cdnjs.cloudflare.com/ajax/libs/${cdnjs_name}/${version}/${min_cdnjs_file}`,
@@ -76,7 +76,7 @@ hexo.extend.filter.register('before_generate', () => {
data[key] = cdnSource[type] data[key] = cdnSource[type]
}) })
if (cond === 'internal') data['main_css'] = 'css/index.css' if (cond === 'internal') data.main_css = 'css/index.css' + (CDN.version ? `?v=${version}` : '')
return data return data
} }
@@ -89,6 +89,9 @@ hexo.extend.filter.register('before_generate', () => {
return obj return obj
} }
themeConfig.asset = Object.assign(createCDNLink(internalSrc,CDN.internal_provider,'internal'), themeConfig.asset = Object.assign(
createCDNLink(thirdPartySrc,CDN.third_party_provider), deleteNullValue(CDN.option)) createCDNLink(internalSrc, CDN.internal_provider, 'internal'),
createCDNLink(thirdPartySrc, CDN.third_party_provider),
deleteNullValue(CDN.option)
)
}) })

View File

@@ -1,8 +1,7 @@
const logger = require('hexo-log')()
hexo.extend.filter.register('before_generate', () => { hexo.extend.filter.register('before_generate', () => {
// Get first two digits of the Hexo version number // Get first two digits of the Hexo version number
const hexoVer = hexo.version.replace(/(^.*\..*)\..*/, '$1') const hexoVer = hexo.version.replace(/(^.*\..*)\..*/, '$1')
const logger = hexo.log
if (hexoVer < 5.3) { if (hexoVer < 5.3) {
logger.error('Please update Hexo to V5.3.0 or higher!') logger.error('Please update Hexo to V5.3.0 or higher!')
@@ -13,7 +12,9 @@ hexo.extend.filter.register('before_generate', () => {
if (hexo.locals.get) { if (hexo.locals.get) {
const data = hexo.locals.get('data') const data = hexo.locals.get('data')
if (data && data.butterfly) { 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' ") logger.error(" 'butterfly.yml' 已經棄用,請使用 '_config.butterfly.yml' ")
process.exit(-1) process.exit(-1)
} }

View File

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

View File

@@ -6,40 +6,40 @@
'use strict' 'use strict'
hexo.extend.filter.register('before_post_render', function (data) { hexo.extend.filter.register('before_post_render', function (data) {
const { config } = this const imgTestReg = /\.(png|jpe?g|gif|svg|webp)(\?.*)?$/i
if (config.post_asset_folder) { let randomCover
const imgTestReg = /\.(png|jpe?g|gif|svg|webp)(\?.*)?$/ 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 topImg = data.top_img
const cover = data.cover
if (topImg && topImg.indexOf('/') === -1 && imgTestReg.test(topImg)) data.top_img = data.path + topImg 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) { const randomCoverFn = () => {
data.randomcover = randomCover() const theme = hexo.theme.config
return data 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 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

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

View File

@@ -7,10 +7,11 @@
hexo.extend.helper.register('inject_head_js', function () { hexo.extend.helper.register('inject_head_js', function () {
const { darkmode, aside } = this.theme const { darkmode, aside } = this.theme
const start = darkmode.start ? darkmode.start : 6
const end = darkmode.end ? darkmode.end : 18
const { theme_color } = hexo.theme.config const { theme_color } = hexo.theme.config
const themeColorLight = theme_color && theme_color.enable && theme_color.meta_theme_color_light || '#ffffff' 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 themeColorDark = (theme_color && theme_color.enable && theme_color.meta_theme_color_dark) || '#0d0d0d'
const localStore = ` const localStore = `
win.saveToLocal = { win.saveToLocal = {
@@ -60,6 +61,23 @@ hexo.extend.helper.register('inject_head_js', function () {
}) })
` `
const getCSS = `
win.getCSS = (url,id = false) => new Promise((resolve, reject) => {
const link = document.createElement('link')
link.rel = 'stylesheet'
link.href = url
if (id) link.id = id
link.onerror = reject
link.onload = link.onreadystatechange = function() {
const loadState = this.readyState
if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
link.onload = link.onreadystatechange = null
resolve()
}
document.head.appendChild(link)
})
`
let darkmodeJs = '' let darkmodeJs = ''
if (darkmode.enable) { if (darkmode.enable) {
darkmodeJs = ` darkmodeJs = `
@@ -93,7 +111,7 @@ hexo.extend.helper.register('inject_head_js', function () {
else if (isNotSpecified || hasNoSupport) { else if (isNotSpecified || hasNoSupport) {
const now = new Date() const now = new Date()
const hour = now.getHours() const hour = now.getHours()
const isNight = hour <= 6 || hour >= 18 const isNight = hour <= ${start} || hour >= ${end}
isNight ? activateDarkMode() : activateLightMode() isNight ? activateDarkMode() : activateLightMode()
} }
window.matchMedia('(prefers-color-scheme: dark)').addListener(function (e) { window.matchMedia('(prefers-color-scheme: dark)').addListener(function (e) {
@@ -108,7 +126,7 @@ hexo.extend.helper.register('inject_head_js', function () {
darkmodeJs += ` darkmodeJs += `
const now = new Date() const now = new Date()
const hour = now.getHours() const hour = now.getHours()
const isNight = hour <= 6 || hour >= 18 const isNight = hour <= ${start} || hour >= ${end}
if (t === undefined) isNight ? activateDarkMode() : activateLightMode() if (t === undefined) isNight ? activateDarkMode() : activateLightMode()
else if (t === 'light') activateLightMode() else if (t === 'light') activateLightMode()
else activateDarkMode() else activateDarkMode()
@@ -144,5 +162,5 @@ hexo.extend.helper.register('inject_head_js', function () {
detectApple() detectApple()
` `
return `<script>(win=>{${localStore + getScript + darkmodeJs + asideStatus + detectApple}})(window)</script>` return `<script>(win=>{${localStore + getScript + getCSS + darkmodeJs + asideStatus + detectApple}})(window)</script>`
}) })

View File

@@ -24,11 +24,8 @@ hexo.extend.helper.register('page_description', function () {
hexo.extend.helper.register('cloudTags', function (options = {}) { hexo.extend.helper.register('cloudTags', function (options = {}) {
const env = this const env = this
let source = options.source let { source, minfontsize, maxfontsize, limit, unit, orderby, order } = options
const minfontsize = options.minfontsize unit = unit || 'px'
const maxfontsize = options.maxfontsize
const limit = options.limit
const unit = options.unit || 'px'
let result = '' let result = ''
if (limit > 0) { if (limit > 0) {
@@ -43,7 +40,7 @@ hexo.extend.helper.register('cloudTags', function (options = {}) {
}) })
const length = sizes.length - 1 const length = sizes.length - 1
source.forEach(tag => { source.sort(orderby, order).forEach(tag => {
const ratio = length ? sizes.indexOf(tag.length) / length : 0 const ratio = length ? sizes.indexOf(tag.length) / length : 0
const size = minfontsize + ((maxfontsize - minfontsize) * ratio) const size = minfontsize + ((maxfontsize - minfontsize) * ratio)
let style = `font-size: ${parseFloat(size.toFixed(2))}${unit};` let style = `font-size: ${parseFloat(size.toFixed(2))}${unit};`
@@ -54,8 +51,8 @@ hexo.extend.helper.register('cloudTags', function (options = {}) {
return result return result
}) })
hexo.extend.helper.register('urlNoIndex', function (url = null) { hexo.extend.helper.register('urlNoIndex', function (url = null, trailingIndex = false, trailingHtml = false) {
return prettyUrls(url || this.url, { trailing_index: false, trailing_html: false }) return prettyUrls(url || this.url, { trailing_index: trailingIndex, trailing_html: trailingHtml })
}) })
hexo.extend.helper.register('md5', function (path) { hexo.extend.helper.register('md5', function (path) {
@@ -74,8 +71,8 @@ hexo.extend.helper.register('injectHtml', function (data) {
hexo.extend.helper.register('findArchivesTitle', function (page, menu, date) { hexo.extend.helper.register('findArchivesTitle', function (page, menu, date) {
if (page.year) { if (page.year) {
const dateStr = page.month ? `${page.year}-${page.month}` : `${page.year}` const dateStr = page.month ? `${page.year}-${page.month}` : `${page.year}`
const date_format = page.month ? hexo.theme.config.aside.card_archives.format : 'YYYY' const dateFormat = page.month ? hexo.theme.config.aside.card_archives.format : 'YYYY'
return date(dateStr, date_format) return date(dateStr, dateFormat)
} }
const defaultTitle = this._p('page.archives') const defaultTitle = this._p('page.archives')
@@ -95,3 +92,11 @@ hexo.extend.helper.register('findArchivesTitle', function (page, menu, date) {
return loop(menu) || defaultTitle return loop(menu) || defaultTitle
}) })
hexo.extend.helper.register('isImgOrUrl', function (path) {
const imgTestReg = /\.(png|jpe?g|gif|svg|webp)(\?.*)?$/i
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, title: post.title,
path: post.path, path: post.path,
cover: post.cover, cover: post.cover,
randomcover: post.randomcover, cover_type: post.cover_type,
weight: 1, weight: 1,
updated: post.updated, updated: post.updated,
created: post.date created: post.date
@@ -50,13 +50,14 @@ hexo.extend.helper.register('related_posts', function (currentPost, allPosts) {
result += '<div class="relatedPosts-list">' result += '<div class="relatedPosts-list">'
for (let i = 0; i < Math.min(relatedPosts.length, limitNum); i++) { for (let i = 0; i < Math.min(relatedPosts.length, limitNum); i++) {
const cover = const cover = relatedPosts[i].cover || 'var(--default-bg-color)'
relatedPosts[i].cover === false
? relatedPosts[i].randomcover
: relatedPosts[i].cover
const title = this.escape_html(relatedPosts[i].title) const title = this.escape_html(relatedPosts[i].title)
result += `<div><a href="${this.url_for(relatedPosts[i].path)}" title="${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') { 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>` 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 { } else {

View File

@@ -1,6 +1,9 @@
/** /**
* Butterfly * Butterfly
* galleryGroup and allery * galleryGroup and gallery
* {% galleryGroup [name] [descr] [url] [img] %}
* {% gallery [lazyload],[rowHeight],[limit] %}
* {% gallery url,[url],[lazyload],[rowHeight],[limit] %}
*/ */
'use strict' 'use strict'
@@ -8,13 +11,45 @@
const urlFor = require('hexo-util').url_for.bind(hexo) const urlFor = require('hexo-util').url_for.bind(hexo)
function gallery (args, content) { function gallery (args, content) {
return `<div class="fj-gallery">${hexo.render.renderSync({ text: content, engine: 'markdown' }).split('\n').join('')} const { data, languages } = hexo.theme.i18n
</div>` args = args.join(' ').split(',')
let rowHeight, limit, lazyload, type, dataStr
if (args[0] === 'url') {
[type, dataStr, lazyload, rowHeight = 220, limit = 10] = args // url,[link],[lazyload],[rowHeight],[limit]
} else {
[lazyload, rowHeight = 220, limit = 10] = args // [lazyload],[rowHeight],[limit]
const regex = /!\[(.*?)\]\(([^\s]*)\s*(?:["'](.*?)["']?)?\s*\)/g
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]
})
}
dataStr = JSON.stringify(arr)
}
type = type ? ' url' : ' data'
const lazyloadClass = lazyload === 'true' ? 'lazyload' : ''
return `<div class="gallery">
<div class="fj-gallery ${lazyloadClass + type}" data-rowHeight="${rowHeight}" data-limit="${limit}">
<span class="gallery-data">${dataStr}</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) { function galleryGroup (args) {
const name = args[0] const name = args[0]
const desrc = args[1] const descr = args[1]
const url = urlFor(args[2]) const url = urlFor(args[2])
const img = urlFor(args[3]) const img = urlFor(args[3])
@@ -23,7 +58,7 @@ function galleryGroup (args) {
<img class="gallery-group-img no-lightbox" src='${img}' alt="Group Image Gallery"> <img class="gallery-group-img no-lightbox" src='${img}' alt="Group Image Gallery">
<figcaption> <figcaption>
<div class="gallery-group-name">${name}</div> <div class="gallery-group-name">${name}</div>
<p>${desrc}</p> <p>${descr}</p>
<a href='${url}'></a> <a href='${url}'></a>
</figcaption> </figcaption>
</figure> </figure>

22
scripts/tag/score.js Normal file
View File

@@ -0,0 +1,22 @@
/**
* Music Score
* {% score %}
*/
'use strict';
function score(args, content) {
function escapeHtmlTags(s) {
let lookup = {
'&': "&amp;",
'"': "&quot;",
'\'': "&apos;",
'<': "&lt;",
'>': "&gt;"
};
return s.replace(/[&"'<>]/g, c => lookup[c]);
}
return `<div class="abc-music-sheet">${escapeHtmlTags(content)}</div>`;
}
hexo.extend.tag.register('score', score, {ends: true});

View File

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

View File

@@ -6,7 +6,7 @@
--hr-before-color: lighten($theme-hr-color, 30%) --hr-before-color: lighten($theme-hr-color, 30%)
--search-bg: $search-bg --search-bg: $search-bg
--search-input-color: $search-input-color --search-input-color: $search-input-color
--search-result-title: $search-result-title --search-a-color: $search-a-color
--preloader-bg: $preloader-bg --preloader-bg: $preloader-bg
--preloader-color: $preloader-word-color --preloader-color: $preloader-word-color
--tab-border-color: $tab-border-color --tab-border-color: $tab-border-color
@@ -33,6 +33,7 @@
--pseudo-hover: $pseudo-hover --pseudo-hover: $pseudo-hover
--headline-presudo: #a0a0a0 --headline-presudo: #a0a0a0
--scrollbar-color: $scrollbar-color --scrollbar-color: $scrollbar-color
--default-bg-color: $theme-color
body body
position: relative position: relative
@@ -49,8 +50,8 @@ body
// scrollbar - chrome/safari // scrollbar - chrome/safari
*::-webkit-scrollbar *::-webkit-scrollbar
width: 8px width: 5px
height: 8px height: 5px
*::-webkit-scrollbar-thumb *::-webkit-scrollbar-thumb
background: var(--scrollbar-color) background: var(--scrollbar-color)
@@ -165,7 +166,7 @@ a
if $site-name-font if $site-name-font
#site-title, #site-title,
#site-subtitle, #site-subtitle,
#site-name, .site-name,
#aside-content .author-info__name, #aside-content .author-info__name,
#aside-content .author-info__description #aside-content .author-info__description
font-family: $site-name-font font-family: $site-name-font
@@ -173,9 +174,6 @@ if $site-name-font
.is-center .is-center
text-align: center text-align: center
.copy-true
user-select: all
.pull-left .pull-left
float: left float: left

View File

@@ -75,6 +75,14 @@ $code-block
&:hover &:hover
border-bottom-color: var(--hl-color) border-bottom-color: var(--hl-color)
&.copy-true
user-select: all
& > table,
& > pre
display: block !important
opacity: 0
.highlight-tools .highlight-tools
position: relative position: relative
display: flex display: flex

View File

@@ -52,7 +52,7 @@
transition: all .3s transition: all .3s
&:hover &:hover
transform: rotate(540deg) transform: rotate(360deg)
#card-info-btn #card-info-btn
display: block display: block
@@ -115,7 +115,7 @@
width: w = 4.2em width: w = 4.2em
height: w height: w
& > img :first-child
@extend .imgHover @extend .imgHover
.content .content
@@ -291,8 +291,8 @@
background: $theme-toc-color background: $theme-toc-color
color: $toc-active-color color: $toc-active-color
:only-child .sticky_layout:only-child
> .card-widget > :first-child
margin-top: 0 margin-top: 0
.card-more-btn .card-more-btn

View File

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

View File

@@ -124,7 +124,8 @@
background: rgba(255, 255, 255, .8) background: rgba(255, 255, 255, .8)
box-shadow: 0 5px 6px -5px rgba(133, 133, 133, .6) box-shadow: 0 5px 6px -5px rgba(133, 133, 133, .6)
a a,
.site-name
color: var(--font-color) color: var(--font-color)
text-shadow: none text-shadow: none
@@ -137,8 +138,16 @@
box-shadow: 0 5px 6px -5px alpha($grey, .6) box-shadow: 0 5px 6px -5px alpha($grey, .6)
transition: transform .2s ease-in-out, opacity .2s ease-in-out 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, a,
#site-name,
#toggle-menu #toggle-menu
color: var(--font-color) color: var(--font-color)
text-shadow: none text-shadow: none
@@ -146,7 +155,12 @@
&:hover &:hover
color: $light-blue color: $light-blue
&.nav-visible &.fixed
#nav
top: 0
transition: all .5s
&.nav-visible:not(.fixed)
#nav #nav
transition: all .5s transition: all .5s
transform: translate3d(0, 100%, 0) transform: translate3d(0, 100%, 0)
@@ -156,6 +170,19 @@
top: 70px top: 70px
transition: top .5s 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 #page
h1.page-title h1.page-title
margin: 8px 0 20px margin: 8px 0 20px
@@ -253,8 +280,15 @@
&.show &.show
opacity: 1 opacity: 1
#blog_name #blog-info
flex: 1 flex: 1
color: var(--light-grey)
@extend .limit-one-line
.site-icon
margin-right: 6px
height: 36px
vertical-align: middle
#toggle-menu #toggle-menu
display: none display: none
@@ -270,10 +304,9 @@
&:hover &:hover
color: var(--white) color: var(--white)
#site-name .site-name
text-shadow: 2px 2px 4px rgba($dark-black, .15) text-shadow: 2px 2px 4px rgba($dark-black, .15)
font-weight: bold font-weight: bold
cursor: pointer
.menus_items .menus_items
display: inline display: inline

View File

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

View File

@@ -102,31 +102,35 @@ beautify()
font-family: Monaco, 'Ubuntu Mono', monospace font-family: Monaco, 'Ubuntu Mono', monospace
line-height: 1em line-height: 1em
if hexo-config('anchor') if hexo-config('anchor.button.enable')
a.headerlink a.headerlink
&:after &:after
@extend .fontawesomeIcon @extend .fontawesomeIcon
float: right float: right
color: var(--headline-presudo) color: var(--headline-presudo)
content: '\f0c1' content: $archor-button-icon
font-size: .95em font-size: .95em
opacity: 0
transition: all .3s transition: all .3s
&:hover &:hover
&:after &:after
color: var(--pseudo-hover) color: var(--pseudo-hover)
h1, if !hexo-config('anchor.button.always_show')
h2, a.headerlink
h3, &:after
h4, opacity: 0
h5,
h6 h1,
&:hover h2,
a.headerlink h3,
&:after h4,
opacity: 1 h5,
h6
&:hover
a.headerlink
&:after
opacity: 1
ol, ol,
ul ul
@@ -140,15 +144,26 @@ beautify()
p p
margin: 0 0 8px margin: 0 0 8px
> :last-child
margin-bottom: 0 !important
hr
margin: 20px 0
if hexo-config('beautify.enable') if hexo-config('beautify.enable')
if hexo-config('beautify.field') == 'site' if hexo-config('beautify.field') == 'site'
beautify() beautify()
else if hexo-config('beautify.field') == 'post' else if hexo-config('beautify.field') == 'post'
&.post-content &.post-content
beautify() beautify()
else
hr
margin: 20px 0
border: 1px inset
width 100%
> :last-child &:before
margin-bottom: 0 !important content: none
#post #post
.tag_share .tag_share

View File

@@ -47,3 +47,22 @@
+maxWidth900() +maxWidth900()
#hide-aside-btn #hide-aside-btn
display: none 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-theme-color: $button-bg
--waline-active-color: $button-hover-color --waline-active-color: $button-hover-color
.vuser .wl-comment-actions > button:not(last-child)
transition: all .5s padding-right: 4px
&:hover
transform: rotate(360deg)
if hexo-config('valine.bg') if hexo-config('valine.bg')
#vcomment #vcomment
@@ -84,12 +81,16 @@ if hexo-config('waline.bg')
&::-webkit-scrollbar &::-webkit-scrollbar
display: none display: none
// mathjax // Mathjax
mjx-container[display], .mathjax-overflow
.has-jax
overflow-x: auto overflow-x: auto
overflow-y: hidden overflow-y: hidden
line-height: normal !important
span.mathjax-overflow
display: inline-block
padding: 0 2px
max-width: 100%
vertical-align: bottom
.aplayer .aplayer
color: $font-black color: $font-black
@@ -113,3 +114,15 @@ mjx-container[display],
.snackbar-css .snackbar-css
border-radius: 5px !important border-radius: 5px !important
.abc-music-sheet
margin: 0 0 20px
opacity: 0
transition: opacity .3s
&.abcjs-container
opacity: 1
+maxWidth768()
.fancybox__toolbar__column.is-middle
display: none

View File

@@ -6,7 +6,7 @@ if hexo-config('darkmode.enable') || hexo-config('display_mode') == 'dark'
--hr-before-color: alpha(#FFFFFF, .7) --hr-before-color: alpha(#FFFFFF, .7)
--search-bg: #121212 --search-bg: #121212
--search-input-color: alpha(#FFFFFF, .7) --search-input-color: alpha(#FFFFFF, .7)
--search-result-title: alpha(#FFFFFF, .9) --search-a-color: alpha(#FFFFFF, .7)
--preloader-bg: darken(#121212, 2) --preloader-bg: darken(#121212, 2)
--preloader-color: alpha(#FFFFFF, .7) --preloader-color: alpha(#FFFFFF, .7)
--tab-border-color: #2c2c2c --tab-border-color: #2c2c2c

View File

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

View File

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

View File

@@ -18,7 +18,7 @@
padding: 20px 5px padding: 20px 5px
+minWidth2000() +minWidth2000()
max-width: 1500px max-width: 1700px
& > div:first-child:not(.recent-posts) & > div:first-child:not(.recent-posts)
@extend .cardHover @extend .cardHover

View File

@@ -15,7 +15,7 @@
height: auto height: auto
&:hover &:hover
img.post_bg img.post-bg
transform: scale(1.1) transform: scale(1.1)
&.ads-wrap &.ads-wrap
@@ -31,7 +31,7 @@
width: 100% width: 100%
height: 230px height: 230px
img.post_bg .post-bg
@extend .imgHover @extend .imgHover
&.right &.right

View File

@@ -16,7 +16,7 @@
@extend .list-beauty @extend .list-beauty
a a
color: var(--search-result-title) color: var(--search-a-color)
&:hover &:hover
color: $search-color color: $search-color
@@ -26,12 +26,15 @@
color: $search-keyword-highlight color: $search-keyword-highlight
font-weight: bold font-weight: bold
.algolia-hits-item-title
font-weight: 600
.algolia-hit-item-content .algolia-hit-item-content
margin: 0 0 8px margin: 0 0 8px
word-break: break-all word-break: break-word
.ais-Pagination .ais-Pagination
margin: 20px 0 0 margin: 15px 0 0
padding: 0 padding: 0
text-align: center text-align: center
@@ -61,20 +64,16 @@
.ais-Pagination-item--disabled .ais-Pagination-item--disabled
visibility: hidden visibility: hidden
.algolia-logo
padding-top: 2px
width: 80px
height: 30px
#algolia-hits #algolia-hits
> div > div
overflow-y: scroll overflow-y: scroll
margin: 0 -20px
+minWidth768() padding: 0 22px
max-height: calc(80vh - 240px) max-height: calc(80vh - 240px)
+maxWidth768() +maxWidth768()
height: calc(100vh - 260px) max-height: none
height: calc(var(--search-height) - 265px)
#algolia-info #algolia-info
div div
@@ -82,10 +81,7 @@
.algolia-poweredBy .algolia-poweredBy
float: right float: right
vertical-align: text-top
.apple svg
#algolia-search height: 1.1em
#algolia-hits
> div
+maxWidth768()
height: calc(90vh - 260px)

View File

@@ -9,6 +9,7 @@
width: 600px width: 600px
border-radius: 8px border-radius: 8px
background: var(--search-bg) background: var(--search-bg)
--search-height: 100vh
+maxWidth768() +maxWidth768()
top: 0 top: 0

View File

@@ -18,7 +18,7 @@
.search-wrap .search-wrap
display: none display: none
.local-search__hit-item .local-search-hit-item
position: relative position: relative
padding-left: 24px padding-left: 24px
line-height: 1.7 line-height: 1.7
@@ -43,25 +43,32 @@
a a
display: block display: block
color: var(--search-result-title) color: var(--search-a-color)
font-weight: 600
cursor: pointer
&:hover &:hover
color: $search-color color: $search-color
.search-result .search-result-title
margin: 0 8px 8px 0 font-weight: 600
word-break: break-all
.search-keyword .search-result
color: $search-keyword-highlight margin: 0 0 8px
font-weight: bold word-break: break-word
.search-result-list .search-result-list
overflow-y: auto overflow-y: overlay
max-height: calc(80vh - 130px) margin: 0 -20px
padding: 0 22px
max-height: calc(80vh - 200px)
+maxWidth768() +maxWidth768()
padding-bottom: 40px max-height: calc(var(--search-height) - 220px) !important
max-height: 75vh !important
.no-result
& + #local-search-stats-wrap
display: none
.search-keyword
background: transparent
color: $search-keyword-highlight
font-weight: bold

View File

@@ -94,9 +94,46 @@
overflow: auto overflow: auto
padding: 0 0 16px padding: 0 0 16px
.fj-gallery .gallery
margin: 0 0 16px margin: 0 0 16px
opacity: 0 text-align: center
.img-alt .fj-gallery
opacity: 0
.img-alt
display: none
&.lazyload
+ button
display: inline-block
.gallery-data
display: none
button
display: none 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

@@ -71,7 +71,7 @@ $button-hover-color = $themeColorEnable && hexo-config('theme_color.button_hover
$button-bg = $theme-color $button-bg = $theme-color
$pseudo-hover = $button-hover-color $pseudo-hover = $button-hover-color
// scrollbar // 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
$table-thead-bg = #99a9bf $table-thead-bg = #99a9bf
// reward // reward
@@ -82,7 +82,7 @@ $search-bg = #f6f8fa
$search-input-color = $font-black $search-input-color = $font-black
$search-color = $theme-color $search-color = $theme-color
$search-keyword-highlight = #F47466 $search-keyword-highlight = #F47466
$search-result-title = $font-black $search-a-color = $font-black
// comments // comments
$comments-switch-first-text = $bright-blue $comments-switch-first-text = $bright-blue
$comments-switch-second-text = $light-orange $comments-switch-second-text = $light-orange
@@ -181,3 +181,5 @@ $tab-button-active-bg = $card-bg
$tab-to-top-color = #99a9bf $tab-to-top-color = #99a9bf
// Tag Plugins - timeline // 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 () { document.addEventListener('DOMContentLoaded', function () {
let blogNameWidth, menusWidth, searchWidth, $nav let headerContentWidth, $nav
let mobileSidebarOpen = false 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) { if (init) {
blogNameWidth = document.getElementById('site-name').offsetWidth const blogInfoWidth = getAllWidth(document.querySelector('#blog-info > a').children)
const $menusEle = document.querySelectorAll('#menus .menus_item') const menusWidth = getAllWidth(document.getElementById('menus').children)
menusWidth = 0 headerContentWidth = blogInfoWidth + menusWidth
$menusEle.length && $menusEle.forEach(i => { menusWidth += i.offsetWidth })
const $searchEle = document.querySelector('#search-button')
searchWidth = $searchEle ? $searchEle.offsetWidth : 0
$nav = document.getElementById('nav') $nav = document.getElementById('nav')
} }
let hideMenuIndex = '' let hideMenuIndex = ''
if (window.innerWidth < 768) hideMenuIndex = true if (window.innerWidth <= 768) hideMenuIndex = true
else hideMenuIndex = blogNameWidth + menusWidth + searchWidth > $nav.offsetWidth - 120 else hideMenuIndex = headerContentWidth > $nav.offsetWidth - 120
if (hideMenuIndex) { if (hideMenuIndex) {
$nav.classList.add('hide-menu') $nav.classList.add('hide-menu')
@@ -67,28 +70,17 @@ document.addEventListener('DOMContentLoaded', function () {
const highLight = GLOBAL_CONFIG.highlight const highLight = GLOBAL_CONFIG.highlight
if (!highLight) return if (!highLight) return
const isHighlightCopy = highLight.highlightCopy const { highlightCopy, highlightLang, highlightHeightLimit, plugin } = highLight
const isHighlightLang = highLight.highlightLang
const isHighlightShrink = GLOBAL_CONFIG_SITE.isHighlightShrink const isHighlightShrink = GLOBAL_CONFIG_SITE.isHighlightShrink
const highlightHeightLimit = highLight.highlightHeightLimit const isShowTool = highlightCopy || highlightLang || isHighlightShrink !== undefined
const isShowTool = isHighlightCopy || isHighlightLang || isHighlightShrink !== undefined const $figureHighlight = plugin === 'highlighjs' ? document.querySelectorAll('figure.highlight') : document.querySelectorAll('pre[class*="language-"]')
const $figureHighlight = highLight.plugin === 'highlighjs' ? document.querySelectorAll('figure.highlight') : document.querySelectorAll('pre[class*="language-"]')
if (!((isShowTool || highlightHeightLimit) && $figureHighlight.length)) return if (!((isShowTool || highlightHeightLimit) && $figureHighlight.length)) return
const isPrismjs = highLight.plugin === 'prismjs' const isPrismjs = plugin === 'prismjs'
let highlightShrinkEle = ''
let highlightCopyEle = ''
const highlightShrinkClass = isHighlightShrink === true ? 'closed' : '' const highlightShrinkClass = isHighlightShrink === true ? 'closed' : ''
const highlightShrinkEle = isHighlightShrink !== undefined ? `<i class="fas fa-angle-down expand ${highlightShrinkClass}"></i>` : ''
if (isHighlightShrink !== undefined) { const highlightCopyEle = highlightCopy ? '<div class="copy-notice"></div><i class="fas fa-paste copy-button"></i>' : ''
highlightShrinkEle = `<i class="fas fa-angle-down expand ${highlightShrinkClass}"></i>`
}
if (isHighlightCopy) {
highlightCopyEle = '<div class="copy-notice"></div><i class="fas fa-paste copy-button"></i>'
}
const copy = (text, ctx) => { const copy = (text, ctx) => {
if (document.queryCommandSupported && document.queryCommandSupported('copy')) { if (document.queryCommandSupported && document.queryCommandSupported('copy')) {
@@ -97,7 +89,7 @@ document.addEventListener('DOMContentLoaded', function () {
btf.snackbarShow(GLOBAL_CONFIG.copy.success) btf.snackbarShow(GLOBAL_CONFIG.copy.success)
} else { } else {
const prevEle = ctx.previousElementSibling const prevEle = ctx.previousElementSibling
prevEle.innerText = GLOBAL_CONFIG.copy.success prevEle.textContent = GLOBAL_CONFIG.copy.success
prevEle.style.opacity = 1 prevEle.style.opacity = 1
setTimeout(() => { prevEle.style.opacity = 0 }, 700) setTimeout(() => { prevEle.style.opacity = 0 }, 700)
} }
@@ -105,7 +97,7 @@ document.addEventListener('DOMContentLoaded', function () {
if (GLOBAL_CONFIG.Snackbar !== undefined) { if (GLOBAL_CONFIG.Snackbar !== undefined) {
btf.snackbarShow(GLOBAL_CONFIG.copy.noSupport) btf.snackbarShow(GLOBAL_CONFIG.copy.noSupport)
} else { } else {
ctx.previousElementSibling.innerText = GLOBAL_CONFIG.copy.noSupport ctx.previousElementSibling.textContent = GLOBAL_CONFIG.copy.noSupport
} }
} }
} }
@@ -116,8 +108,8 @@ document.addEventListener('DOMContentLoaded', function () {
$buttonParent.classList.add('copy-true') $buttonParent.classList.add('copy-true')
const selection = window.getSelection() const selection = window.getSelection()
const range = document.createRange() const range = document.createRange()
if (isPrismjs) range.selectNodeContents($buttonParent.querySelectorAll('pre code')[0]) const preCodeSelector = isPrismjs ? 'pre code' : 'table .code pre'
else range.selectNodeContents($buttonParent.querySelectorAll('table .code pre')[0]) range.selectNodeContents($buttonParent.querySelectorAll(`${preCodeSelector}`)[0])
selection.removeAllRanges() selection.removeAllRanges()
selection.addRange(range) selection.addRange(range)
const text = selection.toString() const text = selection.toString()
@@ -172,33 +164,29 @@ document.addEventListener('DOMContentLoaded', function () {
} }
} }
if (isHighlightLang) { if (isPrismjs) {
if (isPrismjs) { $figureHighlight.forEach(item => {
$figureHighlight.forEach(function (item) { if (highlightLang) {
const langName = item.getAttribute('data-language') ? item.getAttribute('data-language') : 'Code' const langName = item.getAttribute('data-language') || 'Code'
const highlightLangEle = `<div class="code-lang">${langName}</div>` const highlightLangEle = `<div class="code-lang">${langName}</div>`
btf.wrap(item, 'figure', { class: 'highlight' }) btf.wrap(item, 'figure', { class: 'highlight' })
createEle(highlightLangEle, item) createEle(highlightLangEle, item)
}) } else {
} else { btf.wrap(item, 'figure', { class: 'highlight' })
$figureHighlight.forEach(function (item) { createEle('', item)
}
})
} else {
$figureHighlight.forEach(function (item) {
if (highlightLang) {
let langName = item.getAttribute('class').split(' ')[1] let langName = item.getAttribute('class').split(' ')[1]
if (langName === 'plain' || langName === undefined) langName = 'Code' if (langName === 'plain' || langName === undefined) langName = 'Code'
const highlightLangEle = `<div class="code-lang">${langName}</div>` const highlightLangEle = `<div class="code-lang">${langName}</div>`
createEle(highlightLangEle, item, 'hl') createEle(highlightLangEle, item, 'hl')
}) } else {
}
} else {
if (isPrismjs) {
$figureHighlight.forEach(function (item) {
btf.wrap(item, 'figure', { class: 'highlight' })
createEle('', item)
})
} else {
$figureHighlight.forEach(function (item) {
createEle('', item, 'hl') createEle('', item, 'hl')
}) }
} })
} }
} }
@@ -229,26 +217,79 @@ document.addEventListener('DOMContentLoaded', function () {
* justified-gallery 圖庫排版 * justified-gallery 圖庫排版
*/ */
const runJustifiedGallery = function (ele) { const runJustifiedGallery = function (ele) {
ele.forEach(item => { const htmlStr = arr => {
const $imgList = item.querySelectorAll('img') let str = ''
const replaceDq = str => str.replace(/"/g, '&quot;') // replace double quotes to &quot;
$imgList.forEach(i => { arr.forEach(i => {
const dataLazySrc = i.getAttribute('data-lazy-src') const alt = i.alt ? `alt="${replaceDq(i.alt)}"` : ''
if (dataLazySrc) i.src = dataLazySrc const title = i.title ? `title="${replaceDq(i.title)}"` : ''
btf.wrap(i, 'div', { class: 'fj-gallery-item' }) str += `<div class="fj-gallery-item"><img src="${i.url}" ${alt + title}"></div>`
}) })
}) return str
}
const lazyloadFn = (i, arr, limit) => {
const loadItem = 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
}
const fetchUrl = async (url) => {
const response = await fetch(url)
return await response.json()
}
const runJustifiedGallery = (item, arr) => {
if (!item.classList.contains('lazyload')) item.innerHTML = htmlStr(arr)
else {
const limit = item.getAttribute('data-limit')
lazyloadFn(item, arr, limit)
const clickBtnFn = () => {
const lastItemLength = lazyloadFn(item, arr, limit)
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)
}
btf.initJustifiedGallery(item)
btf.loadLightbox(item.querySelectorAll('img'))
}
const addJustifiedGallery = () => {
ele.forEach(item => {
item.classList.contains('url')
? fetchUrl(item.textContent).then(res => { runJustifiedGallery(item, res) })
: runJustifiedGallery(item, JSON.parse(item.textContent))
})
}
if (window.fjGallery) { if (window.fjGallery) {
setTimeout(() => { btf.initJustifiedGallery(ele) }, 100) addJustifiedGallery()
return return
} }
const newEle = document.createElement('link') getCSS(`${GLOBAL_CONFIG.source.justifiedGallery.css}`)
newEle.rel = 'stylesheet' getScript(`${GLOBAL_CONFIG.source.justifiedGallery.js}`).then(addJustifiedGallery)
newEle.href = GLOBAL_CONFIG.source.justifiedGallery.css }
document.body.appendChild(newEle)
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')
}
} }
/** /**
@@ -257,6 +298,12 @@ document.addEventListener('DOMContentLoaded', function () {
const scrollFn = function () { const scrollFn = function () {
const $rightside = document.getElementById('rightside') const $rightside = document.getElementById('rightside')
const innerHeight = window.innerHeight + 56 const innerHeight = window.innerHeight + 56
let initTop = 0
let isChatShow = true
const $header = document.getElementById('page-header')
const isChatBtnHide = typeof chatBtnHide === 'function'
const isChatBtnShow = typeof chatBtnShow === 'function'
const isShowPercent = GLOBAL_CONFIG.percent.rightside
// 當滾動條小于 56 的時候 // 當滾動條小于 56 的時候
if (document.body.scrollHeight <= innerHeight) { if (document.body.scrollHeight <= innerHeight) {
@@ -265,52 +312,48 @@ document.addEventListener('DOMContentLoaded', function () {
} }
// find the scroll direction // find the scroll direction
function scrollDirection (currentTop) { const scrollDirection = currentTop => {
const result = currentTop > initTop // true is down & false is up const result = currentTop > initTop // true is down & false is up
initTop = currentTop initTop = currentTop
return result return result
} }
let initTop = 0 const scrollTask = btf.throttle(() => {
let isChatShow = true const currentTop = window.scrollY || document.documentElement.scrollTop
const $header = document.getElementById('page-header') const isDown = scrollDirection(currentTop)
const isChatBtnHide = typeof chatBtnHide === 'function' if (currentTop > 56) {
const isChatBtnShow = typeof chatBtnShow === 'function' if (isDown) {
if ($header.classList.contains('nav-visible')) $header.classList.remove('nav-visible')
window.scrollCollect = () => { if (isChatBtnShow && isChatShow === true) {
return btf.throttle(function (e) { chatBtnHide()
const currentTop = window.scrollY || document.documentElement.scrollTop isChatShow = false
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)'
} }
} else { } else {
if (currentTop === 0) { if (!$header.classList.contains('nav-visible')) $header.classList.add('nav-visible')
$header.classList.remove('nav-fixed', 'nav-visible') if (isChatBtnHide && isChatShow === false) {
chatBtnShow()
isChatShow = true
} }
$rightside.style.cssText = "opacity: ''; transform: ''"
} }
$header.classList.add('nav-fixed')
if (document.body.scrollHeight <= innerHeight) { if (window.getComputedStyle($rightside).getPropertyValue('opacity') === '0') {
$rightside.style.cssText = 'opacity: 0.8; transform: translateX(-58px)' $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) window.addEventListener('scroll', scrollCollect)
} }
@@ -325,26 +368,15 @@ document.addEventListener('DOMContentLoaded', function () {
if (!($article && (isToc || isAnchor))) return if (!($article && (isToc || isAnchor))) return
let $tocLink, $cardToc, scrollPercent, autoScrollToc, isExpand let $tocLink, $cardToc, autoScrollToc, $tocPercentage, isExpand
if (isToc) { if (isToc) {
const $cardTocLayout = document.getElementById('card-toc') const $cardTocLayout = document.getElementById('card-toc')
$cardToc = $cardTocLayout.getElementsByClassName('toc-content')[0] $cardToc = $cardTocLayout.getElementsByClassName('toc-content')[0]
$tocLink = $cardToc.querySelectorAll('.toc-link') $tocLink = $cardToc.querySelectorAll('.toc-link')
const $tocPercentage = $cardTocLayout.querySelector('.toc-percentage') $tocPercentage = $cardTocLayout.querySelector('.toc-percentage')
isExpand = $cardToc.classList.contains('is-expand') 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 = { window.mobileToc = {
open: () => { open: () => {
$cardTocLayout.style.cssText = 'animation: toc-open .3s; opacity: 1; right: 55px' $cardTocLayout.style.cssText = 'animation: toc-open .3s; opacity: 1; right: 55px'
@@ -433,16 +465,33 @@ document.addEventListener('DOMContentLoaded', function () {
} }
// main of scroll // main of scroll
window.tocScrollFn = function () { window.tocScrollFn = btf.throttle(() => {
return btf.throttle(function () { const currentTop = window.scrollY || document.documentElement.scrollTop
const currentTop = window.scrollY || document.documentElement.scrollTop if (isToc && GLOBAL_CONFIG.percent.toc) {
isToc && scrollPercent(currentTop) $tocPercentage.textContent = btf.getScrollPercent(currentTop, $article)
findHeadPosition(currentTop) }
}, 100)() findHeadPosition(currentTop)
} }, 100)
window.addEventListener('scroll', tocScrollFn) window.addEventListener('scroll', tocScrollFn)
} }
const modeChangeFn = mode => {
if (!window.themeChange) {
return
}
const turnMode = item => window.themeChange[item](mode)
Object.keys(window.themeChange).forEach(item => {
if (['disqus', 'disqusjs'].includes(item)) {
setTimeout(() => turnMode(item), 300)
} else {
turnMode(item)
}
})
}
/** /**
* Rightside * Rightside
*/ */
@@ -455,7 +504,7 @@ document.addEventListener('DOMContentLoaded', function () {
newEle.className = 'fas fa-sign-out-alt exit-readmode' newEle.className = 'fas fa-sign-out-alt exit-readmode'
$body.appendChild(newEle) $body.appendChild(newEle)
function clickFn () { const clickFn = () => {
$body.classList.remove('read-mode') $body.classList.remove('read-mode')
newEle.remove() newEle.remove()
newEle.removeEventListener('click', clickFn) newEle.removeEventListener('click', clickFn)
@@ -464,8 +513,8 @@ document.addEventListener('DOMContentLoaded', function () {
newEle.addEventListener('click', clickFn) newEle.addEventListener('click', clickFn)
}, },
switchDarkMode: () => { // Switch Between Light And Dark Mode switchDarkMode: () => { // Switch Between Light And Dark Mode
const nowMode = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'light' const willChangeMode = document.documentElement.getAttribute('data-theme') === 'dark' ? 'light' : 'dark'
if (nowMode === 'light') { if (willChangeMode === 'dark') {
activateDarkMode() activateDarkMode()
saveToLocal.set('theme', 'dark', 2) saveToLocal.set('theme', 'dark', 2)
GLOBAL_CONFIG.Snackbar !== undefined && btf.snackbarShow(GLOBAL_CONFIG.Snackbar.day_to_night) GLOBAL_CONFIG.Snackbar !== undefined && btf.snackbarShow(GLOBAL_CONFIG.Snackbar.day_to_night)
@@ -474,11 +523,7 @@ document.addEventListener('DOMContentLoaded', function () {
saveToLocal.set('theme', 'light', 2) saveToLocal.set('theme', 'light', 2)
GLOBAL_CONFIG.Snackbar !== undefined && btf.snackbarShow(GLOBAL_CONFIG.Snackbar.night_to_day) GLOBAL_CONFIG.Snackbar !== undefined && btf.snackbarShow(GLOBAL_CONFIG.Snackbar.night_to_day)
} }
// handle some cases modeChangeFn(willChangeMode)
typeof utterancesTheme === 'function' && utterancesTheme()
typeof changeGiscusTheme === 'function' && changeGiscusTheme()
typeof FB === 'object' && window.loadFBComment()
typeof runMermaid === 'function' && window.runMermaid()
}, },
showOrHideBtn: (e) => { // rightside 點擊設置 按鈕 展開 showOrHideBtn: (e) => { // rightside 點擊設置 按鈕 展開
const rightsideHideClassList = document.getElementById('rightside-config-hide').classList const rightsideHideClassList = document.getElementById('rightside-config-hide').classList
@@ -496,9 +541,8 @@ document.addEventListener('DOMContentLoaded', function () {
}, },
hideAsideBtn: () => { // Hide aside hideAsideBtn: () => { // Hide aside
const $htmlDom = document.documentElement.classList const $htmlDom = document.documentElement.classList
$htmlDom.contains('hide-aside') const saveStatus = $htmlDom.contains('hide-aside') ? 'show' : 'hide'
? saveToLocal.set('aside-status', 'show', 2) saveToLocal.set('aside-status', saveStatus, 2)
: saveToLocal.set('aside-status', 'hide', 2)
$htmlDom.toggle('hide-aside') $htmlDom.toggle('hide-aside')
}, },
@@ -547,21 +591,16 @@ document.addEventListener('DOMContentLoaded', function () {
} }
/** /**
* 複製時加上版權信息 * 複製時加上版權信息
*/ */
const addCopyright = () => { const addCopyright = () => {
const copyright = GLOBAL_CONFIG.copyright const copyright = GLOBAL_CONFIG.copyright
document.body.oncopy = (e) => { document.body.oncopy = (e) => {
e.preventDefault() e.preventDefault()
let textFont; const copyFont = window.getSelection(0).toString() const copyFont = window.getSelection(0).toString()
let textFont = copyFont
if (copyFont.length > copyright.limitCount) { if (copyFont.length > copyright.limitCount) {
textFont = copyFont + '\n' + '\n' + '\n' + textFont = `${copyFont}\n\n\n${copyright.languages.author}\n${copyright.languages.link}${window.location.href}\n${copyright.languages.source}\n${copyright.languages.info}`
copyright.languages.author + '\n' +
copyright.languages.link + window.location.href + '\n' +
copyright.languages.source + '\n' +
copyright.languages.info
} else {
textFont = copyFont
} }
if (e.clipboardData) { if (e.clipboardData) {
return e.clipboardData.setData('text', textFont) return e.clipboardData.setData('text', textFont)
@@ -578,7 +617,7 @@ document.addEventListener('DOMContentLoaded', function () {
const $runtimeCount = document.getElementById('runtimeshow') const $runtimeCount = document.getElementById('runtimeshow')
if ($runtimeCount) { if ($runtimeCount) {
const publishDate = $runtimeCount.getAttribute('data-publishDate') const publishDate = $runtimeCount.getAttribute('data-publishDate')
$runtimeCount.innerText = btf.diffDate(publishDate) + ' ' + GLOBAL_CONFIG.runtime $runtimeCount.textContent = `${btf.diffDate(publishDate)} ${GLOBAL_CONFIG.runtime}`
} }
} }
@@ -589,7 +628,7 @@ document.addEventListener('DOMContentLoaded', function () {
const $lastPushDateItem = document.getElementById('last-push-date') const $lastPushDateItem = document.getElementById('last-push-date')
if ($lastPushDateItem) { if ($lastPushDateItem) {
const lastPushDate = $lastPushDateItem.getAttribute('data-lastPushDate') const lastPushDate = $lastPushDateItem.getAttribute('data-lastPushDate')
$lastPushDateItem.innerText = btf.diffDate(lastPushDate, true) $lastPushDateItem.textContent = btf.diffDate(lastPushDate, true)
} }
} }
@@ -722,10 +761,9 @@ document.addEventListener('DOMContentLoaded', function () {
const relativeDate = function (selector) { const relativeDate = function (selector) {
selector.forEach(item => { selector.forEach(item => {
const $this = item const timeVal = item.getAttribute('datetime')
const timeVal = $this.getAttribute('datetime') item.textContent = btf.diffDate(timeVal, true)
$this.innerText = btf.diffDate(timeVal, true) item.style.display = 'inline'
$this.style.display = 'inline'
}) })
} }
@@ -740,6 +778,13 @@ document.addEventListener('DOMContentLoaded', function () {
clickFnOfSubMenu() clickFnOfSubMenu()
GLOBAL_CONFIG.islazyload && lazyloadImg() GLOBAL_CONFIG.islazyload && lazyloadImg()
GLOBAL_CONFIG.copyright !== undefined && addCopyright() GLOBAL_CONFIG.copyright !== undefined && addCopyright()
if (GLOBAL_CONFIG.autoDarkmode) {
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', e => {
if (saveToLocal.get('theme') !== undefined) return
e.matches ? modeChangeFn('dark') : modeChangeFn('light')
})
}
} }
window.refreshFn = function () { window.refreshFn = function () {

View File

@@ -1,10 +1,13 @@
window.addEventListener('load', () => { window.addEventListener('load', () => {
const $searchMask = document.getElementById('search-mask')
const $searchDialog = document.querySelector('#algolia-search .search-dialog')
const openSearch = () => { const openSearch = () => {
const bodyStyle = document.body.style const bodyStyle = document.body.style
bodyStyle.width = '100%' bodyStyle.width = '100%'
bodyStyle.overflow = 'hidden' bodyStyle.overflow = 'hidden'
btf.animateIn(document.getElementById('search-mask'), 'to_show 0.5s') btf.animateIn($searchMask, 'to_show 0.5s')
btf.animateIn(document.querySelector('#algolia-search .search-dialog'), 'titleScale 0.5s') btf.animateIn($searchDialog, 'titleScale 0.5s')
setTimeout(() => { document.querySelector('#algolia-search .ais-SearchBox-input').focus() }, 100) setTimeout(() => { document.querySelector('#algolia-search .ais-SearchBox-input').focus() }, 100)
// shortcut: ESC // shortcut: ESC
@@ -14,22 +17,33 @@ window.addEventListener('load', () => {
document.removeEventListener('keydown', f) document.removeEventListener('keydown', f)
} }
}) })
fixSafariHeight()
window.addEventListener('resize', fixSafariHeight)
} }
const closeSearch = () => { const closeSearch = () => {
const bodyStyle = document.body.style const bodyStyle = document.body.style
bodyStyle.width = '' bodyStyle.width = ''
bodyStyle.overflow = '' bodyStyle.overflow = ''
btf.animateOut(document.querySelector('#algolia-search .search-dialog'), 'search_close .5s') btf.animateOut($searchDialog, 'search_close .5s')
btf.animateOut(document.getElementById('search-mask'), 'to_hide 0.5s') btf.animateOut($searchMask, 'to_hide 0.5s')
window.removeEventListener('resize', fixSafariHeight)
}
// fix safari
const fixSafariHeight = () => {
if (window.innerWidth < 768) {
$searchDialog.style.setProperty('--search-height', window.innerHeight + 'px')
}
} }
const searchClickFn = () => { const searchClickFn = () => {
document.querySelector('#search-button > .search').addEventListener('click', openSearch) document.querySelector('#search-button > .search').addEventListener('click', openSearch)
} }
const searchClickFnOnce = () => { const searchFnOnce = () => {
document.getElementById('search-mask').addEventListener('click', closeSearch) $searchMask.addEventListener('click', closeSearch)
document.querySelector('#algolia-search .search-close-button').addEventListener('click', closeSearch) document.querySelector('#algolia-search .search-close-button').addEventListener('click', closeSearch)
} }
@@ -56,7 +70,7 @@ window.addEventListener('load', () => {
post = '...' post = '...'
} }
let matchContent = pre + content.substring(start, end) + post const matchContent = pre + content.substring(start, end) + post
return matchContent return matchContent
} }
@@ -68,10 +82,11 @@ window.addEventListener('load', () => {
const search = instantsearch({ const search = instantsearch({
indexName: algolia.indexName, indexName: algolia.indexName,
/* global algoliasearch */
searchClient: algoliasearch(algolia.appId, algolia.apiKey), searchClient: algoliasearch(algolia.appId, algolia.apiKey),
searchFunction(helper) { searchFunction (helper) {
helper.state.query && helper.search() helper.state.query && helper.search()
}, }
}) })
const configure = instantsearch.widgets.configure({ const configure = instantsearch.widgets.configure({
@@ -89,21 +104,21 @@ window.addEventListener('load', () => {
const hits = instantsearch.widgets.hits({ const hits = instantsearch.widgets.hits({
container: '#algolia-hits', container: '#algolia-hits',
templates: { templates: {
item(data) { item (data) {
const link = data.permalink ? data.permalink : (GLOBAL_CONFIG.root + data.path) const link = data.permalink ? data.permalink : (GLOBAL_CONFIG.root + data.path)
const result = data._highlightResult const result = data._highlightResult
const content = result.contentStripTruncate const content = result.contentStripTruncate
? cutContent(result.contentStripTruncate.value) ? cutContent(result.contentStripTruncate.value)
: result.contentStrip : result.contentStrip
? cutContent(result.contentStrip.value) ? cutContent(result.contentStrip.value)
: result.content : result.content
? cutContent(result.content.value) ? cutContent(result.content.value)
: '' : ''
return ` return `
<a href="${link}" class="algolia-hit-item-link"> <a href="${link}" class="algolia-hit-item-link">
${result.title.value || 'no-title'} <span class="algolia-hits-item-title">${result.title.value || 'no-title'}</span>
</a> <p class="algolia-hit-item-content">${content}</p>
<p class="algolia-hit-item-content">${content}</p>` </a>`
}, },
empty: function (data) { empty: function (data) {
return ( return (
@@ -130,7 +145,7 @@ window.addEventListener('load', () => {
}) })
const powerBy = instantsearch.widgets.poweredBy({ const powerBy = instantsearch.widgets.poweredBy({
container: '#algolia-info > .algolia-poweredBy', container: '#algolia-info > .algolia-poweredBy'
}) })
const pagination = instantsearch.widgets.pagination({ const pagination = instantsearch.widgets.pagination({
@@ -144,16 +159,15 @@ 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() search.start()
searchClickFn() searchClickFn()
searchClickFnOnce() searchFnOnce()
window.addEventListener('pjax:complete', () => { window.addEventListener('pjax:complete', () => {
getComputedStyle(document.querySelector('#algolia-search .search-dialog')).display === 'block' && closeSearch() !btf.isHidden($searchMask) && closeSearch()
searchClickFn() searchClickFn()
}) })

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