mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-12 22:17:06 +08:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f0eaf2d8b0 | ||
|
|
9e6958f25b | ||
|
|
36527a3b81 | ||
|
|
c439930786 | ||
|
|
f4e5cef399 | ||
|
|
92121d7bbe | ||
|
|
aced08c860 | ||
|
|
4e1cb0b2b5 | ||
|
|
aa7173fc69 | ||
|
|
597f0d2019 | ||
|
|
c48ce9af8c | ||
|
|
531269c60e | ||
|
|
6057297f44 | ||
|
|
4b381350a1 |
11
README.md
11
README.md
@@ -12,6 +12,8 @@
|
|||||||

|

|
||||||

|

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

|
||||||
|
|
||||||
Demo: 👍 [Butterfly](https://butterfly.js.org/) || 🤞 [MYW](https://immyw.com/)
|
Demo: 👍 [Butterfly](https://butterfly.js.org/) || 🤞 [MYW](https://immyw.com/)
|
||||||
|
|
||||||
Docs: 📖 [Butterfly Docs](https://butterfly.js.org/posts/21cfbf15/)
|
Docs: 📖 [Butterfly Docs](https://butterfly.js.org/posts/21cfbf15/)
|
||||||
@@ -80,9 +82,9 @@ npm i hexo-theme-butterfly
|
|||||||
- [X] Comment (Disqus/Disqusjs/Livere/Gitalk/Valine/Waline/Utterances/Facebook Comments/Twikoo)
|
- [X] Comment (Disqus/Disqusjs/Livere/Gitalk/Valine/Waline/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
|
||||||
- [x] Google AdSense
|
- [x] Google AdSense
|
||||||
- [x] Webmaster Verification (google/Bing/Baidu/360/Yandex)
|
- [x] Webmaster Verification
|
||||||
- [x] Change website colour scheme
|
- [x] Change website colour scheme
|
||||||
- [x] Typewriter Effect: activate_power_mode
|
- [x] Typewriter Effect: activate_power_mode
|
||||||
- [x] Background effects (Canvas ribbon/canvas_ribbon_piao/canvas_nest)
|
- [x] Background effects (Canvas ribbon/canvas_ribbon_piao/canvas_nest)
|
||||||
@@ -97,6 +99,9 @@ npm i hexo-theme-butterfly
|
|||||||
|
|
||||||
## Screenshots
|
## Screenshots
|
||||||
|
|
||||||
|

|
||||||
|

|
||||||
|

|
||||||
|

|
||||||

|

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

|

|
||||||
@@ -12,6 +12,8 @@
|
|||||||

|

|
||||||

|

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

|
||||||
|
|
||||||
預覽: 👍 [Butterfly](https://butterfly.js.org/) || 🤞 [MYW](https://immyw.com/)
|
預覽: 👍 [Butterfly](https://butterfly.js.org/) || 🤞 [MYW](https://immyw.com/)
|
||||||
|
|
||||||
文檔: 📖 [Butterfly Docs](https://butterfly.js.org/posts/21cfbf15/)
|
文檔: 📖 [Butterfly Docs](https://butterfly.js.org/posts/21cfbf15/)
|
||||||
@@ -79,7 +81,7 @@ theme: butterfly
|
|||||||
- [X] 多種評論系統(Disqus/Disqusjs/Livere/Gitalk/Valine/Waline/Utterances/Facebook Comments/Twikoo)
|
- [X] 多種評論系統(Disqus/Disqusjs/Livere/Gitalk/Valine/Waline/Utterances/Facebook Comments/Twikoo)
|
||||||
- [x] 支持雙評論部署
|
- [x] 支持雙評論部署
|
||||||
- [x] 多種在線聊天(Chatra/Tidio/Daovoice/Gitter/Crisp)
|
- [x] 多種在線聊天(Chatra/Tidio/Daovoice/Gitter/Crisp)
|
||||||
- [x] 多種分析系統(百度分析/谷歌分析/騰訊分析/CNZZ分析)
|
- [x] 多種分析系統
|
||||||
- [x] 谷歌廣告/手動廣告位置
|
- [x] 谷歌廣告/手動廣告位置
|
||||||
- [x] 各種站長驗證(Google/Bing/Baidu/360/Yandex)
|
- [x] 各種站長驗證(Google/Bing/Baidu/360/Yandex)
|
||||||
- [x] 修改網站配色
|
- [x] 修改網站配色
|
||||||
@@ -96,6 +98,9 @@ theme: butterfly
|
|||||||
|
|
||||||
## 截圖
|
## 截圖
|
||||||
|
|
||||||
|

|
||||||
|

|
||||||
|

|
||||||
|

|
||||||

|

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

|

|
||||||
32
_config.yml
32
_config.yml
@@ -4,7 +4,7 @@
|
|||||||
# format: name: link || icon
|
# format: name: link || icon
|
||||||
# sub-menu
|
# sub-menu
|
||||||
# name || icon:
|
# name || icon:
|
||||||
# name || link || icon
|
# name: link || icon
|
||||||
|
|
||||||
menu:
|
menu:
|
||||||
# Home: / || fas fa-home
|
# Home: / || fas fa-home
|
||||||
@@ -459,25 +459,11 @@ google_adsense:
|
|||||||
# Verification (站長驗證)
|
# Verification (站長驗證)
|
||||||
# --------------------------------------
|
# --------------------------------------
|
||||||
|
|
||||||
# Google Webmaster tools verification setting
|
site_verification:
|
||||||
# See: https://www.google.com/webmasters/
|
# - name: google_site_verification
|
||||||
google_site_verification:
|
# content: xxxxxx
|
||||||
|
# - name: baidu_site_verification
|
||||||
# Bing Webmaster tools verification setting
|
# content: xxxxxxx
|
||||||
# See: https://www.bing.com/webmaster/
|
|
||||||
bing_site_verification:
|
|
||||||
|
|
||||||
# Baidu Webmaster tools verification setting
|
|
||||||
# See: https://ziyuan.baidu.com/site/
|
|
||||||
baidu_site_verification:
|
|
||||||
|
|
||||||
# 360 Webmaster tools verification setting
|
|
||||||
# see http://zhanzhang.so.com/
|
|
||||||
qihu_site_verification:
|
|
||||||
|
|
||||||
# Yandex Webmaster tools verification setting
|
|
||||||
# see https://webmaster.yandex.com/
|
|
||||||
yandex_site_verification:
|
|
||||||
|
|
||||||
# Beautify/Effect (美化/效果)
|
# Beautify/Effect (美化/效果)
|
||||||
# --------------------------------------
|
# --------------------------------------
|
||||||
@@ -828,10 +814,12 @@ pangu:
|
|||||||
field: site # site/post
|
field: site # site/post
|
||||||
|
|
||||||
# Lazyload (圖片懶加載)
|
# Lazyload (圖片懶加載)
|
||||||
# https://github.com/verlok/lazyload
|
# https://github.com/verlok/vanilla-lazyload
|
||||||
lazyload:
|
lazyload:
|
||||||
enable: false
|
enable: false
|
||||||
post: /img/loading.gif
|
field: site # site/post
|
||||||
|
placeholder:
|
||||||
|
blur: false
|
||||||
|
|
||||||
# PWA
|
# PWA
|
||||||
# See https://github.com/JLHwung/hexo-offline
|
# See https://github.com/JLHwung/hexo-offline
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
- var top_img = theme.error_404.background || theme.default_top_img
|
|
||||||
- var bg_img = `background-image: url('${url_for(top_img)}')`
|
|
||||||
|
|
||||||
doctype html
|
|
||||||
html(lang=config.language data-theme=theme.display_mode)
|
|
||||||
head
|
|
||||||
include includes/head.pug
|
|
||||||
body
|
|
||||||
if theme.preloader
|
|
||||||
!=partial('includes/loading/loading', {}, {cache: true})
|
|
||||||
|
|
||||||
if theme.fireworks && theme.fireworks.enable
|
|
||||||
canvas.fireworks
|
|
||||||
|
|
||||||
if theme.background
|
|
||||||
#web_bg
|
|
||||||
|
|
||||||
#error-wrap
|
|
||||||
.error-content
|
|
||||||
.error-img(style=bg_img)
|
|
||||||
.error-info
|
|
||||||
h1.error_title= '404'
|
|
||||||
.error_subtitle= theme.error_404.subtitle
|
|
||||||
a.button--animated(href=config.root)
|
|
||||||
i.fas.fa-rocket
|
|
||||||
= _p('error404.back_button')
|
|
||||||
|
|
||||||
include includes/additional-js.pug
|
|
||||||
17
layout/includes/404.pug
Normal file
17
layout/includes/404.pug
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
- var top_img = theme.error_404.background || theme.default_top_img
|
||||||
|
- var bg_img = `background-image: url('${url_for(top_img)}')`
|
||||||
|
|
||||||
|
#body-wrap.error
|
||||||
|
div(style='display: none')
|
||||||
|
include ./header/index.pug
|
||||||
|
|
||||||
|
#error-wrap
|
||||||
|
.error-content
|
||||||
|
.error-img(style=bg_img)
|
||||||
|
.error-info
|
||||||
|
h1.error_title= '404'
|
||||||
|
.error_subtitle= theme.error_404.subtitle
|
||||||
|
a.button--animated(href=config.root)
|
||||||
|
i.fas.fa-rocket
|
||||||
|
= _p('error404.back_button')
|
||||||
|
|
||||||
@@ -6,14 +6,16 @@
|
|||||||
|
|
||||||
var 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
|
||||||
var 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 )
|
||||||
|
|
||||||
|
let titleVal = pageTitle.replace(/'/ig,"\\'")
|
||||||
-
|
-
|
||||||
|
|
||||||
script#config-diff
|
script#config-diff.
|
||||||
.
|
var GLOBAL_CONFIG_SITE = {
|
||||||
var GLOBAL_CONFIG_SITE = {
|
title: '!{titleVal}',
|
||||||
isPost: !{is_post()},
|
isPost: !{is_post()},
|
||||||
isHome: !{is_home()},
|
isHome: !{is_home()},
|
||||||
isHighlightShrink: !{isHighlightShrink},
|
isHighlightShrink: !{isHighlightShrink},
|
||||||
isToc: !{showToc},
|
isToc: !{showToc},
|
||||||
postUpdate: '!{full_date(page.updated)}'
|
postUpdate: '!{full_date(page.updated)}'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,3 @@
|
|||||||
if theme.google_site_verification
|
if theme.site_verification
|
||||||
meta(name="google-site-verification" content=theme.google_site_verification)
|
each item in theme.site_verification
|
||||||
|
meta(name=item.name content=item.content)
|
||||||
if theme.bing_site_verification
|
|
||||||
meta(name="msvalidate.01" content=theme.bing_site_verification)
|
|
||||||
|
|
||||||
if theme.baidu_site_verification
|
|
||||||
meta(name="baidu-site-verification" content=theme.baidu_site_verification)
|
|
||||||
|
|
||||||
if theme.qihu_site_verification
|
|
||||||
meta(name="360-site-verification" content=theme.qihu_site_verification)
|
|
||||||
|
|
||||||
if theme.yandex_site_verification
|
|
||||||
meta(name="yandex-verification" content=theme.yandex_site_verification)
|
|
||||||
@@ -15,28 +15,32 @@ html(lang=config.language data-theme=theme.display_mode class=htmlClassHideAside
|
|||||||
|
|
||||||
!=partial('includes/sidebar', {}, {cache: true})
|
!=partial('includes/sidebar', {}, {cache: true})
|
||||||
|
|
||||||
#body-wrap(class=pageType)
|
if page.type !== '404'
|
||||||
include ./header/index.pug
|
#body-wrap(class=pageType)
|
||||||
|
include ./header/index.pug
|
||||||
|
|
||||||
main#content-inner.layout(class=hideAside)
|
main#content-inner.layout(class=hideAside)
|
||||||
if body
|
if body
|
||||||
div!= body
|
div!= body
|
||||||
|
else
|
||||||
|
block content
|
||||||
|
if theme.aside.enable && page.aside !== false
|
||||||
|
include widget/index.pug
|
||||||
|
|
||||||
|
- var footerBg = theme.footer_bg
|
||||||
|
if (footerBg)
|
||||||
|
if (footerBg === true)
|
||||||
|
- var footer_bg = bg_img
|
||||||
|
else
|
||||||
|
- var footer_bg = theme.footer_bg.indexOf('/') !== -1 ? `background-image: url('${url_for(footerBg)}')` : `background: ${footerBg}`
|
||||||
else
|
else
|
||||||
block content
|
- var footer_bg = ''
|
||||||
if theme.aside.enable && page.aside !== false
|
|
||||||
include widget/index.pug
|
|
||||||
|
|
||||||
- var footerBg = theme.footer_bg
|
footer#footer(style=footer_bg)
|
||||||
if (footerBg)
|
!=partial('includes/footer', {}, {cache: true})
|
||||||
if (footerBg === true)
|
|
||||||
- var footer_bg = bg_img
|
|
||||||
else
|
|
||||||
- var footer_bg = theme.footer_bg.indexOf('/') !== -1 ? `background-image: url('${url_for(footerBg)}')` : `background: ${footerBg}`
|
|
||||||
else
|
|
||||||
- var footer_bg = ''
|
|
||||||
|
|
||||||
footer#footer(style=footer_bg)
|
else
|
||||||
!=partial('includes/footer', {}, {cache: true})
|
include ./404.pug
|
||||||
|
|
||||||
include ./rightside.pug
|
include ./rightside.pug
|
||||||
!=partial('includes/third-party/search/index', {}, {cache: true})
|
!=partial('includes/third-party/search/index', {}, {cache: true})
|
||||||
|
|||||||
@@ -11,10 +11,7 @@ mixin articleSort(posts)
|
|||||||
.article-sort-item(class=no_cover)
|
.article-sort-item(class=no_cover)
|
||||||
if article.cover && theme.cover.archives_enable
|
if article.cover && theme.cover.archives_enable
|
||||||
a.article-sort-item-img(href=url_for(article.path) title=title)
|
a.article-sort-item-img(href=url_for(article.path) title=title)
|
||||||
if theme.lazyload.enable
|
img(src=url_for(article.cover) alt=title onerror=`this.onerror=null;this.src='${url_for(theme.error_img.post_page)}'`)
|
||||||
img(data-lazy-src=url_for(article.cover) alt=title onerror=`this.onerror=null;this.src='${url_for(theme.error_img.post_page)}'`)
|
|
||||||
else
|
|
||||||
img(src=url_for(article.cover) alt=title onerror=`this.onerror=null;this.src='${url_for(theme.error_img.post_page)}'`)
|
|
||||||
.article-sort-item-info
|
.article-sort-item-info
|
||||||
.article-sort-item-time
|
.article-sort-item-time
|
||||||
i.far.fa-calendar-alt
|
i.far.fa-calendar-alt
|
||||||
|
|||||||
@@ -9,10 +9,7 @@ mixin postUI(posts)
|
|||||||
if post_cover && theme.cover.index_enable
|
if post_cover && theme.cover.index_enable
|
||||||
.post_cover(class=leftOrRight)
|
.post_cover(class=leftOrRight)
|
||||||
a(href=url_for(link) title=title)
|
a(href=url_for(link) title=title)
|
||||||
if theme.lazyload.enable
|
img.post_bg(src=url_for(post_cover) onerror=`this.onerror=null;this.src='`+ url_for(theme.error_img.post_page) + `'` alt=title)
|
||||||
img.post_bg(data-lazy-src=url_for(post_cover) onerror=`this.onerror=null;this.src='`+ url_for(theme.error_img.post_page) + `'` alt=title)
|
|
||||||
else
|
|
||||||
img.post_bg(src=url_for(post_cover) onerror=`this.onerror=null;this.src='`+ url_for(theme.error_img.post_page) + `'` alt=title)
|
|
||||||
.recent-post-info(class=no_cover)
|
.recent-post-info(class=no_cover)
|
||||||
a.article-title(href=url_for(link) title=title)= title
|
a.article-title(href=url_for(link) title=title)= title
|
||||||
.article-meta-wrap
|
.article-meta-wrap
|
||||||
|
|||||||
@@ -13,10 +13,7 @@
|
|||||||
each item in i.link_list
|
each item in i.link_list
|
||||||
.flink-list-item
|
.flink-list-item
|
||||||
a(href=url_for(item.link) title=item.name target="_blank")
|
a(href=url_for(item.link) title=item.name target="_blank")
|
||||||
if theme.lazyload.enable
|
img(src=url_for(item.avatar) onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.flink) + `'` alt=item.name )
|
||||||
img(data-lazy-src=url_for(item.avatar) onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.flink) + `'` alt=item.name )
|
|
||||||
else
|
|
||||||
img(src=url_for(item.avatar) onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.flink) + `'` alt=item.name )
|
|
||||||
span.flink-item-name= item.name
|
span.flink-item-name= item.name
|
||||||
span.flink-item-desc(title=item.descr)= item.descr
|
span.flink-item-desc(title=item.descr)= item.descr
|
||||||
!= page.content
|
!= page.content
|
||||||
|
|||||||
@@ -15,10 +15,7 @@ if is_post()
|
|||||||
.prev-post(class=hasPageNext)
|
.prev-post(class=hasPageNext)
|
||||||
- var pagination_cover = prev.cover === false ? prev.randomcover : prev.cover
|
- var pagination_cover = prev.cover === false ? prev.randomcover : prev.cover
|
||||||
a(href=url_for(prev.path))
|
a(href=url_for(prev.path))
|
||||||
if theme.lazyload.enable
|
img.prev-cover(src=url_for(pagination_cover) onerror=`onerror=null;src='${url_for(theme.error_img.post_page)}'` alt='cover of previous post')
|
||||||
img.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
|
|
||||||
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=prev.title
|
.prev_info=prev.title
|
||||||
@@ -28,10 +25,7 @@ if is_post()
|
|||||||
- var pagination_cover = next.cover == false ? next.randomcover : next.cover
|
- var pagination_cover = next.cover == false ? next.randomcover : next.cover
|
||||||
.next-post(class=hasPagePrev)
|
.next-post(class=hasPagePrev)
|
||||||
a(href=url_for(next.path))
|
a(href=url_for(next.path))
|
||||||
if theme.lazyload.enable
|
img.next-cover(src=url_for(pagination_cover) onerror=`onerror=null;src='${url_for(theme.error_img.post_page)}'` alt='cover of next post')
|
||||||
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
|
|
||||||
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=next.title
|
.next_info=next.title
|
||||||
|
|||||||
@@ -8,9 +8,6 @@
|
|||||||
- var clickTo = item.link ? item.link : item.img
|
- var clickTo = item.link ? item.link : item.img
|
||||||
li.reward-item
|
li.reward-item
|
||||||
a(href=url_for(clickTo) target='_blank')
|
a(href=url_for(clickTo) target='_blank')
|
||||||
if theme.lazyload.enable
|
img.post-qr-code-img(src=url_for(item.img) alt=item.text)
|
||||||
img.post-qr-code-img(data-lazy-src=url_for(item.img) alt=item.text)
|
|
||||||
else
|
|
||||||
img.post-qr-code-img(src=url_for(item.img) alt=item.text)
|
|
||||||
.post-qr-code-desc=item.text
|
.post-qr-code-desc=item.text
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,7 @@
|
|||||||
#menu-mask
|
#menu-mask
|
||||||
#sidebar-menus
|
#sidebar-menus
|
||||||
.author-avatar
|
.author-avatar
|
||||||
if theme.lazyload.enable
|
img.avatar-img(src=url_for(theme.avatar.img) onerror=`onerror=null;src='${theme.error_img.flink}'` alt="avatar")
|
||||||
img.avatar-img(data-lazy-src=url_for(theme.avatar.img) onerror=`onerror=null;src='${theme.error_img.flink}'` alt="avatar")
|
|
||||||
else
|
|
||||||
img.avatar-img(src=url_for(theme.avatar.img) onerror=`onerror=null;src='${theme.error_img.flink}'` alt="avatar")
|
|
||||||
.site-data
|
.site-data
|
||||||
if site.posts.length
|
if site.posts.length
|
||||||
.data-item.is-center
|
.data-item.is-center
|
||||||
|
|||||||
@@ -57,3 +57,4 @@ if is_post() && !theme.comments.lazyload && theme.comments.count && theme.commen
|
|||||||
} else {
|
} else {
|
||||||
DISQUSWIDGETS.getCount({reset: true});
|
DISQUSWIDGETS.getCount({reset: true});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ script.
|
|||||||
path: location.pathname,
|
path: location.pathname,
|
||||||
emojiCDN: '#{theme.waline.emojiCDN}',
|
emojiCDN: '#{theme.waline.emojiCDN}',
|
||||||
emojiMaps: !{emojiMaps},
|
emojiMaps: !{emojiMaps},
|
||||||
visitor: #{theme.waline.visitor}
|
visitor: #{theme.waline.visitor},
|
||||||
|
dark: '[data-theme="dark"]'
|
||||||
}, !{JSON.stringify(theme.waline.option)}))
|
}, !{JSON.stringify(theme.waline.option)}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -103,3 +103,7 @@ script.
|
|||||||
newestCommentInit()
|
newestCommentInit()
|
||||||
document.addEventListener('pjax:complete', newestCommentInit)
|
document.addEventListener('pjax:complete', newestCommentInit)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
43
layout/includes/third-party/pjax.pug
vendored
43
layout/includes/third-party/pjax.pug
vendored
@@ -26,6 +26,29 @@ script.
|
|||||||
scrollRestoration: false
|
scrollRestoration: false
|
||||||
})
|
})
|
||||||
|
|
||||||
|
document.addEventListener('pjax:send', function () {
|
||||||
|
|
||||||
|
// removeEventListener toc scroll
|
||||||
|
window.removeEventListener('scroll', window.tocScrollFn)
|
||||||
|
|
||||||
|
typeof preloader === 'object' && preloader.initLoading()
|
||||||
|
|
||||||
|
if (window.aplayers) {
|
||||||
|
for (let i = 0; i < window.aplayers.length; i++) {
|
||||||
|
if (!window.aplayers[i].options.fixed) {
|
||||||
|
window.aplayers[i].destroy()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
typeof typed === 'object' && typed.destroy()
|
||||||
|
|
||||||
|
//reset readmode
|
||||||
|
const $bodyClassList = document.body.classList
|
||||||
|
$bodyClassList.contains('read-mode') && $bodyClassList.remove('read-mode')
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
document.addEventListener('pjax:complete', function () {
|
document.addEventListener('pjax:complete', function () {
|
||||||
window.refreshFn()
|
window.refreshFn()
|
||||||
|
|
||||||
@@ -61,26 +84,6 @@ script.
|
|||||||
typeof preloader === 'object' && preloader.endLoading()
|
typeof preloader === 'object' && preloader.endLoading()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
document.addEventListener('pjax:send', function () {
|
|
||||||
typeof preloader === 'object' && preloader.initLoading()
|
|
||||||
|
|
||||||
if (window.aplayers) {
|
|
||||||
for (let i = 0; i < window.aplayers.length; i++) {
|
|
||||||
if (!window.aplayers[i].options.fixed) {
|
|
||||||
window.aplayers[i].destroy()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
typeof typed === 'object' && typed.destroy()
|
|
||||||
|
|
||||||
//reset readmode
|
|
||||||
const $bodyClassList = document.body.classList
|
|
||||||
$bodyClassList.contains('read-mode') && $bodyClassList.remove('read-mode')
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
document.addEventListener('pjax:error', (e) => {
|
document.addEventListener('pjax:error', (e) => {
|
||||||
if (e.request.status === 404) {
|
if (e.request.status === 404) {
|
||||||
pjax.loadUrl('/404.html')
|
pjax.loadUrl('/404.html')
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
if theme.aside.card_author.enable
|
if theme.aside.card_author.enable
|
||||||
.card-widget.card-info
|
.card-widget.card-info
|
||||||
.card-info-avatar.is-center
|
.card-info-avatar.is-center
|
||||||
if theme.lazyload.enable
|
img.avatar-img(src=url_for(theme.avatar.img) onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.flink) + `'` alt="avatar")
|
||||||
img.avatar-img(data-lazy-src=url_for(theme.avatar.img) onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.flink) + `'` alt="avatar")
|
|
||||||
else
|
|
||||||
img.avatar-img(src=url_for(theme.avatar.img) onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.flink) + `'` alt="avatar")
|
|
||||||
.author-info__name= config.author
|
.author-info__name= config.author
|
||||||
.author-info__description!= theme.aside.card_author.description || config.description
|
.author-info__description!= theme.aside.card_author.description || config.description
|
||||||
|
|
||||||
|
|||||||
@@ -14,10 +14,7 @@ if theme.aside.card_recent_post.enable
|
|||||||
.aside-list-item(class=no_cover)
|
.aside-list-item(class=no_cover)
|
||||||
if post_cover && theme.cover.aside_enable
|
if post_cover && theme.cover.aside_enable
|
||||||
a.thumbnail(href=url_for(link) title=title)
|
a.thumbnail(href=url_for(link) title=title)
|
||||||
if theme.lazyload.enable
|
img(src=url_for(post_cover) onerror=`this.onerror=null;this.src='${url_for(theme.error_img.post_page)}'` alt=title)
|
||||||
img(data-lazy-src=url_for(post_cover) onerror=`this.onerror=null;this.src='${url_for(theme.error_img.post_page)}'` alt=title)
|
|
||||||
else
|
|
||||||
img(src=url_for(post_cover) onerror=`this.onerror=null;this.src='${url_for(theme.error_img.post_page)}'` alt=title)
|
|
||||||
.content
|
.content
|
||||||
a.title(href=url_for(link) title=title)= title
|
a.title(href=url_for(link) title=title)= title
|
||||||
if theme.aside.card_recent_post.sort === 'updated'
|
if theme.aside.card_recent_post.sort === 'updated'
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hexo-theme-butterfly",
|
"name": "hexo-theme-butterfly",
|
||||||
"version": "3.7.1",
|
"version": "3.7.7",
|
||||||
"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": {
|
||||||
|
|||||||
@@ -9,7 +9,10 @@ hexo.extend.generator.register('404', function (locals) {
|
|||||||
if (!hexo.theme.config.error_404.enable) return
|
if (!hexo.theme.config.error_404.enable) return
|
||||||
return {
|
return {
|
||||||
path: '404.html',
|
path: '404.html',
|
||||||
data: locals.posts,
|
layout: ['page'],
|
||||||
layout: ['404']
|
data: {
|
||||||
|
type: '404',
|
||||||
|
top_img: false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ const logger = require('hexo-log')()
|
|||||||
|
|
||||||
hexo.extend.filter.register('before_generate', () => {
|
hexo.extend.filter.register('before_generate', () => {
|
||||||
// Get first two digits of the Hexo version number
|
// Get first two digits of the Hexo version number
|
||||||
var hexoVer = hexo.version.replace(/(^.*\..*)\..*/, '$1')
|
const hexoVer = hexo.version.replace(/(^.*\..*)\..*/, '$1')
|
||||||
|
|
||||||
if (hexoVer < 5) {
|
if (hexoVer < 5) {
|
||||||
logger.error('Please update Hexo to V5.0.0 or higher!')
|
logger.error('Please update Hexo to V5.0.0 or higher!')
|
||||||
|
|||||||
@@ -8,9 +8,22 @@
|
|||||||
|
|
||||||
const urlFor = require('hexo-util').url_for.bind(hexo)
|
const urlFor = require('hexo-util').url_for.bind(hexo)
|
||||||
|
|
||||||
|
function lazyload (htmlContent) {
|
||||||
|
const bg = hexo.theme.config.lazyload.placeholder ? urlFor(hexo.theme.config.lazyload.placeholder) : 'data:image/gif;base64,R0lGODdhAQABAPAAAMPDwwAAACwAAAAAAQABAAACAkQBADs='
|
||||||
|
return htmlContent.replace(/(<img.*? src=)/ig, `$1 "${bg}" data-lazy-src=`)
|
||||||
|
}
|
||||||
|
|
||||||
|
hexo.extend.filter.register('after_render:html', function (data) {
|
||||||
|
const config = hexo.theme.config.lazyload
|
||||||
|
if (!config.enable) return
|
||||||
|
if (config.field !== 'site') return
|
||||||
|
return lazyload.call(this, data)
|
||||||
|
})
|
||||||
|
|
||||||
hexo.extend.filter.register('after_post_render', data => {
|
hexo.extend.filter.register('after_post_render', data => {
|
||||||
if (!hexo.theme.config.lazyload.enable) return
|
const config = hexo.theme.config.lazyload
|
||||||
const bg = hexo.theme.config.lazyload.post ? urlFor(hexo.theme.config.lazyload.post) : 'data:image/gif;base64,R0lGODdhAQABAPAAAMPDwwAAACwAAAAAAQABAAACAkQBADs='
|
if (!config.enable) return
|
||||||
data.content = data.content.replace(/(<img.*? src=)/ig, `$1 "${bg}" data-lazy-src=`)
|
if (config.field !== 'post') return
|
||||||
|
data.content = lazyload.call(this, data.content)
|
||||||
return data
|
return data
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ hexo.extend.helper.register('related_posts', function (currentPost, allPosts) {
|
|||||||
const limitNum = config.related_post.limit || 6
|
const limitNum = config.related_post.limit || 6
|
||||||
const dateType = config.related_post.date_type || 'created'
|
const dateType = config.related_post.date_type || 'created'
|
||||||
const headlineLang = this._p('post.recommend')
|
const headlineLang = this._p('post.recommend')
|
||||||
const lazySrc = config.lazyload.enable ? 'data-lazy-src' : 'src'
|
|
||||||
|
|
||||||
relatedPosts = relatedPosts.sort(compare('weight'))
|
relatedPosts = relatedPosts.sort(compare('weight'))
|
||||||
|
|
||||||
@@ -67,9 +66,7 @@ hexo.extend.helper.register('related_posts', function (currentPost, allPosts) {
|
|||||||
relatedPosts[i].title +
|
relatedPosts[i].title +
|
||||||
'">'
|
'">'
|
||||||
result +=
|
result +=
|
||||||
'<img class="cover" ' +
|
'<img class="cover" src="' +
|
||||||
lazySrc +
|
|
||||||
'="' +
|
|
||||||
this.url_for(cover) +
|
this.url_for(cover) +
|
||||||
'" alt="cover">'
|
'" alt="cover">'
|
||||||
if (dateType === 'created') {
|
if (dateType === 'created') {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ function btn (args) {
|
|||||||
option = option.trim()
|
option = option.trim()
|
||||||
|
|
||||||
return `<a class="btn-beautify button--animated ${option}" href="${urlFor(url)}"
|
return `<a class="btn-beautify button--animated ${option}" href="${urlFor(url)}"
|
||||||
title="${text}">${icon.length > 0 ? `<i class="${icon} fa-fw"></i>` : ''}<span>${text}</span></a>`
|
title="${text}">${icon.length ? `<i class="${icon}"></i>` : ''}${text.length ? `<span>${text}</span>` : ''}</a>`
|
||||||
}
|
}
|
||||||
|
|
||||||
hexo.extend.tag.register('btn', btn, { ends: false })
|
hexo.extend.tag.register('btn', btn, { ends: false })
|
||||||
|
|||||||
16
scripts/tag/label.js
Normal file
16
scripts/tag/label.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
/**
|
||||||
|
* Butterfly
|
||||||
|
* label
|
||||||
|
* {% label text color %}
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
function addLabel (args, content) {
|
||||||
|
const text = args[0]
|
||||||
|
const className = args[1] || 'default'
|
||||||
|
|
||||||
|
return `<mark class="hl-label ${className}">${text}</mark> `
|
||||||
|
}
|
||||||
|
|
||||||
|
hexo.extend.tag.register('label', addLabel, { ends: false })
|
||||||
@@ -206,6 +206,15 @@ img
|
|||||||
&:not([src])
|
&:not([src])
|
||||||
opacity: 0
|
opacity: 0
|
||||||
|
|
||||||
|
// lazyload blur
|
||||||
|
if hexo-config('lazyload.enable') && hexo-config('lazyload.blur') && !hexo-config('lazyload.placeholder')
|
||||||
|
img
|
||||||
|
&[data-lazy-src]:not(.loaded)
|
||||||
|
filter: blur(10px) brightness(1)
|
||||||
|
|
||||||
|
&[data-lazy-src].error
|
||||||
|
filter: none
|
||||||
|
|
||||||
.img-alt
|
.img-alt
|
||||||
margin: -.5rem 0 .5rem
|
margin: -.5rem 0 .5rem
|
||||||
color: #858585
|
color: #858585
|
||||||
|
|||||||
@@ -185,6 +185,9 @@ no-beautify()
|
|||||||
else
|
else
|
||||||
no-beautify()
|
no-beautify()
|
||||||
|
|
||||||
|
> :last-child
|
||||||
|
margin-bottom: 0 !important
|
||||||
|
|
||||||
#post
|
#post
|
||||||
.tag_share
|
.tag_share
|
||||||
.post-meta
|
.post-meta
|
||||||
|
|||||||
@@ -91,14 +91,20 @@ if hexo-config('darkmode.enable') || hexo-config('display_mode') == 'dark'
|
|||||||
.hide-button,
|
.hide-button,
|
||||||
.btn-beautify,
|
.btn-beautify,
|
||||||
.mermaid,
|
.mermaid,
|
||||||
|
.hl-label,
|
||||||
.post-outdate-notice,
|
.post-outdate-notice,
|
||||||
.error-img,
|
.error-img,
|
||||||
#article-container iframe,
|
#article-container iframe,
|
||||||
img,
|
|
||||||
.gist,
|
.gist,
|
||||||
.ads-wrap
|
.ads-wrap
|
||||||
filter: brightness(.8)
|
filter: brightness(.8)
|
||||||
|
|
||||||
|
img
|
||||||
|
if hexo-config('lazyload.enable') && hexo-config('lazyload.blur') && !hexo-config('lazyload.placeholder')
|
||||||
|
filter: blur(0) brightness(.8)
|
||||||
|
else
|
||||||
|
filter: brightness(.8)
|
||||||
|
|
||||||
#aside-content .aside-list > .aside-list-item:not(:last-child)
|
#aside-content .aside-list > .aside-list-item:not(:last-child)
|
||||||
border-bottom: 1px dashed alpha(#FFFFFF, .1)
|
border-bottom: 1px dashed alpha(#FFFFFF, .1)
|
||||||
|
|
||||||
|
|||||||
@@ -173,24 +173,15 @@ if hexo-config('readmode')
|
|||||||
border: 1px solid var(--gray) !important
|
border: 1px solid var(--gray) !important
|
||||||
|
|
||||||
.hide-button,
|
.hide-button,
|
||||||
.btn-beautify
|
.btn-beautify,
|
||||||
|
.hl-label
|
||||||
|
border: 1px solid var(--gray) !important
|
||||||
background: var(--readmode-light-color) !important
|
background: var(--readmode-light-color) !important
|
||||||
color: var(--font-color) !important
|
color: var(--font-color) !important
|
||||||
|
|
||||||
.btn-beautify
|
|
||||||
border: 1px solid var(--gray) !important
|
|
||||||
|
|
||||||
.button--animated:before
|
.button--animated:before
|
||||||
background: var(--readmode-light-color) !important
|
background: var(--readmode-light-color) !important
|
||||||
|
|
||||||
.hide-inline,
|
|
||||||
.hide-block
|
|
||||||
& >.hide-button
|
|
||||||
border: 1px solid var(--gray)
|
|
||||||
|
|
||||||
& > .button--animated:before
|
|
||||||
background: var(--readmode-light-color)
|
|
||||||
|
|
||||||
.note
|
.note
|
||||||
border: 2px solid var(--gray)
|
border: 2px solid var(--gray)
|
||||||
border-left-color: var(--gray) !important
|
border-left-color: var(--gray) !important
|
||||||
|
|||||||
@@ -11,6 +11,9 @@
|
|||||||
color: $btn-color
|
color: $btn-color
|
||||||
line-height: 2
|
line-height: 2
|
||||||
|
|
||||||
|
i + span
|
||||||
|
margin-left: .3rem
|
||||||
|
|
||||||
&:not(.block) + .btn-beautify:not(.block)
|
&:not(.block) + .btn-beautify:not(.block)
|
||||||
margin: 0 .2rem 1rem
|
margin: 0 .2rem 1rem
|
||||||
|
|
||||||
|
|||||||
11
source/css/_tags/label.styl
Normal file
11
source/css/_tags/label.styl
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
.hl-label
|
||||||
|
padding: 2px 4px
|
||||||
|
border-radius: 3px
|
||||||
|
color: $btn-color
|
||||||
|
|
||||||
|
&.default
|
||||||
|
background-color: $btn-default-color
|
||||||
|
|
||||||
|
for $type in $tagsP-types
|
||||||
|
&.{$type}
|
||||||
|
background-color: lookup('$tagsP-' + $type + '-color')
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 45 KiB |
@@ -388,11 +388,14 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
const $article = document.getElementById('article-container')
|
const $article = document.getElementById('article-container')
|
||||||
|
|
||||||
// main of scroll
|
// main of scroll
|
||||||
window.addEventListener('scroll', btf.throttle(function (e) {
|
window.tocScrollFn = function () {
|
||||||
const currentTop = window.scrollY || document.documentElement.scrollTop
|
return btf.throttle(function () {
|
||||||
scrollPercent(currentTop)
|
const currentTop = window.scrollY || document.documentElement.scrollTop
|
||||||
findHeadPosition(currentTop)
|
scrollPercent(currentTop)
|
||||||
}, 100))
|
findHeadPosition(currentTop)
|
||||||
|
}, 100)()
|
||||||
|
}
|
||||||
|
window.addEventListener('scroll', tocScrollFn)
|
||||||
|
|
||||||
const scrollPercent = function (currentTop) {
|
const scrollPercent = function (currentTop) {
|
||||||
const docHeight = $article.clientHeight
|
const docHeight = $article.clientHeight
|
||||||
@@ -410,7 +413,11 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
const updateAnchor = function (anchor) {
|
const updateAnchor = function (anchor) {
|
||||||
if (window.history.replaceState && anchor !== window.location.hash) {
|
if (window.history.replaceState && anchor !== window.location.hash) {
|
||||||
if (!anchor) anchor = location.pathname
|
if (!anchor) anchor = location.pathname
|
||||||
window.history.replaceState({}, '', anchor)
|
const title = GLOBAL_CONFIG_SITE.title
|
||||||
|
window.history.replaceState({
|
||||||
|
url: location.href,
|
||||||
|
title: title
|
||||||
|
}, title, anchor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user