mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-10 21:17:07 +08:00
Compare commits
57 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f0eaf2d8b0 | ||
|
|
9e6958f25b | ||
|
|
36527a3b81 | ||
|
|
c439930786 | ||
|
|
f4e5cef399 | ||
|
|
92121d7bbe | ||
|
|
aced08c860 | ||
|
|
4e1cb0b2b5 | ||
|
|
aa7173fc69 | ||
|
|
597f0d2019 | ||
|
|
c48ce9af8c | ||
|
|
531269c60e | ||
|
|
637da0702b | ||
|
|
6057297f44 | ||
|
|
4b381350a1 | ||
|
|
6904850044 | ||
|
|
4c5abe0cc5 | ||
|
|
e8cfc6e083 | ||
|
|
823dc03090 | ||
|
|
24cf0a11e6 | ||
|
|
a7e512d764 | ||
|
|
4a69c623fc | ||
|
|
eb823b0a2d | ||
|
|
8f412c90da | ||
|
|
6a1330de84 | ||
|
|
eb5a356a4e | ||
|
|
f4b07340f7 | ||
|
|
17d8062968 | ||
|
|
d4b69051aa | ||
|
|
59f6ce63e3 | ||
|
|
cd78f639dd | ||
|
|
8e4c20f6d4 | ||
|
|
e984efa35c | ||
|
|
863cf1e780 | ||
|
|
85b8a83371 | ||
|
|
d73960f2a2 | ||
|
|
fcd430902d | ||
|
|
ee45f6517f | ||
|
|
67201ac58d | ||
|
|
315d3b50df | ||
|
|
727a2d97d9 | ||
|
|
54b67987c1 | ||
|
|
26df41c772 | ||
|
|
4e7051ad77 | ||
|
|
955b4bae6a | ||
|
|
95ddf28f3b | ||
|
|
e901f9ad35 | ||
|
|
462422e279 | ||
|
|
bad24849bd | ||
|
|
eb242f0809 | ||
|
|
b1795e3def | ||
|
|
54b212ead3 | ||
|
|
4bbc035f54 | ||
|
|
40ba3bb92f | ||
|
|
e2cb0242bb | ||
|
|
559afab632 | ||
|
|
c134d4fc86 |
11
README.md
11
README.md
@@ -12,6 +12,8 @@
|
||||

|
||||

|
||||
|
||||

|
||||
|
||||
Demo: 👍 [Butterfly](https://butterfly.js.org/) || 🤞 [MYW](https://immyw.com/)
|
||||
|
||||
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] Multiple Comment System Support
|
||||
- [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] Webmaster Verification (google/Bing/Baidu/360/Yandex)
|
||||
- [x] Webmaster Verification
|
||||
- [x] Change website colour scheme
|
||||
- [x] Typewriter Effect: activate_power_mode
|
||||
- [x] Background effects (Canvas ribbon/canvas_ribbon_piao/canvas_nest)
|
||||
@@ -97,6 +99,9 @@ npm i hexo-theme-butterfly
|
||||
|
||||
## Screenshots
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
|
||||

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

|
||||

|
||||
|
||||

