mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-12 22:17:06 +08:00
Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4a69c623fc | ||
|
|
eb823b0a2d | ||
|
|
83299dfd2f | ||
|
|
8f412c90da | ||
|
|
d82f69e83b | ||
|
|
6fda7ef004 | ||
|
|
ecca2621c2 | ||
|
|
9536df735c | ||
|
|
8227acb1b7 | ||
|
|
3a1ed95c32 | ||
|
|
dc1c7c5efd | ||
|
|
97fe932ad9 | ||
|
|
01e7929c02 | ||
|
|
02af3077e7 | ||
|
|
88b1cc553c | ||
|
|
6a1330de84 | ||
|
|
7f03c3f716 |
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -26,7 +26,7 @@ If you are a problem when visiting the website, please open your browser 'develo
|
|||||||
<!-- Check all with "x" especially FAQ & Documentation!! (使用 "x" 選擇) -->
|
<!-- 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 [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://demo.jerryc.me/posts/21cfbf15/).
|
- [] 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.
|
- [] 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 Information
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||

|

|
||||||

|

|
||||||
|
|
||||||
Demo: 👍 [Butterfly](https://demo.jerryc.me/) || 🤞 [JerryC](https://jerryc.me/)
|
Demo: 👍 [Butterfly](https://butterfly.js.org/) || 🤞 [JerryC](https://jerryc.me/)
|
||||||
|
|
||||||
Docs: 📖 [Butterfly Docs](https://demo.jerryc.me/posts/21cfbf15/)
|
Docs: 📖 [Butterfly Docs](https://butterfly.js.org/posts/21cfbf15/)
|
||||||
|
|
||||||
Based on [hexo-theme-melody](https://github.com/Molunerfinn/hexo-theme-melody) theme.
|
Based on [hexo-theme-melody](https://github.com/Molunerfinn/hexo-theme-melody) theme.
|
||||||
|
|
||||||
@@ -71,7 +71,7 @@ npm i hexo-theme-butterfly
|
|||||||
- [x] Related articles
|
- [x] Related articles
|
||||||
- [x] Displays outdated notice for a post
|
- [x] Displays outdated notice for a post
|
||||||
- [x] Share (AddThis/Sharejs/Addtoany)
|
- [x] Share (AddThis/Sharejs/Addtoany)
|
||||||
- [X] Comment (Disqus/Disqusjs/Livere/Gitalk/Valine/Utterances/Facebook Comments)
|
- [X] Comment (Disqus/Disqusjs/Livere/Gitalk/Valine/Utterances/Facebook Comments/Twikoo)
|
||||||
- [x] Multiple Comment System Support
|
- [x] Multiple Comment System Support
|
||||||
- [x] Online Chats (Chatra/Tidio/Daovoice/Gitter/Crisp)
|
- [x] Online Chats (Chatra/Tidio/Daovoice/Gitter/Crisp)
|
||||||
- [x] Web analytics (Baidu Analytics/Google Analytics/Tencent Analytics/CNZZ Analytics)
|
- [x] Web analytics (Baidu Analytics/Google Analytics/Tencent Analytics/CNZZ Analytics)
|
||||||
|
|||||||
@@ -7,9 +7,9 @@
|
|||||||

|

|
||||||
|
|
||||||
|
|
||||||
預覽: 👍 [Butterfly](https://demo.jerryc.me/) || 🤞 [JerryC](https://jerryc.me/)
|
預覽: 👍 [Butterfly](https://butterfly.js.org/) || 🤞 [JerryC](https://jerryc.me/)
|
||||||
|
|
||||||
文檔: 📖 [Butterfly Docs](https://demo.jerryc.me/posts/21cfbf15/)
|
文檔: 📖 [Butterfly Docs](https://butterfly.js.org/posts/21cfbf15/)
|
||||||
|
|
||||||
一款基於[hexo-theme-melody](https://github.com/Molunerfinn/hexo-theme-melody)修改的主題
|
一款基於[hexo-theme-melody](https://github.com/Molunerfinn/hexo-theme-melody)修改的主題
|
||||||
|
|
||||||
@@ -71,7 +71,7 @@ theme: butterfly
|
|||||||
- [x] 顯示相關文章
|
- [x] 顯示相關文章
|
||||||
- [x] 過期文章提醒
|
- [x] 過期文章提醒
|
||||||
- [x] 多種分享系統(AddThis/Sharejs/Addtoany)
|
- [x] 多種分享系統(AddThis/Sharejs/Addtoany)
|
||||||
- [X] 多種評論系統(Disqus/Disqusjs/Livere/Gitalk/Valine/Utterances/Facebook Comments)
|
- [X] 多種評論系統(Disqus/Disqusjs/Livere/Gitalk/Valine/Utterances/Facebook Comments/Twikoo)
|
||||||
- [x] 支持雙評論部署
|
- [x] 支持雙評論部署
|
||||||
- [x] 多種在線聊天(Chatra/Tidio/Daovoice/Gitter/Crisp)
|
- [x] 多種在線聊天(Chatra/Tidio/Daovoice/Gitter/Crisp)
|
||||||
- [x] 多種分析系統(百度分析/谷歌分析/騰訊分析/CNZZ分析)
|
- [x] 多種分析系統(百度分析/谷歌分析/騰訊分析/CNZZ分析)
|
||||||
|
|||||||
16
_config.yml
16
_config.yml
@@ -173,6 +173,7 @@ index_post_content:
|
|||||||
toc:
|
toc:
|
||||||
enable: true
|
enable: true
|
||||||
number: true
|
number: true
|
||||||
|
style_simple: false
|
||||||
|
|
||||||
post_copyright:
|
post_copyright:
|
||||||
enable: true
|
enable: true
|
||||||
@@ -239,7 +240,7 @@ addtoany:
|
|||||||
|
|
||||||
comments:
|
comments:
|
||||||
# Up to two comments system, the first will be shown as default
|
# Up to two comments system, the first will be shown as default
|
||||||
# Choose: Disqus/Disqusjs/Livere/Gitalk/Valine/Utterances/Facebook Comments
|
# Choose: Disqus/Disqusjs/Livere/Gitalk/Valine/Utterances/Facebook Comments/Twikoo
|
||||||
use:
|
use:
|
||||||
# - Valine
|
# - Valine
|
||||||
# - Disqus
|
# - Disqus
|
||||||
@@ -374,11 +375,6 @@ footer:
|
|||||||
since: 2020
|
since: 2020
|
||||||
custom_text:
|
custom_text:
|
||||||
copyright: true # Copyright of theme and framework
|
copyright: true # Copyright of theme and framework
|
||||||
ICP: # Chinese ICP License
|
|
||||||
enable: false
|
|
||||||
url:
|
|
||||||
text:
|
|
||||||
icon: /img/icp.png
|
|
||||||
|
|
||||||
# Analysis
|
# Analysis
|
||||||
# --------------------------------------
|
# --------------------------------------
|
||||||
@@ -542,6 +538,7 @@ ClickShowText:
|
|||||||
# - LOVE
|
# - LOVE
|
||||||
# - YOU
|
# - YOU
|
||||||
fontSize: 15px
|
fontSize: 15px
|
||||||
|
random: false
|
||||||
mobile: false
|
mobile: false
|
||||||
|
|
||||||
# Default display mode (網站默認的顯示模式)
|
# Default display mode (網站默認的顯示模式)
|
||||||
@@ -672,10 +669,14 @@ newest_comments:
|
|||||||
enable: false
|
enable: false
|
||||||
forum:
|
forum:
|
||||||
api_key:
|
api_key:
|
||||||
|
twikoo: false
|
||||||
|
|
||||||
# Bottom right button (右下角按鈕)
|
# Bottom right button (右下角按鈕)
|
||||||
# --------------------------------------
|
# --------------------------------------
|
||||||
|
|
||||||
|
# Change font size
|
||||||
|
change_font_size: false
|
||||||
|
|
||||||
# Conversion between Traditional and Simplified Chinese (簡繁轉換)
|
# Conversion between Traditional and Simplified Chinese (簡繁轉換)
|
||||||
translate:
|
translate:
|
||||||
enable: false
|
enable: false
|
||||||
@@ -814,6 +815,9 @@ Open_Graph_meta: true
|
|||||||
# Caches the contents in a fragment, speed up the generation (開啟hexo自帶的緩存,加快生成速度)
|
# Caches the contents in a fragment, speed up the generation (開啟hexo自帶的緩存,加快生成速度)
|
||||||
fragment_cache: true
|
fragment_cache: true
|
||||||
|
|
||||||
|
# Add the vendor prefixes to ensure compatibility
|
||||||
|
css_prefix: true
|
||||||
|
|
||||||
# Inject
|
# Inject
|
||||||
# Insert the code to head (before '</head>' tag) and the bottom (before '</body>' tag)
|
# Insert the code to head (before '</head>' tag) and the bottom (before '</body>' tag)
|
||||||
# 插入代码到头部 </head> 之前 和 底部 </body> 之前
|
# 插入代码到头部 </head> 之前 和 底部 </body> 之前
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ local_search:
|
|||||||
label: 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}"
|
||||||
powered_by: Powered by
|
|
||||||
|
|
||||||
pagination:
|
pagination:
|
||||||
prev: Previous Post
|
prev: Previous Post
|
||||||
@@ -74,6 +73,7 @@ aside:
|
|||||||
headline: Newest Comments
|
headline: Newest Comments
|
||||||
loading_text: loading...
|
loading_text: loading...
|
||||||
error: Unable to get the data, please make sure the settings are correct.
|
error: Unable to get the data, please make sure the settings are correct.
|
||||||
|
zero: No Comment
|
||||||
card_toc: Catalog
|
card_toc: Catalog
|
||||||
|
|
||||||
date_suffix:
|
date_suffix:
|
||||||
@@ -88,12 +88,15 @@ share: Share
|
|||||||
|
|
||||||
rightside:
|
rightside:
|
||||||
readmode_title: Read Mode
|
readmode_title: Read Mode
|
||||||
translate_title: Switch Between Traditional Chinese And Simplified Chinese
|
font_plus_title: Increase font size
|
||||||
night_mode_title: Switch Between Light And Dark Mode
|
font_minus_title: Decrease font size
|
||||||
|
translate_title: Toggle Between Traditional Chinese And Simplified Chinese
|
||||||
|
night_mode_title: Toggle Between Light And Dark Mode
|
||||||
back_to_top: Back To Top
|
back_to_top: Back To Top
|
||||||
toc: Table Of Contents
|
toc: Table Of Contents
|
||||||
scroll_to_comment: Scroll To Comments
|
scroll_to_comment: Scroll To Comments
|
||||||
setting: Setting
|
setting: Setting
|
||||||
|
aside: Toggle between single-column and double-column
|
||||||
|
|
||||||
copy_copyright:
|
copy_copyright:
|
||||||
author: Author
|
author: Author
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ local_search:
|
|||||||
label: 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}"
|
||||||
powered_by: Powered by
|
|
||||||
|
|
||||||
pagination:
|
pagination:
|
||||||
prev: Previous Post
|
prev: Previous Post
|
||||||
@@ -74,6 +73,7 @@ aside:
|
|||||||
headline: Newest Comments
|
headline: Newest Comments
|
||||||
loading_text: loading...
|
loading_text: loading...
|
||||||
error: Unable to get the data, please make sure the settings are correct.
|
error: Unable to get the data, please make sure the settings are correct.
|
||||||
|
zero: No Comment
|
||||||
card_toc: Catalog
|
card_toc: Catalog
|
||||||
|
|
||||||
date_suffix:
|
date_suffix:
|
||||||
@@ -88,12 +88,15 @@ share: Share
|
|||||||
|
|
||||||
rightside:
|
rightside:
|
||||||
readmode_title: Read Mode
|
readmode_title: Read Mode
|
||||||
|
font_plus_title: Increase font size
|
||||||
|
font_minus_title: Decrease font size
|
||||||
translate_title: Switch Between Traditional Chinese And Simplified Chinese
|
translate_title: Switch Between Traditional Chinese And Simplified Chinese
|
||||||
night_mode_title: Switch Between Light And Dark Mode
|
night_mode_title: Switch Between Light And Dark Mode
|
||||||
back_to_top: Back To Top
|
back_to_top: Back To Top
|
||||||
toc: Table Of Contents
|
toc: Table Of Contents
|
||||||
scroll_to_comment: Scroll To Comments
|
scroll_to_comment: Scroll To Comments
|
||||||
setting: Setting
|
setting: Setting
|
||||||
|
aside: Toggle between single-column and double-column
|
||||||
|
|
||||||
copy_copyright:
|
copy_copyright:
|
||||||
author: Author
|
author: Author
|
||||||
|
|||||||
@@ -42,8 +42,6 @@ local_search:
|
|||||||
label: 本地搜索
|
label: 本地搜索
|
||||||
input_placeholder: 搜索文章
|
input_placeholder: 搜索文章
|
||||||
hits_empty: '找不到您查询的内容:${query}'
|
hits_empty: '找不到您查询的内容:${query}'
|
||||||
powered: '提供支持'
|
|
||||||
by: 由
|
|
||||||
|
|
||||||
pagination:
|
pagination:
|
||||||
prev: 上一篇
|
prev: 上一篇
|
||||||
@@ -75,7 +73,8 @@ aside:
|
|||||||
card_newest_comments:
|
card_newest_comments:
|
||||||
headline: 最新评论
|
headline: 最新评论
|
||||||
loading_text: 正在加载中...
|
loading_text: 正在加载中...
|
||||||
error: 无法获取资料,请确认相关配置是否正确
|
error: 无法获取评论,请确认相关配置是否正确
|
||||||
|
zero: 没有评论
|
||||||
card_toc: 目录
|
card_toc: 目录
|
||||||
|
|
||||||
date_suffix:
|
date_suffix:
|
||||||
@@ -90,12 +89,15 @@ share: 分享
|
|||||||
|
|
||||||
rightside:
|
rightside:
|
||||||
readmode_title: 阅读模式
|
readmode_title: 阅读模式
|
||||||
|
font_plus_title: 放大字体
|
||||||
|
font_minus_title: 缩小字体
|
||||||
translate_title: 简繁转换
|
translate_title: 简繁转换
|
||||||
night_mode_title: 浅色和深色模式转换
|
night_mode_title: 浅色和深色模式转换
|
||||||
back_to_top: 回到顶部
|
back_to_top: 回到顶部
|
||||||
toc: 目录
|
toc: 目录
|
||||||
scroll_to_comment: 直达评论
|
scroll_to_comment: 直达评论
|
||||||
setting: 设置
|
setting: 设置
|
||||||
|
aside: 单栏和双栏切换
|
||||||
|
|
||||||
copy_copyright:
|
copy_copyright:
|
||||||
author: 作者
|
author: 作者
|
||||||
|
|||||||
@@ -42,8 +42,6 @@ local_search:
|
|||||||
label: 本地搜尋
|
label: 本地搜尋
|
||||||
input_placeholder: 搜尋文章
|
input_placeholder: 搜尋文章
|
||||||
hits_empty: '找不到您查詢的內容:${query}'
|
hits_empty: '找不到您查詢的內容:${query}'
|
||||||
powered: '提供支援'
|
|
||||||
by: 由
|
|
||||||
|
|
||||||
pagination:
|
pagination:
|
||||||
prev: 上一篇
|
prev: 上一篇
|
||||||
@@ -75,7 +73,8 @@ aside:
|
|||||||
card_newest_comments:
|
card_newest_comments:
|
||||||
headline: 最新評論
|
headline: 最新評論
|
||||||
loading_text: 正在加載中...
|
loading_text: 正在加載中...
|
||||||
error: 無法獲取資料,請確認相關配置是否正確
|
error: 無法獲取評論,請確認相關配置是否正確
|
||||||
|
zero: 沒有評論
|
||||||
card_toc: 目錄
|
card_toc: 目錄
|
||||||
|
|
||||||
date_suffix:
|
date_suffix:
|
||||||
@@ -90,12 +89,15 @@ share: 分享
|
|||||||
|
|
||||||
rightside:
|
rightside:
|
||||||
readmode_title: 閱讀模式
|
readmode_title: 閱讀模式
|
||||||
|
font_plus_title: 放大字型
|
||||||
|
font_minus_title: 縮小字型
|
||||||
translate_title: 簡繁轉換
|
translate_title: 簡繁轉換
|
||||||
night_mode_title: 淺色和深色模式轉換
|
night_mode_title: 淺色和深色模式轉換
|
||||||
back_to_top: 回到頂部
|
back_to_top: 回到頂部
|
||||||
toc: 目錄
|
toc: 目錄
|
||||||
scroll_to_comment: 直達評論
|
scroll_to_comment: 直達評論
|
||||||
setting: 設定
|
setting: 設定
|
||||||
|
aside: 單欄和雙欄切換
|
||||||
|
|
||||||
copy_copyright:
|
copy_copyright:
|
||||||
author: 作者
|
author: 作者
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
div
|
div
|
||||||
script(src=url_for(theme.CDN.jquery))
|
|
||||||
script(src=url_for(theme.CDN.utils))
|
script(src=url_for(theme.CDN.utils))
|
||||||
script(src=url_for(theme.CDN.main))
|
script(src=url_for(theme.CDN.main))
|
||||||
|
|
||||||
@@ -8,11 +7,9 @@ div
|
|||||||
|
|
||||||
if theme.medium_zoom
|
if theme.medium_zoom
|
||||||
script(src=url_for(theme.CDN.medium_zoom))
|
script(src=url_for(theme.CDN.medium_zoom))
|
||||||
else if theme.fancybox
|
|
||||||
script(src=url_for(theme.CDN.fancybox))
|
|
||||||
|
|
||||||
if theme.instantpage
|
if theme.instantpage
|
||||||
script(src=url_for(theme.CDN.instantpage) type="module" defer)
|
script(src=url_for(theme.CDN.instantpage) type="module")
|
||||||
|
|
||||||
if theme.lazyload.enable
|
if theme.lazyload.enable
|
||||||
script(src=url_for(theme.CDN.lazyload))
|
script(src=url_for(theme.CDN.lazyload))
|
||||||
@@ -36,9 +33,6 @@ div
|
|||||||
if theme.subtitle.enable && is_home() && theme.index_img !== false
|
if theme.subtitle.enable && is_home() && theme.index_img !== false
|
||||||
include ./third-party/subtitle.pug
|
include ./third-party/subtitle.pug
|
||||||
|
|
||||||
if page.type === 'artitalk'
|
|
||||||
include ./third-party/artitalk.pug
|
|
||||||
|
|
||||||
include ./third-party/math/index.pug
|
include ./third-party/math/index.pug
|
||||||
|
|
||||||
if commentsJsLoad
|
if commentsJsLoad
|
||||||
|
|||||||
@@ -15,9 +15,3 @@
|
|||||||
a(href='https://github.com/jerryc127/hexo-theme-butterfly')= 'Butterfly'
|
a(href='https://github.com/jerryc127/hexo-theme-butterfly')= 'Butterfly'
|
||||||
if theme.footer.custom_text
|
if theme.footer.custom_text
|
||||||
.footer_custom_text!=`${theme.footer.custom_text}`
|
.footer_custom_text!=`${theme.footer.custom_text}`
|
||||||
if theme.footer.ICP.enable
|
|
||||||
.icp
|
|
||||||
a(href=theme.footer.ICP.url)
|
|
||||||
if theme.footer.ICP.icon
|
|
||||||
img.icp-icon(src=url_for(theme.footer.ICP.icon) alt='ICP')
|
|
||||||
span=theme.footer.ICP.text
|
|
||||||
|
|||||||
@@ -51,16 +51,13 @@ if (theme.pwa && theme.pwa.enable)
|
|||||||
|
|
||||||
//- main css
|
//- main css
|
||||||
link(rel='stylesheet', href=url_for(theme.CDN.main_css))
|
link(rel='stylesheet', href=url_for(theme.CDN.main_css))
|
||||||
link(rel='stylesheet', href=url_for(theme.CDN.fontawesome))
|
link(rel='stylesheet', href=url_for(theme.CDN.fontawesome) media="print" onload="this.media='all'")
|
||||||
|
|
||||||
if theme.fancybox
|
|
||||||
link(rel='stylesheet', href=url_for(theme.CDN.fancybox_css))
|
|
||||||
|
|
||||||
if (theme.snackbar && theme.snackbar.enable)
|
if (theme.snackbar && theme.snackbar.enable)
|
||||||
link(rel='stylesheet', href=url_for(theme.CDN.snackbar_css))
|
link(rel='stylesheet', href=url_for(theme.CDN.snackbar_css) media="print" onload="this.media='all'")
|
||||||
|
|
||||||
if theme.algolia_search.enable
|
if theme.algolia_search.enable
|
||||||
link(rel='stylesheet' href=url_for(theme.CDN.algolia_search_css))
|
link(rel='stylesheet' href=url_for(theme.CDN.algolia_search_css) media="print" onload="this.media='all'")
|
||||||
script(src=url_for(theme.CDN.algolia_search) defer)
|
script(src=url_for(theme.CDN.algolia_search) defer)
|
||||||
|
|
||||||
//- google_adsense
|
//- google_adsense
|
||||||
@@ -71,7 +68,7 @@ if theme.algolia_search.enable
|
|||||||
|
|
||||||
//- font
|
//- font
|
||||||
if theme.blog_title_font && theme.blog_title_font.font_link
|
if theme.blog_title_font && theme.blog_title_font.font_link
|
||||||
link(rel='stylesheet' href=url_for(theme.blog_title_font.font_link))
|
link(rel='stylesheet' href=url_for(theme.blog_title_font.font_link) media="print" onload="this.media='all'")
|
||||||
|
|
||||||
//- global config
|
//- global config
|
||||||
!=partial('includes/head/config', {}, {cache:theme.fragment_cache})
|
!=partial('includes/head/config', {}, {cache:theme.fragment_cache})
|
||||||
|
|||||||
@@ -50,14 +50,6 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
let ClickShowText = 'undefined';
|
|
||||||
if (theme.ClickShowText && theme.ClickShowText.enable) {
|
|
||||||
ClickShowText = JSON.stringify({
|
|
||||||
text: theme.ClickShowText.text.join(","),
|
|
||||||
fontSize: theme.ClickShowText.fontSize
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
let Snackbar = 'undefined';
|
let Snackbar = 'undefined';
|
||||||
if (theme.snackbar && theme.snackbar.enable) {
|
if (theme.snackbar && theme.snackbar.enable) {
|
||||||
Snackbar = JSON.stringify({
|
Snackbar = JSON.stringify({
|
||||||
@@ -116,12 +108,18 @@ script.
|
|||||||
month: '!{_p("date_suffix.month")}'
|
month: '!{_p("date_suffix.month")}'
|
||||||
},
|
},
|
||||||
copyright: !{copyright},
|
copyright: !{copyright},
|
||||||
ClickShowText: !{ClickShowText},
|
|
||||||
lightbox: '!{ theme.medium_zoom ? "mediumZoom" : (theme.fancybox ? "fancybox" : "null" )}',
|
lightbox: '!{ theme.medium_zoom ? "mediumZoom" : (theme.fancybox ? "fancybox" : "null" )}',
|
||||||
Snackbar: !{Snackbar},
|
Snackbar: !{Snackbar},
|
||||||
|
source: {
|
||||||
|
jQuery: '!{url_for(theme.CDN.jquery)}',
|
||||||
justifiedGallery: {
|
justifiedGallery: {
|
||||||
js: '!{theme.CDN.justifiedGallery_js}',
|
js: '!{url_for(theme.CDN.justifiedGallery_js)}',
|
||||||
css: '!{theme.CDN.justifiedGallery_css}'
|
css: '!{url_for(theme.CDN.justifiedGallery_css)}'
|
||||||
|
},
|
||||||
|
fancybox: {
|
||||||
|
js: '!{url_for(theme.CDN.fancybox)}',
|
||||||
|
css: '!{url_for(theme.CDN.fancybox_css)}'
|
||||||
|
}
|
||||||
},
|
},
|
||||||
isPhotoFigcaption: !{theme.photofigcaption},
|
isPhotoFigcaption: !{theme.photofigcaption},
|
||||||
islazyload: !{theme.lazyload.enable},
|
islazyload: !{theme.lazyload.enable},
|
||||||
@@ -156,5 +154,17 @@ script.
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://stackoverflow.com/questions/16839698/jquery-getscript-alternative-in-native-javascript
|
||||||
|
const getScript = url => new Promise((resolve, reject) => {
|
||||||
|
const script = document.createElement('script')
|
||||||
|
script.src = url
|
||||||
|
script.async = true
|
||||||
|
script.onerror = reject
|
||||||
|
script.onload = script.onreadystatechange = function() {
|
||||||
|
const loadState = this.readyState
|
||||||
|
if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
|
||||||
|
script.onload = script.onreadystatechange = null
|
||||||
|
resolve()
|
||||||
|
}
|
||||||
|
document.head.appendChild(script)
|
||||||
|
})
|
||||||
@@ -4,8 +4,8 @@
|
|||||||
else if (page.highlight_shrink === true || page.highlight_shrink === false) isHighlightShrink = page.highlight_shrink
|
else if (page.highlight_shrink === true || page.highlight_shrink === false) isHighlightShrink = page.highlight_shrink
|
||||||
else isHighlightShrink = theme.highlight_shrink
|
else isHighlightShrink = theme.highlight_shrink
|
||||||
|
|
||||||
const pageToc = page.toc === true || page.toc === false ? page.toc : theme.toc.enable
|
var pageToc = page.toc === true || page.toc === false ? page.toc : theme.toc.enable
|
||||||
const showToc = is_post() && theme.aside.enable && pageToc && (toc(page.content) !== '' || page.encrypt == true )
|
var showToc = is_post() && theme.aside.enable && pageToc && (toc(page.content) !== '' || page.encrypt == true )
|
||||||
-
|
-
|
||||||
|
|
||||||
script#config_change
|
script#config_change
|
||||||
|
|||||||
@@ -61,5 +61,11 @@ script
|
|||||||
| }
|
| }
|
||||||
| }
|
| }
|
||||||
|
|
||||||
|
if theme.change_font_size
|
||||||
|
| const fontSizeVal = saveToLocal.get('global-font-size')
|
||||||
|
| if (fontSizeVal !== undefined) {
|
||||||
|
| document.documentElement.style.setProperty('--global-font-size', fontSizeVal + 'px')
|
||||||
|
| }
|
||||||
|
|
||||||
| })()
|
| })()
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
link(rel="preconnect" href="//cdn.jsdelivr.net")
|
link(rel="preconnect" href="//cdn.jsdelivr.net")
|
||||||
|
|
||||||
if theme.google_analytics
|
if theme.google_analytics
|
||||||
link(rel="preconnect" href="//www.google-analytics.com" crossorigin)
|
link(rel="preconnect" href="//www.google-analytics.com" crossorigin='')
|
||||||
|
|
||||||
if theme.baidu_analytics
|
if theme.baidu_analytics
|
||||||
link(rel="preconnect" href="//hm.baidu.com")
|
link(rel="preconnect" href="//hm.baidu.com")
|
||||||
@@ -13,7 +13,7 @@ if theme.cnzz_analytics
|
|||||||
link(rel="preconnect" href="//s4.cnzz.com")
|
link(rel="preconnect" href="//s4.cnzz.com")
|
||||||
|
|
||||||
if theme.blog_title_font && theme.blog_title_font.font_link && theme.blog_title_font.font_link.indexOf('//fonts.googleapis.com') != -1
|
if theme.blog_title_font && theme.blog_title_font.font_link && theme.blog_title_font.font_link.indexOf('//fonts.googleapis.com') != -1
|
||||||
link(rel="preconnect" href="//fonts.googleapis.com" crossorigin)
|
link(rel="preconnect" href="//fonts.googleapis.com" crossorigin='')
|
||||||
|
|
||||||
if theme.busuanzi.site_uv || theme.busuanzi.site_pv || theme.busuanzi.page_pv
|
if theme.busuanzi.site_uv || theme.busuanzi.site_pv || theme.busuanzi.page_pv
|
||||||
link(rel="preconnect" href="//busuanzi.ibruce.info")
|
link(rel="preconnect" href="//busuanzi.ibruce.info")
|
||||||
|
|||||||
@@ -2,15 +2,15 @@ nav#nav
|
|||||||
span#blog_name
|
span#blog_name
|
||||||
a#site-name(href=url_for('/')) #[=config.title]
|
a#site-name(href=url_for('/')) #[=config.title]
|
||||||
|
|
||||||
span#menus
|
#menus
|
||||||
if (theme.algolia_search.enable || theme.local_search.enable)
|
if (theme.algolia_search.enable || theme.local_search.enable)
|
||||||
#search_button
|
#search-button
|
||||||
a.site-page.social-icon.search
|
a.site-page.social-icon.search
|
||||||
i.fas.fa-search.fa-fw
|
i.fas.fa-search.fa-fw
|
||||||
span=' '+_p('search')
|
span=' '+_p('search')
|
||||||
!=fragment_cache('menus', function(){return partial('includes/header/menu_item')})
|
!=fragment_cache('menus', function(){return partial('includes/header/menu_item')})
|
||||||
|
|
||||||
span#toggle-menu.close
|
#toggle-menu
|
||||||
a.site-page
|
a.site-page
|
||||||
i.fas.fa-bars.fa-fw
|
i.fas.fa-bars.fa-fw
|
||||||
|
|
||||||
|
|||||||
@@ -57,26 +57,32 @@
|
|||||||
|
|
||||||
if !theme.comments.lazyload && page.comments !== false && theme.comments.use && theme.comments.count
|
if !theme.comments.lazyload && page.comments !== false && theme.comments.use && theme.comments.count
|
||||||
- var whichCount = theme.comments.use[0]
|
- var whichCount = theme.comments.use[0]
|
||||||
if whichCount !== 'Livere' && whichCount !== 'Utterances'
|
|
||||||
|
mixin countBlock
|
||||||
span.post-meta-separator |
|
span.post-meta-separator |
|
||||||
span.post-meta-commentcount
|
span.post-meta-commentcount
|
||||||
if whichCount === 'Disqus' || whichCount === 'Disqusjs'
|
|
||||||
i.far.fa-comments.fa-fw.post-meta-icon
|
i.far.fa-comments.fa-fw.post-meta-icon
|
||||||
span.post-meta-label= _p('post.comments') + ':'
|
span.post-meta-label= _p('post.comments') + ':'
|
||||||
span.disqus-comment-count.comment-count
|
if block
|
||||||
|
block
|
||||||
|
|
||||||
|
if whichCount === 'Disqus' || whichCount === 'Disqusjs'
|
||||||
|
+countBlock
|
||||||
|
span.disqus-comment-count
|
||||||
a(href=full_url_for(page.path) + '#disqus_thread')
|
a(href=full_url_for(page.path) + '#disqus_thread')
|
||||||
else if whichCount === 'Valine'
|
else if whichCount === 'Valine'
|
||||||
i.far.fa-comments.fa-fw.post-meta-icon
|
+countBlock
|
||||||
span.post-meta-label= _p('post.comments') + ':'
|
|
||||||
a(href=url_for(page.path) + '#post-comment' itemprop="discussionUrl")
|
a(href=url_for(page.path) + '#post-comment' itemprop="discussionUrl")
|
||||||
span.valine-comment-count.comment-count(data-xid=url_for(page.path) itemprop="commentCount")
|
span.valine-comment-count(data-xid=url_for(page.path) itemprop="commentCount")
|
||||||
else if whichCount === 'Gitalk'
|
else if whichCount === 'Gitalk'
|
||||||
i.far.fa-comments.fa-fw.post-meta-icon
|
+countBlock
|
||||||
span.post-meta-label= _p('post.comments') + ':'
|
|
||||||
a(href=url_for(page.path) + '#post-comment')
|
a(href=url_for(page.path) + '#post-comment')
|
||||||
span.gitalk-comment-count.comment-count
|
span.gitalk-comment-count
|
||||||
|
else if whichCount === 'Twikoo'
|
||||||
|
+countBlock
|
||||||
|
a(href=url_for(page.path) + '#post-comment')
|
||||||
|
span#twikoo-count
|
||||||
else if whichCount === 'Facebook Comments'
|
else if whichCount === 'Facebook Comments'
|
||||||
i.far.fa-comments.fa-fw.post-meta-icon
|
+countBlock
|
||||||
span.post-meta-label= _p('post.comments') + ':'
|
a(href=url_for(page.path) + '#post-comment')
|
||||||
a.comment-count(href=url_for(page.path) + '#post-comment')
|
|
||||||
span.fb-comments-count(data-href=urlNoIndex())
|
span.fb-comments-count(data-href=urlNoIndex())
|
||||||
@@ -78,4 +78,4 @@ mixin postUI(posts)
|
|||||||
|
|
||||||
if theme.ad && theme.ad.index
|
if theme.ad && theme.ad.index
|
||||||
if (index + 1) % 3 == 0
|
if (index + 1) % 3 == 0
|
||||||
.recent-post-item.ad-height!=theme.ad.index
|
.recent-post-item.ads-wrap!=theme.ad.index
|
||||||
|
|||||||
@@ -1,4 +1,28 @@
|
|||||||
|
- let option = theme.artitalk.option ? JSON.stringify(theme.artitalk.option) : false
|
||||||
|
|
||||||
if top_img === false
|
if top_img === false
|
||||||
h1.page-title= page.title
|
h1.page-title= page.title
|
||||||
|
|
||||||
#artitalk_main
|
#artitalk_main
|
||||||
|
script.
|
||||||
|
(()=>{
|
||||||
|
let setting = {
|
||||||
|
appId: '!{theme.artitalk.appId}',
|
||||||
|
appKey: '!{theme.artitalk.appKey}',
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!{Boolean(option)}) {
|
||||||
|
const otherSetting = !{option}
|
||||||
|
setting = Object.assign({}, setting, otherSetting)
|
||||||
|
}
|
||||||
|
|
||||||
|
const init = () => {
|
||||||
|
new Artitalk(setting)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof Artitalk === 'function') {
|
||||||
|
init()
|
||||||
|
} else {
|
||||||
|
getScript('!{theme.CDN.artitalk}').then(init)
|
||||||
|
}
|
||||||
|
})()
|
||||||
@@ -18,9 +18,9 @@ else
|
|||||||
- var pagination_cover = page.prev.cover === false ? page.prev.randomcover : page.prev.cover
|
- var pagination_cover = page.prev.cover === false ? page.prev.randomcover : page.prev.cover
|
||||||
a(href=url_for(page.prev.path))
|
a(href=url_for(page.prev.path))
|
||||||
if theme.lazyload.enable
|
if theme.lazyload.enable
|
||||||
img.prev-cover(data-lazy-src=url_for(pagination_cover) onerror=`onerror=null;src='${url_for(theme.error_img.post_page)}'` )
|
img.prev-cover(data-lazy-src=url_for(pagination_cover) onerror=`onerror=null;src='${url_for(theme.error_img.post_page)}'` alt='cover of previous post')
|
||||||
else
|
else
|
||||||
img.prev-cover(src=url_for(pagination_cover) onerror=`onerror=null;src='${url_for(theme.error_img.post_page)}'` )
|
img.prev-cover(src=url_for(pagination_cover) onerror=`onerror=null;src='${url_for(theme.error_img.post_page)}'` alt='cover of previous post')
|
||||||
.pagination-info
|
.pagination-info
|
||||||
.label=_p('pagination.prev')
|
.label=_p('pagination.prev')
|
||||||
.prev_info=page.prev.title
|
.prev_info=page.prev.title
|
||||||
@@ -31,9 +31,9 @@ else
|
|||||||
.next-post(class=hasPagePrev)
|
.next-post(class=hasPagePrev)
|
||||||
a(href=url_for(page.next.path))
|
a(href=url_for(page.next.path))
|
||||||
if theme.lazyload.enable
|
if theme.lazyload.enable
|
||||||
img.next-cover(data-lazy-src=url_for(pagination_cover) onerror=`onerror=null;src='${url_for(theme.error_img.post_page)}'`)
|
img.next-cover(data-lazy-src=url_for(pagination_cover) onerror=`onerror=null;src='${url_for(theme.error_img.post_page)}'` alt='cover of next post')
|
||||||
else
|
else
|
||||||
img.next-cover(src=url_for(pagination_cover) onerror=`onerror=null;src='${url_for(theme.error_img.post_page)}'`)
|
img.next-cover(src=url_for(pagination_cover) onerror=`onerror=null;src='${url_for(theme.error_img.post_page)}'` alt='cover of next post')
|
||||||
.pagination-info
|
.pagination-info
|
||||||
.label=_p('pagination.next')
|
.label=_p('pagination.next')
|
||||||
.next_info=page.next.title
|
.next_info=page.next.title
|
||||||
@@ -3,25 +3,30 @@
|
|||||||
if is_post() && theme.readmode
|
if is_post() && theme.readmode
|
||||||
button#readmode(type="button" title=_p('rightside.readmode_title'))
|
button#readmode(type="button" title=_p('rightside.readmode_title'))
|
||||||
i.fas.fa-book-open
|
i.fas.fa-book-open
|
||||||
|
if theme.change_font_size
|
||||||
|
button#font-plus(type="button" title=_p('rightside.font_plus_title'))
|
||||||
|
i.fas.fa-plus
|
||||||
|
button#font-minus(type="button" title=_p('rightside.font_minus_title'))
|
||||||
|
i.fas.fa-minus
|
||||||
if theme.translate.enable
|
if theme.translate.enable
|
||||||
button#translateLink(type="button" title=_p('rightside.translate_title'))= theme.translate.default
|
button#translateLink(type="button" title=_p('rightside.translate_title'))= theme.translate.default
|
||||||
if theme.darkmode.enable && theme.darkmode.button
|
if theme.darkmode.enable && theme.darkmode.button
|
||||||
button#darkmode(type="button" title=_p('rightside.night_mode_title'))
|
button#darkmode(type="button" title=_p('rightside.night_mode_title'))
|
||||||
i.fas.fa-adjust
|
i.fas.fa-adjust
|
||||||
if theme.aside.enable && theme.aside.button && page.aside !== false
|
if theme.aside.enable && theme.aside.button && page.aside !== false
|
||||||
button#hide-aside-btn(type="button")
|
button#hide-aside-btn(type="button" title=_p('rightside.aside'))
|
||||||
i.fas.fa-arrows-alt-h
|
i.fas.fa-arrows-alt-h
|
||||||
#rightside-config-show
|
#rightside-config-show
|
||||||
if is_post()
|
if is_post()
|
||||||
if (theme.readmode || theme.translate.enable || (theme.darkmode.enable && theme.darkmode.button))
|
if (theme.readmode || theme.translate.enable || (theme.darkmode.enable && theme.darkmode.button) || theme.change_font_size)
|
||||||
button#rightside_config(type="button" title=_p("rightside.setting"))
|
button#rightside_config(type="button" title=_p("rightside.setting"))
|
||||||
i.fas.fa-cog
|
i.fas.fa-cog.fa-spin
|
||||||
if showToc && theme.aside.mobile
|
if showToc
|
||||||
button#mobile-toc-button.close(type="button" title=_p("rightside.toc"))
|
button#mobile-toc-button.close(type="button" title=_p("rightside.toc"))
|
||||||
i.fas.fa-list-ul
|
i.fas.fa-list-ul
|
||||||
else if theme.translate.enable || (theme.darkmode.enable && theme.darkmode.button)
|
else if theme.translate.enable || (theme.darkmode.enable && theme.darkmode.button) || theme.change_font_size
|
||||||
button#rightside_config(type="button" title=_p("rightside.setting"))
|
button#rightside_config(type="button" title=_p("rightside.setting"))
|
||||||
i.fas.fa-cog
|
i.fas.fa-cog.fa-spin
|
||||||
|
|
||||||
if theme.chat_btn
|
if theme.chat_btn
|
||||||
button#chat_btn(type="button" title=_p("rightside.chat_btn"))
|
button#chat_btn(type="button" title=_p("rightside.chat_btn"))
|
||||||
|
|||||||
2
layout/includes/third-party/aplayer.pug
vendored
2
layout/includes/third-party/aplayer.pug
vendored
@@ -1,3 +1,3 @@
|
|||||||
link(rel='stylesheet' href=url_for(theme.CDN.aplayer_css))
|
link(rel='stylesheet' href=url_for(theme.CDN.aplayer_css) media="print" onload="this.media='all'")
|
||||||
script(src=url_for(theme.CDN.aplayer_js))
|
script(src=url_for(theme.CDN.aplayer_js))
|
||||||
script(src=url_for(theme.CDN.meting_js))
|
script(src=url_for(theme.CDN.meting_js))
|
||||||
24
layout/includes/third-party/artitalk.pug
vendored
24
layout/includes/third-party/artitalk.pug
vendored
@@ -1,24 +0,0 @@
|
|||||||
- let option = theme.artitalk.option ? JSON.stringify(theme.artitalk.option) : false
|
|
||||||
|
|
||||||
script.
|
|
||||||
(()=>{
|
|
||||||
let setting = {
|
|
||||||
appId: '!{theme.artitalk.appId}',
|
|
||||||
appKey: '!{theme.artitalk.appKey}',
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!{Boolean(option)}) {
|
|
||||||
const otherSetting = !{option}
|
|
||||||
setting = Object.assign({}, setting, otherSetting)
|
|
||||||
}
|
|
||||||
|
|
||||||
const init = () => {
|
|
||||||
new Artitalk(setting)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof Artitalk === 'function') {
|
|
||||||
init()
|
|
||||||
} else {
|
|
||||||
$.getScript('!{theme.CDN.artitalk}',init)
|
|
||||||
}
|
|
||||||
})()
|
|
||||||
2
layout/includes/third-party/baidu_push.pug
vendored
2
layout/includes/third-party/baidu_push.pug
vendored
@@ -3,7 +3,7 @@ if theme.baidu_push
|
|||||||
(function(){
|
(function(){
|
||||||
const bp = document.createElement('script');
|
const bp = document.createElement('script');
|
||||||
const curProtocol = window.location.protocol.split(':')[0];
|
const curProtocol = window.location.protocol.split(':')[0];
|
||||||
if (curProtocol === 'https'){
|
if (curProtocol === 'https') {
|
||||||
bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
|
bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ script.
|
|||||||
if (window.disqusJsLoad) initDisqusjs()
|
if (window.disqusJsLoad) initDisqusjs()
|
||||||
else {
|
else {
|
||||||
addDisqusjsCSS()
|
addDisqusjsCSS()
|
||||||
$.getScript('!{url_for(theme.CDN.disqusjs)}', initDisqusjs)
|
getScript('!{url_for(theme.CDN.disqusjs)}').then(initDisqusjs)
|
||||||
window.disqusJsLoad = true
|
window.disqusJsLoad = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ script.
|
|||||||
if (typeof Gitalk === 'function') initGitalk()
|
if (typeof Gitalk === 'function') initGitalk()
|
||||||
else {
|
else {
|
||||||
addGitalkSource()
|
addGitalkSource()
|
||||||
$.getScript('!{url_for(theme.CDN.gitalk)}', initGitalk)
|
getScript('!{url_for(theme.CDN.gitalk)}').then(initGitalk)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ hr
|
|||||||
when 'Utterances'
|
when 'Utterances'
|
||||||
#utterances-wrap
|
#utterances-wrap
|
||||||
when 'Twikoo'
|
when 'Twikoo'
|
||||||
#twikoo
|
#twikoo-wrap
|
||||||
when 'Facebook Comments'
|
when 'Facebook Comments'
|
||||||
.fb-comments(data-colorscheme = theme.display_mode === 'dark' ? 'dark' : 'light'
|
.fb-comments(data-colorscheme = theme.display_mode === 'dark' ? 'dark' : 'light'
|
||||||
data-numposts= theme.facebook_comments.pageSize || 10
|
data-numposts= theme.facebook_comments.pageSize || 10
|
||||||
|
|||||||
37
layout/includes/third-party/comments/twikoo.pug
vendored
37
layout/includes/third-party/comments/twikoo.pug
vendored
@@ -1,24 +1,43 @@
|
|||||||
script.
|
script.
|
||||||
function loadTwikoo () {
|
(()=>{
|
||||||
function init () {
|
const $countDom = document.getElementById('twikoo-count')
|
||||||
|
const init = () => {
|
||||||
twikoo.init({
|
twikoo.init({
|
||||||
envId: '!{theme.twikoo}'
|
envId: '!{theme.twikoo}',
|
||||||
|
el: '#twikoo-wrap'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof twikoo.init === 'function') {
|
const getCount = () => {
|
||||||
|
twikoo.getCommentsCount({
|
||||||
|
envId: '!{theme.twikoo}',
|
||||||
|
urls: [window.location.pathname],
|
||||||
|
includeReply: false
|
||||||
|
}).then(function (res) {
|
||||||
|
$countDom.innerText = res[0].count
|
||||||
|
}).catch(function (err) {
|
||||||
|
console.error(err);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const loadTwikoo = (bool = false) => {
|
||||||
|
if (typeof twikoo === 'object') {
|
||||||
init()
|
init()
|
||||||
|
bool && $countDom && setTimeout(getCount,0)
|
||||||
} else {
|
} else {
|
||||||
$.getScript('!{theme.CDN.twikoo}', init)
|
getScript('!{theme.CDN.twikoo}').then(()=> {
|
||||||
|
init()
|
||||||
|
bool && $countDom && setTimeout(getCount,0)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('!{theme.comments.use[0]}' === 'Twikoo' || !!{theme.comments.lazyload}) {
|
if ('!{theme.comments.use[0]}' === 'Twikoo' || !!{theme.comments.lazyload}) {
|
||||||
if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('twikoo'), loadTwikoo)
|
if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('twikoo-wrap'), loadTwikoo)
|
||||||
else loadTwikoo()
|
else loadTwikoo(true)
|
||||||
} else {
|
} else {
|
||||||
function loadOtherComment () {
|
window.loadOtherComment = () => {
|
||||||
loadTwikoo()
|
loadTwikoo()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
})()
|
||||||
@@ -36,12 +36,12 @@ script.
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (typeof Valine === 'function') initValine()
|
if (typeof Valine === 'function') initValine()
|
||||||
else $.getScript('!{url_for(theme.CDN.valine)}', initValine)
|
else getScript('!{url_for(theme.CDN.valine)}').then(initValine)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('!{theme.comments.use[0]}' === 'Valine' || !!{theme.comments.lazyload}) {
|
if ('!{theme.comments.use[0]}' === 'Valine' || !!{theme.comments.lazyload}) {
|
||||||
if (!{theme.comments.lazyload}) btf.loadComment(document.querySelector('#vcomment'),loadValine)
|
if (!{theme.comments.lazyload}) btf.loadComment(document.querySelector('#vcomment'),loadValine)
|
||||||
else setTimeout(() => loadValine(), 0)
|
else setTimeout(loadValine, 0)
|
||||||
} else {
|
} else {
|
||||||
function loadOtherComment () {
|
function loadOtherComment () {
|
||||||
loadValine()
|
loadValine()
|
||||||
|
|||||||
9
layout/includes/third-party/effect.pug
vendored
9
layout/includes/third-party/effect.pug
vendored
@@ -25,4 +25,11 @@ 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.CDN.click_heart) async mobile=`${theme.click_heart.mobile}`)
|
||||||
|
|
||||||
if theme.ClickShowText && theme.ClickShowText.enable
|
if theme.ClickShowText && theme.ClickShowText.enable
|
||||||
script#click-show-text(src=url_for(theme.CDN.ClickShowText) async mobile=`${theme.ClickShowText.mobile}`)
|
script#click-show-text(
|
||||||
|
src= url_for(theme.CDN.ClickShowText)
|
||||||
|
data-mobile= `${theme.ClickShowText.mobile}`
|
||||||
|
data-text= theme.ClickShowText.text.join(",")
|
||||||
|
data-fontsize= theme.ClickShowText.fontSize
|
||||||
|
data-random= `${theme.ClickShowText.random}`
|
||||||
|
async
|
||||||
|
)
|
||||||
7
layout/includes/third-party/math/katex.pug
vendored
7
layout/includes/third-party/math/katex.pug
vendored
@@ -2,6 +2,9 @@ link(rel="stylesheet" type="text/css" href=theme.CDN.katex)
|
|||||||
script(src=url_for(theme.CDN.katex_copytex))
|
script(src=url_for(theme.CDN.katex_copytex))
|
||||||
link(rel="stylesheet" type="text/css" href=theme.CDN.katex_copytex_css)
|
link(rel="stylesheet" type="text/css" href=theme.CDN.katex_copytex_css)
|
||||||
script.
|
script.
|
||||||
$(function () {
|
(() => {
|
||||||
$('span.katex-display').wrap('<div class="katex-wrap"></div>')
|
document.querySelectorAll('#article-container span.katex-display').forEach(item => {
|
||||||
|
btf.wrap(item, 'div', '', 'katex-wrap')
|
||||||
})
|
})
|
||||||
|
})()
|
||||||
|
|
||||||
2
layout/includes/third-party/math/mermaid.pug
vendored
2
layout/includes/third-party/math/mermaid.pug
vendored
@@ -2,7 +2,7 @@ script.
|
|||||||
if (document.getElementsByClassName('mermaid').length) {
|
if (document.getElementsByClassName('mermaid').length) {
|
||||||
if (window.mermaidJsLoad) mermaid.init()
|
if (window.mermaidJsLoad) mermaid.init()
|
||||||
else {
|
else {
|
||||||
$.getScript('!{theme.CDN.mermaid}', function () {
|
getScript('!{theme.CDN.mermaid}').then(() => {
|
||||||
window.mermaidJsLoad = true
|
window.mermaidJsLoad = true
|
||||||
mermaid.initialize({
|
mermaid.initialize({
|
||||||
theme: '!{theme.mermaid.theme}',
|
theme: '!{theme.mermaid.theme}',
|
||||||
|
|||||||
@@ -13,22 +13,23 @@ script.
|
|||||||
return content
|
return content
|
||||||
}
|
}
|
||||||
|
|
||||||
const getDisqusComment = () => {
|
const getComment = () => {
|
||||||
let disqusArray = []
|
fetch('https://disqus.com/api/3.0/forums/listPosts.json?forum=!{theme.newest_comments.disqus.forum}&related=thread&limit=!{theme.newest_comments.limit}&api_key=!{theme.newest_comments.disqus.api_key}')
|
||||||
$.getJSON('https://disqus.com/api/3.0/forums/listPosts.json?forum=!{theme.newest_comments.disqus.forum}&related=thread&limit=!{theme.newest_comments.limit}&api_key=!{theme.newest_comments.disqus.api_key}', function(data){
|
.then(response => response.json())
|
||||||
$.each(data.response, (i, item) => {
|
.then(data => {
|
||||||
disqusArray.push({
|
const disqusArray = data.response.map(item => {
|
||||||
|
return {
|
||||||
'avatar': item.author.avatar.cache,
|
'avatar': item.author.avatar.cache,
|
||||||
'content': changeContent(item.message),
|
'content': changeContent(item.message),
|
||||||
'nick': item.author.name,
|
'nick': item.author.name,
|
||||||
'url': item.url,
|
'url': item.url,
|
||||||
'date': item.createdAt
|
'date': item.createdAt
|
||||||
})
|
}
|
||||||
})
|
})
|
||||||
// set expiry to 10 min
|
// set expiry to 10 min
|
||||||
saveToLocal.set('disqus-newest-comments', JSON.stringify(disqusArray), 10/(60*24))
|
saveToLocal.set('disqus-newest-comments', JSON.stringify(disqusArray), 10/(60*24))
|
||||||
generateHtml(disqusArray)
|
generateHtml(disqusArray)
|
||||||
}).fail(()=>{
|
}).catch(e => {
|
||||||
const $dom = document.querySelector('#card-newest-comments .aside-list')
|
const $dom = document.querySelector('#card-newest-comments .aside-list')
|
||||||
$dom.innerHTML= "!{_p('aside.card_newest_comments.error')}"
|
$dom.innerHTML= "!{_p('aside.card_newest_comments.error')}"
|
||||||
})
|
})
|
||||||
@@ -37,11 +38,16 @@ script.
|
|||||||
const generateHtml = array => {
|
const generateHtml = array => {
|
||||||
let result = ''
|
let result = ''
|
||||||
|
|
||||||
|
if (array.length) {
|
||||||
for (let i = 0; i < array.length; i++) {
|
for (let i = 0; i < array.length; i++) {
|
||||||
result += '<div class=\'aside-list-item\'>'
|
result += '<div class=\'aside-list-item\'>'
|
||||||
|
|
||||||
if (!{theme.newest_comments.avatar}) {
|
if (!{theme.newest_comments.avatar}) {
|
||||||
result += `<a href='${array[i].url}' class='thumbnail'><img src='${array[i].avatar}' alt='${array[i].nick}'></a>`
|
let name = 'src'
|
||||||
|
if(!{theme.lazyload.enable}) {
|
||||||
|
name = 'data-lazy-src'
|
||||||
|
}
|
||||||
|
result += `<a href='${array[i].url}' class='thumbnail'><img ${name}='${array[i].avatar}' alt='${array[i].nick}'></a>`
|
||||||
}
|
}
|
||||||
|
|
||||||
result += `<div class='content'>
|
result += `<div class='content'>
|
||||||
@@ -49,9 +55,13 @@ script.
|
|||||||
<div class='name'><span>${array[i].nick}</span><time> / ${btf.diffDate(array[i].date, true)}</time></div>
|
<div class='name'><span>${array[i].nick}</span><time> / ${btf.diffDate(array[i].date, true)}</time></div>
|
||||||
</div></div>`
|
</div></div>`
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
result += '!{_p("aside.card_newest_comments.zero")}'
|
||||||
|
}
|
||||||
|
|
||||||
let $dom = document.querySelector('#card-newest-comments .aside-list')
|
let $dom = document.querySelector('#card-newest-comments .aside-list')
|
||||||
$dom.innerHTML= result
|
$dom.innerHTML= result
|
||||||
|
window.lazyLoadInstance && window.lazyLoadInstance.update()
|
||||||
window.pjax && window.pjax.refresh($dom)
|
window.pjax && window.pjax.refresh($dom)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,7 +71,7 @@ script.
|
|||||||
if (data) {
|
if (data) {
|
||||||
generateHtml(JSON.parse(data))
|
generateHtml(JSON.parse(data))
|
||||||
} else {
|
} else {
|
||||||
getDisqusComment()
|
getComment()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,21 +13,22 @@ script.
|
|||||||
return content
|
return content
|
||||||
}
|
}
|
||||||
|
|
||||||
const getGithubIssues = () => {
|
const getComment = () => {
|
||||||
let githubArray = []
|
fetch('https://api.github.com/repos/!{theme.newest_comments.github_issues.repo}/issues/comments?sort=updated&direction=desc&per_page=!{theme.newest_comments.limit}&page=1')
|
||||||
$.getJSON('https://api.github.com/repos/!{theme.newest_comments.github_issues.repo}/issues/comments?sort=updated&direction=desc&per_page=!{theme.newest_comments.limit}&page=1', (data) => {
|
.then(response => response.json())
|
||||||
$.each(data, (index, item) => {
|
.then(data => {
|
||||||
githubArray.push({
|
const githubArray = data.map(item => {
|
||||||
|
return {
|
||||||
'avatar': item.user.avatar_url,
|
'avatar': item.user.avatar_url,
|
||||||
'content': changeContent(item.body),
|
'content': changeContent(item.body),
|
||||||
'nick': item.user.login,
|
'nick': item.user.login,
|
||||||
'url': item.html_url,
|
'url': item.html_url,
|
||||||
'date': item.updated_at
|
'date': item.updated_at
|
||||||
})
|
}
|
||||||
})
|
})
|
||||||
saveToLocal.set('github-newest-comments', JSON.stringify(githubArray), 10/(60*24))
|
saveToLocal.set('github-newest-comments', JSON.stringify(githubArray), 10/(60*24))
|
||||||
generateHtml(githubArray)
|
generateHtml(githubArray)
|
||||||
}).fail(()=>{
|
}).catch(e => {
|
||||||
const $dom = document.querySelector('#card-newest-comments .aside-list')
|
const $dom = document.querySelector('#card-newest-comments .aside-list')
|
||||||
$dom.innerHTML= "!{_p('aside.card_newest_comments.error')}"
|
$dom.innerHTML= "!{_p('aside.card_newest_comments.error')}"
|
||||||
})
|
})
|
||||||
@@ -36,11 +37,16 @@ script.
|
|||||||
const generateHtml = array => {
|
const generateHtml = array => {
|
||||||
let result = ''
|
let result = ''
|
||||||
|
|
||||||
|
if (array.length) {
|
||||||
for (let i = 0; i < array.length; i++) {
|
for (let i = 0; i < array.length; i++) {
|
||||||
result += '<div class=\'aside-list-item\'>'
|
result += '<div class=\'aside-list-item\'>'
|
||||||
|
|
||||||
if (!{theme.newest_comments.avatar}) {
|
if (!{theme.newest_comments.avatar}) {
|
||||||
result += `<a href='${array[i].url}' class="thumbnail"><img src='${array[i].avatar}' alt='${array[i].nick}'></a>`
|
let name = 'src'
|
||||||
|
if(!{theme.lazyload.enable}) {
|
||||||
|
name = 'data-lazy-src'
|
||||||
|
}
|
||||||
|
result += `<a href='${array[i].url}' class="thumbnail"><img ${name}='${array[i].avatar}' alt='${array[i].nick}'></a>`
|
||||||
}
|
}
|
||||||
|
|
||||||
result += `<div class='content'>
|
result += `<div class='content'>
|
||||||
@@ -48,9 +54,13 @@ script.
|
|||||||
<div class='name'><span>${array[i].nick}</span><time> / ${btf.diffDate(array[i].date, true)}</time></div>
|
<div class='name'><span>${array[i].nick}</span><time> / ${btf.diffDate(array[i].date, true)}</time></div>
|
||||||
</div></div>`
|
</div></div>`
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
result += '!{_p("aside.card_newest_comments.zero")}'
|
||||||
|
}
|
||||||
|
|
||||||
let $dom = document.querySelector('#card-newest-comments .aside-list')
|
let $dom = document.querySelector('#card-newest-comments .aside-list')
|
||||||
$dom.innerHTML= result
|
$dom.innerHTML= result
|
||||||
|
window.lazyLoadInstance && window.lazyLoadInstance.update()
|
||||||
window.pjax && window.pjax.refresh($dom)
|
window.pjax && window.pjax.refresh($dom)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,7 +70,7 @@ script.
|
|||||||
if (data) {
|
if (data) {
|
||||||
generateHtml(JSON.parse(data))
|
generateHtml(JSON.parse(data))
|
||||||
} else {
|
} else {
|
||||||
getGithubIssues()
|
getComment()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,3 +4,5 @@ else if theme.newest_comments.github_issues.enable
|
|||||||
include ./github-issues.pug
|
include ./github-issues.pug
|
||||||
else if theme.newest_comments.disqus.enable
|
else if theme.newest_comments.disqus.enable
|
||||||
include ./disqus-comment.pug
|
include ./disqus-comment.pug
|
||||||
|
else if theme.newest_comments.twikoo
|
||||||
|
include ./twikoo-comment.pug
|
||||||
@@ -16,6 +16,7 @@ script.
|
|||||||
|
|
||||||
const getIcon = (icon, mail) => {
|
const getIcon = (icon, mail) => {
|
||||||
if (icon) return icon
|
if (icon) return icon
|
||||||
|
|
||||||
let defaultIcon = '!{ theme.newest_comments.leancloud.default_avatar ? `?d=${theme.newest_comments.leancloud.default_avatar}` : ''}'
|
let defaultIcon = '!{ theme.newest_comments.leancloud.default_avatar ? `?d=${theme.newest_comments.leancloud.default_avatar}` : ''}'
|
||||||
let iconUrl = `https://gravatar.loli.net/avatar/${md5(mail.toLowerCase()) + defaultIcon}`
|
let iconUrl = `https://gravatar.loli.net/avatar/${md5(mail.toLowerCase()) + defaultIcon}`
|
||||||
return iconUrl
|
return iconUrl
|
||||||
@@ -24,11 +25,16 @@ script.
|
|||||||
const generateHtml = array => {
|
const generateHtml = array => {
|
||||||
let result = ''
|
let result = ''
|
||||||
|
|
||||||
|
if (array.length) {
|
||||||
for (let i = 0; i < array.length; i++) {
|
for (let i = 0; i < array.length; i++) {
|
||||||
result += '<div class=\'aside-list-item\'>'
|
result += '<div class=\'aside-list-item\'>'
|
||||||
|
|
||||||
if (!{theme.newest_comments.avatar}) {
|
if (!{theme.newest_comments.avatar}) {
|
||||||
result += `<a href='${array[i].url}' class="thumbnail"><img src='${getIcon(array[i].avatar, array[i].mail)}' alt='${array[i].nick}'></a>`
|
let name = 'src'
|
||||||
|
if(!{theme.lazyload.enable}) {
|
||||||
|
name = 'data-lazy-src'
|
||||||
|
}
|
||||||
|
result += `<a href='${array[i].url}' class="thumbnail"><img ${name}='${getIcon(array[i].avatar, array[i].mail)}' alt='${array[i].nick}'></a>`
|
||||||
}
|
}
|
||||||
|
|
||||||
result += `<div class='content'>
|
result += `<div class='content'>
|
||||||
@@ -36,13 +42,17 @@ script.
|
|||||||
<div class='name'><span>${array[i].nick}</span><time> / ${btf.diffDate(array[i].date, true)}</time></div>
|
<div class='name'><span>${array[i].nick}</span><time> / ${btf.diffDate(array[i].date, true)}</time></div>
|
||||||
</div></div>`
|
</div></div>`
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
result += '!{_p("aside.card_newest_comments.zero")}'
|
||||||
|
}
|
||||||
|
|
||||||
let $dom = document.querySelector('#card-newest-comments .aside-list')
|
let $dom = document.querySelector('#card-newest-comments .aside-list')
|
||||||
$dom.innerHTML= result
|
$dom.innerHTML= result
|
||||||
|
window.lazyLoadInstance && window.lazyLoadInstance.update()
|
||||||
window.pjax && window.pjax.refresh($dom)
|
window.pjax && window.pjax.refresh($dom)
|
||||||
}
|
}
|
||||||
|
|
||||||
const getValineData = () => {
|
const getComment = () => {
|
||||||
let serverURL = ''
|
let serverURL = ''
|
||||||
if (!{Boolean(theme.newest_comments.leancloud.serverURL)}) {
|
if (!{Boolean(theme.newest_comments.leancloud.serverURL)}) {
|
||||||
serverURL = '!{theme.newest_comments.leancloud.serverURL}'
|
serverURL = '!{theme.newest_comments.leancloud.serverURL}'
|
||||||
@@ -51,9 +61,7 @@ script.
|
|||||||
}
|
}
|
||||||
|
|
||||||
var settings = {
|
var settings = {
|
||||||
"url": `${serverURL}/1.1/classes/Comment?limit=!{theme.newest_comments.limit}&order=-createdAt`,
|
|
||||||
"method": "GET",
|
"method": "GET",
|
||||||
"timeout": 0,
|
|
||||||
"headers": {
|
"headers": {
|
||||||
"X-LC-Id": '!{theme.newest_comments.leancloud.appId}',
|
"X-LC-Id": '!{theme.newest_comments.leancloud.appId}',
|
||||||
"X-LC-Key": '!{theme.newest_comments.leancloud.appKey}',
|
"X-LC-Key": '!{theme.newest_comments.leancloud.appKey}',
|
||||||
@@ -61,23 +69,22 @@ script.
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
$.ajax(settings).done((response) => {
|
fetch(`${serverURL}/1.1/classes/Comment?limit=!{theme.newest_comments.limit}&order=-createdAt`,settings)
|
||||||
var valineArray = []
|
.then(response => response.json())
|
||||||
response.results.forEach((e)=>{
|
.then(data => {
|
||||||
valineArray.push({
|
const valineArray = data.results.map(function (e) {
|
||||||
|
return {
|
||||||
'avatar': e.QQAvatar,
|
'avatar': e.QQAvatar,
|
||||||
'content': changeContent(e.comment),
|
'content': changeContent(e.comment),
|
||||||
'mail': e.mail,
|
'mail': e.mail,
|
||||||
'nick': e.nick,
|
'nick': e.nick,
|
||||||
'url': e.url,
|
'url': e.url,
|
||||||
'date': e.createdAt,
|
'date': e.createdAt,
|
||||||
|
}
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
|
||||||
saveToLocal.set('leancloud-newest-comments', JSON.stringify(valineArray), 10/(60*24))
|
saveToLocal.set('leancloud-newest-comments', JSON.stringify(valineArray), 10/(60*24))
|
||||||
generateHtml(valineArray)
|
generateHtml(valineArray)
|
||||||
|
}).catch(e => {
|
||||||
}).fail(()=>{
|
|
||||||
const $dom = document.querySelector('#card-newest-comments .aside-list')
|
const $dom = document.querySelector('#card-newest-comments .aside-list')
|
||||||
$dom.innerHTML= "!{_p('aside.card_newest_comments.error')}"
|
$dom.innerHTML= "!{_p('aside.card_newest_comments.error')}"
|
||||||
})
|
})
|
||||||
@@ -89,7 +96,7 @@ script.
|
|||||||
if (data) {
|
if (data) {
|
||||||
generateHtml(JSON.parse(data))
|
generateHtml(JSON.parse(data))
|
||||||
} else {
|
} else {
|
||||||
getValineData()
|
getComment()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
84
layout/includes/third-party/newest-comments/twikoo-comment.pug
vendored
Normal file
84
layout/includes/third-party/newest-comments/twikoo-comment.pug
vendored
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
script.
|
||||||
|
window.addEventListener('load', () => {
|
||||||
|
const changeContent = (content) => {
|
||||||
|
if (content === '') return content
|
||||||
|
|
||||||
|
content = content.replace(/<[^>]+>/g,"") // remove html tag
|
||||||
|
content = content.replace(/(http(s?):)([/|.|\w|\s|-])*\.(?:jpg|jpeg|gif|png|webp)/g, '') // remove image link
|
||||||
|
content = content.replace(/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gi, '') // remove url
|
||||||
|
|
||||||
|
if (content.length > 150) {
|
||||||
|
content = content.substring(0,150) + '...'
|
||||||
|
}
|
||||||
|
return content
|
||||||
|
}
|
||||||
|
|
||||||
|
const getComment = () => {
|
||||||
|
const runTwikoo = () => {
|
||||||
|
twikoo.getRecentComments({
|
||||||
|
envId: '!{theme.twikoo}',
|
||||||
|
pageSize: !{theme.newest_comments.limit},
|
||||||
|
includeReply: true
|
||||||
|
}).then(function (res) {
|
||||||
|
saveToLocal.set('twikoo-newest-comments', JSON.stringify(res), 10/(60*24))
|
||||||
|
generateHtml(res)
|
||||||
|
}).catch(function (err) {
|
||||||
|
const $dom = document.querySelector('#card-newest-comments .aside-list')
|
||||||
|
$dom.innerHTML= "!{_p('aside.card_newest_comments.error')}"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof twikoo === 'object') {
|
||||||
|
runTwikoo()
|
||||||
|
} else {
|
||||||
|
getScript('!{theme.CDN.twikoo}').then(runTwikoo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const generateHtml = array => {
|
||||||
|
let result = ''
|
||||||
|
|
||||||
|
if (array.length) {
|
||||||
|
for (let i = 0; i < array.length; i++) {
|
||||||
|
result += '<div class=\'aside-list-item\'>'
|
||||||
|
|
||||||
|
if (!{theme.newest_comments.avatar}) {
|
||||||
|
let name = 'src'
|
||||||
|
if(!{theme.lazyload.enable}) {
|
||||||
|
name = 'data-lazy-src'
|
||||||
|
}
|
||||||
|
result += `<a href='${array[i].url + '#' + array[i].id}' class='thumbnail'><img ${name}='${array[i].avatar}' alt='${array[i].nick}'></a>`
|
||||||
|
}
|
||||||
|
|
||||||
|
result += `<div class='content'>
|
||||||
|
<a class='comment' href='${array[i].url + '#' + array[i].id}'>${changeContent(array[i].commentText)}</a>
|
||||||
|
<div class='name'><span>${array[i].nick}</span><time> / ${btf.diffDate(array[i].created, true)}</time></div>
|
||||||
|
</div></div>`
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
result += '!{_p("aside.card_newest_comments.zero")}'
|
||||||
|
}
|
||||||
|
|
||||||
|
let $dom = document.querySelector('#card-newest-comments .aside-list')
|
||||||
|
$dom.innerHTML= result
|
||||||
|
window.lazyLoadInstance && window.lazyLoadInstance.update()
|
||||||
|
window.pjax && window.pjax.refresh($dom)
|
||||||
|
}
|
||||||
|
|
||||||
|
const newestCommentInit = () => {
|
||||||
|
if (document.querySelector('#card-newest-comments .aside-list')) {
|
||||||
|
const data = saveToLocal.get('twikoo-newest-comments')
|
||||||
|
if (data) {
|
||||||
|
generateHtml(JSON.parse(data))
|
||||||
|
} else {
|
||||||
|
getComment()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
newestCommentInit()
|
||||||
|
document.addEventListener('pjax:complete', newestCommentInit)
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
5
layout/includes/third-party/pangu.pug
vendored
5
layout/includes/third-party/pangu.pug
vendored
@@ -2,7 +2,8 @@ script.
|
|||||||
function panguFn () {
|
function panguFn () {
|
||||||
if (typeof pangu === 'object') pangu.spacingElementById('content-inner')
|
if (typeof pangu === 'object') pangu.spacingElementById('content-inner')
|
||||||
else {
|
else {
|
||||||
$.getScript('!{url_for(theme.CDN.pangu)}', () => {
|
getScript('!{url_for(theme.CDN.pangu)}')
|
||||||
|
.then(() => {
|
||||||
pangu.spacingElementById('content-inner')
|
pangu.spacingElementById('content-inner')
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -16,4 +17,4 @@ script.
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', panguFn)
|
document.addEventListener('DOMContentLoaded', panguInit)
|
||||||
|
|||||||
14
layout/includes/third-party/pjax.pug
vendored
14
layout/includes/third-party/pjax.pug
vendored
@@ -29,8 +29,12 @@ script.
|
|||||||
document.addEventListener('pjax:complete', function () {
|
document.addEventListener('pjax:complete', function () {
|
||||||
window.refreshFn()
|
window.refreshFn()
|
||||||
|
|
||||||
$('script[data-pjax]').each(function () {
|
document.querySelectorAll('script[data-pjax]').forEach(item => {
|
||||||
$(this).parent().append($(this).remove())
|
const newScript = document.createElement('script')
|
||||||
|
const content = item.text || item.textContent || item.innerHTML || ""
|
||||||
|
Array.from(item.attributes).forEach(attr => newScript.setAttribute(attr.name, attr.value))
|
||||||
|
newScript.appendChild(document.createTextNode(content))
|
||||||
|
item.parentNode.replaceChild(newScript, item)
|
||||||
})
|
})
|
||||||
|
|
||||||
GLOBAL_CONFIG.islazyload && window.lazyLoadInstance.update()
|
GLOBAL_CONFIG.islazyload && window.lazyLoadInstance.update()
|
||||||
@@ -69,10 +73,8 @@ script.
|
|||||||
|
|
||||||
typeof typed === 'object' && typed.destroy()
|
typeof typed === 'object' && typed.destroy()
|
||||||
|
|
||||||
$(window).off('scroll')
|
|
||||||
|
|
||||||
//reset readmode
|
//reset readmode
|
||||||
$('body').hasClass('read-mode') && $('body').removeClass('read-mode')
|
const $bodyClassList = document.body.classList
|
||||||
|
$bodyClassList.contains('read-mode') && $bodyClassList.remove('read-mode')
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -7,18 +7,6 @@
|
|||||||
input(placeholder=_p("local_search.input_placeholder") type="text").local-search-box--input
|
input(placeholder=_p("local_search.input_placeholder") type="text").local-search-box--input
|
||||||
hr
|
hr
|
||||||
#local-search-results
|
#local-search-results
|
||||||
#local-hits
|
|
||||||
#local-stats
|
|
||||||
#hr.local-search-stats__hr
|
|
||||||
case config.language
|
|
||||||
when "zh-CN"
|
|
||||||
span=_p("local_search.by")
|
|
||||||
| #[a(href="https://github.com/wzpan/hexo-generator-search" style={'color': '#49B1F5'}) hexo-generator-search]
|
|
||||||
| #[span=_p("local_search.powered")]
|
|
||||||
when "en"
|
|
||||||
default
|
|
||||||
span=_p("local_search.powered_by")
|
|
||||||
| #[a(href="https://github.com/wzpan/hexo-generator-search" style={'color': '#49B1F5'}) hexo-generator-search]
|
|
||||||
span.search-close-button
|
span.search-close-button
|
||||||
i.fas.fa-times
|
i.fas.fa-times
|
||||||
#search-mask
|
#search-mask
|
||||||
@@ -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))
|
link(rel='stylesheet' href=url_for(theme.CDN.sharejs_css) media="print" onload="this.media='all'")
|
||||||
script(src=url_for(theme.CDN.sharejs) defer)
|
script(src=url_for(theme.CDN.sharejs) defer)
|
||||||
50
layout/includes/third-party/subtitle.pug
vendored
50
layout/includes/third-party/subtitle.pug
vendored
@@ -1,9 +1,12 @@
|
|||||||
- var source = theme.subtitle.source
|
- let source = theme.subtitle.source
|
||||||
|
|
||||||
case source
|
case source
|
||||||
when 1
|
when 1
|
||||||
script.
|
script.
|
||||||
function subtitleType () {
|
function subtitleType () {
|
||||||
$.getJSON('https://api.btstu.cn/yan/api.php?charset=utf-8&encode=json',function (data) {
|
fetch('https://api.btstu.cn/yan/api.php?charset=utf-8&encode=json')
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
if (!{theme.subtitle.effect}) {
|
if (!{theme.subtitle.effect}) {
|
||||||
var sub = "!{theme.subtitle.sub}".length == 0 ? new Array() : "!{theme.subtitle.sub}".split(',')
|
var sub = "!{theme.subtitle.sub}".length == 0 ? new Array() : "!{theme.subtitle.sub}".split(',')
|
||||||
var both = sub.unshift(data.text)
|
var both = sub.unshift(data.text)
|
||||||
@@ -21,8 +24,11 @@ case source
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!{theme.subtitle.effect}) {
|
if (!{theme.subtitle.effect}) {
|
||||||
if (typeof Typed === 'function') subtitleType()
|
if (typeof Typed === 'function') {
|
||||||
else $.getScript('!{url_for(theme.CDN.typed)}', subtitleType)
|
subtitleType()
|
||||||
|
} else {
|
||||||
|
getScript('!{url_for(theme.CDN.typed)}').then(subtitleType)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
subtitleType()
|
subtitleType()
|
||||||
}
|
}
|
||||||
@@ -30,7 +36,9 @@ case source
|
|||||||
when 2
|
when 2
|
||||||
script.
|
script.
|
||||||
function subtitleType () {
|
function subtitleType () {
|
||||||
$.getJSON('https://v1.hitokoto.cn', function (data) {
|
fetch('https://v1.hitokoto.cn')
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
if (!{theme.subtitle.effect}) {
|
if (!{theme.subtitle.effect}) {
|
||||||
var from = '出自 ' + data.from
|
var from = '出自 ' + data.from
|
||||||
var sub = "!{theme.subtitle.sub}".length == 0 ? new Array() : "!{theme.subtitle.sub}".split(',')
|
var sub = "!{theme.subtitle.sub}".length == 0 ? new Array() : "!{theme.subtitle.sub}".split(',')
|
||||||
@@ -49,8 +57,11 @@ case source
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!{theme.subtitle.effect}) {
|
if (!{theme.subtitle.effect}) {
|
||||||
if (typeof Typed === 'function') subtitleType()
|
if (typeof Typed === 'function') {
|
||||||
else $.getScript('!{url_for(theme.CDN.typed)}', subtitleType)
|
subtitleType()
|
||||||
|
} else {
|
||||||
|
getScript('!{url_for(theme.CDN.typed)}').then(subtitleType)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
subtitleType()
|
subtitleType()
|
||||||
}
|
}
|
||||||
@@ -58,7 +69,7 @@ case source
|
|||||||
when 3
|
when 3
|
||||||
script.
|
script.
|
||||||
function subtitleType () {
|
function subtitleType () {
|
||||||
$.getScript('http://yijuzhan.com/api/word.php?m=js', function () {
|
getScript('http://yijuzhan.com/api/word.php?m=js').then(() => {
|
||||||
var con = str[0]
|
var con = str[0]
|
||||||
if (!{theme.subtitle.effect}) {
|
if (!{theme.subtitle.effect}) {
|
||||||
var from = '出自 ' + str[1]
|
var from = '出自 ' + str[1]
|
||||||
@@ -78,8 +89,11 @@ case source
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!{theme.subtitle.effect}) {
|
if (!{theme.subtitle.effect}) {
|
||||||
if (typeof Typed === 'function') subtitleType()
|
if (typeof Typed === 'function') {
|
||||||
else $.getScript('!{url_for(theme.CDN.typed)}', subtitleType)
|
subtitleType()
|
||||||
|
} else {
|
||||||
|
getScript('!{url_for(theme.CDN.typed)}').then(subtitleType)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
subtitleType()
|
subtitleType()
|
||||||
}
|
}
|
||||||
@@ -87,7 +101,7 @@ case source
|
|||||||
when 4
|
when 4
|
||||||
script.
|
script.
|
||||||
function subtitleType () {
|
function subtitleType () {
|
||||||
$.getScript('https://sdk.jinrishici.com/v2/browser/jinrishici.js',function () {
|
getScript('https://sdk.jinrishici.com/v2/browser/jinrishici.js').then(() => {
|
||||||
jinrishici.load(function (result) {
|
jinrishici.load(function (result) {
|
||||||
if (!{theme.subtitle.effect}) {
|
if (!{theme.subtitle.effect}) {
|
||||||
var sub = "!{theme.subtitle.sub}".length == 0 ? new Array() : "!{theme.subtitle.sub}".split(',')
|
var sub = "!{theme.subtitle.sub}".length == 0 ? new Array() : "!{theme.subtitle.sub}".split(',')
|
||||||
@@ -108,8 +122,11 @@ case source
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!{theme.subtitle.effect}) {
|
if (!{theme.subtitle.effect}) {
|
||||||
if (typeof Typed === 'function') subtitleType()
|
if (typeof Typed === 'function') {
|
||||||
else $.getScript('!{url_for(theme.CDN.typed)}', subtitleType)
|
subtitleType()
|
||||||
|
} else {
|
||||||
|
getScript('!{url_for(theme.CDN.typed)}').then(subtitleType)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
subtitleType()
|
subtitleType()
|
||||||
}
|
}
|
||||||
@@ -131,8 +148,11 @@ case source
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!{theme.subtitle.effect}) {
|
if (!{theme.subtitle.effect}) {
|
||||||
if (typeof Typed === 'function') subtitleType()
|
if (typeof Typed === 'function') {
|
||||||
else $.getScript('!{url_for(theme.CDN.typed)}', subtitleType)
|
subtitleType()
|
||||||
|
} else {
|
||||||
|
getScript('!{url_for(theme.CDN.typed)}').then(subtitleType)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
subtitleType()
|
subtitleType()
|
||||||
}
|
}
|
||||||
@@ -1,2 +1,3 @@
|
|||||||
.card-widget.card-ad
|
if theme.ad && theme.ad.aside
|
||||||
|
.card-widget.ads-wrap
|
||||||
!= theme.ad.aside
|
!= theme.ad.aside
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
.card-widget.card-announcement
|
if theme.aside.card_announcement.enable
|
||||||
|
.card-widget.card-announcement
|
||||||
.card-content
|
.card-content
|
||||||
.item-headline
|
.item-headline
|
||||||
i.fas.fa-bullhorn.card-announcement-animation
|
i.fas.fa-bullhorn.card-announcement-animation
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
.card-widget.card-archives
|
if theme.aside.card_archives.enable
|
||||||
|
.card-widget.card-archives
|
||||||
.card-content
|
.card-content
|
||||||
.item-headline
|
.item-headline
|
||||||
i.fas.fa-archive
|
i.fas.fa-archive
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
.card-widget.card-info
|
if theme.aside.card_author.enable
|
||||||
|
.card-widget.card-info
|
||||||
.card-content
|
.card-content
|
||||||
.card-info-avatar.is-center
|
.card-info-avatar.is-center
|
||||||
if theme.lazyload.enable
|
if theme.lazyload.enable
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
if site.categories.length
|
if theme.aside.card_categories.enable
|
||||||
|
if site.categories.length
|
||||||
.card-widget.card-categories
|
.card-widget.card-categories
|
||||||
.card-content
|
.card-content
|
||||||
.item-headline
|
.item-headline
|
||||||
i.fas.fa-folder-open
|
i.fas.fa-folder-open
|
||||||
span= _p('aside.card_categories')
|
span= _p('aside.card_categories')
|
||||||
!=aside_categories({ limit: theme.aside.card_categories.limit === 0 ? 0 : theme.aside.card_categories.limit || 8 , expand: theme.aside.card_categories.expand })
|
!=aside_categories({ limit: theme.aside.card_categories.limit === 0 ? 0 : theme.aside.card_categories.limit || 8 , expand: theme.aside.card_categories.expand })
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
.card-widget#card-newest-comments
|
if theme.newest_comments.enable
|
||||||
|
.card-widget#card-newest-comments
|
||||||
.card-content
|
.card-content
|
||||||
.item-headline
|
.item-headline
|
||||||
i.fas.fa-bolt
|
i.fas.fa-bolt
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
.card-widget.card-recent-post
|
if theme.aside.card_recent_post.enable
|
||||||
|
.card-widget.card-recent-post
|
||||||
.card-content
|
.card-content
|
||||||
.item-headline
|
.item-headline
|
||||||
i.fas.fa-history
|
i.fas.fa-history
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
if site.tags.length
|
if theme.aside.card_tags.enable
|
||||||
|
if site.tags.length
|
||||||
.card-widget.card-tags
|
.card-widget.card-tags
|
||||||
.card-content
|
.card-content
|
||||||
.item-headline
|
.item-headline
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
.card-widget.card-webinfo
|
if theme.aside.card_webinfo.enable
|
||||||
|
.card-widget.card-webinfo
|
||||||
.card-content
|
.card-content
|
||||||
.item-headline
|
.item-headline
|
||||||
i.fas.fa-chart-line
|
i.fas.fa-chart-line
|
||||||
|
|||||||
@@ -1,28 +1,26 @@
|
|||||||
#aside_content.aside_content
|
#aside_content.aside_content
|
||||||
if theme.aside.card_author.enable
|
//- post
|
||||||
|
if is_post()
|
||||||
|
if showToc && theme.toc.style_simple
|
||||||
|
.sticky_layout
|
||||||
|
include ./card_post_toc.pug
|
||||||
|
else
|
||||||
!=partial('includes/widget/card_author', {}, {cache:theme.fragment_cache})
|
!=partial('includes/widget/card_author', {}, {cache:theme.fragment_cache})
|
||||||
if theme.aside.card_announcement.enable
|
|
||||||
!=partial('includes/widget/card_announcement', {}, {cache:theme.fragment_cache})
|
!=partial('includes/widget/card_announcement', {}, {cache:theme.fragment_cache})
|
||||||
.sticky_layout
|
.sticky_layout
|
||||||
if is_post()
|
|
||||||
if showToc
|
if showToc
|
||||||
include ./card_post_toc.pug
|
include ./card_post_toc.pug
|
||||||
if theme.aside.card_recent_post.enable
|
|
||||||
!=partial('includes/widget/card_recent_post', {}, {cache:theme.fragment_cache})
|
!=partial('includes/widget/card_recent_post', {}, {cache:theme.fragment_cache})
|
||||||
if theme.ad && theme.ad.aside
|
|
||||||
!=partial('includes/widget/card_ad', {}, {cache:theme.fragment_cache})
|
!=partial('includes/widget/card_ad', {}, {cache:theme.fragment_cache})
|
||||||
else
|
else
|
||||||
if theme.aside.card_recent_post.enable
|
//- page
|
||||||
|
!=partial('includes/widget/card_author', {}, {cache:theme.fragment_cache})
|
||||||
|
!=partial('includes/widget/card_announcement', {}, {cache:theme.fragment_cache})
|
||||||
|
.sticky_layout
|
||||||
!=partial('includes/widget/card_recent_post', {}, {cache:theme.fragment_cache})
|
!=partial('includes/widget/card_recent_post', {}, {cache:theme.fragment_cache})
|
||||||
if theme.ad && theme.ad.aside
|
|
||||||
!=partial('includes/widget/card_ad', {}, {cache:theme.fragment_cache})
|
!=partial('includes/widget/card_ad', {}, {cache:theme.fragment_cache})
|
||||||
if theme.newest_comments.enable
|
|
||||||
!=partial('includes/widget/card_newest_comment', {}, {cache:theme.fragment_cache})
|
!=partial('includes/widget/card_newest_comment', {}, {cache:theme.fragment_cache})
|
||||||
if theme.aside.card_categories.enable
|
|
||||||
!=partial('includes/widget/card_categories', {}, {cache:theme.fragment_cache})
|
!=partial('includes/widget/card_categories', {}, {cache:theme.fragment_cache})
|
||||||
if theme.aside.card_tags.enable
|
|
||||||
!=partial('includes/widget/card_tags', {}, {cache:theme.fragment_cache})
|
!=partial('includes/widget/card_tags', {}, {cache:theme.fragment_cache})
|
||||||
if theme.aside.card_archives.enable
|
|
||||||
!=partial('includes/widget/card_archives', {}, {cache:theme.fragment_cache})
|
!=partial('includes/widget/card_archives', {}, {cache:theme.fragment_cache})
|
||||||
if theme.aside.card_webinfo.enable
|
|
||||||
!=partial('includes/widget/card_webinfo', {}, {cache:theme.fragment_cache})
|
!=partial('includes/widget/card_webinfo', {}, {cache:theme.fragment_cache})
|
||||||
@@ -19,7 +19,7 @@ block content
|
|||||||
|
|
||||||
//- ad
|
//- ad
|
||||||
if theme.ad && theme.ad.post
|
if theme.ad && theme.ad.post
|
||||||
.post-ad!=theme.ad.post
|
.ads-wrap!=theme.ad.post
|
||||||
|
|
||||||
include includes/pagination.pug
|
include includes/pagination.pug
|
||||||
if theme.related_post && theme.related_post.enable
|
if theme.related_post && theme.related_post.enable
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hexo-theme-butterfly",
|
"name": "hexo-theme-butterfly",
|
||||||
"version": "3.3.0",
|
"version": "3.4.2",
|
||||||
"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": {
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
"hexo-renderer-stylus": "^2.0.1",
|
"hexo-renderer-stylus": "^2.0.1",
|
||||||
"hexo-renderer-pug": "^1.0.0"
|
"hexo-renderer-pug": "^1.0.0"
|
||||||
},
|
},
|
||||||
"homepage": "https://demo.jerryc.me/",
|
"homepage": "https://butterfly.js.org/",
|
||||||
"author": "Jerry <wong@jerryc.me>",
|
"author": "Jerry <wong@jerryc.me>",
|
||||||
"license": "Apache-2.0"
|
"license": "Apache-2.0"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,11 +65,11 @@ hexo.extend.helper.register('aside_categories', function (categories, options) {
|
|||||||
|
|
||||||
result += '</a>'
|
result += '</a>'
|
||||||
|
|
||||||
result += '</li>'
|
|
||||||
|
|
||||||
if (child) {
|
if (child) {
|
||||||
result += `<ul class="card-category-list child">${child}</ul>`
|
result += `<ul class="card-category-list child">${child}</ul>`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result += '</li>'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ function galleryGroup (args) {
|
|||||||
|
|
||||||
return `
|
return `
|
||||||
<figure class="gallery-group">
|
<figure class="gallery-group">
|
||||||
<img class="gallery-group-img" src='${img}'>
|
<img class="gallery-group-img" src='${img}' alt="Group Image Gallery">
|
||||||
<figcaption>
|
<figcaption>
|
||||||
<div class="gallery-group-name">${name}</div>
|
<div class="gallery-group-name">${name}</div>
|
||||||
<p>${desrc}</p>
|
<p>${desrc}</p>
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ function hideBlock (args, content) {
|
|||||||
group += '"'
|
group += '"'
|
||||||
|
|
||||||
return `<div class="hide-block"><button type="button" class="hide-button button--animated" ${group}>${display}
|
return `<div class="hide-block"><button type="button" class="hide-button button--animated" ${group}>${display}
|
||||||
</button><span class="hide-content">${hexo.render.renderSync({ text: content, engine: 'markdown' })}</span></div>`
|
</button><div class="hide-content">${hexo.render.renderSync({ text: content, engine: 'markdown' })}</div></div>`
|
||||||
}
|
}
|
||||||
|
|
||||||
function hideToggle (args, content) {
|
function hideToggle (args, content) {
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ function postTabs (args, content) {
|
|||||||
const icon = tabIcon.trim()
|
const icon = tabIcon.trim()
|
||||||
tabIcon.length > 0 && (tabIcon = `<i class="${icon}"${isOnlyicon}></i>`)
|
tabIcon.length > 0 && (tabIcon = `<i class="${icon}"${isOnlyicon}></i>`)
|
||||||
|
|
||||||
const toTop = '<button type="button" class="tab-to-top"><i class="fas fa-arrow-up"></i></button>'
|
const toTop = '<button type="button" class="tab-to-top" aria-label="scroll to top"><i class="fas fa-arrow-up"></i></button>'
|
||||||
|
|
||||||
const isActive = (tabActive > 0 && tabActive === tabId) || (tabActive === 0 && tabId === 1) ? ' active' : ''
|
const isActive = (tabActive > 0 && tabActive === tabId) || (tabActive === 0 && tabId === 1) ? ' active' : ''
|
||||||
tabNav += `<li class="tab${isActive}"><button type="button" data-href="#${tabHref}">${tabIcon + tabCaption.trim()}</button></li>`
|
tabNav += `<li class="tab${isActive}"><button type="button" data-href="#${tabHref}">${tabIcon + tabCaption.trim()}</button></li>`
|
||||||
|
|||||||
@@ -37,6 +37,10 @@ maxWidth900()
|
|||||||
@media screen and (max-width: 900px)
|
@media screen and (max-width: 900px)
|
||||||
{block}
|
{block}
|
||||||
|
|
||||||
|
minWidth901()
|
||||||
|
@media screen and (min-width: 901px)
|
||||||
|
{block}
|
||||||
|
|
||||||
minWidth900()
|
minWidth900()
|
||||||
@media screen and (min-width: 900px)
|
@media screen and (min-width: 900px)
|
||||||
{block}
|
{block}
|
||||||
@@ -151,6 +155,13 @@ if hexo-config('avatar.effect') == true
|
|||||||
100%
|
100%
|
||||||
opacity: 1
|
opacity: 1
|
||||||
|
|
||||||
|
@keyframes to_hide
|
||||||
|
0%
|
||||||
|
opacity: 1
|
||||||
|
|
||||||
|
100%
|
||||||
|
opacity: 0
|
||||||
|
|
||||||
@keyframes ribbon_to_show
|
@keyframes ribbon_to_show
|
||||||
0%
|
0%
|
||||||
opacity: 0
|
opacity: 0
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
[data-theme='light']
|
:root
|
||||||
|
--global-font-size: $font-size
|
||||||
--global-bg: $body-bg
|
--global-bg: $body-bg
|
||||||
--font-color: $font-black
|
--font-color: $font-black
|
||||||
--hr-border: lighten($theme-hr-color, 50%)
|
--hr-border: lighten($theme-hr-color, 50%)
|
||||||
@@ -36,7 +37,7 @@ body
|
|||||||
min-height: 100%
|
min-height: 100%
|
||||||
background: var(--global-bg)
|
background: var(--global-bg)
|
||||||
color: var(--font-color)
|
color: var(--font-color)
|
||||||
font-size: $font-size
|
font-size: var(--global-font-size)
|
||||||
font-family: $font-family
|
font-family: $font-family
|
||||||
line-height: $text-line-height
|
line-height: $text-line-height
|
||||||
-webkit-tap-highlight-color: rgba(0, 0, 0, 0)
|
-webkit-tap-highlight-color: rgba(0, 0, 0, 0)
|
||||||
@@ -57,7 +58,8 @@ body
|
|||||||
input::placeholder
|
input::placeholder
|
||||||
color: var(--font-color)
|
color: var(--font-color)
|
||||||
|
|
||||||
#web_bg
|
if $web-bg
|
||||||
|
#web_bg
|
||||||
position: fixed
|
position: fixed
|
||||||
z-index: -999
|
z-index: -999
|
||||||
width: 100%
|
width: 100%
|
||||||
@@ -198,8 +200,8 @@ img
|
|||||||
max-width: 100%
|
max-width: 100%
|
||||||
transition: all .2s
|
transition: all .2s
|
||||||
|
|
||||||
img[src=''],
|
&[src=''],
|
||||||
img:not([src])
|
&:not([src])
|
||||||
opacity: 0
|
opacity: 0
|
||||||
|
|
||||||
.img-alt
|
.img-alt
|
||||||
@@ -208,10 +210,3 @@ img:not([src])
|
|||||||
|
|
||||||
&:hover
|
&:hover
|
||||||
text-decoration: none !important
|
text-decoration: none !important
|
||||||
|
|
||||||
.post-ad
|
|
||||||
margin: 2rem 0
|
|
||||||
|
|
||||||
.ad-height
|
|
||||||
display: block !important
|
|
||||||
height: auto !important
|
|
||||||
@@ -132,6 +132,7 @@ blockquote
|
|||||||
position: absolute
|
position: absolute
|
||||||
right: 1.7rem
|
right: 1.7rem
|
||||||
opacity: 0
|
opacity: 0
|
||||||
|
transition: opacity .4s
|
||||||
|
|
||||||
.copy-button
|
.copy-button
|
||||||
position: absolute
|
position: absolute
|
||||||
|
|||||||
@@ -10,10 +10,6 @@
|
|||||||
+maxWidth900()
|
+maxWidth900()
|
||||||
width: 100%
|
width: 100%
|
||||||
|
|
||||||
if hexo-config('aside.mobile') == false
|
|
||||||
+maxWidth768()
|
|
||||||
display: none
|
|
||||||
|
|
||||||
> .card-widget:first-child
|
> .card-widget:first-child
|
||||||
margin-top: 0
|
margin-top: 0
|
||||||
|
|
||||||
@@ -27,11 +23,16 @@
|
|||||||
border-radius: 8px
|
border-radius: 8px
|
||||||
background: var(--card-bg)
|
background: var(--card-bg)
|
||||||
box-shadow: 0 4px 8px 6px rgba(7, 17, 27, .06)
|
box-shadow: 0 4px 8px 6px rgba(7, 17, 27, .06)
|
||||||
transition: all .3s
|
transition: box-shadow .3s
|
||||||
|
|
||||||
&:hover
|
&:hover
|
||||||
box-shadow: 0 4px 12px 12px rgba(7, 17, 27, .15)
|
box-shadow: 0 4px 12px 12px rgba(7, 17, 27, .15)
|
||||||
|
|
||||||
|
if hexo-config('aside.mobile') == false
|
||||||
|
+maxWidth768()
|
||||||
|
&:not(#card-toc)
|
||||||
|
display: none
|
||||||
|
|
||||||
.card-info
|
.card-info
|
||||||
img
|
img
|
||||||
width: 110px
|
width: 110px
|
||||||
@@ -229,6 +230,7 @@
|
|||||||
padding: 0 0 0 .8rem
|
padding: 0 0 0 .8rem
|
||||||
|
|
||||||
> .parent
|
> .parent
|
||||||
|
> a
|
||||||
.card-category-list
|
.card-category-list
|
||||||
&-name
|
&-name
|
||||||
width: 70% !important
|
width: 70% !important
|
||||||
@@ -248,7 +250,7 @@
|
|||||||
transform: rotate(-90deg)
|
transform: rotate(-90deg)
|
||||||
|
|
||||||
if hexo-config('aside.card_categories.expand') == false
|
if hexo-config('aside.card_categories.expand') == false
|
||||||
+ .child
|
> .child
|
||||||
display: none
|
display: none
|
||||||
|
|
||||||
.card-webinfo
|
.card-webinfo
|
||||||
@@ -265,23 +267,37 @@
|
|||||||
|
|
||||||
// toc
|
// toc
|
||||||
#card-toc
|
#card-toc
|
||||||
|
+minWidth901()
|
||||||
|
right: 0 !important
|
||||||
|
|
||||||
+maxWidth900()
|
+maxWidth900()
|
||||||
position: fixed
|
position: fixed
|
||||||
right: 45px
|
right: -100%
|
||||||
bottom: 30px
|
bottom: 30px
|
||||||
z-index: 100
|
z-index: 100
|
||||||
display: none
|
max-height: calc(100% - 60px)
|
||||||
width: $toc-mobile-width
|
width: $toc-mobile-width
|
||||||
|
opacity: 0
|
||||||
transform-origin: right bottom
|
transform-origin: right bottom
|
||||||
animation: toc-open .3s
|
|
||||||
|
|
||||||
.toc-child
|
|
||||||
display: block !important
|
|
||||||
|
|
||||||
.toc-content
|
.toc-content
|
||||||
overflow-y: auto
|
overflow-y: auto
|
||||||
max-height: calc(100vh - 120px)
|
max-height: calc(100vh - 120px)
|
||||||
|
|
||||||
|
+maxWidth900()
|
||||||
|
max-height: calc(100vh - 140px)
|
||||||
|
|
||||||
|
.toc-child
|
||||||
|
display: none
|
||||||
|
|
||||||
|
+maxWidth900()
|
||||||
|
display: block !important
|
||||||
|
|
||||||
|
.toc-item
|
||||||
|
&.active
|
||||||
|
.toc-child
|
||||||
|
display: block
|
||||||
|
|
||||||
ol,
|
ol,
|
||||||
li
|
li
|
||||||
list-style: none
|
list-style: none
|
||||||
@@ -314,6 +330,10 @@
|
|||||||
font-style: italic
|
font-style: italic
|
||||||
font-size: 1.2rem
|
font-size: 1.2rem
|
||||||
|
|
||||||
|
:only-child
|
||||||
|
> .card-widget
|
||||||
|
margin-top: 0
|
||||||
|
|
||||||
@keyframes toc-open
|
@keyframes toc-open
|
||||||
0%
|
0%
|
||||||
transform: scale(.7)
|
transform: scale(.7)
|
||||||
|
|||||||
@@ -31,3 +31,5 @@
|
|||||||
.icp-icon
|
.icp-icon
|
||||||
padding: 0 4px
|
padding: 0 4px
|
||||||
vertical-align: text-bottom
|
vertical-align: text-bottom
|
||||||
|
max-height: 1.4em
|
||||||
|
width auto
|
||||||
|
|||||||
@@ -133,9 +133,9 @@
|
|||||||
.post-title
|
.post-title
|
||||||
@extend .limit-more-line
|
@extend .limit-more-line
|
||||||
margin-bottom: .4rem
|
margin-bottom: .4rem
|
||||||
font-size: 2.5em
|
|
||||||
font-weight: normal
|
|
||||||
color: var(--white)
|
color: var(--white)
|
||||||
|
font-weight: normal
|
||||||
|
font-size: 2.5em
|
||||||
line-height: 1.5
|
line-height: 1.5
|
||||||
-webkit-line-clamp: 3
|
-webkit-line-clamp: 3
|
||||||
|
|
||||||
@@ -193,9 +193,6 @@
|
|||||||
border-bottom: 1px solid var(--light-grey)
|
border-bottom: 1px solid var(--light-grey)
|
||||||
color: var(--text-highlight-color)
|
color: var(--text-highlight-color)
|
||||||
|
|
||||||
[data-theme='light']
|
|
||||||
#post
|
|
||||||
#post-info
|
|
||||||
#post-meta,
|
#post-meta,
|
||||||
#post-meta a
|
#post-meta a
|
||||||
color: #78818a
|
color: #78818a
|
||||||
@@ -349,12 +346,15 @@ _:future,
|
|||||||
font-size: inherit
|
font-size: inherit
|
||||||
|
|
||||||
.menus_items
|
.menus_items
|
||||||
|
position: absolute
|
||||||
|
left: 0
|
||||||
|
visibility: hidden
|
||||||
|
opacity: 0
|
||||||
|
|
||||||
|
#search-button span
|
||||||
display: none !important
|
display: none !important
|
||||||
|
|
||||||
#search_button span
|
#search-button
|
||||||
display: none !important
|
|
||||||
|
|
||||||
#search_button
|
|
||||||
display: inline
|
display: inline
|
||||||
padding: 0 0 0 .7rem
|
padding: 0 0 0 .7rem
|
||||||
|
|
||||||
|
|||||||
@@ -275,3 +275,6 @@ no-beautify()
|
|||||||
color: $noticeOutdate-border
|
color: $noticeOutdate-border
|
||||||
content: '\f071'
|
content: '\f071'
|
||||||
transform: translateY(-50%)
|
transform: translateY(-50%)
|
||||||
|
|
||||||
|
.ads-wrap
|
||||||
|
margin: 2rem 0
|
||||||
|
|||||||
@@ -29,10 +29,6 @@
|
|||||||
&:hover
|
&:hover
|
||||||
background-color: var(--btn-hover-color)
|
background-color: var(--btn-hover-color)
|
||||||
|
|
||||||
#rightside_config
|
|
||||||
i
|
|
||||||
animation: avatar_turn_around 2s linear infinite
|
|
||||||
|
|
||||||
#mobile-toc-button
|
#mobile-toc-button
|
||||||
display: none
|
display: none
|
||||||
|
|
||||||
|
|||||||
@@ -106,7 +106,8 @@ if hexo-config('darkmode.enable') || hexo-config('display_mode') == 'dark'
|
|||||||
.error-img,
|
.error-img,
|
||||||
#article-container iframe,
|
#article-container iframe,
|
||||||
img,
|
img,
|
||||||
.gist
|
.gist,
|
||||||
|
.ads-wrap
|
||||||
filter: brightness(.8)
|
filter: brightness(.8)
|
||||||
|
|
||||||
#aside_content .aside-list > .aside-list-item:not(:last-child)
|
#aside_content .aside-list > .aside-list-item:not(:last-child)
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
if hexo-config('readmode')
|
if hexo-config('readmode')
|
||||||
[data-theme='light']
|
|
||||||
.read-mode
|
.read-mode
|
||||||
--font-color: #4c4948
|
--font-color: #4c4948
|
||||||
--readmode-light-color: #fff
|
--readmode-light-color: #fff
|
||||||
|
|||||||
@@ -43,6 +43,10 @@
|
|||||||
order: 2
|
order: 2
|
||||||
border-radius: 0 8px 8px 0
|
border-radius: 0 8px 8px 0
|
||||||
|
|
||||||
|
&.ads-wrap
|
||||||
|
display: block !important
|
||||||
|
height: auto !important
|
||||||
|
|
||||||
.post_cover
|
.post_cover
|
||||||
overflow: hidden
|
overflow: hidden
|
||||||
width: 45%
|
width: 45%
|
||||||
|
|||||||
@@ -57,9 +57,6 @@
|
|||||||
color: $search-keyword-highlight
|
color: $search-keyword-highlight
|
||||||
font-weight: bold
|
font-weight: bold
|
||||||
|
|
||||||
.local-search-stats__hr
|
|
||||||
display: none !important
|
|
||||||
|
|
||||||
.search-result-list
|
.search-result-list
|
||||||
overflow-y: auto
|
overflow-y: auto
|
||||||
max-height: 10.5rem
|
max-height: 10.5rem
|
||||||
|
|||||||
@@ -99,6 +99,9 @@ figure.gallery-group
|
|||||||
img
|
img
|
||||||
opacity: 0
|
opacity: 0
|
||||||
|
|
||||||
|
.img-alt
|
||||||
|
display: none
|
||||||
|
|
||||||
.fancybox
|
.fancybox
|
||||||
width: auto
|
width: auto
|
||||||
text-align: inherit
|
text-align: inherit
|
||||||
@@ -10,6 +10,12 @@
|
|||||||
&.open
|
&.open
|
||||||
display: none
|
display: none
|
||||||
|
|
||||||
|
& + div
|
||||||
|
display: block
|
||||||
|
|
||||||
|
& + span
|
||||||
|
display: inline
|
||||||
|
|
||||||
& > .hide-content
|
& > .hide-content
|
||||||
display: none
|
display: none
|
||||||
|
|
||||||
@@ -41,6 +47,9 @@
|
|||||||
i
|
i
|
||||||
transform: rotate(90deg)
|
transform: rotate(90deg)
|
||||||
|
|
||||||
|
& + div
|
||||||
|
display: block
|
||||||
|
|
||||||
& > .hide-content
|
& > .hide-content
|
||||||
display: none
|
display: none
|
||||||
margin: 1.5rem 1.2rem
|
margin: 1.5rem 1.2rem
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
@import 'nib'
|
if hexo-config('css_prefix')
|
||||||
|
@import 'nib'
|
||||||
|
|
||||||
@import '_third-party/normalize.min.css'
|
@import '_third-party/normalize.min.css'
|
||||||
// project
|
// project
|
||||||
@import 'var'
|
@import 'var'
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.1 KiB |
File diff suppressed because it is too large
Load Diff
@@ -1,9 +1,9 @@
|
|||||||
$(function () {
|
window.addEventListener('load', () => {
|
||||||
const openSearch = () => {
|
const openSearch = () => {
|
||||||
$('body').css({ width: '100%', overflow: 'hidden' })
|
document.body.style.cssText = 'width: 100%;overflow: hidden'
|
||||||
$('#algolia-search .search-dialog').css('display', 'block')
|
document.querySelector('#algolia-search .search-dialog').style.display = 'block'
|
||||||
$('.ais-search-box--input').focus()
|
document.querySelector('#algolia-search .ais-search-box--input').focus()
|
||||||
$('#search-mask').fadeIn()
|
btf.fadeIn(document.getElementById('search-mask'), 0.5)
|
||||||
// shortcut: ESC
|
// shortcut: ESC
|
||||||
document.addEventListener('keydown', function f (event) {
|
document.addEventListener('keydown', function f (event) {
|
||||||
if (event.code === 'Escape') {
|
if (event.code === 'Escape') {
|
||||||
@@ -14,30 +14,23 @@ $(function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const closeSearch = () => {
|
const closeSearch = () => {
|
||||||
$('body').css({ width: '', overflow: '' })
|
document.body.style.cssText = "width: '';overflow: ''"
|
||||||
$('#algolia-search .search-dialog').css({
|
const $searchDialog = document.querySelector('#algolia-search .search-dialog')
|
||||||
animation: 'search_close .5s'
|
$searchDialog.style.animation = 'search_close .5s'
|
||||||
})
|
setTimeout(() => { $searchDialog.style.cssText = "display: none; animation: ''" }, 500)
|
||||||
|
btf.fadeOut(document.getElementById('search-mask'), 0.5)
|
||||||
setTimeout(function () {
|
|
||||||
$('#algolia-search .search-dialog').css({
|
|
||||||
animation: '',
|
|
||||||
display: 'none'
|
|
||||||
})
|
|
||||||
}, 500)
|
|
||||||
|
|
||||||
$('#search-mask').fadeOut()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const searchClickFn = () => {
|
const searchClickFn = () => {
|
||||||
$('a.social-icon.search').on('click', openSearch)
|
document.querySelector('#search-button > .search').addEventListener('click', openSearch)
|
||||||
$('#search-mask, .search-close-button').on('click touchstart', closeSearch)
|
document.getElementById('search-mask').addEventListener('click', closeSearch)
|
||||||
|
document.querySelector('#algolia-search .search-close-button').addEventListener('click', closeSearch)
|
||||||
}
|
}
|
||||||
|
|
||||||
searchClickFn()
|
searchClickFn()
|
||||||
|
|
||||||
window.addEventListener('pjax:complete', function () {
|
window.addEventListener('pjax:complete', function () {
|
||||||
closeSearch()
|
getComputedStyle(document.querySelector('#algolia-search .search-dialog')).display === 'block' && closeSearch()
|
||||||
searchClickFn()
|
searchClickFn()
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -55,9 +48,9 @@ $(function () {
|
|||||||
hitsPerPage: algolia.hits.per_page || 10
|
hitsPerPage: algolia.hits.per_page || 10
|
||||||
},
|
},
|
||||||
searchFunction: function (helper) {
|
searchFunction: function (helper) {
|
||||||
const searchInput = $('#algolia-search-input').find('input')
|
const searchInput = document.querySelector('#algolia-search-input input')
|
||||||
|
|
||||||
if (searchInput.val()) {
|
if (searchInput.value) {
|
||||||
helper.search()
|
helper.search()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,14 @@
|
|||||||
$(function () {
|
window.addEventListener('load', () => {
|
||||||
let loadFlag = false
|
let loadFlag = false
|
||||||
const openSearch = function () {
|
const openSearch = function () {
|
||||||
$('body').css({
|
document.body.style.cssText = 'width: 100%;overflow: hidden'
|
||||||
width: '100%',
|
document.querySelector('#local-search .search-dialog').style.display = 'block'
|
||||||
overflow: 'hidden'
|
document.querySelector('#local-search-input input').focus()
|
||||||
})
|
btf.fadeIn(document.getElementById('search-mask'), 0.5)
|
||||||
$('#local-search .search-dialog').css('display', 'block')
|
|
||||||
$('#local-search-input input').focus()
|
|
||||||
$('#search-mask').fadeIn()
|
|
||||||
if (!loadFlag) {
|
if (!loadFlag) {
|
||||||
search(GLOBAL_CONFIG.localSearch.path)
|
search(GLOBAL_CONFIG.localSearch.path)
|
||||||
loadFlag = true
|
loadFlag = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// shortcut: ESC
|
// shortcut: ESC
|
||||||
document.addEventListener('keydown', function f (event) {
|
document.addEventListener('keydown', function f (event) {
|
||||||
if (event.code === 'Escape') {
|
if (event.code === 'Escape') {
|
||||||
@@ -23,60 +19,48 @@ $(function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const closeSearch = function () {
|
const closeSearch = function () {
|
||||||
$('body').css({
|
document.body.style.cssText = "width: '';overflow: ''"
|
||||||
width: '',
|
const $searchDialog = document.querySelector('#local-search .search-dialog')
|
||||||
overflow: ''
|
$searchDialog.style.animation = 'search_close .5s'
|
||||||
})
|
setTimeout(() => { $searchDialog.style.cssText = "display: none; animation: ''" }, 500)
|
||||||
$('#local-search .search-dialog').css({
|
btf.fadeOut(document.getElementById('search-mask'), 0.5)
|
||||||
animation: 'search_close .5s'
|
|
||||||
})
|
|
||||||
|
|
||||||
setTimeout(function () {
|
|
||||||
$('#local-search .search-dialog').css({
|
|
||||||
animation: '',
|
|
||||||
display: 'none'
|
|
||||||
})
|
|
||||||
}, 500)
|
|
||||||
|
|
||||||
$('#search-mask').fadeOut()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// click function
|
||||||
const searchClickFn = () => {
|
const searchClickFn = () => {
|
||||||
$('a.social-icon.search').on('click', openSearch)
|
document.querySelector('#search-button > .search').addEventListener('click', openSearch)
|
||||||
$('#search-mask, .search-close-button').on('click', closeSearch)
|
document.getElementById('search-mask').addEventListener('click', closeSearch)
|
||||||
|
document.querySelector('#local-search .search-close-button').addEventListener('click', closeSearch)
|
||||||
}
|
}
|
||||||
|
|
||||||
searchClickFn()
|
searchClickFn()
|
||||||
|
|
||||||
|
// pjax
|
||||||
window.addEventListener('pjax:complete', function () {
|
window.addEventListener('pjax:complete', function () {
|
||||||
$('#local-search .search-dialog').is(':visible') && closeSearch()
|
getComputedStyle(document.querySelector('#local-search .search-dialog')).display === 'block' && closeSearch()
|
||||||
searchClickFn()
|
searchClickFn()
|
||||||
})
|
})
|
||||||
|
|
||||||
function search (path) {
|
function search (path) {
|
||||||
$.ajax({
|
fetch(GLOBAL_CONFIG.root + path)
|
||||||
url: GLOBAL_CONFIG.root + path,
|
.then(response => response.text())
|
||||||
dataType: 'xml',
|
.then(str => new window.DOMParser().parseFromString(str, 'text/xml'))
|
||||||
success: function (xmlResponse) {
|
.then(data => {
|
||||||
// get the contents from search data
|
const datas = [...data.querySelectorAll('entry')].map(function (item) {
|
||||||
const datas = $('entry', xmlResponse).map(function () {
|
|
||||||
return {
|
return {
|
||||||
title: $('title', this).text(),
|
title: item.querySelector('title').textContent,
|
||||||
content: $('content', this).text(),
|
content: item.querySelector('content').textContent,
|
||||||
url: $('url', this).text()
|
url: item.querySelector('url').textContent
|
||||||
}
|
}
|
||||||
}).get()
|
})
|
||||||
|
|
||||||
const $input = $('#local-search-input input')[0]
|
const $input = document.querySelector('#local-search-input input')
|
||||||
const $resultContent = $('#local-hits')[0]
|
const $resultContent = document.getElementById('local-search-results')
|
||||||
$input.addEventListener('input', function () {
|
$input.addEventListener('input', function () {
|
||||||
let str = '<div class="search-result-list">'
|
let str = '<div class="search-result-list">'
|
||||||
const keywords = this.value.trim().toLowerCase().split(/[\s]+/)
|
const keywords = this.value.trim().toLowerCase().split(/[\s]+/)
|
||||||
$resultContent.innerHTML = ''
|
$resultContent.innerHTML = ''
|
||||||
if (this.value.trim().length <= 0) {
|
if (this.value.trim().length <= 0) return
|
||||||
$('.local-search-stats__hr').hide()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
let count = 0
|
let count = 0
|
||||||
// perform local searching
|
// perform local searching
|
||||||
datas.forEach(function (data) {
|
datas.forEach(function (data) {
|
||||||
@@ -141,7 +125,6 @@ $(function () {
|
|||||||
|
|
||||||
str += '<div class="local-search__hit-item"><a href="' + dataUrl + '" class="search-result-title">' + dataTitle + '</a>'
|
str += '<div class="local-search__hit-item"><a href="' + dataUrl + '" class="search-result-title">' + dataTitle + '</a>'
|
||||||
count += 1
|
count += 1
|
||||||
$('.local-search-stats__hr').show()
|
|
||||||
|
|
||||||
if (dataContent !== '') {
|
if (dataContent !== '') {
|
||||||
str += '<p class="search-result">' + matchContent + '...</p>'
|
str += '<p class="search-result">' + matchContent + '...</p>'
|
||||||
@@ -158,7 +141,6 @@ $(function () {
|
|||||||
$resultContent.innerHTML = str
|
$resultContent.innerHTML = str
|
||||||
window.pjax && window.pjax.refresh($resultContent)
|
window.pjax && window.pjax.refresh($resultContent)
|
||||||
})
|
})
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* eslint-disable no-undef */
|
/* eslint-disable no-undef */
|
||||||
(function () {
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
const translate = GLOBAL_CONFIG.translate
|
const translate = GLOBAL_CONFIG.translate
|
||||||
const snackbarData = GLOBAL_CONFIG.Snackbar
|
const snackbarData = GLOBAL_CONFIG.Snackbar
|
||||||
const defaultEncoding = translate.defaultEncoding // 網站默認語言,1: 繁體中文, 2: 簡體中文
|
const defaultEncoding = translate.defaultEncoding // 網站默認語言,1: 繁體中文, 2: 簡體中文
|
||||||
@@ -88,12 +88,13 @@
|
|||||||
translateButtonObject = document.getElementById('translateLink')
|
translateButtonObject = document.getElementById('translateLink')
|
||||||
if (translateButtonObject) {
|
if (translateButtonObject) {
|
||||||
if (currentEncoding !== targetEncoding) {
|
if (currentEncoding !== targetEncoding) {
|
||||||
setTimeout(function () { translateBody() }, translateDelay)
|
setTimeout(translateBody, translateDelay)
|
||||||
if (targetEncoding === 1) { translateButtonObject.innerHTML = msgToSimplifiedChinese } else translateButtonObject.innerHTML = msgToTraditionalChinese
|
if (targetEncoding === 1) translateButtonObject.innerHTML = msgToSimplifiedChinese
|
||||||
|
else translateButtonObject.innerHTML = msgToTraditionalChinese
|
||||||
}
|
}
|
||||||
translateButtonObject.addEventListener('click', translatePage, false)
|
translateButtonObject.addEventListener('click', translatePage, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
translateInitialization()
|
translateInitialization()
|
||||||
document.addEventListener('pjax:complete', translateInitialization)
|
document.addEventListener('pjax:complete', translateInitialization)
|
||||||
})()
|
})
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
/* eslint-disable no-unused-vars */
|
const btf = {
|
||||||
|
|
||||||
var btf = {
|
|
||||||
debounce: function (func, wait, immediate) {
|
debounce: function (func, wait, immediate) {
|
||||||
let timeout
|
let timeout
|
||||||
return function () {
|
return function () {
|
||||||
@@ -56,23 +54,10 @@ var btf = {
|
|||||||
const clientWidth = document.body.clientWidth
|
const clientWidth = document.body.clientWidth
|
||||||
const paddingRight = innerWidth - clientWidth
|
const paddingRight = innerWidth - clientWidth
|
||||||
if (innerWidth !== clientWidth) {
|
if (innerWidth !== clientWidth) {
|
||||||
$('body').css('padding-right', paddingRight)
|
document.body.style.paddingRight = paddingRight + 'px'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
scrollToDest: name => {
|
|
||||||
const scrollOffset = $(name).offset().top
|
|
||||||
let offset
|
|
||||||
if ($(window).scrollTop() > scrollOffset) {
|
|
||||||
offset = 65
|
|
||||||
} else {
|
|
||||||
offset = 0
|
|
||||||
}
|
|
||||||
$('body,html').animate({
|
|
||||||
scrollTop: scrollOffset - offset
|
|
||||||
})
|
|
||||||
},
|
|
||||||
|
|
||||||
snackbarShow: (text, showAction, duration) => {
|
snackbarShow: (text, showAction, duration) => {
|
||||||
const sa = (typeof showAction !== 'undefined') ? showAction : false
|
const sa = (typeof showAction !== 'undefined') ? showAction : false
|
||||||
const dur = (typeof duration !== 'undefined') ? duration : 2000
|
const dur = (typeof duration !== 'undefined') ? duration : 2000
|
||||||
@@ -88,6 +73,9 @@ var btf = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
initJustifiedGallery: function (selector) {
|
initJustifiedGallery: function (selector) {
|
||||||
|
if (!(selector instanceof jQuery)) {
|
||||||
|
selector = $(selector)
|
||||||
|
}
|
||||||
selector.each(function (i, o) {
|
selector.each(function (i, o) {
|
||||||
if ($(this).is(':visible')) {
|
if ($(this).is(':visible')) {
|
||||||
$(this).justifiedGallery({
|
$(this).justifiedGallery({
|
||||||
@@ -145,5 +133,119 @@ var btf = {
|
|||||||
} else {
|
} else {
|
||||||
callback()
|
callback()
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
scrollToDest: (pos, time) => {
|
||||||
|
if (pos < 0 || time < 0) {
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const currentPos = window.scrollY || window.screenTop
|
||||||
|
if (currentPos > pos) pos = pos - 70
|
||||||
|
|
||||||
|
if ('CSS' in window && CSS.supports('scroll-behavior', 'smooth')) {
|
||||||
|
window.scrollTo({
|
||||||
|
top: pos,
|
||||||
|
behavior: 'smooth'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let start = null
|
||||||
|
time = time || 500
|
||||||
|
window.requestAnimationFrame(function step (currentTime) {
|
||||||
|
start = !start ? currentTime : start
|
||||||
|
if (currentPos < pos) {
|
||||||
|
const progress = currentTime - start
|
||||||
|
window.scrollTo(0, ((pos - currentPos) * progress / time) + currentPos)
|
||||||
|
if (progress < time) {
|
||||||
|
window.requestAnimationFrame(step)
|
||||||
|
} else {
|
||||||
|
window.scrollTo(0, pos)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const progress = currentTime - start
|
||||||
|
window.scrollTo(0, currentPos - ((currentPos - pos) * progress / time))
|
||||||
|
if (progress < time) {
|
||||||
|
window.requestAnimationFrame(step)
|
||||||
|
} else {
|
||||||
|
window.scrollTo(0, pos)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
fadeIn: (ele, time) => {
|
||||||
|
ele.style.cssText = `display:block;animation: to_show ${time}s`
|
||||||
|
},
|
||||||
|
|
||||||
|
fadeOut: (ele, time) => {
|
||||||
|
ele.addEventListener('animationend', function f () {
|
||||||
|
ele.style.cssText = "display: none; animation: '' "
|
||||||
|
ele.removeEventListener('animationend', f)
|
||||||
|
})
|
||||||
|
ele.style.animation = `to_hide ${time}s`
|
||||||
|
},
|
||||||
|
|
||||||
|
getParents: (elem, selector) => {
|
||||||
|
for (; elem && elem !== document; elem = elem.parentNode) {
|
||||||
|
if (elem.matches(selector)) return elem
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
},
|
||||||
|
|
||||||
|
siblings: (ele, selector) => {
|
||||||
|
return [...ele.parentNode.children].filter((child) => {
|
||||||
|
if (selector) {
|
||||||
|
return child !== ele && child.matches(selector)
|
||||||
|
}
|
||||||
|
return child !== ele
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {*} selector
|
||||||
|
* @param {*} eleType the type of create element
|
||||||
|
* @param {*} id id
|
||||||
|
* @param {*} cn class name
|
||||||
|
*/
|
||||||
|
wrap: function (selector, eleType, id = '', cn = '') {
|
||||||
|
const creatEle = document.createElement(eleType)
|
||||||
|
if (id) creatEle.id = id
|
||||||
|
if (cn) creatEle.className = cn
|
||||||
|
selector.parentNode.insertBefore(creatEle, selector)
|
||||||
|
creatEle.appendChild(selector)
|
||||||
|
},
|
||||||
|
|
||||||
|
unwrap: function (el) {
|
||||||
|
const elParentNode = el.parentNode
|
||||||
|
if (elParentNode !== document.body) {
|
||||||
|
elParentNode.parentNode.insertBefore(el, elParentNode)
|
||||||
|
elParentNode.parentNode.removeChild(elParentNode)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
isJqueryLoad: (fn) => {
|
||||||
|
if (typeof jQuery === 'undefined') {
|
||||||
|
getScript(GLOBAL_CONFIG.source.jQuery).then(fn)
|
||||||
|
} else {
|
||||||
|
fn()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
isHidden: (ele) => ele.offsetHeight === 0 && ele.offsetWidth === 0,
|
||||||
|
|
||||||
|
getEleTop: (ele) => {
|
||||||
|
let actualTop = ele.offsetTop
|
||||||
|
let current = ele.offsetParent
|
||||||
|
|
||||||
|
while (current !== null) {
|
||||||
|
actualTop += current.offsetTop
|
||||||
|
current = current.offsetParent
|
||||||
|
}
|
||||||
|
|
||||||
|
return actualTop
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user