mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-12 22:17:06 +08:00
Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9479f8a704 | ||
|
|
793e004a3a | ||
|
|
b3e5b7c30d | ||
|
|
c2c199bd16 | ||
|
|
3e30f301a0 | ||
|
|
5b1473c2c8 | ||
|
|
ec78f66470 | ||
|
|
a33602e023 | ||
|
|
ee3c143424 | ||
|
|
4461473aa6 | ||
|
|
3cb2120630 | ||
|
|
df678dfde2 | ||
|
|
34bb030345 | ||
|
|
0726c2263f | ||
|
|
7ebed025f0 | ||
|
|
4248103024 | ||
|
|
ab6672429f | ||
|
|
ca4c0e2a6b | ||
|
|
26e8c618d8 | ||
|
|
c1ac4a5e16 | ||
|
|
e0fd3c9f92 | ||
|
|
96e8d624dc | ||
|
|
84ad5c5dd6 |
61
.github/ISSUE_TEMPLATE/bug_report.md
vendored
61
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -1,61 +0,0 @@
|
|||||||
---
|
|
||||||
name: Bug report
|
|
||||||
about: Create a report to help us improve
|
|
||||||
title: ''
|
|
||||||
labels: ''
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
<!-- Do not delete the template (不要刪除模板) -->
|
|
||||||
|
|
||||||
<!--
|
|
||||||
IMPORTANT: Please follow the template to create a new issue.
|
|
||||||
重要:請依照該模板來提交。
|
|
||||||
|
|
||||||
If you upgrade from the old version, and an error occurs when running, please copy the new content in the config to the butterfly.yml
|
|
||||||
如果你是由舊版本升級到新版,執行時出現報錯,請首先把config裡新的內容複製到舊的butterfly設定去(如有)
|
|
||||||
|
|
||||||
If you are a problem when visiting the website, please open your browser 'developer tools (shortcut F12)' and check the console if there is an error, include your website address in the feedback
|
|
||||||
如果你是線上訪問出現問題,請檢查瀏覽器‘開發人員工具(快捷鍵F12)’的console是否有報錯,反饋時附上你的網站
|
|
||||||
-->
|
|
||||||
|
|
||||||
|
|
||||||
## I want to create a Bug report <!-- 我想要建立一個 Bug report -->
|
|
||||||
|
|
||||||
<!-- Check all with "x" especially FAQ & Documentation!! (使用 "x" 選擇) -->
|
|
||||||
<!-- 請確認是否都已經翻閲過如下的資料, 尤其是安裝文件!! -->
|
|
||||||
- [] Yes, I have read [Hexo Docs page](https://hexo.io/docs/), especially [Templates](https://hexo.io/docs/templates.html), [Variables](https://hexo.io/docs/variables.html), [Helpers](https://hexo.io/docs/helpers.html) and [Troubleshooting](https://hexo.io/docs/troubleshooting.html).
|
|
||||||
- [] Yes, I have read [Butterfly Documentation](https://butterfly.js.org/posts/21cfbf15/).
|
|
||||||
- [] And yes, I already searched for current [issues](https://github.com/jerryc127/hexo-theme-butterfly/issues?utf8=%E2%9C%93&q=is%3Aissue) and this did not help me.
|
|
||||||
|
|
||||||
## Butterfly Information
|
|
||||||
|
|
||||||
<!-- Butterfly的版本 -->
|
|
||||||
<!-- 檢視主題的package.json -->
|
|
||||||
**Butterfly Version:**
|
|
||||||
|
|
||||||
<!-- Windows/macOS/Linux/Android/iOS -->
|
|
||||||
**Platform:**
|
|
||||||
|
|
||||||
<!-- Chrome/Safari/FireFox/.. -->
|
|
||||||
**Browser:**
|
|
||||||
|
|
||||||
## Expected behavior <!-- (預期行為) -->
|
|
||||||
|
|
||||||
## Actual behavior <!-- (實際行為) -->
|
|
||||||
|
|
||||||
## Steps to reproduce the behavior <!-- (重現步驟) -->
|
|
||||||
1. Go to '...'
|
|
||||||
2. Click on '....'
|
|
||||||
3. Scroll down to '....'
|
|
||||||
4. See error
|
|
||||||
|
|
||||||
<!-- If applicable, add screenshots to help explain your problem -->
|
|
||||||
<!-- 請儘量提供截圖來定位問題 -->
|
|
||||||
## Screenshots <!-- (截圖) -->
|
|
||||||
|
|
||||||
<!-- Provide your website to find the issues -->
|
|
||||||
## Website
|
|
||||||
|
|
||||||
## Describe the bug
|
|
||||||
63
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
63
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
name: Bug report
|
||||||
|
description: Create a report to help us improve
|
||||||
|
title: '[Bug]: '
|
||||||
|
|
||||||
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
重要:請依照該模板來提交
|
||||||
|
Please follow the template to create a new issue
|
||||||
|
- type: input
|
||||||
|
id: butterfly-ver
|
||||||
|
attributes:
|
||||||
|
label: 使用的 Butterfly 版本? | What version of Butterfly are you use?
|
||||||
|
description: 檢視主題的 package.json | Check the theme's package.json
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: dropdown
|
||||||
|
id: browser
|
||||||
|
attributes:
|
||||||
|
label: 使用的瀏覽器? || What browse are you using?
|
||||||
|
options:
|
||||||
|
- Chrome
|
||||||
|
- Edge
|
||||||
|
- Safari
|
||||||
|
- Opera
|
||||||
|
- Other
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: dropdown
|
||||||
|
id: platform
|
||||||
|
attributes:
|
||||||
|
label: 使用的系統? || What operating system are you using?
|
||||||
|
options:
|
||||||
|
- Windows
|
||||||
|
- macOS
|
||||||
|
- Linux
|
||||||
|
- Android
|
||||||
|
- iOS
|
||||||
|
- Other
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
id: description
|
||||||
|
attributes:
|
||||||
|
label: 問題描述 | Describe the bug
|
||||||
|
description: 請描述你的問題現象 | A clear and concise description of what the bug is.
|
||||||
|
placeholder: 請儘量提供截圖來定位問題 | If applicable, add screenshots to help explain your problem
|
||||||
|
value:
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: input
|
||||||
|
id: website
|
||||||
|
attributes:
|
||||||
|
label: 出現問題網站 | Website
|
||||||
|
description: 請提供下可復現網站地址 | Please supply a website url which can reproduce problem.
|
||||||
|
placeholder:
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
22
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
22
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
blank_issues_enabled: false
|
||||||
|
contact_links:
|
||||||
|
- name: Questions about Butterfly
|
||||||
|
url: https://github.com/jerryc127/hexo-theme-butterfly/discussions
|
||||||
|
about: 一些使用問題請到 Discussion 詢問。 Please ask questions in Discussion.
|
||||||
|
|
||||||
|
- name: Butterfly Q&A
|
||||||
|
url: https://butterfly.js.org/posts/98d20436/
|
||||||
|
about: Butterfly Q&A
|
||||||
|
|
||||||
|
- name: Telegram
|
||||||
|
url: https://t.me/bu2fly
|
||||||
|
about: 'Official Telegram Group'
|
||||||
|
|
||||||
|
- name: QQ 1群
|
||||||
|
url: https://jq.qq.com/?_wv=1027&k=KU9105XR
|
||||||
|
about: '群號 1070540070,不要兩個Q群都添加'
|
||||||
|
|
||||||
|
- name: QQ 2群
|
||||||
|
url: https://jq.qq.com/?_wv=1027&k=r1nK0DQz
|
||||||
|
about: '群號 978221020,不要兩個Q群都添加'
|
||||||
|
|
||||||
9
.github/ISSUE_TEMPLATE/custom.md
vendored
9
.github/ISSUE_TEMPLATE/custom.md
vendored
@@ -1,9 +0,0 @@
|
|||||||
---
|
|
||||||
name: Custom issue template
|
|
||||||
about: Describe this issue template's purpose here.
|
|
||||||
title: ''
|
|
||||||
labels: ''
|
|
||||||
assignees: ''
|
|
||||||
---
|
|
||||||
|
|
||||||
|
|
||||||
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@@ -1,20 +0,0 @@
|
|||||||
---
|
|
||||||
name: Feature request
|
|
||||||
about: Suggest an idea for this project
|
|
||||||
title: ''
|
|
||||||
labels: ''
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**Is your feature request related to a problem? Please describe.**
|
|
||||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
|
||||||
|
|
||||||
**Describe the solution you'd like**
|
|
||||||
A clear and concise description of what you want to happen.
|
|
||||||
|
|
||||||
**Describe alternatives you've considered**
|
|
||||||
A clear and concise description of any alternative solutions or features you've considered.
|
|
||||||
|
|
||||||
**Additional context**
|
|
||||||
Add any other context or screenshots about the feature request here.
|
|
||||||
14
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
Normal file
14
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
name: Feature request
|
||||||
|
description: Suggest an idea for this project
|
||||||
|
title: '[Feature]: '
|
||||||
|
|
||||||
|
body:
|
||||||
|
- type: textarea
|
||||||
|
id: feature-request
|
||||||
|
attributes:
|
||||||
|
label: 想要的功能 | What feature do you want?
|
||||||
|
description: 請描述你需要的新功能 | A clear and concise description of what the feature is.
|
||||||
|
placeholder:
|
||||||
|
value:
|
||||||
|
validations:
|
||||||
|
require: true
|
||||||
2
.github/stale.yml
vendored
2
.github/stale.yml
vendored
@@ -10,7 +10,7 @@ exemptLabels:
|
|||||||
- enhancement
|
- enhancement
|
||||||
- documentation
|
- documentation
|
||||||
# Label to use when marking an issue as stale
|
# Label to use when marking an issue as stale
|
||||||
staleLabel: wontfix
|
staleLabel: stale
|
||||||
# Comment to post when marking an issue as stale. Set to `false` to disable
|
# Comment to post when marking an issue as stale. Set to `false` to disable
|
||||||
markComment: >
|
markComment: >
|
||||||
This issue has been automatically marked as stale because it has not had
|
This issue has been automatically marked as stale because it has not had
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||

|

|
||||||

|

|
||||||

|

|
||||||

|

|
||||||

|

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

|

|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||

|

|
||||||

|

|
||||||

|

|
||||||

|

|
||||||

|

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

|

|
||||||
|
|||||||
156
_config.yml
156
_config.yml
@@ -39,6 +39,7 @@ social:
|
|||||||
# fas fa-envelope: mailto:xxxxxx@gmail.com || Email
|
# fas fa-envelope: mailto:xxxxxx@gmail.com || Email
|
||||||
|
|
||||||
# search (搜索)
|
# search (搜索)
|
||||||
|
# see https://butterfly.js.org/posts/ceeb73f/#搜索系統
|
||||||
# --------------------------------------
|
# --------------------------------------
|
||||||
|
|
||||||
# Algolia search
|
# Algolia search
|
||||||
@@ -50,6 +51,8 @@ algolia_search:
|
|||||||
# Local search
|
# Local search
|
||||||
local_search:
|
local_search:
|
||||||
enable: false
|
enable: false
|
||||||
|
preload: false
|
||||||
|
CDN:
|
||||||
|
|
||||||
# Math (數學)
|
# Math (數學)
|
||||||
# --------------------------------------
|
# --------------------------------------
|
||||||
@@ -148,6 +151,7 @@ post_meta:
|
|||||||
label: true # true or false 顯示描述性文字
|
label: true # true or false 顯示描述性文字
|
||||||
|
|
||||||
# wordcount (字數統計)
|
# wordcount (字數統計)
|
||||||
|
# see https://butterfly.js.org/posts/ceeb73f/#字數統計
|
||||||
wordcount:
|
wordcount:
|
||||||
enable: false
|
enable: false
|
||||||
post_wordcount: true
|
post_wordcount: true
|
||||||
@@ -181,6 +185,7 @@ toc:
|
|||||||
post_copyright:
|
post_copyright:
|
||||||
enable: true
|
enable: true
|
||||||
decode: false
|
decode: false
|
||||||
|
author_href:
|
||||||
license: CC BY-NC-SA 4.0
|
license: CC BY-NC-SA 4.0
|
||||||
license_url: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
license_url: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||||
|
|
||||||
@@ -308,7 +313,7 @@ valine:
|
|||||||
waline:
|
waline:
|
||||||
serverURL: # Waline server address url
|
serverURL: # Waline server address url
|
||||||
bg: # waline background
|
bg: # waline background
|
||||||
visitor: false
|
pageview: false
|
||||||
option:
|
option:
|
||||||
|
|
||||||
# utterances
|
# utterances
|
||||||
@@ -468,6 +473,8 @@ site_verification:
|
|||||||
# blockquote_padding_color: "#49b1f5"
|
# blockquote_padding_color: "#49b1f5"
|
||||||
# blockquote_background_color: "#49b1f5"
|
# blockquote_background_color: "#49b1f5"
|
||||||
# scrollbar_color: "#49b1f5"
|
# scrollbar_color: "#49b1f5"
|
||||||
|
# meta_theme_color_light: "ffffff"
|
||||||
|
# meta_theme_color_dark: "#0d0d0d"
|
||||||
|
|
||||||
# The top_img settings of home page
|
# The top_img settings of home page
|
||||||
# default: top img - full screen, site info - middle (默認top_img全屏,site_info在中間)
|
# default: top img - full screen, site info - middle (默認top_img全屏,site_info在中間)
|
||||||
@@ -614,6 +621,7 @@ aside:
|
|||||||
button: true
|
button: true
|
||||||
mobile: true # display on mobile
|
mobile: true # display on mobile
|
||||||
position: right # left or right
|
position: right # left or right
|
||||||
|
archives: true
|
||||||
card_author:
|
card_author:
|
||||||
enable: true
|
enable: true
|
||||||
description:
|
description:
|
||||||
@@ -776,7 +784,7 @@ snackbar:
|
|||||||
enable: false
|
enable: false
|
||||||
position: bottom-left
|
position: bottom-left
|
||||||
bg_light: '#49b1f5' # The background color of Toast Notification in light mode
|
bg_light: '#49b1f5' # The background color of Toast Notification in light mode
|
||||||
bg_dark: '#121212' # The background color of Toast Notification in dark mode
|
bg_dark: '#1f1f1f' # The background color of Toast Notification in dark mode
|
||||||
|
|
||||||
# https://instant.page/
|
# https://instant.page/
|
||||||
# prefetch (預加載)
|
# prefetch (預加載)
|
||||||
@@ -827,88 +835,62 @@ inject:
|
|||||||
# Don't modify the following settings unless you know how they work
|
# Don't modify the following settings unless you know how they work
|
||||||
# 非必要請不要修改
|
# 非必要請不要修改
|
||||||
CDN:
|
CDN:
|
||||||
# main
|
# The CDN provider of internal scripts (主題內部 js 的 cdn 配置)
|
||||||
main_css:
|
# option: local/jsdelivr
|
||||||
main:
|
# Dev version cannot choose jsdelivr (dev版的主題不能設置為 jsdelivr)
|
||||||
utils:
|
internal_provider: local
|
||||||
|
# The CDN provider of third party scripts (第三方 js 的 cdn 配置)
|
||||||
# pjax
|
# option: local/jsdelivr
|
||||||
pjax:
|
# when set it to local, you need to install hexo-butterfly-extjs
|
||||||
|
third_party_provider: jsdelivr
|
||||||
# comments
|
option:
|
||||||
gitalk:
|
# main_css:
|
||||||
gitalk_css:
|
# main:
|
||||||
blueimp_md5:
|
# utils:
|
||||||
valine:
|
# translate:
|
||||||
disqusjs:
|
# local_search:
|
||||||
disqusjs_css:
|
# algolia_js:
|
||||||
utterances:
|
# algolia_search_v4:
|
||||||
twikoo:
|
# instantsearch_v4:
|
||||||
waline:
|
# pjax:
|
||||||
giscus:
|
# gitalk:
|
||||||
|
# gitalk_css:
|
||||||
# share
|
# blueimp_md5:
|
||||||
addtoany:
|
# valine:
|
||||||
sharejs:
|
# disqusjs:
|
||||||
sharejs_css:
|
# disqusjs_css:
|
||||||
|
# twikoo:
|
||||||
# search
|
# waline_js:
|
||||||
local_search:
|
# waline_css:
|
||||||
algolia_js:
|
# sharejs:
|
||||||
algolia_search_v4:
|
# sharejs_css:
|
||||||
instantsearch_v4:
|
# mathjax:
|
||||||
|
# katex:
|
||||||
# math
|
# katex_copytex:
|
||||||
mathjax:
|
# katex_copytex_css:
|
||||||
katex:
|
# mermaid:
|
||||||
katex_copytex:
|
# canvas_ribbon:
|
||||||
katex_copytex_css:
|
# canvas_fluttering_ribbon:
|
||||||
mermaid:
|
# canvas_nest:
|
||||||
|
# lazyload:
|
||||||
# count
|
# instantpage:
|
||||||
busuanzi:
|
# typed:
|
||||||
|
# pangu:
|
||||||
# background effect
|
# fancybox_css_v4:
|
||||||
canvas_ribbon:
|
# fancybox_v4:
|
||||||
canvas_fluttering_ribbon:
|
# medium_zoom:
|
||||||
canvas_nest:
|
# snackbar_css:
|
||||||
|
# snackbar:
|
||||||
lazyload:
|
# activate_power_mode:
|
||||||
instantpage:
|
# fireworks:
|
||||||
typed:
|
# click_heart:
|
||||||
pangu:
|
# ClickShowText:
|
||||||
|
# fontawesomeV6:
|
||||||
# photo
|
# flickr_justified_gallery_js:
|
||||||
fancybox_css_v4:
|
# flickr_justified_gallery_css:
|
||||||
fancybox_v4:
|
# aplayer_css:
|
||||||
medium_zoom:
|
# aplayer_js:
|
||||||
|
# meting_js:
|
||||||
# snackbar
|
# prismjs_js:
|
||||||
snackbar_css:
|
# prismjs_lineNumber_js:
|
||||||
snackbar:
|
# prismjs_autoloader:
|
||||||
|
|
||||||
# effect
|
|
||||||
activate_power_mode:
|
|
||||||
fireworks:
|
|
||||||
click_heart:
|
|
||||||
ClickShowText:
|
|
||||||
|
|
||||||
# fontawesome
|
|
||||||
fontawesome:
|
|
||||||
|
|
||||||
# Conversion between Traditional and Simplified Chinese
|
|
||||||
translate:
|
|
||||||
|
|
||||||
# flickr-justified-gallery
|
|
||||||
flickr_justified_gallery_js:
|
|
||||||
flickr_justified_gallery_css:
|
|
||||||
|
|
||||||
# aplayer
|
|
||||||
aplayer_css:
|
|
||||||
aplayer_js:
|
|
||||||
meting_js:
|
|
||||||
|
|
||||||
# Prism.js
|
|
||||||
prismjs_js:
|
|
||||||
prismjs_lineNumber_js:
|
|
||||||
prismjs_autoloader:
|
|
||||||
@@ -43,7 +43,6 @@ search:
|
|||||||
hits_stats: '${hits} results found in ${time} ms'
|
hits_stats: '${hits} results found in ${time} ms'
|
||||||
|
|
||||||
local_search:
|
local_search:
|
||||||
label: 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}"
|
||||||
|
|
||||||
@@ -103,6 +102,7 @@ rightside:
|
|||||||
scroll_to_comment: Scroll To Comments
|
scroll_to_comment: Scroll To Comments
|
||||||
setting: Setting
|
setting: Setting
|
||||||
aside: Toggle between single-column and double-column
|
aside: Toggle between single-column and double-column
|
||||||
|
chat: Chat
|
||||||
|
|
||||||
copy_copyright:
|
copy_copyright:
|
||||||
author: Author
|
author: Author
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ search:
|
|||||||
hits_stats: '${hits} results found in ${time} ms'
|
hits_stats: '${hits} results found in ${time} ms'
|
||||||
|
|
||||||
local_search:
|
local_search:
|
||||||
label: 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}"
|
||||||
|
|
||||||
@@ -103,6 +102,7 @@ rightside:
|
|||||||
scroll_to_comment: Scroll To Comments
|
scroll_to_comment: Scroll To Comments
|
||||||
setting: Setting
|
setting: Setting
|
||||||
aside: Toggle between single-column and double-column
|
aside: Toggle between single-column and double-column
|
||||||
|
chat: Chat
|
||||||
|
|
||||||
copy_copyright:
|
copy_copyright:
|
||||||
author: Author
|
author: Author
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ search:
|
|||||||
hits_stats: '找到 ${hits} 条结果,用时 ${time} 毫秒'
|
hits_stats: '找到 ${hits} 条结果,用时 ${time} 毫秒'
|
||||||
|
|
||||||
local_search:
|
local_search:
|
||||||
label: 本地搜索
|
|
||||||
input_placeholder: 搜索文章
|
input_placeholder: 搜索文章
|
||||||
hits_empty: '找不到您查询的内容:${query}'
|
hits_empty: '找不到您查询的内容:${query}'
|
||||||
|
|
||||||
@@ -104,6 +103,7 @@ rightside:
|
|||||||
scroll_to_comment: 直达评论
|
scroll_to_comment: 直达评论
|
||||||
setting: 设置
|
setting: 设置
|
||||||
aside: 单栏和双栏切换
|
aside: 单栏和双栏切换
|
||||||
|
chat: 聊天
|
||||||
|
|
||||||
copy_copyright:
|
copy_copyright:
|
||||||
author: 作者
|
author: 作者
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ search:
|
|||||||
hits_stats: '找到 ${hits} 條結果,用時 ${time} 毫秒'
|
hits_stats: '找到 ${hits} 條結果,用時 ${time} 毫秒'
|
||||||
|
|
||||||
local_search:
|
local_search:
|
||||||
label: 本地搜尋
|
|
||||||
input_placeholder: 搜尋文章
|
input_placeholder: 搜尋文章
|
||||||
hits_empty: '找不到您查詢的內容:${query}'
|
hits_empty: '找不到您查詢的內容:${query}'
|
||||||
|
|
||||||
@@ -104,6 +103,7 @@ rightside:
|
|||||||
scroll_to_comment: 直達評論
|
scroll_to_comment: 直達評論
|
||||||
setting: 設定
|
setting: 設定
|
||||||
aside: 單欄和雙欄切換
|
aside: 單欄和雙欄切換
|
||||||
|
chat: 聊天
|
||||||
|
|
||||||
copy_copyright:
|
copy_copyright:
|
||||||
author: 作者
|
author: 作者
|
||||||
|
|||||||
@@ -1,34 +1,34 @@
|
|||||||
div
|
div
|
||||||
script(src=url_for(theme.CDN.utils))
|
script(src=url_for(theme.asset.utils))
|
||||||
script(src=url_for(theme.CDN.main))
|
script(src=url_for(theme.asset.main))
|
||||||
|
|
||||||
if theme.translate.enable
|
if theme.translate.enable
|
||||||
script(src=url_for(theme.CDN.translate))
|
script(src=url_for(theme.asset.translate))
|
||||||
|
|
||||||
if theme.medium_zoom
|
if theme.medium_zoom
|
||||||
script(src=url_for(theme.CDN.medium_zoom))
|
script(src=url_for(theme.asset.medium_zoom))
|
||||||
else if theme.fancybox
|
else if theme.fancybox
|
||||||
script(src=url_for(theme.CDN.fancybox_v4))
|
script(src=url_for(theme.asset.fancybox_v4))
|
||||||
|
|
||||||
if theme.instantpage
|
if theme.instantpage
|
||||||
script(src=url_for(theme.CDN.instantpage), type='module')
|
script(src=url_for(theme.asset.instantpage), type='module')
|
||||||
|
|
||||||
if theme.lazyload.enable
|
if theme.lazyload.enable
|
||||||
script(src=url_for(theme.CDN.lazyload))
|
script(src=url_for(theme.asset.lazyload))
|
||||||
|
|
||||||
if theme.snackbar.enable
|
if theme.snackbar.enable
|
||||||
script(src=url_for(theme.CDN.snackbar))
|
script(src=url_for(theme.asset.snackbar))
|
||||||
|
|
||||||
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
|
//- search
|
||||||
if theme.algolia_search.enable
|
if theme.algolia_search.enable
|
||||||
script(src=url_for(theme.CDN.algolia_search_v4))
|
script(src=url_for(theme.asset.algolia_search_v4))
|
||||||
script(src=url_for(theme.CDN.instantsearch_v4))
|
script(src=url_for(theme.asset.instantsearch_v4))
|
||||||
script(src=url_for(theme.CDN.algolia_js))
|
script(src=url_for(theme.asset.algolia_js))
|
||||||
else if theme.local_search.enable
|
else if theme.local_search.enable
|
||||||
script(src=url_for(theme.CDN.local_search))
|
script(src=url_for(theme.asset.local_search))
|
||||||
|
|
||||||
if theme.preloader
|
if theme.preloader
|
||||||
!= partial("includes/loading/loading-js", {}, { cache: true })
|
!= partial("includes/loading/loading-js", {}, { cache: true })
|
||||||
@@ -69,4 +69,4 @@ 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=url_for(theme.CDN.busuanzi))
|
script(async data-pjax src='//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js')
|
||||||
|
|||||||
@@ -16,7 +16,9 @@
|
|||||||
- else pageKeywords = Array.isArray(config.keywords) ? (config.keywords).join(','): ([]).join(',') || config.keywords
|
- 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 themeColor = theme.display_mode === 'dark' ? '#0d0d0d' : '#ffffff'
|
- var themeColorLight = theme.theme_color && theme.theme_color.enable && theme.theme_color.meta_theme_color_light || '#ffffff'
|
||||||
|
- var themeColorDark = theme.theme_color && theme.theme_color.enable && theme.theme_color.meta_theme_color_dark || '#0d0d0d'
|
||||||
|
- var themeColor = theme.display_mode === 'dark' ? themeColorDark : themeColorLight
|
||||||
|
|
||||||
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")
|
||||||
@@ -46,14 +48,14 @@ if (theme.pwa && theme.pwa.enable)
|
|||||||
!=partial('includes/head/pwa', {}, {cache: true})
|
!=partial('includes/head/pwa', {}, {cache: true})
|
||||||
|
|
||||||
//- main css
|
//- main css
|
||||||
link(rel='stylesheet', href=url_for(theme.CDN.main_css))
|
link(rel='stylesheet', href=url_for(theme.asset.main_css))
|
||||||
link(rel='stylesheet', href=url_for(theme.CDN.fontawesome) media="print" onload="this.media='all'")
|
link(rel='stylesheet', href=url_for(theme.asset.fontawesomeV6) 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.CDN.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.CDN.fancybox_css_v4) media="print" onload="this.media='all'")
|
link(rel='stylesheet' href=url_for(theme.asset.fancybox_css_v4) media="print" onload="this.media='all'")
|
||||||
|
|
||||||
//- google_adsense
|
//- google_adsense
|
||||||
!=partial('includes/head/google_adsense', {}, {cache: true})
|
!=partial('includes/head/google_adsense', {}, {cache: true})
|
||||||
|
|||||||
@@ -19,7 +19,8 @@
|
|||||||
let localSearch = 'undefined';
|
let localSearch = 'undefined';
|
||||||
if (theme.local_search && theme.local_search.enable) {
|
if (theme.local_search && theme.local_search.enable) {
|
||||||
localSearch = JSON.stringify({
|
localSearch = JSON.stringify({
|
||||||
path: config.search.path,
|
path: theme.local_search.CDN ? theme.local_search.CDN : config.root + config.search.path,
|
||||||
|
preload: theme.local_search.preload,
|
||||||
languages: {
|
languages: {
|
||||||
// search languages
|
// search languages
|
||||||
hits_empty: _p("search.local_search.hits_empty"),
|
hits_empty: _p("search.local_search.hits_empty"),
|
||||||
@@ -113,8 +114,8 @@ script.
|
|||||||
Snackbar: !{Snackbar},
|
Snackbar: !{Snackbar},
|
||||||
source: {
|
source: {
|
||||||
justifiedGallery: {
|
justifiedGallery: {
|
||||||
js: '!{url_for(theme.CDN.flickr_justified_gallery_js)}',
|
js: '!{url_for(theme.asset.flickr_justified_gallery_js)}',
|
||||||
css: '!{url_for(theme.CDN.flickr_justified_gallery_css)}'
|
css: '!{url_for(theme.asset.flickr_justified_gallery_css)}'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
isPhotoFigcaption: !{theme.photofigcaption},
|
isPhotoFigcaption: !{theme.photofigcaption},
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
else isHighlightShrink = theme.highlight_shrink
|
else isHighlightShrink = theme.highlight_shrink
|
||||||
|
|
||||||
var showToc = false
|
var showToc = false
|
||||||
if (theme.aside.enable) {
|
if (theme.aside.enable && page.aside !== false) {
|
||||||
let tocEnable = false
|
let tocEnable = false
|
||||||
if (is_post()) {
|
if (is_post()) {
|
||||||
if (theme.toc.post) tocEnable = true
|
if (theme.toc.post) tocEnable = true
|
||||||
|
|||||||
@@ -61,16 +61,24 @@
|
|||||||
if block
|
if block
|
||||||
block
|
block
|
||||||
|
|
||||||
if theme.busuanzi.page_pv
|
- const commentUse = comments.use
|
||||||
+pvBlock('','post-meta-pv-cv','')
|
if commentUse && !comments.lazyload
|
||||||
span#busuanzi_value_page_pv
|
case commentUse[0]
|
||||||
else if comments.use && !comments.lazyload
|
when 'Valine'
|
||||||
if (comments.use.includes('Valine') && theme.valine.visitor) || (comments.use.includes('Waline') && theme.waline.visitor)
|
if theme.valine.visitor
|
||||||
+pvBlock(url_for(page.path),'leancloud_visitors',page.title)
|
+pvBlock(url_for(page.path),'leancloud_visitors',page.title)
|
||||||
span.leancloud-visitors-count
|
span.leancloud-visitors-count
|
||||||
else if (comments.use.includes('Twikoo') && theme.twikoo.visitor)
|
when 'Waline'
|
||||||
|
if theme.waline.pageview
|
||||||
|
+pvBlock('','','')
|
||||||
|
span.waline-pageview-count(data-path=url_for(page.path))
|
||||||
|
when 'Twikoo'
|
||||||
|
if theme.twikoo.visitor
|
||||||
+pvBlock('','','')
|
+pvBlock('','','')
|
||||||
span#twikoo_visitors
|
span#twikoo_visitors
|
||||||
|
else if theme.busuanzi.page_pv
|
||||||
|
+pvBlock('','post-meta-pv-cv','')
|
||||||
|
span#busuanzi_value_page_pv
|
||||||
|
|
||||||
if comments.count && !comments.lazyload && page.comments !== false && comments.use
|
if comments.count && !comments.lazyload && page.comments !== false && comments.use
|
||||||
- var whichCount = comments.use[0]
|
- var whichCount = comments.use[0]
|
||||||
@@ -96,7 +104,7 @@
|
|||||||
when 'Waline'
|
when 'Waline'
|
||||||
+countBlock
|
+countBlock
|
||||||
a(href=url_for(page.path) + '#post-comment')
|
a(href=url_for(page.path) + '#post-comment')
|
||||||
span.waline-comment-count(id=url_for(page.path))
|
span.waline-comment-count(data-path=url_for(page.path))
|
||||||
when 'Gitalk'
|
when 'Gitalk'
|
||||||
+countBlock
|
+countBlock
|
||||||
a(href=url_for(page.path) + '#post-comment')
|
a(href=url_for(page.path) + '#post-comment')
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
- var htmlClassHideAside = theme.aside.enable && theme.aside.hide ? 'hide-aside' : ''
|
- var htmlClassHideAside = theme.aside.enable && theme.aside.hide ? 'hide-aside' : ''
|
||||||
|
- page.aside = is_archive() ? theme.aside.archives : page.aside
|
||||||
- var hideAside = !theme.aside.enable || page.aside === false ? 'hide-aside' : ''
|
- var hideAside = !theme.aside.enable || page.aside === false ? 'hide-aside' : ''
|
||||||
- var pageType = is_post() ? 'post' : 'page'
|
- var pageType = is_post() ? 'post' : 'page'
|
||||||
|
|
||||||
|
|||||||
@@ -4,64 +4,64 @@
|
|||||||
script.
|
script.
|
||||||
(()=>{
|
(()=>{
|
||||||
const replaceSymbol = (str) => {
|
const replaceSymbol = (str) => {
|
||||||
return str.replace(/[\p{P}\p{S}]/gu, '-')
|
return str.replace(/[\p{P}\p{S}]/gu, "-")
|
||||||
}
|
}
|
||||||
|
|
||||||
let result = ''
|
let result = ""
|
||||||
fetch('!{url_for(page.flink_url)}')
|
fetch("!{url_for(page.flink_url)}")
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(str => {
|
.then(str => {
|
||||||
for(let i = 0; i < str.length; i++){
|
for(let i = 0; i < str.length; i++){
|
||||||
const replaceClassName = replaceSymbol(str[i].class_name)
|
const replaceClassName = replaceSymbol(str[i].class_name)
|
||||||
const className = str[i].class_name ? `<h2 id='${replaceClassName}'><a href="#${replaceClassName}" class="headerlink" title="${str[i].class_name}"></a>${str[i].class_name}</h2>` : ''
|
const className = str[i].class_name ? `<h2 id="${replaceClassName}"><a href="#${replaceClassName}" class="headerlink" title="${str[i].class_name}"></a>${str[i].class_name}</h2>` : ""
|
||||||
const classDesc = str[i].class_desc ? `<div class='flink-desc'>${str[i].class_desc}</div>` : ''
|
const classDesc = str[i].class_desc ? `<div class="flink-desc">${str[i].class_desc}</div>` : ""
|
||||||
|
|
||||||
let listResult = ''
|
let listResult = ""
|
||||||
const lists = str[i].link_list
|
const lists = str[i].link_list
|
||||||
for(let j = 0; j < lists.length; j++){
|
for(let j = 0; j < lists.length; j++){
|
||||||
listResult += `
|
listResult += `
|
||||||
<div class="flink-list-item">
|
<div class="flink-list-item">
|
||||||
<a href='${lists[j].link}' title='${lists[j].name}' target='_blank'>
|
<a href="${lists[j].link}" title="${lists[j].name}" target="_blank">
|
||||||
<div class='flink-item-icon'>
|
<div class="flink-item-icon">
|
||||||
<img class='no-lightbox' src='${lists[j].avatar}' onerror='this.onerror=null;this.src="!{url_for(theme.error_img.flink)}"' alt='${lists[j].name}' />
|
<img class="no-lightbox" src="${lists[j].avatar}" onerror='this.onerror=null;this.src="!{url_for(theme.error_img.flink)}"' alt="${lists[j].name}" />
|
||||||
</div>
|
</div>
|
||||||
<div class='flink-item-name'>${lists[j].name}</div>
|
<div class="flink-item-name">${lists[j].name}</div>
|
||||||
<div class='flink-item-desc' title='${lists[j].descr}'>${lists[j].descr}</div>
|
<div class="flink-item-desc" title="${lists[j].descr}">${lists[j].descr}</div>
|
||||||
</a>
|
</a>
|
||||||
</div>`
|
</div>`
|
||||||
}
|
}
|
||||||
|
|
||||||
result += `${className}${classDesc} <div class='flink-list'>${listResult}</div>`
|
result += `${className}${classDesc} <div class="flink-list">${listResult}</div>`
|
||||||
}
|
}
|
||||||
|
|
||||||
document.querySelector('.flink').insertAdjacentHTML('afterbegin', result)
|
document.querySelector(".flink").insertAdjacentHTML("afterbegin", result)
|
||||||
})
|
})
|
||||||
})()
|
})()
|
||||||
|
|
||||||
else
|
else
|
||||||
if site.data.link
|
if site.data.link
|
||||||
- let result = ''
|
- let result = ""
|
||||||
each i in site.data.link
|
each i in site.data.link
|
||||||
- let className = i.class_name ? markdown(`## ${i.class_name}`) : ''
|
- let className = i.class_name ? markdown(`## ${i.class_name}`) : ""
|
||||||
- let classDesc = i.class_desc ? `<div class='flink-desc'>${i.class_desc}</div>` : ''
|
- let classDesc = i.class_desc ? `<div class="flink-desc">${i.class_desc}</div>` : ""
|
||||||
|
|
||||||
- let listResult = ''
|
- let listResult = ""
|
||||||
|
|
||||||
each j in i.link_list
|
each j in i.link_list
|
||||||
-
|
-
|
||||||
listResult += `
|
listResult += `
|
||||||
<div class="flink-list-item">
|
<div class="flink-list-item">
|
||||||
<a href='${j.link}' title='${j.name}' target='_blank'>
|
<a href="${j.link}" title="${j.name}" target="_blank">
|
||||||
<div class='flink-item-icon'>
|
<div class="flink-item-icon">
|
||||||
<img class='no-lightbox' src='${j.avatar}' onerror='this.onerror=null;this.src="${url_for(theme.error_img.flink)}"' alt='${j.name}' />
|
<img class="no-lightbox" src="${j.avatar}" onerror='this.onerror=null;this.src="${url_for(theme.error_img.flink)}"' alt="${j.name}" />
|
||||||
</div>
|
</div>
|
||||||
<div class='flink-item-name'>${j.name}</div>
|
<div class="flink-item-name">${j.name}</div>
|
||||||
<div class='flink-item-desc' title='${j.descr}'>${j.descr}</div>
|
<div class="flink-item-desc" title="${j.descr}">${j.descr}</div>
|
||||||
</a>
|
</a>
|
||||||
</div>`
|
</div>`
|
||||||
-
|
-
|
||||||
|
|
||||||
- result += `${className}${classDesc} <div class='flink-list'>${listResult}</div>`
|
- result += `${className}${classDesc} <div class="flink-list">${listResult}</div>`
|
||||||
|
|
||||||
- page.content = result + page.content
|
- page.content = result + page.content
|
||||||
!= page.content
|
!= page.content
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
if theme.post_copyright.enable && page.copyright !== false
|
if theme.post_copyright.enable && page.copyright !== false
|
||||||
- let author = page.copyright_author ? page.copyright_author : config.author
|
- let author = page.copyright_author || config.author
|
||||||
- let authorHref = page.copyright_author_href ? page.copyright_author_href : `mailto:${config.email}`
|
- let authorHref = page.copyright_author_href || theme.post_copyright.author_href || config.url
|
||||||
- let url = page.copyright_url ? page.copyright_url : page.permalink
|
- let url = page.copyright_url || page.permalink
|
||||||
- let info = page.copyright_info ? page.copyright_info : _p('post.copyright.copyright_content', theme.post_copyright.license_url, theme.post_copyright.license, config.url, config.title)
|
- let info = page.copyright_info || _p('post.copyright.copyright_content', theme.post_copyright.license_url, theme.post_copyright.license, config.url, config.title)
|
||||||
.post-copyright
|
.post-copyright
|
||||||
.post-copyright__author
|
.post-copyright__author
|
||||||
span.post-copyright-meta= _p('post.copyright.author') + ": "
|
span.post-copyright-meta= _p('post.copyright.author') + ": "
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ mixin rightsideItem(array)
|
|||||||
i.fas.fa-list-ul
|
i.fas.fa-list-ul
|
||||||
when 'chat'
|
when 'chat'
|
||||||
if chat_btn
|
if chat_btn
|
||||||
button#chat_btn(type="button" title=_p("rightside.chat_btn"))
|
button#chat_btn(type="button" title=_p("rightside.chat"))
|
||||||
i.fas.fa-sms
|
i.fas.fa-sms
|
||||||
when 'comment'
|
when 'comment'
|
||||||
if commentsJsLoad
|
if commentsJsLoad
|
||||||
|
|||||||
@@ -3,18 +3,13 @@
|
|||||||
#sidebar-menus
|
#sidebar-menus
|
||||||
.avatar-img.is-center
|
.avatar-img.is-center
|
||||||
img(src=url_for(theme.avatar.img) onerror=`onerror=null;src='${theme.error_img.flink}'` alt="avatar")
|
img(src=url_for(theme.avatar.img) onerror=`onerror=null;src='${theme.error_img.flink}'` alt="avatar")
|
||||||
.site-data.is-center
|
.sidebar-site-data.site-data.is-center
|
||||||
.data-item
|
|
||||||
a(href=url_for(config.archive_dir) + '/')
|
a(href=url_for(config.archive_dir) + '/')
|
||||||
.headline= _p('aside.articles')
|
.headline= _p('aside.articles')
|
||||||
.length-num= site.posts.length
|
.length-num= site.posts.length
|
||||||
|
|
||||||
.data-item
|
|
||||||
a(href=url_for(config.tag_dir) + '/' )
|
a(href=url_for(config.tag_dir) + '/' )
|
||||||
.headline= _p('aside.tags')
|
.headline= _p('aside.tags')
|
||||||
.length-num= site.tags.length
|
.length-num= site.tags.length
|
||||||
|
|
||||||
.data-item
|
|
||||||
a(href=url_for(config.category_dir) + '/')
|
a(href=url_for(config.category_dir) + '/')
|
||||||
.headline= _p('aside.categories')
|
.headline= _p('aside.categories')
|
||||||
.length-num= site.categories.length
|
.length-num= site.categories.length
|
||||||
|
|||||||
6
layout/includes/third-party/aplayer.pug
vendored
6
layout/includes/third-party/aplayer.pug
vendored
@@ -1,3 +1,3 @@
|
|||||||
link(rel='stylesheet' href=url_for(theme.CDN.aplayer_css) media="print" onload="this.media='all'")
|
link(rel='stylesheet' href=url_for(theme.asset.aplayer_css) media="print" onload="this.media='all'")
|
||||||
script(src=url_for(theme.CDN.aplayer_js))
|
script(src=url_for(theme.asset.aplayer_js))
|
||||||
script(src=url_for(theme.CDN.meting_js))
|
script(src=url_for(theme.asset.meting_js))
|
||||||
@@ -28,7 +28,7 @@ script.
|
|||||||
if (typeof twikoo === 'object') {
|
if (typeof twikoo === 'object') {
|
||||||
runTwikoo()
|
runTwikoo()
|
||||||
} else {
|
} else {
|
||||||
getScript('!{theme.CDN.twikoo}').then(runTwikoo)
|
getScript('!{theme.asset.twikoo}').then(runTwikoo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ script.
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (typeof Valine === 'function') initValine()
|
if (typeof Valine === 'function') initValine()
|
||||||
else getScript('!{url_for(theme.CDN.valine)}').then(initValine)
|
else getScript('!{url_for(theme.asset.valine)}').then(initValine)
|
||||||
}
|
}
|
||||||
|
|
||||||
window.pjax ? loadValine() : window.addEventListener('load', loadValine)
|
window.pjax ? loadValine() : window.addEventListener('load', loadValine)
|
||||||
|
|||||||
@@ -5,12 +5,13 @@ script.
|
|||||||
let initData = {
|
let initData = {
|
||||||
el: null,
|
el: null,
|
||||||
serverURL: '!{theme.waline.serverURL}',
|
serverURL: '!{theme.waline.serverURL}',
|
||||||
|
comment: true
|
||||||
}
|
}
|
||||||
const waline = new Waline(initData)
|
const waline = Waline.init(initData)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof Waline === 'function') initWaline()
|
if (typeof Waline === 'function') initWaline()
|
||||||
else getScript('!{url_for(theme.CDN.waline)}').then(initWaline)
|
else getScript('!{url_for(theme.asset.waline_js)}').then(initWaline)
|
||||||
}
|
}
|
||||||
|
|
||||||
window.pjax ? loadWaline() : window.addEventListener('load', loadWaline)
|
window.pjax ? loadWaline() : window.addEventListener('load', loadWaline)
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ script.
|
|||||||
function addDisqusjsCSS () {
|
function addDisqusjsCSS () {
|
||||||
const ele = document.createElement('link')
|
const ele = document.createElement('link')
|
||||||
ele.rel = 'stylesheet'
|
ele.rel = 'stylesheet'
|
||||||
ele.href= '!{url_for(theme.CDN.disqusjs_css)}'
|
ele.href= '!{url_for(theme.asset.disqusjs_css)}'
|
||||||
document.getElementsByTagName('head')[0].appendChild(ele)
|
document.getElementsByTagName('head')[0].appendChild(ele)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ script.
|
|||||||
if (window.disqusJsLoad) initDisqusjs()
|
if (window.disqusJsLoad) initDisqusjs()
|
||||||
else {
|
else {
|
||||||
addDisqusjsCSS()
|
addDisqusjsCSS()
|
||||||
getScript('!{url_for(theme.CDN.disqusjs)}').then(initDisqusjs)
|
getScript('!{url_for(theme.asset.disqusjs)}').then(initDisqusjs)
|
||||||
window.disqusJsLoad = true
|
window.disqusJsLoad = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ script.
|
|||||||
if (typeof FB === 'object') FB.XFBML.parse()
|
if (typeof FB === 'object') FB.XFBML.parse()
|
||||||
else {
|
else {
|
||||||
let ele = document.createElement('script')
|
let ele = document.createElement('script')
|
||||||
ele.setAttribute('src','https://connect.facebook.net/!{theme.facebook_comments.lang}/sdk.js#xfbml=1&version=v11.0')
|
ele.setAttribute('src','https://connect.facebook.net/!{theme.facebook_comments.lang}/sdk.js#xfbml=1&version=v13.0&appId=!{theme.facebook_comments.app_id}&autoLogAppEvents=1')
|
||||||
ele.setAttribute('async', 'true')
|
ele.setAttribute('async', 'true')
|
||||||
ele.setAttribute('defer', 'true')
|
ele.setAttribute('defer', 'true')
|
||||||
ele.setAttribute('crossorigin', 'anonymous')
|
ele.setAttribute('crossorigin', 'anonymous')
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ script.
|
|||||||
let nowTheme = document.documentElement.getAttribute('data-theme') === 'dark' ? '!{themes.dark}' : '!{themes.light}'
|
let nowTheme = document.documentElement.getAttribute('data-theme') === 'dark' ? '!{themes.dark}' : '!{themes.light}'
|
||||||
|
|
||||||
const config = Object.assign({
|
const config = Object.assign({
|
||||||
src: '!{theme.CDN.giscus}',
|
src: 'https://giscus.app/client.js',
|
||||||
'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}',
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ script.
|
|||||||
function addGitalkSource () {
|
function addGitalkSource () {
|
||||||
const ele = document.createElement('link')
|
const ele = document.createElement('link')
|
||||||
ele.rel = 'stylesheet'
|
ele.rel = 'stylesheet'
|
||||||
ele.href= '!{url_for(theme.CDN.gitalk_css)}'
|
ele.href= '!{url_for(theme.asset.gitalk_css)}'
|
||||||
document.getElementsByTagName('head')[0].appendChild(ele)
|
document.getElementsByTagName('head')[0].appendChild(ele)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ script.
|
|||||||
if (typeof Gitalk === 'function') initGitalk()
|
if (typeof Gitalk === 'function') initGitalk()
|
||||||
else {
|
else {
|
||||||
addGitalkSource()
|
addGitalkSource()
|
||||||
getScript('!{url_for(theme.CDN.gitalk)}').then(initGitalk)
|
getScript('!{url_for(theme.asset.gitalk)}').then(initGitalk)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ script.
|
|||||||
envId: '!{envId}',
|
envId: '!{envId}',
|
||||||
region: '!{region}',
|
region: '!{region}',
|
||||||
onCommentLoaded: function () {
|
onCommentLoaded: function () {
|
||||||
btf.loadLightbox(document.querySelectorAll('#twikoo .tk-content img:not(.vemoji)'))
|
btf.loadLightbox(document.querySelectorAll('#twikoo .tk-content img:not(.tk-owo-emotion)'))
|
||||||
}
|
}
|
||||||
}, !{JSON.stringify(option)}))
|
}, !{JSON.stringify(option)}))
|
||||||
}
|
}
|
||||||
@@ -37,7 +37,7 @@ script.
|
|||||||
setTimeout(runFn,0)
|
setTimeout(runFn,0)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
getScript('!{theme.CDN.twikoo}').then(runFn)
|
getScript('!{theme.asset.twikoo}').then(runFn)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('!{use[0]}' === 'Twikoo' || !!{lazyload}) {
|
if ('!{use[0]}' === 'Twikoo' || !!{lazyload}) {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ script.
|
|||||||
function loadUtterances () {
|
function loadUtterances () {
|
||||||
let ele = document.createElement('script')
|
let ele = document.createElement('script')
|
||||||
ele.setAttribute('id', 'utterances_comment')
|
ele.setAttribute('id', 'utterances_comment')
|
||||||
ele.setAttribute('src', '!{url_for(theme.CDN.utterances)}')
|
ele.setAttribute('src', 'https://utteranc.es/client.js')
|
||||||
ele.setAttribute('repo', '!{theme.utterances.repo}')
|
ele.setAttribute('repo', '!{theme.utterances.repo}')
|
||||||
ele.setAttribute('issue-term', '!{theme.utterances.issue_term}')
|
ele.setAttribute('issue-term', '!{theme.utterances.issue_term}')
|
||||||
let nowTheme = document.documentElement.getAttribute('data-theme') === 'dark' ? '#{theme.utterances.dark_theme}' : '#{theme.utterances.light_theme}'
|
let nowTheme = document.documentElement.getAttribute('data-theme') === 'dark' ? '#{theme.utterances.dark_theme}' : '#{theme.utterances.light_theme}'
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ script.
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (typeof Valine === 'function') initValine()
|
if (typeof Valine === 'function') initValine()
|
||||||
else getScript('!{url_for(theme.CDN.valine)}').then(initValine)
|
else getScript('!{url_for(theme.asset.valine)}').then(initValine)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('!{theme.comments.use[0]}' === 'Valine' || !!{theme.comments.lazyload}) {
|
if ('!{theme.comments.use[0]}' === 'Valine' || !!{theme.comments.lazyload}) {
|
||||||
|
|||||||
28
layout/includes/third-party/comments/waline.pug
vendored
28
layout/includes/third-party/comments/waline.pug
vendored
@@ -1,23 +1,35 @@
|
|||||||
- const { serverURL, visitor, option } = theme.waline
|
- const { serverURL, option, pageview } = theme.waline
|
||||||
|
- const { lazyload, count, use } = theme.comments
|
||||||
|
|
||||||
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 = new Waline(Object.assign({
|
const waline = Waline.init(Object.assign({
|
||||||
el: '#waline-wrap',
|
el: '#waline-wrap',
|
||||||
serverURL: '!{serverURL}',
|
serverURL: '!{serverURL}',
|
||||||
path: location.pathname,
|
pageview: !{lazyload ? false : pageview},
|
||||||
visitor: !{visitor},
|
dark: 'html[data-theme="dark"]',
|
||||||
dark: 'html[data-theme="dark"]'
|
path: window.location.pathname,
|
||||||
|
comment: !{lazyload ? false : count},
|
||||||
}, !{JSON.stringify(option)}))
|
}, !{JSON.stringify(option)}))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof Waline === 'function') initWaline()
|
if (typeof Waline === 'function') initWaline()
|
||||||
else getScript('!{url_for(theme.CDN.waline)}').then(initWaline)
|
else {
|
||||||
|
insertCSS()
|
||||||
|
getScript('!{url_for(theme.asset.waline_js)}').then(initWaline)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('!{theme.comments.use[0]}' === 'Waline' || !!{theme.comments.lazyload}) {
|
if ('!{use[0]}' === 'Waline' || !!{lazyload}) {
|
||||||
if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('waline-wrap'),loadWaline)
|
if (!{lazyload}) btf.loadComment(document.getElementById('waline-wrap'),loadWaline)
|
||||||
else setTimeout(loadWaline, 0)
|
else setTimeout(loadWaline, 0)
|
||||||
} else {
|
} else {
|
||||||
function loadOtherComment () {
|
function loadOtherComment () {
|
||||||
|
|||||||
14
layout/includes/third-party/effect.pug
vendored
14
layout/includes/third-party/effect.pug
vendored
@@ -1,19 +1,19 @@
|
|||||||
if theme.fireworks && theme.fireworks.enable
|
if theme.fireworks && theme.fireworks.enable
|
||||||
canvas.fireworks(mobile=`${theme.fireworks.mobile}`)
|
canvas.fireworks(mobile=`${theme.fireworks.mobile}`)
|
||||||
script(src=url_for(theme.CDN.fireworks))
|
script(src=url_for(theme.asset.fireworks))
|
||||||
|
|
||||||
if (theme.canvas_ribbon && theme.canvas_ribbon.enable)
|
if (theme.canvas_ribbon && theme.canvas_ribbon.enable)
|
||||||
script(defer id="ribbon" src=url_for(theme.CDN.canvas_ribbon) size=theme.canvas_ribbon.size
|
script(defer id="ribbon" src=url_for(theme.asset.canvas_ribbon) size=theme.canvas_ribbon.size
|
||||||
alpha=theme.canvas_ribbon.alpha zIndex=theme.canvas_ribbon.zIndex mobile=`${theme.canvas_ribbon.mobile}` data-click=`${theme.canvas_ribbon.click_to_change}`)
|
alpha=theme.canvas_ribbon.alpha zIndex=theme.canvas_ribbon.zIndex mobile=`${theme.canvas_ribbon.mobile}` data-click=`${theme.canvas_ribbon.click_to_change}`)
|
||||||
|
|
||||||
if (theme.canvas_fluttering_ribbon && theme.canvas_fluttering_ribbon.enable)
|
if (theme.canvas_fluttering_ribbon && theme.canvas_fluttering_ribbon.enable)
|
||||||
script(defer id="fluttering_ribbon" mobile=`${theme.canvas_fluttering_ribbon.mobile}` src=url_for(theme.CDN.canvas_fluttering_ribbon))
|
script(defer id="fluttering_ribbon" mobile=`${theme.canvas_fluttering_ribbon.mobile}` src=url_for(theme.asset.canvas_fluttering_ribbon))
|
||||||
|
|
||||||
if (theme.canvas_nest && theme.canvas_nest.enable)
|
if (theme.canvas_nest && theme.canvas_nest.enable)
|
||||||
script#canvas_nest(defer color=theme.canvas_nest.color opacity=theme.canvas_nest.opacity zIndex=theme.canvas_nest.zIndex count=theme.canvas_nest.count mobile=`${theme.canvas_nest.mobile}` src=url_for(theme.CDN.canvas_nest))
|
script#canvas_nest(defer color=theme.canvas_nest.color opacity=theme.canvas_nest.opacity zIndex=theme.canvas_nest.zIndex count=theme.canvas_nest.count mobile=`${theme.canvas_nest.mobile}` src=url_for(theme.asset.canvas_nest))
|
||||||
|
|
||||||
if theme.activate_power_mode.enable
|
if theme.activate_power_mode.enable
|
||||||
script(src=url_for(theme.CDN.activate_power_mode))
|
script(src=url_for(theme.asset.activate_power_mode))
|
||||||
script.
|
script.
|
||||||
POWERMODE.colorful = !{theme.activate_power_mode.colorful};
|
POWERMODE.colorful = !{theme.activate_power_mode.colorful};
|
||||||
POWERMODE.shake = !{theme.activate_power_mode.shake};
|
POWERMODE.shake = !{theme.activate_power_mode.shake};
|
||||||
@@ -22,11 +22,11 @@ if theme.activate_power_mode.enable
|
|||||||
|
|
||||||
//- 鼠標特效
|
//- 鼠標特效
|
||||||
if theme.click_heart && theme.click_heart.enable
|
if theme.click_heart && theme.click_heart.enable
|
||||||
script#click-heart(src=url_for(theme.CDN.click_heart) async mobile=`${theme.click_heart.mobile}`)
|
script#click-heart(src=url_for(theme.asset.click_heart) async mobile=`${theme.click_heart.mobile}`)
|
||||||
|
|
||||||
if theme.ClickShowText && theme.ClickShowText.enable
|
if theme.ClickShowText && theme.ClickShowText.enable
|
||||||
script#click-show-text(
|
script#click-show-text(
|
||||||
src= url_for(theme.CDN.ClickShowText)
|
src= url_for(theme.asset.ClickShowText)
|
||||||
data-mobile= `${theme.ClickShowText.mobile}`
|
data-mobile= `${theme.ClickShowText.mobile}`
|
||||||
data-text= theme.ClickShowText.text.join(",")
|
data-text= theme.ClickShowText.text.join(",")
|
||||||
data-fontsize= theme.ClickShowText.fontSize
|
data-fontsize= theme.ClickShowText.fontSize
|
||||||
|
|||||||
6
layout/includes/third-party/math/katex.pug
vendored
6
layout/includes/third-party/math/katex.pug
vendored
@@ -1,6 +1,6 @@
|
|||||||
link(rel="stylesheet" type="text/css" href=theme.CDN.katex)
|
link(rel="stylesheet" type="text/css" href=theme.asset.katex)
|
||||||
script(src=url_for(theme.CDN.katex_copytex))
|
script(src=url_for(theme.asset.katex_copytex))
|
||||||
link(rel="stylesheet" type="text/css" href=theme.CDN.katex_copytex_css)
|
link(rel="stylesheet" type="text/css" href=theme.asset.katex_copytex_css)
|
||||||
script.
|
script.
|
||||||
(() => {
|
(() => {
|
||||||
document.querySelectorAll('#article-container span.katex-display').forEach(item => {
|
document.querySelectorAll('#article-container span.katex-display').forEach(item => {
|
||||||
|
|||||||
2
layout/includes/third-party/math/mathjax.pug
vendored
2
layout/includes/third-party/math/mathjax.pug
vendored
@@ -37,7 +37,7 @@ script.
|
|||||||
}
|
}
|
||||||
|
|
||||||
const script = document.createElement('script')
|
const script = document.createElement('script')
|
||||||
script.src = '!{theme.CDN.mathjax}'
|
script.src = '!{theme.asset.mathjax}'
|
||||||
script.id = 'MathJax-script'
|
script.id = 'MathJax-script'
|
||||||
script.async = true
|
script.async = true
|
||||||
document.head.appendChild(script)
|
document.head.appendChild(script)
|
||||||
|
|||||||
2
layout/includes/third-party/math/mermaid.pug
vendored
2
layout/includes/third-party/math/mermaid.pug
vendored
@@ -18,7 +18,7 @@ script.
|
|||||||
}
|
}
|
||||||
|
|
||||||
const loadMermaid = () => {
|
const loadMermaid = () => {
|
||||||
window.loadMermaid ? runMermaid() : getScript('!{theme.CDN.mermaid}').then(runMermaid)
|
window.loadMermaid ? runMermaid() : getScript('!{theme.asset.mermaid}').then(runMermaid)
|
||||||
}
|
}
|
||||||
|
|
||||||
window.pjax ? loadMermaid() : document.addEventListener('DOMContentLoaded', loadMermaid)
|
window.pjax ? loadMermaid() : document.addEventListener('DOMContentLoaded', loadMermaid)
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ script.
|
|||||||
if (typeof twikoo === 'object') {
|
if (typeof twikoo === 'object') {
|
||||||
runTwikoo()
|
runTwikoo()
|
||||||
} else {
|
} else {
|
||||||
getScript('!{theme.CDN.twikoo}').then(runTwikoo)
|
getScript('!{theme.asset.twikoo}').then(runTwikoo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
- let default_avatar = theme.valine.avatar
|
- let default_avatar = theme.valine.avatar
|
||||||
|
|
||||||
script(src=url_for(theme.CDN.blueimp_md5))
|
script(src=url_for(theme.asset.blueimp_md5))
|
||||||
script.
|
script.
|
||||||
window.addEventListener('load', () => {
|
window.addEventListener('load', () => {
|
||||||
const changeContent = (content) => {
|
const changeContent = (content) => {
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
- let { avatar,avatarCDN } = theme.waline
|
|
||||||
|
|
||||||
script.
|
script.
|
||||||
window.addEventListener('load', () => {
|
window.addEventListener('load', () => {
|
||||||
const changeContent = (content) => {
|
const changeContent = (content) => {
|
||||||
@@ -45,11 +43,11 @@ script.
|
|||||||
|
|
||||||
const getComment = () => {
|
const getComment = () => {
|
||||||
const loadWaline = () => {
|
const loadWaline = () => {
|
||||||
Waline.Widget.RecentComments({
|
Waline.RecentComments({
|
||||||
serverURL: '!{theme.waline.serverURL}',
|
serverURL: '!{theme.waline.serverURL}',
|
||||||
count: !{theme.newest_comments.limit}
|
count: !{theme.newest_comments.limit}
|
||||||
}).then(res => {
|
}).then(({comments}) => {
|
||||||
const walineArray = res.comments.map(e => {
|
const walineArray = comments.map(e => {
|
||||||
return {
|
return {
|
||||||
'content': changeContent(e.comment),
|
'content': changeContent(e.comment),
|
||||||
'avatar': e.avatar,
|
'avatar': e.avatar,
|
||||||
@@ -67,7 +65,7 @@ script.
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (typeof Waline === 'function') loadWaline()
|
if (typeof Waline === 'function') loadWaline()
|
||||||
else getScript('!{url_for(theme.CDN.waline)}').then(loadWaline)
|
else getScript('!{url_for(theme.asset.waline_js)}').then(loadWaline)
|
||||||
}
|
}
|
||||||
|
|
||||||
const newestCommentInit = () => {
|
const newestCommentInit = () => {
|
||||||
|
|||||||
2
layout/includes/third-party/pangu.pug
vendored
2
layout/includes/third-party/pangu.pug
vendored
@@ -2,7 +2,7 @@ script.
|
|||||||
function panguFn () {
|
function panguFn () {
|
||||||
if (typeof pangu === 'object') pangu.autoSpacingPage()
|
if (typeof pangu === 'object') pangu.autoSpacingPage()
|
||||||
else {
|
else {
|
||||||
getScript('!{url_for(theme.CDN.pangu)}')
|
getScript('!{url_for(theme.asset.pangu)}')
|
||||||
.then(() => {
|
.then(() => {
|
||||||
pangu.autoSpacingPage()
|
pangu.autoSpacingPage()
|
||||||
})
|
})
|
||||||
|
|||||||
7
layout/includes/third-party/pjax.pug
vendored
7
layout/includes/third-party/pjax.pug
vendored
@@ -12,7 +12,7 @@ if choose
|
|||||||
if choose.includes('Utterances') || choose.includes('Giscus')
|
if choose.includes('Utterances') || choose.includes('Giscus')
|
||||||
- pjaxSelectors.unshift('link[rel="canonical"]')
|
- pjaxSelectors.unshift('link[rel="canonical"]')
|
||||||
|
|
||||||
script(src=url_for(theme.CDN.pjax))
|
script(src=url_for(theme.asset.pjax))
|
||||||
script.
|
script.
|
||||||
let pjaxSelectors = !{JSON.stringify(pjaxSelectors)}
|
let pjaxSelectors = !{JSON.stringify(pjaxSelectors)}
|
||||||
|
|
||||||
@@ -27,10 +27,11 @@ script.
|
|||||||
document.addEventListener('pjax:send', function () {
|
document.addEventListener('pjax:send', function () {
|
||||||
|
|
||||||
// removeEventListener scroll
|
// removeEventListener scroll
|
||||||
window.removeEventListener('scroll', window.tocScrollFn)
|
window.tocScrollFn && window.removeEventListener('scroll', window.tocScrollFn)
|
||||||
window.removeEventListener('scroll', scrollCollect)
|
window.scrollCollect && window.removeEventListener('scroll', scrollCollect)
|
||||||
|
|
||||||
typeof preloader === 'object' && preloader.initLoading()
|
typeof preloader === 'object' && preloader.initLoading()
|
||||||
|
document.getElementById('rightside').style.cssText = "opacity: ''; transform: ''"
|
||||||
|
|
||||||
if (window.aplayers) {
|
if (window.aplayers) {
|
||||||
for (let i = 0; i < window.aplayers.length; i++) {
|
for (let i = 0; i < window.aplayers.length; i++) {
|
||||||
|
|||||||
6
layout/includes/third-party/prismjs.pug
vendored
6
layout/includes/third-party/prismjs.pug
vendored
@@ -1,5 +1,5 @@
|
|||||||
if config.prismjs && config.prismjs.enable && !config.prismjs.preprocess
|
if config.prismjs && config.prismjs.enable && !config.prismjs.preprocess
|
||||||
script(src=url_for(theme.CDN.prismjs_js))
|
script(src=url_for(theme.asset.prismjs_js))
|
||||||
script(src=url_for(theme.CDN.prismjs_autoloader))
|
script(src=url_for(theme.asset.prismjs_autoloader))
|
||||||
if config.prismjs.line_number
|
if config.prismjs.line_number
|
||||||
script(src=url_for(theme.CDN.prismjs_lineNumber_js))
|
script(src=url_for(theme.asset.prismjs_lineNumber_js))
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#algolia-search
|
#algolia-search
|
||||||
.search-dialog
|
.search-dialog
|
||||||
nav.search-nav
|
nav.search-nav
|
||||||
span.search-dialog-title= 'Algolia'
|
span.search-dialog-title= _p('search.title')
|
||||||
button.search-close-button
|
button.search-close-button
|
||||||
i.fas.fa-times
|
i.fas.fa-times
|
||||||
|
|
||||||
@@ -11,6 +11,8 @@
|
|||||||
#algolia-search-results
|
#algolia-search-results
|
||||||
#algolia-hits
|
#algolia-hits
|
||||||
#algolia-pagination
|
#algolia-pagination
|
||||||
#algolia-stats
|
#algolia-info
|
||||||
|
.algolia-stats
|
||||||
|
.algolia-poweredBy
|
||||||
|
|
||||||
#search-mask
|
#search-mask
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#local-search
|
#local-search
|
||||||
.search-dialog
|
.search-dialog
|
||||||
nav.search-nav
|
nav.search-nav
|
||||||
span.search-dialog-title=_p("search.local_search.label")
|
span.search-dialog-title= _p('search.title')
|
||||||
span#loading-status
|
span#loading-status
|
||||||
button.search-close-button
|
button.search-close-button
|
||||||
i.fas.fa-times
|
i.fas.fa-times
|
||||||
|
|||||||
@@ -5,6 +5,6 @@
|
|||||||
a(class="a2a_button_" + name)
|
a(class="a2a_button_" + name)
|
||||||
|
|
||||||
a.a2a_dd(href="https://www.addtoany.com/share")
|
a.a2a_dd(href="https://www.addtoany.com/share")
|
||||||
script(async src=url_for(theme.CDN.addtoany))
|
script(async src='https://static.addtoany.com/menu/page.js')
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
.social-share(data-image=url_for(page.cover|| theme.avatar.img) data-sites= theme.sharejs.sites)
|
.social-share(data-image=url_for(page.cover|| theme.avatar.img) data-sites= theme.sharejs.sites)
|
||||||
link(rel='stylesheet' href=url_for(theme.CDN.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.CDN.sharejs) defer)
|
script(src=url_for(theme.asset.sharejs) defer)
|
||||||
8
layout/includes/third-party/subtitle.pug
vendored
8
layout/includes/third-party/subtitle.pug
vendored
@@ -29,7 +29,7 @@ case source
|
|||||||
if (typeof Typed === 'function') {
|
if (typeof Typed === 'function') {
|
||||||
subtitleType()
|
subtitleType()
|
||||||
} else {
|
} else {
|
||||||
getScript('!{url_for(theme.CDN.typed)}').then(subtitleType)
|
getScript('!{url_for(theme.asset.typed)}').then(subtitleType)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
subtitleType()
|
subtitleType()
|
||||||
@@ -61,7 +61,7 @@ case source
|
|||||||
if (typeof Typed === 'function') {
|
if (typeof Typed === 'function') {
|
||||||
subtitleType()
|
subtitleType()
|
||||||
} else {
|
} else {
|
||||||
getScript('!{url_for(theme.CDN.typed)}').then(subtitleType)
|
getScript('!{url_for(theme.asset.typed)}').then(subtitleType)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
subtitleType()
|
subtitleType()
|
||||||
@@ -94,7 +94,7 @@ case source
|
|||||||
if (typeof Typed === 'function') {
|
if (typeof Typed === 'function') {
|
||||||
subtitleType()
|
subtitleType()
|
||||||
} else {
|
} else {
|
||||||
getScript('!{url_for(theme.CDN.typed)}').then(subtitleType)
|
getScript('!{url_for(theme.asset.typed)}').then(subtitleType)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
subtitleType()
|
subtitleType()
|
||||||
@@ -121,7 +121,7 @@ case source
|
|||||||
if (typeof Typed === 'function') {
|
if (typeof Typed === 'function') {
|
||||||
subtitleType()
|
subtitleType()
|
||||||
} else {
|
} else {
|
||||||
getScript('!{url_for(theme.CDN.typed)}').then(subtitleType)
|
getScript('!{url_for(theme.asset.typed)}').then(subtitleType)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
subtitleType()
|
subtitleType()
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
if theme.aside.card_announcement.enable
|
if theme.aside.card_announcement.enable
|
||||||
.card-widget.card-announcement
|
.card-widget.card-announcement
|
||||||
.item-headline
|
.item-headline
|
||||||
i.fas.fa-bullhorn.card-announcement-animation
|
i.fas.fa-bullhorn.fa-shake
|
||||||
span= _p('aside.card_announcement')
|
span= _p('aside.card_announcement')
|
||||||
.announcement_content!= theme.aside.card_announcement.content
|
.announcement_content!= theme.aside.card_announcement.content
|
||||||
@@ -6,18 +6,13 @@ if theme.aside.card_author.enable
|
|||||||
.author-info__name= config.author
|
.author-info__name= config.author
|
||||||
.author-info__description!= theme.aside.card_author.description || config.description
|
.author-info__description!= theme.aside.card_author.description || config.description
|
||||||
|
|
||||||
.card-info-data.is-center
|
.card-info-data.site-data.is-center
|
||||||
.card-info-data-item
|
|
||||||
a(href=url_for(config.archive_dir) + '/')
|
a(href=url_for(config.archive_dir) + '/')
|
||||||
.headline= _p('aside.articles')
|
.headline= _p('aside.articles')
|
||||||
.length-num= site.posts.length
|
.length-num= site.posts.length
|
||||||
|
|
||||||
.card-info-data-item
|
|
||||||
a(href=url_for(config.tag_dir) + '/')
|
a(href=url_for(config.tag_dir) + '/')
|
||||||
.headline= _p('aside.tags')
|
.headline= _p('aside.tags')
|
||||||
.length-num= site.tags.length
|
.length-num= site.tags.length
|
||||||
|
|
||||||
.card-info-data-item
|
|
||||||
a(href=url_for(config.category_dir) + '/')
|
a(href=url_for(config.category_dir) + '/')
|
||||||
.headline= _p('aside.categories')
|
.headline= _p('aside.categories')
|
||||||
.length-num= site.categories.length
|
.length-num= site.categories.length
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ block content
|
|||||||
a(href=url_for(item.path)).post-meta__tags #[=item.name]
|
a(href=url_for(item.path)).post-meta__tags #[=item.name]
|
||||||
include includes/third-party/share/index.pug
|
include includes/third-party/share/index.pug
|
||||||
|
|
||||||
if theme.reward.enable
|
if theme.reward.enable && theme.reward.QR_code
|
||||||
!=partial('includes/post/reward', {}, {cache: true})
|
!=partial('includes/post/reward', {}, {cache: true})
|
||||||
|
|
||||||
//- ad
|
//- ad
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hexo-theme-butterfly",
|
"name": "hexo-theme-butterfly",
|
||||||
"version": "4.0.0",
|
"version": "4.2.1",
|
||||||
"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": {
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"hexo-renderer-stylus": "^2.0.1",
|
"hexo-renderer-stylus": "^2.0.1",
|
||||||
"hexo-renderer-pug": "^2.0.0"
|
"hexo-renderer-pug": "^3.0.0"
|
||||||
},
|
},
|
||||||
"homepage": "https://butterfly.js.org/",
|
"homepage": "https://butterfly.js.org/",
|
||||||
"author": "Jerry <my@crazywong.com>",
|
"author": "Jerry <my@crazywong.com>",
|
||||||
|
|||||||
@@ -6,115 +6,120 @@
|
|||||||
|
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
|
const { version } = require('../../package.json')
|
||||||
|
const path = require('path')
|
||||||
|
|
||||||
hexo.extend.filter.register('before_generate', () => {
|
hexo.extend.filter.register('before_generate', () => {
|
||||||
const themeConfig = hexo.theme.config
|
const themeConfig = hexo.theme.config
|
||||||
|
const { CDN, comments } = themeConfig
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Merge CDN
|
* Merge CDN
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const defaultCDN = {
|
const internalSrcCDN = {
|
||||||
|
main_css: '/css/index.css',
|
||||||
|
main: `https://cdn.jsdelivr.net/npm/hexo-theme-butterfly@${version}/source/js/main.min.js`,
|
||||||
|
utils: `https://cdn.jsdelivr.net/npm/hexo-theme-butterfly@${version}/source/js/utils.min.js`,
|
||||||
|
translate: `https://cdn.jsdelivr.net/npm/hexo-theme-butterfly@${version}/source/js/tw_cn.min.js`,
|
||||||
|
local_search: `https://cdn.jsdelivr.net/npm/hexo-theme-butterfly@${version}/source/js/search/local-search.min.js`,
|
||||||
|
algolia_js: `https://cdn.jsdelivr.net/npm/hexo-theme-butterfly@${version}/source/js/search/algolia.min.js`,
|
||||||
|
}
|
||||||
|
|
||||||
|
const internalSrcLocal = {
|
||||||
main_css: '/css/index.css',
|
main_css: '/css/index.css',
|
||||||
main: '/js/main.js',
|
main: '/js/main.js',
|
||||||
utils: '/js/utils.js',
|
utils: '/js/utils.js',
|
||||||
|
translate: '/js/tw_cn.js',
|
||||||
|
local_search: '/js/search/local-search.js',
|
||||||
|
algolia_js: '/js/search/algolia.js',
|
||||||
|
}
|
||||||
|
|
||||||
// pjax
|
const thirdPartySrcCDN = {
|
||||||
|
algolia_search_v4: 'https://cdn.jsdelivr.net/npm/algoliasearch@4/dist/algoliasearch-lite.umd.js',
|
||||||
|
instantsearch_v4: 'https://cdn.jsdelivr.net/npm/instantsearch.js@4/dist/instantsearch.production.min.js',
|
||||||
pjax: 'https://cdn.jsdelivr.net/npm/pjax/pjax.min.js',
|
pjax: 'https://cdn.jsdelivr.net/npm/pjax/pjax.min.js',
|
||||||
|
|
||||||
// comments
|
|
||||||
gitalk: 'https://cdn.jsdelivr.net/npm/gitalk@latest/dist/gitalk.min.js',
|
gitalk: 'https://cdn.jsdelivr.net/npm/gitalk@latest/dist/gitalk.min.js',
|
||||||
gitalk_css: 'https://cdn.jsdelivr.net/npm/gitalk/dist/gitalk.min.css',
|
gitalk_css: 'https://cdn.jsdelivr.net/npm/gitalk/dist/gitalk.min.css',
|
||||||
blueimp_md5: 'https://cdn.jsdelivr.net/npm/blueimp-md5/js/md5.min.js',
|
blueimp_md5: 'https://cdn.jsdelivr.net/npm/blueimp-md5/js/md5.min.js',
|
||||||
valine: 'https://cdn.jsdelivr.net/npm/valine/dist/Valine.min.js',
|
valine: 'https://cdn.jsdelivr.net/npm/valine/dist/Valine.min.js',
|
||||||
disqusjs: 'https://cdn.jsdelivr.net/npm/disqusjs@1/dist/disqus.js',
|
disqusjs: 'https://cdn.jsdelivr.net/npm/disqusjs@1/dist/disqus.js',
|
||||||
disqusjs_css: 'https://cdn.jsdelivr.net/npm/disqusjs@1/dist/disqusjs.css',
|
disqusjs_css: 'https://cdn.jsdelivr.net/npm/disqusjs@1/dist/disqusjs.css',
|
||||||
utterances: 'https://utteranc.es/client.js',
|
twikoo: 'https://cdn.jsdelivr.net/npm/twikoo@1/dist/twikoo.all.min.js',
|
||||||
twikoo: 'https://cdn.jsdelivr.net/npm/twikoo/dist/twikoo.all.min.js',
|
waline_js: 'https://cdn.jsdelivr.net/npm/@waline/client/dist/waline.js',
|
||||||
waline: 'https://cdn.jsdelivr.net/npm/@waline/client/dist/Waline.min.js',
|
waline_css: 'https://cdn.jsdelivr.net/npm/@waline/client/dist/waline.css',
|
||||||
giscus: 'https://giscus.app/client.js',
|
sharejs: 'https://cdn.jsdelivr.net/gh/overtrue/share.js@master/dist/js/social-share.min.js',
|
||||||
|
|
||||||
// share
|
|
||||||
addtoany: 'https://static.addtoany.com/menu/page.js',
|
|
||||||
sharejs: 'https://cdn.jsdelivr.net/npm/social-share.js/dist/js/social-share.min.js',
|
|
||||||
sharejs_css: 'https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css',
|
sharejs_css: 'https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css',
|
||||||
|
|
||||||
// search
|
|
||||||
local_search: '/js/search/local-search.js',
|
|
||||||
algolia_js: '/js/search/algolia.js',
|
|
||||||
algolia_search_v4: 'https://cdn.jsdelivr.net/npm/algoliasearch@4/dist/algoliasearch-lite.umd.js',
|
|
||||||
instantsearch_v4: 'https://cdn.jsdelivr.net/npm/instantsearch.js@4/dist/instantsearch.production.min.js',
|
|
||||||
|
|
||||||
// math
|
|
||||||
mathjax: 'https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js',
|
mathjax: 'https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js',
|
||||||
katex: 'https://cdn.jsdelivr.net/npm/katex@latest/dist/katex.min.css',
|
katex: 'https://cdn.jsdelivr.net/npm/katex@latest/dist/katex.min.css',
|
||||||
katex_copytex: 'https://cdn.jsdelivr.net/npm/katex@latest/dist/contrib/copy-tex.min.js',
|
katex_copytex: 'https://cdn.jsdelivr.net/npm/katex@latest/dist/contrib/copy-tex.min.js',
|
||||||
katex_copytex_css: 'https://cdn.jsdelivr.net/npm/katex@latest/dist/contrib/copy-tex.css',
|
katex_copytex_css: 'https://cdn.jsdelivr.net/npm/katex@latest/dist/contrib/copy-tex.css',
|
||||||
mermaid: 'https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js',
|
mermaid: 'https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js',
|
||||||
|
|
||||||
// count
|
|
||||||
busuanzi: '//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js',
|
|
||||||
|
|
||||||
// background effect
|
|
||||||
canvas_ribbon: 'https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-ribbon.min.js',
|
canvas_ribbon: 'https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-ribbon.min.js',
|
||||||
canvas_fluttering_ribbon: 'https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-fluttering-ribbon.min.js',
|
canvas_fluttering_ribbon: 'https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-fluttering-ribbon.min.js',
|
||||||
canvas_nest: 'https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-nest.min.js',
|
canvas_nest: 'https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-nest.min.js',
|
||||||
|
|
||||||
lazyload: 'https://cdn.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.iife.min.js',
|
|
||||||
instantpage: 'https://cdn.jsdelivr.net/npm/instant.page/instantpage.min.js',
|
|
||||||
typed: 'https://cdn.jsdelivr.net/npm/typed.js/lib/typed.min.js',
|
|
||||||
pangu: 'https://cdn.jsdelivr.net/npm/pangu/dist/browser/pangu.min.js',
|
|
||||||
|
|
||||||
// photo
|
|
||||||
fancybox_css_v4: 'https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.css',
|
|
||||||
fancybox_v4: 'https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.js',
|
|
||||||
medium_zoom: 'https://cdn.jsdelivr.net/npm/medium-zoom/dist/medium-zoom.min.js',
|
|
||||||
|
|
||||||
// snackbar
|
|
||||||
snackbar_css: 'https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.css',
|
|
||||||
snackbar: 'https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.js',
|
|
||||||
|
|
||||||
// effect
|
|
||||||
activate_power_mode: 'https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/activate-power-mode.min.js',
|
activate_power_mode: 'https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/activate-power-mode.min.js',
|
||||||
fireworks: 'https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/fireworks.min.js',
|
fireworks: 'https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/fireworks.min.js',
|
||||||
click_heart: 'https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/click-heart.min.js',
|
click_heart: 'https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/click-heart.min.js',
|
||||||
ClickShowText: 'https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/click-show-text.min.js',
|
ClickShowText: 'https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/click-show-text.min.js',
|
||||||
|
lazyload: 'https://cdn.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.iife.min.js',
|
||||||
// fontawesome
|
instantpage: 'https://cdn.jsdelivr.net/npm/instant.page@5/instantpage.min.js',
|
||||||
fontawesome: 'https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css',
|
typed: 'https://cdn.jsdelivr.net/npm/typed.js/lib/typed.min.js',
|
||||||
|
pangu: 'https://cdn.jsdelivr.net/npm/pangu@4/dist/browser/pangu.min.js',
|
||||||
// Conversion between Traditional and Simplified Chinese
|
fancybox_css_v4: 'https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.css',
|
||||||
translate: '/js/tw_cn.js',
|
fancybox_v4: 'https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.js',
|
||||||
|
medium_zoom: 'https://cdn.jsdelivr.net/npm/medium-zoom/dist/medium-zoom.min.js',
|
||||||
// flickr-justified-gallery
|
snackbar_css: 'https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.css',
|
||||||
|
snackbar: 'https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.js',
|
||||||
|
fontawesomeV6: 'https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6/css/all.min.css',
|
||||||
flickr_justified_gallery_js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery@2/dist/fjGallery.min.js',
|
flickr_justified_gallery_js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery@2/dist/fjGallery.min.js',
|
||||||
flickr_justified_gallery_css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery@2/dist/fjGallery.min.css',
|
flickr_justified_gallery_css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery@2/dist/fjGallery.min.css',
|
||||||
|
aplayer_css: 'https://cdn.jsdelivr.net/npm/aplayer@1/dist/APlayer.min.css',
|
||||||
// aplayer
|
aplayer_js: 'https://cdn.jsdelivr.net/npm/aplayer@1/dist/APlayer.min.js',
|
||||||
aplayer_css: 'https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css',
|
|
||||||
aplayer_js: 'https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js',
|
|
||||||
meting_js: 'https://cdn.jsdelivr.net/gh/metowolf/MetingJS@1.2/dist/Meting.min.js',
|
meting_js: 'https://cdn.jsdelivr.net/gh/metowolf/MetingJS@1.2/dist/Meting.min.js',
|
||||||
|
prismjs_js: 'https://cdn.jsdelivr.net/npm/prismjs@1/prism.min.js',
|
||||||
// Prism.js
|
prismjs_lineNumber_js: 'https://cdn.jsdelivr.net/npm/prismjs@1/plugins/line-numbers/prism-line-numbers.min.js',
|
||||||
prismjs_js: 'https://cdn.jsdelivr.net/npm/prismjs/prism.min.js',
|
prismjs_autoloader: 'https://cdn.jsdelivr.net/npm/prismjs@1/plugins/autoloader/prism-autoloader.min.js',
|
||||||
prismjs_lineNumber_js: 'https://cdn.jsdelivr.net/npm/prismjs/plugins/line-numbers/prism-line-numbers.min.js',
|
|
||||||
prismjs_autoloader: 'https://cdn.jsdelivr.net/npm/prismjs/plugins/autoloader/prism-autoloader.min.js'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete null value
|
// delete null value
|
||||||
const deleteNullValue = obj => {
|
const deleteNullValue = obj => {
|
||||||
|
if (!obj) return
|
||||||
for (const i in obj) {
|
for (const i in obj) {
|
||||||
obj[i] === null && delete obj[i]
|
obj[i] === null && delete obj[i]
|
||||||
}
|
}
|
||||||
return obj
|
return obj
|
||||||
}
|
}
|
||||||
|
|
||||||
themeConfig.CDN = Object.assign(defaultCDN, deleteNullValue(themeConfig.CDN))
|
const defaultVal = (obj, choose) => {
|
||||||
|
if (obj === 'internal') {
|
||||||
|
if (choose === 'local') return internalSrcLocal
|
||||||
|
else return internalSrcCDN
|
||||||
|
}
|
||||||
|
|
||||||
|
if (obj === 'external') {
|
||||||
|
if (choose === 'local') {
|
||||||
|
let result = {}
|
||||||
|
try {
|
||||||
|
const data = path.join(hexo.plugin_dir,'hexo-butterfly-extjs/plugins.yml')
|
||||||
|
result = hexo.render.renderSync({ path: data, engine: 'yaml'})
|
||||||
|
Object.keys(result).map(key => {
|
||||||
|
result[key] = '/pluginsSrc/' + result[key]
|
||||||
|
})
|
||||||
|
} catch (e) {}
|
||||||
|
return result
|
||||||
|
} else return thirdPartySrcCDN
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
themeConfig.asset = Object.assign(defaultVal('internal', CDN.internal_provider),
|
||||||
|
defaultVal('external', CDN.third_party_provider), deleteNullValue(CDN.option))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Capitalize the first letter of comment name
|
* Capitalize the first letter of comment name
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let { use } = themeConfig.comments
|
let { use } = comments
|
||||||
|
|
||||||
if (!use) return
|
if (!use) return
|
||||||
|
|
||||||
@@ -122,7 +127,7 @@ hexo.extend.filter.register('before_generate', () => {
|
|||||||
use = use.split(',')
|
use = use.split(',')
|
||||||
}
|
}
|
||||||
|
|
||||||
const newArray = use.map(item => item.toLowerCase().replace(/^\S/, s => s.toUpperCase()))
|
const newArray = use.map(item => item.toLowerCase().replace(/\b[a-z]/g, s => s.toUpperCase()))
|
||||||
|
|
||||||
themeConfig.comments.use = newArray
|
themeConfig.comments.use = newArray
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ 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')
|
||||||
|
|
||||||
if (hexoVer < 5) {
|
if (hexoVer < 5.3) {
|
||||||
logger.error('Please update Hexo to V5.0.0 or higher!')
|
logger.error('Please update Hexo to V5.3.0 or higher!')
|
||||||
logger.error('請把 Hexo 升級到 V5.0.0 或更高的版本!')
|
logger.error('請把 Hexo 升級到 V5.3.0 或更高的版本!')
|
||||||
process.exit(-1)
|
process.exit(-1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,10 @@
|
|||||||
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 { theme_color } = hexo.theme.config
|
||||||
|
const themeColorLight = theme_color && theme_color.enable && theme_color.meta_theme_color_light || '#ffffff'
|
||||||
|
const themeColorDark = theme_color && theme_color.enable && theme_color.meta_theme_color_dark || '#0d0d0d'
|
||||||
|
|
||||||
const localStore = `
|
const localStore = `
|
||||||
win.saveToLocal = {
|
win.saveToLocal = {
|
||||||
set: function setWithExpiry(key, value, ttl) {
|
set: function setWithExpiry(key, value, ttl) {
|
||||||
@@ -62,13 +66,13 @@ hexo.extend.helper.register('inject_head_js', function () {
|
|||||||
win.activateDarkMode = function () {
|
win.activateDarkMode = function () {
|
||||||
document.documentElement.setAttribute('data-theme', 'dark')
|
document.documentElement.setAttribute('data-theme', 'dark')
|
||||||
if (document.querySelector('meta[name="theme-color"]') !== null) {
|
if (document.querySelector('meta[name="theme-color"]') !== null) {
|
||||||
document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
|
document.querySelector('meta[name="theme-color"]').setAttribute('content', '${themeColorDark}')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
win.activateLightMode = function () {
|
win.activateLightMode = function () {
|
||||||
document.documentElement.setAttribute('data-theme', 'light')
|
document.documentElement.setAttribute('data-theme', 'light')
|
||||||
if (document.querySelector('meta[name="theme-color"]') !== null) {
|
if (document.querySelector('meta[name="theme-color"]') !== null) {
|
||||||
document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
|
document.querySelector('meta[name="theme-color"]').setAttribute('content', '${themeColorLight}')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const t = saveToLocal.get('theme')
|
const t = saveToLocal.get('theme')
|
||||||
|
|||||||
@@ -54,14 +54,15 @@ hexo.extend.helper.register('related_posts', function (currentPost, allPosts) {
|
|||||||
relatedPosts[i].cover === false
|
relatedPosts[i].cover === false
|
||||||
? relatedPosts[i].randomcover
|
? relatedPosts[i].randomcover
|
||||||
: relatedPosts[i].cover
|
: relatedPosts[i].cover
|
||||||
result += `<div><a href="${this.url_for(relatedPosts[i].path)}" title="${relatedPosts[i].title}">`
|
const title = this.escape_html(relatedPosts[i].title)
|
||||||
|
result += `<div><a href="${this.url_for(relatedPosts[i].path)}" title="${title}">`
|
||||||
result += `<img class="cover" src="${this.url_for(cover)}" alt="cover">`
|
result += `<img class="cover" src="${this.url_for(cover)}" alt="cover">`
|
||||||
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 {
|
||||||
result += `<div class="content is-center"><div class="date"><i class="fas fa-history fa-fw"></i> ${this.date(relatedPosts[i].updated, hexoConfig.date_format)}</div>`
|
result += `<div class="content is-center"><div class="date"><i class="fas fa-history fa-fw"></i> ${this.date(relatedPosts[i].updated, hexoConfig.date_format)}</div>`
|
||||||
}
|
}
|
||||||
result += `<div class="title">${relatedPosts[i].title}</div>`
|
result += `<div class="title">${title}</div>`
|
||||||
result += '</div></a></div>'
|
result += '</div></a></div>'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
39
scripts/tag/flink.js
Normal file
39
scripts/tag/flink.js
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
/**
|
||||||
|
* flink
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
const urlFor = require('hexo-util').url_for.bind(hexo)
|
||||||
|
|
||||||
|
const flinkFn = (args, content) => {
|
||||||
|
content = hexo.render.renderSync({ text: content, engine: 'yaml' })
|
||||||
|
|
||||||
|
let result = ''
|
||||||
|
|
||||||
|
content.forEach(i => {
|
||||||
|
const className = i.class_name ? `<div class="flink-name">${i.class_name}</div>` : ''
|
||||||
|
const classDesc = i.class_desc ? `<div class="flink-desc">${i.class_desc}</div>` : ''
|
||||||
|
|
||||||
|
let listResult = ''
|
||||||
|
|
||||||
|
i.link_list.forEach(j => {
|
||||||
|
listResult += `
|
||||||
|
<div class="flink-list-item">
|
||||||
|
<a href="${j.link}" title="${j.name}" target="_blank">
|
||||||
|
<div class="flink-item-icon">
|
||||||
|
<img class="no-lightbox" src="${j.avatar}" onerror='this.onerror=null;this.src="${urlFor(hexo.theme.config.error_img.flink)}"' alt="${j.name}" />
|
||||||
|
</div>
|
||||||
|
<div class="flink-item-name">${j.name}</div>
|
||||||
|
<div class="flink-item-desc" title="${j.descr}">${j.descr}</div>
|
||||||
|
</a>
|
||||||
|
</div>`
|
||||||
|
})
|
||||||
|
|
||||||
|
result += `${className}${classDesc} <div class="flink-list">${listResult}</div>`
|
||||||
|
})
|
||||||
|
|
||||||
|
return `<div class="flink">${result}</div>`
|
||||||
|
}
|
||||||
|
|
||||||
|
hexo.extend.tag.register('flink', flinkFn, { ends: true })
|
||||||
@@ -62,8 +62,7 @@ function hideToggle (args, content) {
|
|||||||
if (color) group += `color: ${color}`
|
if (color) group += `color: ${color}`
|
||||||
group += '"'
|
group += '"'
|
||||||
|
|
||||||
return `<div class="hide-toggle" ${border}><div class="hide-button toggle-title" ${group}><i class="fas fa-caret-right fa-fw"></i><span>${display}</span></div>
|
return `<details class="toggle" ${border}><summary class="toggle-button" ${group}>${display}</summary><div class="toggle-content">${hexo.render.renderSync({ text: content, engine: 'markdown' })}</div></details>`
|
||||||
<div class="hide-content">${hexo.render.renderSync({ text: content, engine: 'markdown' })}</div></div>`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hexo.extend.tag.register('hideInline', hideInline)
|
hexo.extend.tag.register('hideInline', hideInline)
|
||||||
|
|||||||
@@ -11,9 +11,7 @@
|
|||||||
.fontawesomeIcon
|
.fontawesomeIcon
|
||||||
display: inline-block
|
display: inline-block
|
||||||
font-weight: 600
|
font-weight: 600
|
||||||
font-style: normal
|
font-family: 'Font Awesome 6 Free'
|
||||||
font-variant: normal
|
|
||||||
font-family: 'Font Awesome 5 Free'
|
|
||||||
text-rendering: auto
|
text-rendering: auto
|
||||||
-webkit-font-smoothing: antialiased
|
-webkit-font-smoothing: antialiased
|
||||||
|
|
||||||
@@ -55,7 +53,7 @@
|
|||||||
|
|
||||||
li
|
li
|
||||||
position: relative
|
position: relative
|
||||||
padding 0.12em 0.4em 0.12em 1.4em
|
padding: .12em .4em .12em 1.4em
|
||||||
|
|
||||||
&:hover
|
&:hover
|
||||||
&:before
|
&:before
|
||||||
@@ -135,10 +133,6 @@ if hexo-config('enter_transitions')
|
|||||||
> :nth-child({i})
|
> :nth-child({i})
|
||||||
animation: sidebarItem (i / 5)s
|
animation: sidebarItem (i / 5)s
|
||||||
|
|
||||||
.card-announcement-animation
|
|
||||||
color: #FF0000
|
|
||||||
animation: announ_animation .8s linear infinite
|
|
||||||
|
|
||||||
.scroll-down-effects
|
.scroll-down-effects
|
||||||
animation: scroll-down-effect 1.5s infinite
|
animation: scroll-down-effect 1.5s infinite
|
||||||
|
|
||||||
@@ -251,14 +245,6 @@ if hexo-config('avatar.effect') == true
|
|||||||
opacity: 1
|
opacity: 1
|
||||||
transform: translateY(0)
|
transform: translateY(0)
|
||||||
|
|
||||||
@keyframes announ_animation
|
|
||||||
0%,
|
|
||||||
to
|
|
||||||
transform: scale(1)
|
|
||||||
|
|
||||||
50%
|
|
||||||
transform: scale(1.2)
|
|
||||||
|
|
||||||
@keyframes sidebarItem
|
@keyframes sidebarItem
|
||||||
0%
|
0%
|
||||||
transform: translateX(200px)
|
transform: translateX(200px)
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ $code-block
|
|||||||
transition: transform .3s
|
transition: transform .3s
|
||||||
|
|
||||||
& + .code-lang
|
& + .code-lang
|
||||||
left: 1.6em
|
left: 1.7em
|
||||||
|
|
||||||
&.closed
|
&.closed
|
||||||
transition: all .3s
|
transition: all .3s
|
||||||
@@ -112,7 +112,7 @@ $code-block
|
|||||||
|
|
||||||
.copy-notice
|
.copy-notice
|
||||||
position: absolute
|
position: absolute
|
||||||
right: 2.1em
|
right: 2.4em
|
||||||
opacity: 0
|
opacity: 0
|
||||||
transition: opacity .4s
|
transition: opacity .4s
|
||||||
|
|
||||||
@@ -160,7 +160,7 @@ $code-block
|
|||||||
transform: rotate(90deg) !important
|
transform: rotate(90deg) !important
|
||||||
|
|
||||||
& ~ .copy-notice
|
& ~ .copy-notice
|
||||||
right: 3.3em
|
right: 3.45em
|
||||||
|
|
||||||
& ~ .copy-button
|
& ~ .copy-button
|
||||||
right: 2.1em
|
right: 2.1em
|
||||||
|
|||||||
@@ -38,24 +38,7 @@
|
|||||||
margin-top: -.42em
|
margin-top: -.42em
|
||||||
|
|
||||||
.card-info-data
|
.card-info-data
|
||||||
display: table
|
|
||||||
margin: 14px 0 4px
|
margin: 14px 0 4px
|
||||||
width: 100%
|
|
||||||
table-layout: fixed
|
|
||||||
|
|
||||||
& > .card-info-data-item
|
|
||||||
display: table-cell
|
|
||||||
|
|
||||||
a
|
|
||||||
.headline
|
|
||||||
@extend .limit-one-line
|
|
||||||
color: var(--font-color)
|
|
||||||
font-size: 1em
|
|
||||||
|
|
||||||
.length-num
|
|
||||||
margin-top: -.42em
|
|
||||||
color: var(--text-highlight-color)
|
|
||||||
font-size: 1.4em
|
|
||||||
|
|
||||||
.card-info-social-icons
|
.card-info-social-icons
|
||||||
margin: 6px 0 -6px
|
margin: 6px 0 -6px
|
||||||
@@ -319,6 +302,11 @@
|
|||||||
&:hover
|
&:hover
|
||||||
animation: more-btn-move 1s infinite
|
animation: more-btn-move 1s infinite
|
||||||
|
|
||||||
|
.card-announcement
|
||||||
|
.item-headline
|
||||||
|
i
|
||||||
|
color: #FF0000
|
||||||
|
|
||||||
.avatar-img
|
.avatar-img
|
||||||
overflow: hidden
|
overflow: hidden
|
||||||
margin: 0 auto
|
margin: 0 auto
|
||||||
@@ -335,6 +323,30 @@
|
|||||||
&:hover
|
&:hover
|
||||||
transform: rotate(360deg)
|
transform: rotate(360deg)
|
||||||
|
|
||||||
|
.site-data
|
||||||
|
display: table
|
||||||
|
width: 100%
|
||||||
|
table-layout: fixed
|
||||||
|
|
||||||
|
& > a
|
||||||
|
display: table-cell
|
||||||
|
|
||||||
|
div
|
||||||
|
transition: all .3s
|
||||||
|
|
||||||
|
&:hover
|
||||||
|
div
|
||||||
|
color: $theme-color !important
|
||||||
|
|
||||||
|
.headline
|
||||||
|
@extend .limit-one-line
|
||||||
|
color: var(--font-color)
|
||||||
|
|
||||||
|
.length-num
|
||||||
|
margin-top: -.32em
|
||||||
|
color: var(--text-highlight-color)
|
||||||
|
font-size: 1.4em
|
||||||
|
|
||||||
@keyframes more-btn-move
|
@keyframes more-btn-move
|
||||||
0%,
|
0%,
|
||||||
100%
|
100%
|
||||||
|
|||||||
@@ -51,6 +51,7 @@
|
|||||||
&.pagination-post
|
&.pagination-post
|
||||||
overflow: hidden
|
overflow: hidden
|
||||||
margin-top: 40px
|
margin-top: 40px
|
||||||
|
width: 100%
|
||||||
background: $dark-black
|
background: $dark-black
|
||||||
|
|
||||||
.layout
|
.layout
|
||||||
|
|||||||
@@ -152,6 +152,11 @@ beautify()
|
|||||||
|
|
||||||
#post
|
#post
|
||||||
.tag_share
|
.tag_share
|
||||||
|
&:after
|
||||||
|
display: block
|
||||||
|
clear: both
|
||||||
|
content: ''
|
||||||
|
|
||||||
.post-meta
|
.post-meta
|
||||||
&__tag-list
|
&__tag-list
|
||||||
display: inline-block
|
display: inline-block
|
||||||
@@ -174,7 +179,7 @@ beautify()
|
|||||||
.post_share
|
.post_share
|
||||||
display: inline-block
|
display: inline-block
|
||||||
float: right
|
float: right
|
||||||
margin: 8px 0
|
margin: 8px 0 0
|
||||||
width: fit-content
|
width: fit-content
|
||||||
|
|
||||||
.social-share
|
.social-share
|
||||||
|
|||||||
@@ -25,24 +25,8 @@
|
|||||||
& > .avatar-img
|
& > .avatar-img
|
||||||
margin: 20px auto
|
margin: 20px auto
|
||||||
|
|
||||||
.site-data
|
.sidebar-site-data
|
||||||
display: table
|
|
||||||
padding: 0 10px
|
padding: 0 10px
|
||||||
width: 100%
|
|
||||||
table-layout: fixed
|
|
||||||
|
|
||||||
.data-item
|
|
||||||
display: table-cell
|
|
||||||
|
|
||||||
& > a > div
|
|
||||||
@extend .limit-one-line
|
|
||||||
|
|
||||||
.length-num
|
|
||||||
color: var(--text-highlight-color)
|
|
||||||
font-size: 1.28em
|
|
||||||
|
|
||||||
.headline
|
|
||||||
color: var(--font-color)
|
|
||||||
|
|
||||||
hr
|
hr
|
||||||
margin: 20px auto
|
margin: 20px auto
|
||||||
|
|||||||
@@ -65,6 +65,9 @@ if hexo-config('waline.bg')
|
|||||||
margin: 0 0 20px
|
margin: 0 0 20px
|
||||||
text-align: center
|
text-align: center
|
||||||
|
|
||||||
|
& > svg
|
||||||
|
height: 100%
|
||||||
|
|
||||||
.utterances,
|
.utterances,
|
||||||
.fb-comments iframe
|
.fb-comments iframe
|
||||||
width: 100% !important
|
width: 100% !important
|
||||||
@@ -86,6 +89,7 @@ mjx-container[display],
|
|||||||
.has-jax
|
.has-jax
|
||||||
overflow-x: auto
|
overflow-x: auto
|
||||||
overflow-y: hidden
|
overflow-y: hidden
|
||||||
|
line-height: normal !important
|
||||||
|
|
||||||
.aplayer
|
.aplayer
|
||||||
color: $font-black
|
color: $font-black
|
||||||
@@ -106,3 +110,6 @@ mjx-container[display],
|
|||||||
|
|
||||||
&:before
|
&:before
|
||||||
content: none
|
content: none
|
||||||
|
|
||||||
|
.snackbar-css
|
||||||
|
border-radius: 5px !important
|
||||||
@@ -142,3 +142,7 @@ if hexo-config('darkmode.enable') || hexo-config('display_mode') == 'dark'
|
|||||||
|
|
||||||
#operare_artitalk .c2
|
#operare_artitalk .c2
|
||||||
background: #121212
|
background: #121212
|
||||||
|
|
||||||
|
#card-toc
|
||||||
|
+maxWidth900()
|
||||||
|
background: lighten(#121212, 5)
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
#article-container
|
#article-container
|
||||||
.flink
|
.flink
|
||||||
|
margin-bottom: 20px
|
||||||
|
|
||||||
.flink-list
|
.flink-list
|
||||||
overflow: auto
|
overflow: auto
|
||||||
padding: 10px 10px 0
|
padding: 10px 10px 0
|
||||||
@@ -23,8 +25,9 @@
|
|||||||
width: calc(100% - 15px) !important
|
width: calc(100% - 15px) !important
|
||||||
|
|
||||||
&:hover
|
&:hover
|
||||||
img
|
.flink-item-icon
|
||||||
transform: rotate(360deg)
|
margin-left: -10px
|
||||||
|
width: 0
|
||||||
|
|
||||||
&:before
|
&:before
|
||||||
position: absolute
|
position: absolute
|
||||||
@@ -54,12 +57,13 @@
|
|||||||
width: 60px
|
width: 60px
|
||||||
height: 60px
|
height: 60px
|
||||||
border-radius: 35px
|
border-radius: 35px
|
||||||
|
transition: width .3s ease-out
|
||||||
|
|
||||||
img
|
img
|
||||||
width: 100%
|
width: 100%
|
||||||
height: 100%
|
height: 100%
|
||||||
|
transition: filter 375ms ease-in .2s, transform .3s
|
||||||
object-fit: cover
|
object-fit: cover
|
||||||
transition: filter 375ms ease-in 0.2s, transform .3s
|
|
||||||
|
|
||||||
.img-alt
|
.img-alt
|
||||||
display: none
|
display: none
|
||||||
@@ -76,3 +80,8 @@
|
|||||||
padding: 16px 10px 16px 0
|
padding: 16px 10px 16px 0
|
||||||
height: 50px
|
height: 50px
|
||||||
font-size: .93em
|
font-size: .93em
|
||||||
|
|
||||||
|
.flink-name
|
||||||
|
margin-bottom: 5px
|
||||||
|
font-weight: bold
|
||||||
|
font-size: 1.5em
|
||||||
@@ -11,7 +11,8 @@
|
|||||||
color: var(--search-input-color)
|
color: var(--search-input-color)
|
||||||
|
|
||||||
.ais-Hits-list
|
.ais-Hits-list
|
||||||
padding-left: 24px
|
margin: 0
|
||||||
|
padding: 0
|
||||||
@extend .list-beauty
|
@extend .list-beauty
|
||||||
|
|
||||||
a
|
a
|
||||||
@@ -25,12 +26,17 @@
|
|||||||
color: $search-keyword-highlight
|
color: $search-keyword-highlight
|
||||||
font-weight: bold
|
font-weight: bold
|
||||||
|
|
||||||
|
.algolia-hit-item-content
|
||||||
|
margin: 0 0 8px
|
||||||
|
word-break: break-all
|
||||||
|
|
||||||
.ais-Pagination
|
.ais-Pagination
|
||||||
margin: 16px 0 0
|
margin: 20px 0 0
|
||||||
padding: 0
|
padding: 0
|
||||||
text-align: center
|
text-align: center
|
||||||
|
|
||||||
.ais-Pagination-list
|
.ais-Pagination-list
|
||||||
|
margin: 0
|
||||||
padding: 0
|
padding: 0
|
||||||
list-style: none
|
list-style: none
|
||||||
|
|
||||||
@@ -52,7 +58,34 @@
|
|||||||
color: #eee
|
color: #eee
|
||||||
cursor: default
|
cursor: default
|
||||||
|
|
||||||
|
.ais-Pagination-item--disabled
|
||||||
|
visibility: hidden
|
||||||
|
|
||||||
.algolia-logo
|
.algolia-logo
|
||||||
padding-top: 2px
|
padding-top: 2px
|
||||||
width: 80px
|
width: 80px
|
||||||
height: 30px
|
height: 30px
|
||||||
|
|
||||||
|
#algolia-hits
|
||||||
|
> div
|
||||||
|
overflow-y: scroll
|
||||||
|
|
||||||
|
+minWidth768()
|
||||||
|
max-height: calc(80vh - 240px)
|
||||||
|
|
||||||
|
+maxWidth768()
|
||||||
|
height: calc(100vh - 260px)
|
||||||
|
|
||||||
|
#algolia-info
|
||||||
|
div
|
||||||
|
display: inline
|
||||||
|
|
||||||
|
.algolia-poweredBy
|
||||||
|
float: right
|
||||||
|
|
||||||
|
.apple
|
||||||
|
#algolia-search
|
||||||
|
#algolia-hits
|
||||||
|
> div
|
||||||
|
+maxWidth768()
|
||||||
|
height: calc(90vh - 260px)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
.search-dialog
|
.search-dialog
|
||||||
position: fixed
|
position: fixed
|
||||||
top: 100px
|
top: 10%
|
||||||
left: 50%
|
left: 50%
|
||||||
z-index: 1001
|
z-index: 1001
|
||||||
display: none
|
display: none
|
||||||
|
|||||||
@@ -51,7 +51,7 @@
|
|||||||
color: $search-color
|
color: $search-color
|
||||||
|
|
||||||
.search-result
|
.search-result
|
||||||
margin: 0 0 8px
|
margin: 0 8px 8px 0
|
||||||
word-break: break-all
|
word-break: break-all
|
||||||
|
|
||||||
.search-keyword
|
.search-keyword
|
||||||
@@ -60,7 +60,7 @@
|
|||||||
|
|
||||||
.search-result-list
|
.search-result-list
|
||||||
overflow-y: auto
|
overflow-y: auto
|
||||||
max-height: 210px
|
max-height: calc(80vh - 130px)
|
||||||
|
|
||||||
+maxWidth768()
|
+maxWidth768()
|
||||||
padding-bottom: 40px
|
padding-bottom: 40px
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
.hide-block
|
.hide-block
|
||||||
& > .hide-button
|
& > .hide-button
|
||||||
display: inline-block
|
display: inline-block
|
||||||
padding: 6px 20px
|
padding: 5px 18px
|
||||||
background: $tag-hide-bg
|
background: $tag-hide-bg
|
||||||
color: var(--white)
|
color: var(--white)
|
||||||
|
|
||||||
@@ -32,27 +32,15 @@
|
|||||||
.hide-block
|
.hide-block
|
||||||
margin: 0 0 16px
|
margin: 0 0 16px
|
||||||
|
|
||||||
.hide-toggle
|
.toggle
|
||||||
margin-bottom: 20px
|
margin-bottom: 20px
|
||||||
border: 1px solid $tag-hide-toggle-bg
|
border: 1px solid $tag-hide-toggle-bg
|
||||||
|
|
||||||
& > .hide-button
|
& > .toggle-button
|
||||||
padding: 6px 10px
|
padding: 6px 15px
|
||||||
background: $tag-hide-toggle-bg
|
background: $tag-hide-toggle-bg
|
||||||
color: #1F2D3D
|
color: #1F2D3D
|
||||||
cursor: pointer
|
cursor: pointer
|
||||||
|
|
||||||
& > i
|
& > .toggle-content
|
||||||
font-size: 1.2em
|
|
||||||
transition: all .3s
|
|
||||||
|
|
||||||
&.open
|
|
||||||
i
|
|
||||||
transform: rotate(90deg)
|
|
||||||
|
|
||||||
& + div
|
|
||||||
display: block
|
|
||||||
|
|
||||||
& > .hide-content
|
|
||||||
display: none
|
|
||||||
margin: 30px 24px
|
margin: 30px 24px
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
document.addEventListener('DOMContentLoaded', function () {
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
let blogNameWidth, menusWidth, searchWidth, $nav, hideMenuIndex
|
let blogNameWidth, menusWidth, searchWidth, $nav
|
||||||
let mobileSidebarOpen = false
|
let mobileSidebarOpen = false
|
||||||
|
|
||||||
const adjustMenu = (init) => {
|
const adjustMenu = (init) => {
|
||||||
@@ -13,6 +13,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
$nav = document.getElementById('nav')
|
$nav = document.getElementById('nav')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let hideMenuIndex = ''
|
||||||
if (window.innerWidth < 768) hideMenuIndex = true
|
if (window.innerWidth < 768) hideMenuIndex = true
|
||||||
else hideMenuIndex = blogNameWidth + menusWidth + searchWidth > $nav.offsetWidth - 120
|
else hideMenuIndex = blogNameWidth + menusWidth + searchWidth > $nav.offsetWidth - 120
|
||||||
|
|
||||||
@@ -259,7 +260,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
|
|
||||||
// 當滾動條小于 56 的時候
|
// 當滾動條小于 56 的時候
|
||||||
if (document.body.scrollHeight <= innerHeight) {
|
if (document.body.scrollHeight <= innerHeight) {
|
||||||
$rightside.style.cssText = 'opacity: 1; transform: translateX(-38px)'
|
$rightside.style.cssText = 'opacity: 1; transform: translateX(-58px)'
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -360,7 +361,9 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
// toc元素點擊
|
// toc元素點擊
|
||||||
$cardToc.addEventListener('click', e => {
|
$cardToc.addEventListener('click', e => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
const $target = e.target.classList.contains('toc-link')
|
const target = e.target.classList
|
||||||
|
if (target.contains('toc-content')) return
|
||||||
|
const $target = target.contains('toc-link')
|
||||||
? e.target
|
? e.target
|
||||||
: e.target.parentElement
|
: e.target.parentElement
|
||||||
btf.scrollToDest(btf.getEleTop(document.getElementById(decodeURI($target.getAttribute('href')).replace('#', ''))), 300)
|
btf.scrollToDest(btf.getEleTop(document.getElementById(decodeURI($target.getAttribute('href')).replace('#', ''))), 300)
|
||||||
@@ -612,13 +615,9 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
$hideInline.forEach(function (item) {
|
$hideInline.forEach(function (item) {
|
||||||
item.addEventListener('click', function (e) {
|
item.addEventListener('click', function (e) {
|
||||||
const $this = this
|
const $this = this
|
||||||
const $hideContent = $this.nextElementSibling
|
$this.classList.add('open')
|
||||||
$this.classList.toggle('open')
|
const $fjGallery = $this.nextElementSibling.querySelectorAll('.fj-gallery')
|
||||||
if ($this.classList.contains('open')) {
|
$fjGallery.length && btf.initJustifiedGallery($fjGallery)
|
||||||
if ($hideContent.querySelectorAll('.fj-gallery').length > 0) {
|
|
||||||
btf.initJustifiedGallery($hideContent.querySelectorAll('.fj-gallery'))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -734,7 +733,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
const unRefreshFn = function () {
|
const unRefreshFn = function () {
|
||||||
window.addEventListener('resize', () => {
|
window.addEventListener('resize', () => {
|
||||||
adjustMenu(false)
|
adjustMenu(false)
|
||||||
hideMenuIndex && mobileSidebarOpen && sidebarFn.close()
|
btf.isHidden(document.getElementById('toggle-menu')) && mobileSidebarOpen && sidebarFn.close()
|
||||||
})
|
})
|
||||||
|
|
||||||
document.getElementById('menu-mask').addEventListener('click', e => { sidebarFn.close() })
|
document.getElementById('menu-mask').addEventListener('click', e => { sidebarFn.close() })
|
||||||
|
|||||||
@@ -26,16 +26,39 @@ window.addEventListener('load', () => {
|
|||||||
|
|
||||||
const searchClickFn = () => {
|
const searchClickFn = () => {
|
||||||
document.querySelector('#search-button > .search').addEventListener('click', openSearch)
|
document.querySelector('#search-button > .search').addEventListener('click', openSearch)
|
||||||
|
}
|
||||||
|
|
||||||
|
const searchClickFnOnce = () => {
|
||||||
document.getElementById('search-mask').addEventListener('click', closeSearch)
|
document.getElementById('search-mask').addEventListener('click', closeSearch)
|
||||||
document.querySelector('#algolia-search .search-close-button').addEventListener('click', closeSearch)
|
document.querySelector('#algolia-search .search-close-button').addEventListener('click', closeSearch)
|
||||||
}
|
}
|
||||||
|
|
||||||
searchClickFn()
|
const cutContent = content => {
|
||||||
|
if (content === '') return ''
|
||||||
|
|
||||||
window.addEventListener('pjax:complete', function () {
|
const firstOccur = content.indexOf('<mark>')
|
||||||
getComputedStyle(document.querySelector('#algolia-search .search-dialog')).display === 'block' && closeSearch()
|
|
||||||
searchClickFn()
|
let start = firstOccur - 30
|
||||||
})
|
let end = firstOccur + 120
|
||||||
|
let pre = ''
|
||||||
|
let post = ''
|
||||||
|
|
||||||
|
if (start <= 0) {
|
||||||
|
start = 0
|
||||||
|
end = 140
|
||||||
|
} else {
|
||||||
|
pre = '...'
|
||||||
|
}
|
||||||
|
|
||||||
|
if (end > content.length) {
|
||||||
|
end = content.length
|
||||||
|
} else {
|
||||||
|
post = '...'
|
||||||
|
}
|
||||||
|
|
||||||
|
let matchContent = pre + content.substring(start, end) + post
|
||||||
|
return matchContent
|
||||||
|
}
|
||||||
|
|
||||||
const algolia = GLOBAL_CONFIG.algolia
|
const algolia = GLOBAL_CONFIG.algolia
|
||||||
const isAlgoliaValid = algolia.appId && algolia.apiKey && algolia.indexName
|
const isAlgoliaValid = algolia.appId && algolia.apiKey && algolia.indexName
|
||||||
@@ -43,38 +66,36 @@ window.addEventListener('load', () => {
|
|||||||
return console.error('Algolia setting is invalid!')
|
return console.error('Algolia setting is invalid!')
|
||||||
}
|
}
|
||||||
|
|
||||||
const searchClient = window.algoliasearch(algolia.appId, algolia.apiKey)
|
|
||||||
const search = instantsearch({
|
const search = instantsearch({
|
||||||
indexName: algolia.indexName,
|
indexName: algolia.indexName,
|
||||||
searchClient
|
searchClient: algoliasearch(algolia.appId, algolia.apiKey),
|
||||||
|
searchFunction(helper) {
|
||||||
|
helper.state.query && helper.search()
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
search.addWidgets([
|
const configure = instantsearch.widgets.configure({
|
||||||
instantsearch.widgets.configure({
|
|
||||||
hitsPerPage: 5
|
hitsPerPage: 5
|
||||||
})
|
})
|
||||||
])
|
|
||||||
|
|
||||||
search.addWidgets([
|
const searchBox = instantsearch.widgets.searchBox({
|
||||||
instantsearch.widgets.searchBox({
|
|
||||||
container: '#algolia-search-input',
|
container: '#algolia-search-input',
|
||||||
showReset: false,
|
showReset: false,
|
||||||
showSubmit: false,
|
showSubmit: false,
|
||||||
placeholder: GLOBAL_CONFIG.algolia.languages.input_placeholder,
|
placeholder: GLOBAL_CONFIG.algolia.languages.input_placeholder,
|
||||||
showLoadingIndicator: true
|
showLoadingIndicator: true
|
||||||
})
|
})
|
||||||
])
|
|
||||||
|
|
||||||
search.addWidgets([
|
const hits = instantsearch.widgets.hits({
|
||||||
instantsearch.widgets.hits({
|
|
||||||
container: '#algolia-hits',
|
container: '#algolia-hits',
|
||||||
templates: {
|
templates: {
|
||||||
item: function (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)
|
||||||
return `
|
return `
|
||||||
<a href="${link}" class="algolia-hit-item-link">
|
<a href="${link}" class="algolia-hit-item-link">
|
||||||
${data._highlightResult.title.value || 'no-title'}
|
${data._highlightResult.title.value || 'no-title'}
|
||||||
</a>`
|
</a>
|
||||||
|
<p class="algolia-hit-item-content">${cutContent(data._highlightResult.contentStripTruncate.value)}</p>`
|
||||||
},
|
},
|
||||||
empty: function (data) {
|
empty: function (data) {
|
||||||
return (
|
return (
|
||||||
@@ -85,27 +106,26 @@ window.addEventListener('load', () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
])
|
|
||||||
|
|
||||||
search.addWidgets([
|
const stats = instantsearch.widgets.stats({
|
||||||
instantsearch.widgets.stats({
|
container: '#algolia-info > .algolia-stats',
|
||||||
container: '#algolia-stats',
|
|
||||||
templates: {
|
templates: {
|
||||||
text: function (data) {
|
text: function (data) {
|
||||||
const icon = '<svg viewBox="0 0 1366 362" xmlns="http://www.w3.org/2000/svg"><linearGradient id="a" x1="428.26" x2="434.14" y1="404.15" y2="409.85" gradientTransform="matrix(94.045 0 0 -94.072 -40382 38480)" gradientUnits="userSpaceOnUse"><stop stop-color="#00aeff" offset="0"/><stop stop-color="#3369e7" offset="1"/></linearGradient><path d="M61.8 15.4h242.8c23.9 0 43.4 19.4 43.4 43.4v242.9c0 23.9-19.4 43.4-43.4 43.4H61.8c-23.9 0-43.4-19.4-43.4-43.4v-243c0-23.9 19.4-43.3 43.4-43.3z" fill="url(#a)"/><path d="M187 98.7c-51.4 0-93.1 41.7-93.1 93.2S135.6 285 187 285s93.1-41.7 93.1-93.2-41.6-93.1-93.1-93.1zm0 158.8c-36.2 0-65.6-29.4-65.6-65.6s29.4-65.6 65.6-65.6 65.6 29.4 65.6 65.6-29.3 65.6-65.6 65.6zm0-117.8v48.9c0 1.4 1.5 2.4 2.8 1.7l43.4-22.5c1-.5 1.3-1.7.8-2.7-9-15.8-25.7-26.6-45-27.3-1 0-2 .8-2 1.9zm-60.8-35.9l-5.7-5.7c-5.6-5.6-14.6-5.6-20.2 0l-6.8 6.8c-5.6 5.6-5.6 14.6 0 20.2l5.6 5.6c.9.9 2.2.7 3-.2 3.3-4.5 6.9-8.8 10.9-12.8 4.1-4.1 8.3-7.7 12.9-11 1-.6 1.1-2 .3-2.9zM217.5 89V77.7c0-7.9-6.4-14.3-14.3-14.3h-33.3c-7.9 0-14.3 6.4-14.3 14.3v11.6c0 1.3 1.2 2.2 2.5 1.9 9.3-2.7 19.1-4.1 29-4.1 9.5 0 18.9 1.3 28 3.8 1.2.3 2.4-.6 2.4-1.9z" fill="#FFF"/><path d="m842.5 267.6c0 26.7-6.8 46.2-20.5 58.6s-34.6 18.6-62.8 18.6c-10.3 0-31.7-2-48.8-5.8l6.3-31c14.3 3 33.2 3.8 43.1 3.8 15.7 0 26.9-3.2 33.6-9.6s10-15.9 10-28.5v-6.4c-3.9 1.9-9 3.8-15.3 5.8-6.3 1.9-13.6 2.9-21.8 2.9-10.8 0-20.6-1.7-29.5-5.1s-16.6-8.4-22.9-15-11.3-14.9-14.8-24.8-5.3-27.6-5.3-40.6c0-12.2 1.9-27.5 5.6-37.7 3.8-10.2 9.2-19 16.5-26.3 7.2-7.3 16-12.9 26.3-17s22.4-6.7 35.5-6.7c12.7 0 24.4 1.6 35.8 3.5s21.1 3.9 29 6.1v155.2zm-108.7-77.2c0 16.4 3.6 34.6 10.8 42.2s16.5 11.4 27.9 11.4c6.2 0 12.1-0.9 17.6-2.6s9.9-3.7 13.4-6.1v-97.1c-2.8-0.6-14.5-3-25.8-3.3-14.2-0.4-25 5.4-32.6 14.7-7.5 9.3-11.3 25.6-11.3 40.8zm294.3 0c0 13.2-1.9 23.2-5.8 34.1s-9.4 20.2-16.5 27.9-15.6 13.7-25.6 17.9-25.4 6.6-33.1 6.6c-7.7-0.1-23-2.3-32.9-6.6s-18.4-10.2-25.5-17.9-12.6-17-16.6-27.9-6-20.9-6-34.1 1.8-25.9 5.8-36.7 9.6-20 16.8-27.7 15.8-13.6 25.6-17.8c9.9-4.2 20.8-6.2 32.6-6.2s22.7 2.1 32.7 6.2c10 4.2 18.6 10.1 25.6 17.8 7.1 7.7 12.6 16.9 16.6 27.7 4.2 10.8 6.3 23.5 6.3 36.7zm-40 0.1c0-16.9-3.7-31-10.9-40.8-7.2-9.9-17.3-14.8-30.2-14.8s-23 4.9-30.2 14.8-10.7 23.9-10.7 40.8c0 17.1 3.6 28.6 10.8 38.5 7.2 10 17.3 14.9 30.2 14.9s23-5 30.2-14.9c7.2-10 10.8-21.4 10.8-38.5zm127.1 86.4c-64.1 0.3-64.1-51.8-64.1-60.1l-0.1-184.8 39.1-6.2v183.6c0 4.7 0 34.5 25.1 34.6v32.9zm68.9 0h-39.3v-168.8l39.3-6.2v175zm-19.7-193.5c13.1 0 23.8-10.6 23.8-23.7s-10.6-23.7-23.8-23.7-23.8 10.6-23.8 23.7 10.7 23.7 23.8 23.7zm117.4 18.6c12.9 0 23.8 1.6 32.6 4.8s15.9 7.7 21.1 13.4 8.9 13.5 11.1 21.7c2.3 8.2 3.4 17.2 3.4 27.1v100.6c-6 1.3-15.1 2.8-27.3 4.6s-25.9 2.7-41.1 2.7c-10.1 0-19.4-1-27.7-2.9-8.4-1.9-15.5-5-21.5-9.3-5.9-4.3-10.5-9.8-13.9-16.6-3.3-6.8-5-16.4-5-26.4 0-9.6 1.9-15.7 5.6-22.3 3.8-6.6 8.9-12 15.3-16.2 6.5-4.2 13.9-7.2 22.4-9s17.4-2.7 26.6-2.7c4.3 0 8.8 0.3 13.6 0.8s9.8 1.4 15.2 2.7v-6.4c0-4.5-0.5-8.8-1.6-12.8-1.1-4.1-3-7.6-5.6-10.7-2.7-3.1-6.2-5.5-10.6-7.2s-10-3-16.7-3c-9 0-17.2 1.1-24.7 2.4s-13.7 2.8-18.4 4.5l-4.7-32.1c4.9-1.7 12.2-3.4 21.6-5.1s19.5-2.6 30.3-2.6zm3.3 141.9c12 0 20.9-0.7 27.1-1.9v-39.8c-2.2-0.6-5.3-1.3-9.4-1.9s-8.6-1-13.6-1c-4.3 0-8.7 0.3-13.1 1-4.4 0.6-8.4 1.8-11.9 3.5s-6.4 4.1-8.5 7.2c-2.2 3.1-3.2 4.9-3.2 9.6 0 9.2 3.2 14.5 9 18 5.9 3.6 13.7 5.3 23.6 5.3zm-772.2-140.9c12.9 0 23.8 1.6 32.6 4.8s15.9 7.7 21.1 13.4c5.3 5.8 8.9 13.5 11.1 21.7 2.3 8.2 3.4 17.2 3.4 27.1v100.6c-6 1.3-15.1 2.8-27.3 4.6s-25.9 2.7-41.1 2.7c-10.1 0-19.4-1-27.7-2.9-8.4-1.9-15.5-5-21.5-9.3-5.9-4.3-10.5-9.8-13.9-16.6-3.3-6.8-5-16.4-5-26.4 0-9.6 1.9-15.7 5.6-22.3 3.8-6.6 8.9-12 15.3-16.2 6.5-4.2 13.9-7.2 22.4-9s17.4-2.7 26.6-2.7c4.3 0 8.8 0.3 13.6 0.8 4.7 0.5 9.8 1.4 15.2 2.7v-6.4c0-4.5-0.5-8.8-1.6-12.8-1.1-4.1-3-7.6-5.6-10.7-2.7-3.1-6.2-5.5-10.6-7.2s-10-3-16.7-3c-9 0-17.2 1.1-24.7 2.4s-13.7 2.8-18.4 4.5l-4.7-32.1c4.9-1.7 12.2-3.4 21.6-5.1 9.4-1.8 19.5-2.6 30.3-2.6zm3.4 142c12 0 20.9-0.7 27.1-1.9v-39.8c-2.2-0.6-5.3-1.3-9.4-1.9s-8.6-1-13.6-1c-4.3 0-8.7 0.3-13.1 1-4.4 0.6-8.4 1.8-11.9 3.5s-6.4 4.1-8.5 7.2c-2.2 3.1-3.2 4.9-3.2 9.6 0 9.2 3.2 14.5 9 18s13.7 5.3 23.6 5.3zm158.5 31.9c-64.1 0.3-64.1-51.8-64.1-60.1l-0.1-184.8 39.1-6.2v183.6c0 4.7 0 34.5 25.1 34.6v32.9z" fill="#182359"/></svg>'
|
|
||||||
const stats = GLOBAL_CONFIG.algolia.languages.hits_stats
|
const stats = GLOBAL_CONFIG.algolia.languages.hits_stats
|
||||||
.replace(/\$\{hits}/, data.nbHits)
|
.replace(/\$\{hits}/, data.nbHits)
|
||||||
.replace(/\$\{time}/, data.processingTimeMS)
|
.replace(/\$\{time}/, data.processingTimeMS)
|
||||||
return (
|
return (
|
||||||
`<hr>${stats}<span class="algolia-logo pull-right">${icon}</span>`
|
`<hr>${stats}`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
])
|
|
||||||
|
|
||||||
search.addWidgets([
|
const powerBy = instantsearch.widgets.poweredBy({
|
||||||
instantsearch.widgets.pagination({
|
container: '#algolia-info > .algolia-poweredBy',
|
||||||
|
})
|
||||||
|
|
||||||
|
const pagination = instantsearch.widgets.pagination({
|
||||||
container: '#algolia-pagination',
|
container: '#algolia-pagination',
|
||||||
totalPages: 5,
|
totalPages: 5,
|
||||||
templates: {
|
templates: {
|
||||||
@@ -115,9 +135,20 @@ window.addEventListener('load', () => {
|
|||||||
next: '<i class="fas fa-angle-right"></i>'
|
next: '<i class="fas fa-angle-right"></i>'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
])
|
|
||||||
|
|
||||||
|
search.addWidgets([configure,searchBox,hits,stats,powerBy,pagination]) // add the widgets to the instantsearch instance
|
||||||
|
|
||||||
search.start()
|
search.start()
|
||||||
|
|
||||||
|
searchClickFn()
|
||||||
|
searchClickFnOnce()
|
||||||
|
|
||||||
|
window.addEventListener('pjax:complete', () => {
|
||||||
|
getComputedStyle(document.querySelector('#algolia-search .search-dialog')).display === 'block' && closeSearch()
|
||||||
|
searchClickFn()
|
||||||
|
})
|
||||||
|
|
||||||
window.pjax && search.on('render', () => {
|
window.pjax && search.on('render', () => {
|
||||||
window.pjax.refresh(document.getElementById('algolia-hits'))
|
window.pjax.refresh(document.getElementById('algolia-hits'))
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,14 +1,17 @@
|
|||||||
window.addEventListener('load', () => {
|
window.addEventListener('load', () => {
|
||||||
let loadFlag = false
|
let loadFlag = false
|
||||||
|
let dataObj = []
|
||||||
|
const $searchMask = document.getElementById('search-mask')
|
||||||
|
|
||||||
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('#local-search .search-dialog'), 'titleScale 0.5s')
|
btf.animateIn(document.querySelector('#local-search .search-dialog'), 'titleScale 0.5s')
|
||||||
setTimeout(() => { document.querySelector('#local-search-input input').focus() }, 100)
|
setTimeout(() => { document.querySelector('#local-search-input input').focus() }, 100)
|
||||||
if (!loadFlag) {
|
if (!loadFlag) {
|
||||||
search(GLOBAL_CONFIG.localSearch.path)
|
search()
|
||||||
loadFlag = true
|
loadFlag = true
|
||||||
}
|
}
|
||||||
// shortcut: ESC
|
// shortcut: ESC
|
||||||
@@ -25,38 +28,38 @@ window.addEventListener('load', () => {
|
|||||||
bodyStyle.width = ''
|
bodyStyle.width = ''
|
||||||
bodyStyle.overflow = ''
|
bodyStyle.overflow = ''
|
||||||
btf.animateOut(document.querySelector('#local-search .search-dialog'), 'search_close .5s')
|
btf.animateOut(document.querySelector('#local-search .search-dialog'), 'search_close .5s')
|
||||||
btf.animateOut(document.getElementById('search-mask'), 'to_hide 0.5s')
|
btf.animateOut($searchMask, 'to_hide 0.5s')
|
||||||
}
|
}
|
||||||
|
|
||||||
// click function
|
|
||||||
const searchClickFn = () => {
|
const searchClickFn = () => {
|
||||||
document.querySelector('#search-button > .search').addEventListener('click', openSearch)
|
document.querySelector('#search-button > .search').addEventListener('click', openSearch)
|
||||||
document.getElementById('search-mask').addEventListener('click', closeSearch)
|
|
||||||
document.querySelector('#local-search .search-close-button').addEventListener('click', closeSearch)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
searchClickFn()
|
const searchClickFnOnce = () => {
|
||||||
|
document.querySelector('#local-search .search-close-button').addEventListener('click', closeSearch)
|
||||||
|
$searchMask.addEventListener('click', closeSearch)
|
||||||
|
if (GLOBAL_CONFIG.localSearch.preload) dataObj = fetchData(GLOBAL_CONFIG.localSearch.path)
|
||||||
|
}
|
||||||
|
|
||||||
// pjax
|
// check url is json or not
|
||||||
window.addEventListener('pjax:complete', function () {
|
const isJson = url => {
|
||||||
getComputedStyle(document.querySelector('#local-search .search-dialog')).display === 'block' && closeSearch()
|
const reg = /\.json$/
|
||||||
searchClickFn()
|
return reg.test(url)
|
||||||
})
|
}
|
||||||
|
|
||||||
async function search (path) {
|
const fetchData = async (path) => {
|
||||||
let datas = []
|
let data = []
|
||||||
const typeF = path.split('.')[1]
|
const response = await fetch(path)
|
||||||
const response = await fetch(GLOBAL_CONFIG.root + path)
|
if (isJson(path)) {
|
||||||
if (typeF === 'json') {
|
data = await response.json()
|
||||||
datas = await response.json()
|
} else {
|
||||||
} else if (typeF === 'xml') {
|
|
||||||
const res = await response.text()
|
const res = await response.text()
|
||||||
const t = await new window.DOMParser().parseFromString(res, 'text/xml')
|
const t = await new window.DOMParser().parseFromString(res, 'text/xml')
|
||||||
const a = await t
|
const a = await t
|
||||||
datas = [...a.querySelectorAll('entry')].map(function (item) {
|
data = [...a.querySelectorAll('entry')].map(item =>{
|
||||||
return {
|
return {
|
||||||
title: item.querySelector('title').textContent,
|
title: item.querySelector('title').textContent,
|
||||||
content: item.querySelector('content').textContent,
|
content: item.querySelector('content') && item.querySelector('content').textContent,
|
||||||
url: item.querySelector('url').textContent
|
url: item.querySelector('url').textContent
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -66,33 +69,39 @@ window.addEventListener('load', () => {
|
|||||||
$loadDataItem.nextElementSibling.style.display = 'block'
|
$loadDataItem.nextElementSibling.style.display = 'block'
|
||||||
$loadDataItem.remove()
|
$loadDataItem.remove()
|
||||||
}
|
}
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
|
||||||
|
const search = () => {
|
||||||
|
if (!GLOBAL_CONFIG.localSearch.preload) {
|
||||||
|
dataObj = fetchData(GLOBAL_CONFIG.localSearch.path)
|
||||||
|
}
|
||||||
|
|
||||||
const $input = document.querySelector('#local-search-input input')
|
const $input = document.querySelector('#local-search-input input')
|
||||||
const $resultContent = document.getElementById('local-search-results')
|
const $resultContent = document.getElementById('local-search-results')
|
||||||
const $loadingStatus = document.getElementById('loading-status')
|
const $loadingStatus = document.getElementById('loading-status')
|
||||||
|
|
||||||
$input.addEventListener('input', function () {
|
$input.addEventListener('input', function () {
|
||||||
const keywords = this.value.trim().toLowerCase().split(/[\s]+/)
|
const keywords = this.value.trim().toLowerCase().split(/[\s]+/)
|
||||||
if (keywords[0] !== '') $loadingStatus.innerHTML = '<i class="fas fa-spinner fa-pulse"></i>'
|
if (keywords[0] !== '') $loadingStatus.innerHTML = '<i class="fas fa-spinner fa-pulse"></i>'
|
||||||
|
|
||||||
$resultContent.innerHTML = ''
|
$resultContent.innerHTML = ''
|
||||||
let str = '<div class="search-result-list">'
|
let str = '<div class="search-result-list">'
|
||||||
if (this.value.trim().length <= 0) return
|
if (keywords.length <= 0) return
|
||||||
let count = 0
|
let count = 0
|
||||||
// perform local searching
|
// perform local searching
|
||||||
datas.forEach(function (data) {
|
dataObj.then(data => {
|
||||||
|
data.forEach(data => {
|
||||||
let isMatch = true
|
let isMatch = true
|
||||||
if (!data.title || data.title.trim() === '') {
|
let dataTitle = data.title ? data.title.trim().toLowerCase() : ''
|
||||||
data.title = ''
|
|
||||||
}
|
|
||||||
let dataTitle = data.title.trim().toLowerCase()
|
|
||||||
const dataContent = data.content ? data.content.trim().replace(/<[^>]+>/g, '').toLowerCase() : ''
|
const dataContent = data.content ? data.content.trim().replace(/<[^>]+>/g, '').toLowerCase() : ''
|
||||||
const dataUrl = data.url.startsWith('/') ? data.url : GLOBAL_CONFIG.root + data.url
|
const dataUrl = data.url.startsWith('/') ? data.url : GLOBAL_CONFIG.root + data.url
|
||||||
let indexTitle = -1
|
let indexTitle = -1
|
||||||
let indexContent = -1
|
let indexContent = -1
|
||||||
let firstOccur = -1
|
let firstOccur = -1
|
||||||
// only match artiles with not empty titles and contents
|
// only match articles with not empty titles and contents
|
||||||
if (dataTitle !== '' || dataContent !== '') {
|
if (dataTitle !== '' || dataContent !== '') {
|
||||||
keywords.forEach(function (keyword, i) {
|
keywords.forEach((keyword, i) => {
|
||||||
indexTitle = dataTitle.indexOf(keyword)
|
indexTitle = dataTitle.indexOf(keyword)
|
||||||
indexContent = dataContent.indexOf(keyword)
|
indexContent = dataContent.indexOf(keyword)
|
||||||
if (indexTitle < 0 && indexContent < 0) {
|
if (indexTitle < 0 && indexContent < 0) {
|
||||||
@@ -112,13 +121,14 @@ window.addEventListener('load', () => {
|
|||||||
|
|
||||||
// show search results
|
// show search results
|
||||||
if (isMatch) {
|
if (isMatch) {
|
||||||
const content = data.content.trim().replace(/<[^>]+>/g, '')
|
|
||||||
if (firstOccur >= 0) {
|
if (firstOccur >= 0) {
|
||||||
// cut out 130 characters
|
// cut out 130 characters
|
||||||
// let start = firstOccur - 30 < 0 ? 0 : firstOccur - 30
|
// let start = firstOccur - 30 < 0 ? 0 : firstOccur - 30
|
||||||
// let end = firstOccur + 50 > content.length ? content.length : firstOccur + 50
|
// let end = firstOccur + 50 > dataContent.length ? dataContent.length : firstOccur + 50
|
||||||
let start = firstOccur - 30
|
let start = firstOccur - 30
|
||||||
let end = firstOccur + 100
|
let end = firstOccur + 100
|
||||||
|
let pre = ''
|
||||||
|
let post = ''
|
||||||
|
|
||||||
if (start < 0) {
|
if (start < 0) {
|
||||||
start = 0
|
start = 0
|
||||||
@@ -126,16 +136,20 @@ window.addEventListener('load', () => {
|
|||||||
|
|
||||||
if (start === 0) {
|
if (start === 0) {
|
||||||
end = 100
|
end = 100
|
||||||
|
} else {
|
||||||
|
pre = '...'
|
||||||
}
|
}
|
||||||
|
|
||||||
if (end > content.length) {
|
if (end > dataContent.length) {
|
||||||
end = content.length
|
end = dataContent.length
|
||||||
|
} else {
|
||||||
|
post = '...'
|
||||||
}
|
}
|
||||||
|
|
||||||
let matchContent = content.substring(start, end)
|
let matchContent = dataContent.substring(start, end)
|
||||||
|
|
||||||
// highlight all keywords
|
// highlight all keywords
|
||||||
keywords.forEach(function (keyword) {
|
keywords.forEach(keyword => {
|
||||||
const regS = new RegExp(keyword, 'gi')
|
const regS = new RegExp(keyword, 'gi')
|
||||||
matchContent = matchContent.replace(regS, '<span class="search-keyword">' + keyword + '</span>')
|
matchContent = matchContent.replace(regS, '<span class="search-keyword">' + keyword + '</span>')
|
||||||
dataTitle = dataTitle.replace(regS, '<span class="search-keyword">' + keyword + '</span>')
|
dataTitle = dataTitle.replace(regS, '<span class="search-keyword">' + keyword + '</span>')
|
||||||
@@ -145,7 +159,7 @@ window.addEventListener('load', () => {
|
|||||||
count += 1
|
count += 1
|
||||||
|
|
||||||
if (dataContent !== '') {
|
if (dataContent !== '') {
|
||||||
str += '<p class="search-result">' + matchContent + '...</p>'
|
str += '<p class="search-result">' + pre + matchContent + post + '</p>'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
str += '</div>'
|
str += '</div>'
|
||||||
@@ -160,5 +174,15 @@ window.addEventListener('load', () => {
|
|||||||
if (keywords[0] !== '') $loadingStatus.innerHTML = ''
|
if (keywords[0] !== '') $loadingStatus.innerHTML = ''
|
||||||
window.pjax && window.pjax.refresh($resultContent)
|
window.pjax && window.pjax.refresh($resultContent)
|
||||||
})
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
searchClickFn()
|
||||||
|
searchClickFnOnce()
|
||||||
|
|
||||||
|
// pjax
|
||||||
|
window.addEventListener('pjax:complete', () => {
|
||||||
|
!btf.isHidden($searchMask) && closeSearch()
|
||||||
|
searchClickFn()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -66,7 +66,8 @@ const btf = {
|
|||||||
backgroundColor: bg,
|
backgroundColor: bg,
|
||||||
showAction: showAction,
|
showAction: showAction,
|
||||||
duration: duration,
|
duration: duration,
|
||||||
pos: position
|
pos: position,
|
||||||
|
customClass: 'snackbar-css'
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user