|
||||
|
||||
預覽: 👍 [Butterfly](https://butterfly.js.org/) || 🤞 [MYW](https://immyw.com/)
|
||||
|
||||
文檔: 📖 [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] 支持雙評論部署
|
||||
- [x] 多種在線聊天(Chatra/Tidio/Daovoice/Gitter/Crisp)
|
||||
- [x] 多種分析系統(百度分析/谷歌分析/騰訊分析/CNZZ分析)
|
||||
- [x] 多種分析系統
|
||||
- [x] 谷歌廣告/手動廣告位置
|
||||
- [x] 各種站長驗證(Google/Bing/Baidu/360/Yandex)
|
||||
- [x] 修改網站配色
|
||||
@@ -96,6 +98,9 @@ theme: butterfly
|
||||
|
||||
## 截圖
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
|
||||

|
||||
32
_config.yml
32
_config.yml
@@ -4,7 +4,7 @@
|
||||
# format: name: link || icon
|
||||
# sub-menu
|
||||
# name || icon:
|
||||
# name || link || icon
|
||||
# name: link || icon
|
||||
|
||||
menu:
|
||||
# Home: / || fas fa-home
|
||||
@@ -459,25 +459,11 @@ google_adsense:
|
||||
# Verification (站長驗證)
|
||||
# --------------------------------------
|
||||
|
||||
# Google Webmaster tools verification setting
|
||||
# See: https://www.google.com/webmasters/
|
||||
google_site_verification:
|
||||
|
||||
# Bing Webmaster tools verification setting
|
||||
# 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:
|
||||
site_verification:
|
||||
# - name: google_site_verification
|
||||
# content: xxxxxx
|
||||
# - name: baidu_site_verification
|
||||
# content: xxxxxxx
|
||||
|
||||
# Beautify/Effect (美化/效果)
|
||||
# --------------------------------------
|
||||
@@ -828,10 +814,12 @@ pangu:
|
||||
field: site # site/post
|
||||
|
||||
# Lazyload (圖片懶加載)
|
||||
# https://github.com/verlok/lazyload
|
||||
# https://github.com/verlok/vanilla-lazyload
|
||||
lazyload:
|
||||
enable: false
|
||||
post: /img/loading.gif
|
||||
field: site # site/post
|
||||
placeholder:
|
||||
blur: false
|
||||
|
||||
# PWA
|
||||
# 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 showToc = is_post() && theme.aside.enable && pageToc && (toc(page.content) !== '' || page.encrypt == true )
|
||||
|
||||
let titleVal = pageTitle.replace(/'/ig,"\\'")
|
||||
-
|
||||
|
||||
script#config-diff
|
||||
.
|
||||
var GLOBAL_CONFIG_SITE = {
|
||||
isPost: !{is_post()},
|
||||
isHome: !{is_home()},
|
||||
isHighlightShrink: !{isHighlightShrink},
|
||||
isToc: !{showToc},
|
||||
postUpdate: '!{full_date(page.updated)}'
|
||||
}
|
||||
script#config-diff.
|
||||
var GLOBAL_CONFIG_SITE = {
|
||||
title: '!{titleVal}',
|
||||
isPost: !{is_post()},
|
||||
isHome: !{is_home()},
|
||||
isHighlightShrink: !{isHighlightShrink},
|
||||
isToc: !{showToc},
|
||||
postUpdate: '!{full_date(page.updated)}'
|
||||
}
|
||||
|
||||
@@ -1,14 +1,3 @@
|
||||
if theme.google_site_verification
|
||||
meta(name="google-site-verification" content=theme.google_site_verification)
|
||||
|
||||
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)
|
||||
if theme.site_verification
|
||||
each item in theme.site_verification
|
||||
meta(name=item.name content=item.content)
|
||||
@@ -15,28 +15,32 @@ html(lang=config.language data-theme=theme.display_mode class=htmlClassHideAside
|
||||
|
||||
!=partial('includes/sidebar', {}, {cache: true})
|
||||
|
||||
#body-wrap(class=pageType)
|
||||
include ./header/index.pug
|
||||
if page.type !== '404'
|
||||
#body-wrap(class=pageType)
|
||||
include ./header/index.pug
|
||||
|
||||
main#content-inner.layout(class=hideAside)
|
||||
if body
|
||||
div!= body
|
||||
main#content-inner.layout(class=hideAside)
|
||||
if 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
|
||||
block content
|
||||
if theme.aside.enable && page.aside !== false
|
||||
include widget/index.pug
|
||||
- var footer_bg = ''
|
||||
|
||||
- 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
|
||||
- var footer_bg = ''
|
||||
footer#footer(style=footer_bg)
|
||||
!=partial('includes/footer', {}, {cache: true})
|
||||
|
||||
footer#footer(style=footer_bg)
|
||||
!=partial('includes/footer', {}, {cache: true})
|
||||
else
|
||||
include ./404.pug
|
||||
|
||||
include ./rightside.pug
|
||||
!=partial('includes/third-party/search/index', {}, {cache: true})
|
||||
|
||||
@@ -11,10 +11,7 @@ mixin articleSort(posts)
|
||||
.article-sort-item(class=no_cover)
|
||||
if article.cover && theme.cover.archives_enable
|
||||
a.article-sort-item-img(href=url_for(article.path) title=title)
|
||||
if theme.lazyload.enable
|
||||
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)}'`)
|
||||
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-time
|
||||
i.far.fa-calendar-alt
|
||||
|
||||
@@ -9,10 +9,7 @@ mixin postUI(posts)
|
||||
if post_cover && theme.cover.index_enable
|
||||
.post_cover(class=leftOrRight)
|
||||
a(href=url_for(link) title=title)
|
||||
if theme.lazyload.enable
|
||||
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)
|
||||
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)
|
||||
a.article-title(href=url_for(link) title=title)= title
|
||||
.article-meta-wrap
|
||||
|
||||
@@ -13,10 +13,7 @@
|
||||
each item in i.link_list
|
||||
.flink-list-item
|
||||
a(href=url_for(item.link) title=item.name target="_blank")
|
||||
if theme.lazyload.enable
|
||||
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 )
|
||||
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-desc(title=item.descr)= item.descr
|
||||
!= page.content
|
||||
|
||||
@@ -15,10 +15,7 @@ if is_post()
|
||||
.prev-post(class=hasPageNext)
|
||||
- var pagination_cover = prev.cover === false ? prev.randomcover : prev.cover
|
||||
a(href=url_for(prev.path))
|
||||
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)}'` 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')
|
||||
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
|
||||
.label=_p('pagination.prev')
|
||||
.prev_info=prev.title
|
||||
@@ -28,10 +25,7 @@ if is_post()
|
||||
- var pagination_cover = next.cover == false ? next.randomcover : next.cover
|
||||
.next-post(class=hasPagePrev)
|
||||
a(href=url_for(next.path))
|
||||
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)}'` 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')
|
||||
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
|
||||
.label=_p('pagination.next')
|
||||
.next_info=next.title
|
||||
|
||||
@@ -8,9 +8,6 @@
|
||||
- var clickTo = item.link ? item.link : item.img
|
||||
li.reward-item
|
||||
a(href=url_for(clickTo) target='_blank')
|
||||
if theme.lazyload.enable
|
||||
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)
|
||||
img.post-qr-code-img(src=url_for(item.img) alt=item.text)
|
||||
.post-qr-code-desc=item.text
|
||||
|
||||
|
||||
@@ -2,10 +2,7 @@
|
||||
#menu-mask
|
||||
#sidebar-menus
|
||||
.author-avatar
|
||||
if theme.lazyload.enable
|
||||
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")
|
||||
img.avatar-img(src=url_for(theme.avatar.img) onerror=`onerror=null;src='${theme.error_img.flink}'` alt="avatar")
|
||||
.site-data
|
||||
if site.posts.length
|
||||
.data-item.is-center
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
- let disqusPageTitle = page.title.replace(/'/ig,"\\'")
|
||||
|
||||
script.
|
||||
function loadDisqus () {
|
||||
var disqus_config = function () {
|
||||
this.page.url = '!{ page.permalink }'
|
||||
this.page.identifier = '!{ page.path }'
|
||||
this.page.title = '!{ page.title }'
|
||||
this.page.title = '!{ disqusPageTitle }'
|
||||
};
|
||||
|
||||
window.disqusReset = () => {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
- let disqusjsApi = theme.disqusjs.api || 'https://disqus.skk.moe/disqus/'
|
||||
- let disqusjsPageTitle = page.title.replace(/'/ig,"\\'")
|
||||
|
||||
script.
|
||||
function loadDisqusjs () {
|
||||
function addDisqusjsCSS () {
|
||||
@@ -15,7 +17,7 @@ script.
|
||||
siteName: '!{theme.disqusjs.siteName}',
|
||||
identifier: '!{ page.path }',
|
||||
url: '!{ page.permalink }',
|
||||
title: '!{ page.title }',
|
||||
title: '!{ disqusjsPageTitle }',
|
||||
api: '!{disqusjsApi}',
|
||||
apikey: '!{theme.disqusjs.apikey}',
|
||||
nocomment: '!{theme.disqusjs.nocomment}',
|
||||
|
||||
@@ -12,7 +12,8 @@ script.
|
||||
path: location.pathname,
|
||||
emojiCDN: '#{theme.waline.emojiCDN}',
|
||||
emojiMaps: !{emojiMaps},
|
||||
visitor: #{theme.waline.visitor}
|
||||
visitor: #{theme.waline.visitor},
|
||||
dark: '[data-theme="dark"]'
|
||||
}, !{JSON.stringify(theme.waline.option)}))
|
||||
}
|
||||
|
||||
|
||||
@@ -15,15 +15,13 @@ script.
|
||||
}
|
||||
|
||||
const findTrueUrl = (array) => {
|
||||
let url = ''
|
||||
Promise.all(array.map(item =>
|
||||
fetch(item.url).then(resp => resp.json()).then(data => {
|
||||
const urlArray = data.body.match(/(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?/ig)
|
||||
if (data.user.login === 'utterances-bot') {
|
||||
url = data.body.match(/https?\:\/\/[^\" ]+/ig).slice(-1)
|
||||
return url[0]
|
||||
return urlArray.pop()
|
||||
} else {
|
||||
url = data.body.match(/https?\:\/\/[^\" ]+/i)
|
||||
return url[0]
|
||||
return urlArray.shift()
|
||||
}
|
||||
})
|
||||
)).then(res => {
|
||||
|
||||
43
layout/includes/third-party/pjax.pug
vendored
43
layout/includes/third-party/pjax.pug
vendored
@@ -26,6 +26,29 @@ script.
|
||||
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 () {
|
||||
window.refreshFn()
|
||||
|
||||
@@ -61,26 +84,6 @@ script.
|
||||
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) => {
|
||||
if (e.request.status === 404) {
|
||||
pjax.loadUrl('/404.html')
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
if theme.aside.card_author.enable
|
||||
.card-widget.card-info
|
||||
.card-info-avatar.is-center
|
||||
if theme.lazyload.enable
|
||||
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")
|
||||
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__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)
|
||||
if post_cover && theme.cover.aside_enable
|
||||
a.thumbnail(href=url_for(link) title=title)
|
||||
if theme.lazyload.enable
|
||||
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)
|
||||
img(src=url_for(post_cover) onerror=`this.onerror=null;this.src='${url_for(theme.error_img.post_page)}'` alt=title)
|
||||
.content
|
||||
a.title(href=url_for(link) title=title)= title
|
||||
if theme.aside.card_recent_post.sort === 'updated'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hexo-theme-butterfly",
|
||||
"version": "3.7.0",
|
||||
"version": "3.7.7",
|
||||
"description": "A Simple and Card UI Design theme for Hexo",
|
||||
"main": "package.json",
|
||||
"scripts": {
|
||||
|
||||
@@ -9,7 +9,10 @@ hexo.extend.generator.register('404', function (locals) {
|
||||
if (!hexo.theme.config.error_404.enable) return
|
||||
return {
|
||||
path: '404.html',
|
||||
data: locals.posts,
|
||||
layout: ['404']
|
||||
layout: ['page'],
|
||||
data: {
|
||||
type: '404',
|
||||
top_img: false
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -2,7 +2,7 @@ const logger = require('hexo-log')()
|
||||
|
||||
hexo.extend.filter.register('before_generate', () => {
|
||||
// Get first two digits of the Hexo version number
|
||||
var hexoVer = hexo.version.replace(/(^.*\..*)\..*/, '$1')
|
||||
const hexoVer = hexo.version.replace(/(^.*\..*)\..*/, '$1')
|
||||
|
||||
if (hexoVer < 5) {
|
||||
logger.error('Please update Hexo to V5.0.0 or higher!')
|
||||
|
||||
@@ -8,9 +8,22 @@
|
||||
|
||||
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 => {
|
||||
if (!hexo.theme.config.lazyload.enable) return
|
||||
const bg = hexo.theme.config.lazyload.post ? urlFor(hexo.theme.config.lazyload.post) : 'data:image/gif;base64,R0lGODdhAQABAPAAAMPDwwAAACwAAAAAAQABAAACAkQBADs='
|
||||
data.content = data.content.replace(/(<img.*? src=)/ig, `$1 "${bg}" data-lazy-src=`)
|
||||
const config = hexo.theme.config.lazyload
|
||||
if (!config.enable) return
|
||||
if (config.field !== 'post') return
|
||||
data.content = lazyload.call(this, data.content)
|
||||
return data
|
||||
})
|
||||
|
||||
@@ -41,7 +41,6 @@ hexo.extend.helper.register('related_posts', function (currentPost, allPosts) {
|
||||
const limitNum = config.related_post.limit || 6
|
||||
const dateType = config.related_post.date_type || 'created'
|
||||
const headlineLang = this._p('post.recommend')
|
||||
const lazySrc = config.lazyload.enable ? 'data-lazy-src' : 'src'
|
||||
|
||||
relatedPosts = relatedPosts.sort(compare('weight'))
|
||||
|
||||
@@ -67,9 +66,7 @@ hexo.extend.helper.register('related_posts', function (currentPost, allPosts) {
|
||||
relatedPosts[i].title +
|
||||
'">'
|
||||
result +=
|
||||
'<img class="cover" ' +
|
||||
lazySrc +
|
||||
'="' +
|
||||
'<img class="cover" src="' +
|
||||
this.url_for(cover) +
|
||||
'" alt="cover">'
|
||||
if (dateType === 'created') {
|
||||
|
||||
@@ -22,7 +22,7 @@ function btn (args) {
|
||||
option = option.trim()
|
||||
|
||||
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 })
|
||||
|
||||
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])
|
||||
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
|
||||
margin: -.5rem 0 .5rem
|
||||
color: #858585
|
||||
|
||||
@@ -185,6 +185,9 @@ no-beautify()
|
||||
else
|
||||
no-beautify()
|
||||
|
||||
> :last-child
|
||||
margin-bottom: 0 !important
|
||||
|
||||
#post
|
||||
.tag_share
|
||||
.post-meta
|
||||
|
||||
@@ -91,14 +91,20 @@ if hexo-config('darkmode.enable') || hexo-config('display_mode') == 'dark'
|
||||
.hide-button,
|
||||
.btn-beautify,
|
||||
.mermaid,
|
||||
.hl-label,
|
||||
.post-outdate-notice,
|
||||
.error-img,
|
||||
#article-container iframe,
|
||||
img,
|
||||
.gist,
|
||||
.ads-wrap
|
||||
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)
|
||||
border-bottom: 1px dashed alpha(#FFFFFF, .1)
|
||||
|
||||
|
||||
@@ -173,24 +173,15 @@ if hexo-config('readmode')
|
||||
border: 1px solid var(--gray) !important
|
||||
|
||||
.hide-button,
|
||||
.btn-beautify
|
||||
.btn-beautify,
|
||||
.hl-label
|
||||
border: 1px solid var(--gray) !important
|
||||
background: var(--readmode-light-color) !important
|
||||
color: var(--font-color) !important
|
||||
|
||||
.btn-beautify
|
||||
border: 1px solid var(--gray) !important
|
||||
|
||||
.button--animated:before
|
||||
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
|
||||
border: 2px solid var(--gray)
|
||||
border-left-color: var(--gray) !important
|
||||
|
||||
@@ -11,6 +11,9 @@
|
||||
color: $btn-color
|
||||
line-height: 2
|
||||
|
||||
i + span
|
||||
margin-left: .3rem
|
||||
|
||||
&:not(.block) + .btn-beautify:not(.block)
|
||||
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')
|
||||
|
||||
// main of scroll
|
||||
window.addEventListener('scroll', btf.throttle(function (e) {
|
||||
const currentTop = window.scrollY || document.documentElement.scrollTop
|
||||
scrollPercent(currentTop)
|
||||
findHeadPosition(currentTop)
|
||||
}, 100))
|
||||
window.tocScrollFn = function () {
|
||||
return btf.throttle(function () {
|
||||
const currentTop = window.scrollY || document.documentElement.scrollTop
|
||||
scrollPercent(currentTop)
|
||||
findHeadPosition(currentTop)
|
||||
}, 100)()
|
||||
}
|
||||
window.addEventListener('scroll', tocScrollFn)
|
||||
|
||||
const scrollPercent = function (currentTop) {
|
||||
const docHeight = $article.clientHeight
|
||||
@@ -410,7 +413,11 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
const updateAnchor = function (anchor) {
|
||||
if (window.history.replaceState && anchor !== window.location.hash) {
|
||||
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