Compare commits

..

5 Commits
2.3.0 ... 2.3.5

29 changed files with 222 additions and 204 deletions

View File

@@ -1,6 +1,6 @@
# hexo-theme-butterfly
<a href="https://github.com/jerryc127/hexo-theme-butterfly/releases"><img alt="Version" src="https://img.shields.io/badge/release-2.3.0-blue"/></a>
<a href="https://github.com/jerryc127/hexo-theme-butterfly/releases"><img alt="Version" src="https://img.shields.io/badge/release-2.3.5-blue"/></a>
<a href="https://jerryc.me"><img alt="Author" src="https://img.shields.io/badge/author-JerryC-blur"/></a>
<a href="https://hexo.io"><img alt="Hexo" src="https://img.shields.io/badge/hexo-4.0+-0e83c"/></a>
<a href="https://nodejs.org/"><img alt="node.js" src="https://img.shields.io/badge/node.js-8.0+-blur"/></a>
@@ -35,7 +35,15 @@ git clone -b dev https://github.com/jerryc127/hexo-theme-butterfly.git themes/Bu
## Documentation
Find in [hexo-theme-butterfly docs](https://docs.jerryc.me) and [JerryC](https://jerryc.me/posts/21cfbf15). it supports `zh-TW`
Find in [hexo-theme-butterfly docs](https://docs.jerryc.me) and [JerryC](https://jerryc.me/posts/21cfbf15). it supports `zh-TW` and `zh-CN`
You can also join the Chat Group.
[ 💬 Join QQ Group [recommend]](https://jq.qq.com/?_wv=1027&k=5KI3Jqb)
[ 💬 Join Telegram Group](https://t.me/hexo_butterfly)
## Screenshots

View File

@@ -1,6 +1,6 @@
# hexo-theme-butterfly
<a href="https://github.com/jerryc127/hexo-theme-butterfly/releases"><img alt="Version" src="https://img.shields.io/badge/release-2.3.0-blue"/></a>
<a href="https://github.com/jerryc127/hexo-theme-butterfly/releases"><img alt="Version" src="https://img.shields.io/badge/release-2.3.5-blue"/></a>
<a href="https://jerryc.me"><img alt="Author" src="https://img.shields.io/badge/author-JerryC-blur"/></a>
<a href="https://hexo.io"><img alt="Hexo" src="https://img.shields.io/badge/hexo-4.0+-0e83c"/></a>
<a href="https://nodejs.org/"><img alt="node.js" src="https://img.shields.io/badge/node.js-8.0+-blur"/></a>
@@ -36,7 +36,14 @@ theme: Butterfly
可查看[hexo-theme-butterfly docs](https://docs.jerryc.me) 和 [JerryC](https://jerryc.me/posts/21cfbf15)
你也可以加入群組
[ 💬 QQ群 [推薦]](https://jq.qq.com/?_wv=1027&k=5KI3Jqb)
[ 💬Telegram群](https://t.me/hexo_butterfly)
## 截圖
![image](https://user-images.githubusercontent.com/16351105/58887365-1272f780-8718-11e9-9329-3292c6ba20d4.png)
![image](https://user-images.githubusercontent.com/16351105/58887457-3cc4b500-8718-11e9-9417-2bdea603c92e.png)

View File

@@ -15,10 +15,6 @@ menu:
- Music || /music/ || fa fa-music
- Movie || /movies/ || fa fa-film
# Favicon
# ---------------
favicon: /img/favicon.ico
# PWA
# See https://github.com/JLHwung/hexo-offline
# ---------------
@@ -104,6 +100,10 @@ mermaid:
# built-in themes: default/forest/dark/neutral
theme: default
# Favicon
# ---------------
favicon: /img/favicon.png
# Post info settings
# ---------------
avatar:
@@ -114,7 +114,7 @@ avatar:
index_img:
# if the banner of page not setting,it will show the top_img
default_top_img: /img/index.jpg
default_top_img: https://i.loli.net/2020/05/01/IuWi8QbHvzjlOPw.jpg
# the banner image of archive page
archive_img:
@@ -144,7 +144,7 @@ cover:
position: both
# 當沒有設置cover時默認的封面顯示
default_cover:
- /img/post.jpg
- https://i.loli.net/2020/05/01/gkihqEjXxJ5UZ1C.jpg
# if the photo link cannot connect,it will show that
lodding_bg:
@@ -271,7 +271,7 @@ valine:
emojiCDN: # emoji CDN
enableQQ: false # enable the Nickname box to automatically get QQ Nickname and QQ Avatar
requiredFields: nick,mail # required fields nick/mail/link
bg: /img/comment_bg.png # valine background
bg: # valine background
count: false # dispaly comment count in top_img
# utterances
@@ -375,6 +375,10 @@ related_post:
# 圖片描述文字
photofigcaption: false
# anchor
# when you scroll in post, the url will update according to header id.
anchor: false
#### 美化/效果 ####
#--------------------------------
@@ -478,6 +482,7 @@ display_mode: light
# 美化頁面顯示
beautify:
enable: false
field: post # site/post
title-prefix-icon: '\f0c1'
title-prefix-icon-color: '#F47466'
@@ -662,9 +667,8 @@ note:
light_bg_offset: 0
# 圖片懶加載
# https://github.com/aFarkas/lazysizes
lazyload:
enable: true
# https://github.com/ApoorvSaxena/lozad.js
lazyload: false
# 避免重複網址分散seo
canonical: true
@@ -735,7 +739,7 @@ CDN:
canvas_ribbon_piao: /js/third-party/piao.js
canvas_nest: /js/third-party/canvas-nest.js
lazyload: https://cdn.jsdelivr.net/npm/lazysizes@latest/lazysizes.min.js
lazyload: https://cdn.jsdelivr.net/npm/lozad/dist/lozad.min.js
instantpage: https://cdn.jsdelivr.net/npm/instant.page@latest/instantpage.min.js
typed: https://cdn.jsdelivr.net/npm/typed.js
js_cookies: https://cdn.jsdelivr.net/npm/js-cookie/dist/js.cookie.min.js

View File

@@ -1,5 +1,5 @@
- var top_img = theme.error_404.background || theme.default_top_img
- var bg_img = `background-image: url(${top_img})`
- var bg_img = `background-image: url(${url_for(top_img)})`
doctype html
html(lang=config.language data-theme=theme.display_mode)

View File

@@ -7,11 +7,11 @@
.md-links
each item in i.link_list
.md-links-item
a(href=item.link title=item.name target="_blank")
if theme.lazyload.enable
img.lazyload(data-src=item.avatar onerror=`this.onerror=null;this.src='` + url_for(theme.lodding_bg.flink) + `'` alt=item.name )
a(href=url_for(item.link) title=item.name target="_blank")
if theme.lazyload
img(data-src=url_for(item.avatar) onerror=`this.onerror=null;this.src='` + url_for(theme.lodding_bg.flink) + `'` alt=item.name )
else
img(src=item.avatar onerror=`this.onerror=null;this.src='` + url_for(theme.lodding_bg.flink) + `'` alt=item.name )
img(src=url_for(item.avatar) onerror=`this.onerror=null;this.src='` + url_for(theme.lodding_bg.flink) + `'` alt=item.name )
.md-links-title= item.name
.md-links-des= item.descr
!= page.content

View File

@@ -42,8 +42,8 @@ if theme.busuanzi.site_uv || theme.busuanzi.site_pv || theme.busuanzi.page_pv
if theme.instantpage.enable
script(src=url_for(theme.CDN.instantpage) type="module")
if theme.lazyload.enable
script(src=url_for(theme.CDN.lazyload) async="")
if theme.lazyload
script(src=url_for(theme.CDN.lazyload))
//- 鼠標特效
if theme.click_heart && theme.click_heart.enable

View File

@@ -102,7 +102,9 @@ script.
highlightLang: !{theme.highlight_lang},
highlightShrink: '!{theme.highlight_shrink}',
isFontAwesomeV5: !{theme.fontawesome_v5 && theme.fontawesome_v5.enable},
isPhotoFigcaption: !{theme.photofigcaption}
isPhotoFigcaption: !{theme.photofigcaption},
islazyload: !{theme.lazyload},
isanchor: !{theme.anchor}
}

View File

@@ -19,7 +19,7 @@ if theme.douban
else if is_current('/games/', [strict])
- var top_img = theme.douban.games_img || theme.default_top_img
- var bg_img = top_img && top_img !== true ? `background-image: url(${top_img})` : ''
- var bg_img = top_img && top_img !== true ? `background-image: url(${url_for(top_img)})` : ''
- var site_title = is_archive() ? _p('page.archives') : page.title || page.tag || page.category || config.title
- var isHomeClass = is_home() ? 'full_page' : 'not-index-bg'
- is_post() ? isHomeClass = 'post-bg' : isHomeClass

View File

@@ -3,11 +3,13 @@
if !Array.isArray(value)
.menus_item
a.site-page(href=url_for(trim(value.split('||')[0])))
if value.split('||')[1]
i.fa-fw(class=trim(value.split('||')[1]))
span=' '+label
else
.menus_item
a.site-page
if label.split('||')[1]
i.fa-fw(class=trim(label.split('||')[1]) aria-hidden="true")
span=' '+ trim(label.split('||')[0])
i.fa.fa-chevron-down.menus-expand(aria-hidden="true")
@@ -15,5 +17,6 @@
each i in value
li
a.site-page(href=url_for(trim(i.split('||')[1])))
if i.split('||')[2]
i.fa-fw(class=trim(i.split('||')[2]))
span=' '+trim(i.split('||')[0])

View File

@@ -11,7 +11,7 @@ mixin articleSort(posts)
if article.cover && theme.cover.archives_enable
.article-sort-img
a.article-sort-item__img(href=url_for(article.path))
img(src=`${article.cover}` alt=article.title || 'No Title' onerror=`this.onerror=null;this.src='`+ url_for(theme.lodding_bg.post_page) + `'`)
img(src=url_for(article.cover) alt=article.title || 'No Title' onerror=`this.onerror=null;this.src='`+ url_for(theme.lodding_bg.post_page) + `'`)
.article-sort-post
a.article-sort-item__post(href=url_for(article.path))
i.fa.fa-clock-o(aria-hidden="true")

View File

@@ -9,10 +9,10 @@ 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.lazyload(data-src=`${post_cover}` onerror=`this.onerror=null;this.src='`+ url_for(theme.lodding_bg.post_page) + `'` alt=title)
if theme.lazyload
img.post_bg(data-src=url_for(post_cover) onerror=`this.onerror=null;this.src='`+ url_for(theme.lodding_bg.post_page) + `'` alt=title)
else
img.post_bg(src=`${post_cover}` onerror=`this.onerror=null;this.src='`+ url_for(theme.lodding_bg.post_page) + `'` alt=title)
img.post_bg(src=url_for(post_cover) onerror=`this.onerror=null;this.src='`+ url_for(theme.lodding_bg.post_page) + `'` alt=title)
.recent-post-info(class=no_cover)
a.article-title(href=url_for(link) title=title)= title
.article-meta-wrap

View File

@@ -17,10 +17,10 @@ else
.prev-post(class=hasPageNext)
- var pagination_cover = page.prev.cover === false ? page.prev.randomcover : page.prev.cover
a(href=url_for(page.prev.path))
if theme.lazyload.enable
img.prev_cover.lazyload(data-src=`${pagination_cover}` onerror=`onerror=null;src='${theme.lodding_bg.post_page}'` )
if theme.lazyload
img.prev_cover(data-src=url_for(pagination_cover) onerror=`onerror=null;src='${url_for(theme.lodding_bg.post_page)}'` )
else
img.prev_cover(src=`${pagination_cover}` onerror=`onerror=null;src='${theme.lodding_bg.post_page}'` )
img.prev_cover(src=url_for(pagination_cover) onerror=`onerror=null;src='${url_for(theme.lodding_bg.post_page)}'` )
.pagination-info
.label=_p('pagination.prev')
.prev_info=page.prev.title
@@ -30,10 +30,10 @@ else
- var pagination_cover = page.next.cover == false ? page.next.randomcover : page.next.cover
.next-post(class=hasPagePrev)
a(href=url_for(page.next.path))
if theme.lazyload.enable
img.next_cover.lazyload(data-src=`${pagination_cover}` onerror=`onerror=null;src='${theme.lodding_bg.post_page}'`)
if theme.lazyload
img.next_cover(data-src=url_for(pagination_cover) onerror=`onerror=null;src='${url_for(theme.lodding_bg.post_page)}'`)
else
img.next_cover(src=`${pagination_cover}` onerror=`onerror=null;src='${theme.lodding_bg.post_page}'`)
img.next_cover(src=url_for(pagination_cover) onerror=`onerror=null;src='${url_for(theme.lodding_bg.post_page)}'`)
.pagination-info
.label=_p('pagination.next')
.next_info=page.next.title

View File

@@ -6,6 +6,6 @@
ul.reward-all
each item in theme.reward.QR_code
li.reward-item
img.lazyload.post-qr-code__img(src=url_for((item.itemlist||item).img) alt=(item.itemlist||item).text)
img.post-qr-code__img(src=url_for((item.itemlist||item).img) alt=(item.itemlist||item).text)
.post-qr-code__desc=(item.itemlist||item).text

View File

@@ -1,4 +1,4 @@
if (theme.sharejs && theme.sharejs.enable)
.social-share(data-image= 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))
script(src=url_for(theme.CDN.sharejs))

View File

@@ -15,10 +15,10 @@
a(href=url_for(link))
if post_cover && theme.cover.aside_enable
.aside-post-cover
if theme.lazyload.enable
img.aside-post-bg.lazyload(data-src=`${post_cover}` onerror=`this.onerror=null;this.src='`+ url_for(theme.lodding_bg.post_page) + `'` title=title alt=title)
if theme.lazyload
img.aside-post-bg(data-src=url_for(post_cover) onerror=`this.onerror=null;this.src='`+ url_for(theme.lodding_bg.post_page) + `'` title=title alt=title)
else
img.aside-post-bg(src=`${post_cover}` onerror=`this.onerror=null;this.src='`+ url_for(theme.lodding_bg.post_page) + `'` title=title alt=title)
img.aside-post-bg(src=url_for(post_cover) onerror=`this.onerror=null;this.src='`+ url_for(theme.lodding_bg.post_page) + `'` title=title alt=title)
.aside-post-title(class=no_cover)
.aside-post_title(href=url_for(link) title=article.title || _p('no_title'))= article.title || _p('no_title')
time.aside-post_meta.post-meta__date(title=_p('post.created') + ' ' + full_date(article.date)) #[=date(article.date, config.date_format)]

View File

@@ -2,7 +2,7 @@ extends includes/layout.pug
block content
article#post(class="")
#article-container!=page.content
#article-container.post-content!=page.content
include includes/post/post-copyright.pug
.tag_share
if (theme.post_meta.post.tags)

View File

@@ -1,6 +1,6 @@
{
"name": "hexo-theme-butterfly",
"version": "2.3.0",
"version": "2.3.5",
"private": true,
"engines": {
"node": ">=8.10.0"

View File

@@ -2,36 +2,19 @@
* Butterfly
* lazyload
* replace src to data-src
* add class 'lazyload'
*/
'use strict'
const url_for = require('hexo-util').url_for.bind(hexo)
const urlFor = require('hexo-util').url_for.bind(hexo)
function lazyProcess (htmlContent) {
var bg = url_for(hexo.theme.config.lodding_bg.post)
return htmlContent.replace(
/<img(.*?)src="(.*?)"(.*?)>/gi,
(str, p1, p2, p3) => {
if (/data-src/gi.test(str)) {
return str
}
if (/class="(.*?)"/gi.test(str)) {
str = str.replace(/class="(.*?)"/gi, (classStr, p1) => {
return classStr.replace(p1, `${p1} lazyload`)
})
str = str.replace(p2, `${bg}`)
return str.replace('>', ` data-src="${p2}">`)
}
str = str.replace(p2, `${bg}`)
return str.replace(p3, ` class="lazyload" data-src="${p2}" ${p3}`)
}
)
var bg = hexo.theme.config.lodding_bg.post ? urlFor(hexo.theme.config.lodding_bg.post) : 'data:image/gif;base64,R0lGODdhAQABAPAAAMPDwwAAACwAAAAAAQABAAACAkQBADs='
return htmlContent.replace(/(<img .*?src=)/ig, `$1 ${bg} data-src=`)
}
var processPost = function (data) {
if (!hexo.theme.config.lazyload.enable) return
if (!hexo.theme.config.lazyload) return
data.content = lazyProcess.call(this, data.content)
return data
}

View File

@@ -8,16 +8,16 @@
'use strict'
const { stripHTML } = require('hexo-util')
const { stripHTML, escapeHTML } = require('hexo-util')
hexo.extend.helper.register('page_description', function () {
const { config, page } = this
let description = page.description || page.content || page.title || config.description
if (description) {
description = stripHTML(description).substring(0, 200)
description = escapeHTML(stripHTML(description).substring(0, 200)
.trim()
.replace(/\n/g, ' ')
).replace(/\n/g, ' ')
return description
}
})
@@ -36,7 +36,7 @@ hexo.extend.helper.register('cloudTags', function (options = {}) {
const source = options.source
const minfontsize = options.minfontsize
const maxfontsize = options.maxfontsize
const limit = options.limit || 8
const limit = options.limit
let result = ''
const tagLimit = limit === 0 ? source.length : limit

View File

@@ -41,8 +41,7 @@ hexo.extend.helper.register('related_posts', function (currentPost, allPosts) {
var limitNum = config.related_post.limit || 6
var dateType = config.related_post.date_type || 'created'
var headlineLang = this._p('post.recommend')
var lazySrc = config.lazyload.enable ? 'data-src' : 'src'
var lazyClass = config.lazyload.enable ? 'lazyload' : ''
var lazySrc = config.lazyload ? 'data-src' : 'src'
relatedPosts = relatedPosts.sort(compare('weight'))
@@ -68,9 +67,7 @@ hexo.extend.helper.register('related_posts', function (currentPost, allPosts) {
relatedPosts[i].title +
'">'
result +=
'<img class="relatedPosts_cover ' +
lazyClass +
'"' +
'<img class="relatedPosts_cover" ' +
lazySrc +
'="' +
cover +

View File

@@ -1,5 +1,4 @@
#article-container
if hexo-config('beautify.enable')
beautify()
headStyle(fontsize)
padding-left: unit(fontsize + .4, 'rem')
@@ -125,11 +124,11 @@
background: transparent
content: ''
line-height: h
else
no-beautify()
ol,
ul
margin-top: .4rem
counter-reset: li
p
margin: 0 0 .5rem
@@ -143,6 +142,17 @@
margin: .3rem 0
padding-left: .3rem
#article-container
if hexo-config('beautify.enable') && hexo-config('beautify.field') == 'site'
beautify()
else if hexo-config('beautify.enable') && hexo-config('beautify.field') == 'post'
no-beautify()
&.post-content
beautify()
else
no-beautify()
a
color: $a-link-color
text-decoration: none

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

BIN
source/img/favicon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 323 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 247 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

View File

@@ -1 +0,0 @@
<svg width="200px" height="200px" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid" class="lds-pacman" style="background: none;"><g ng-attr-style="display:{{config.showBean}}" style="display:block"><circle cx="74.5405" cy="50" r="4" ng-attr-fill="{{config.c2}}" fill="#a3d9ef"><animate attributeName="cx" calcMode="linear" values="95;35" keyTimes="0;1" dur="0.8" begin="-0.536s" repeatCount="indefinite"></animate><animate attributeName="fill-opacity" calcMode="linear" values="0;1;1" keyTimes="0;0.2;1" dur="0.8" begin="-0.536s" repeatCount="indefinite"></animate></circle><circle cx="94.9405" cy="50" r="4" ng-attr-fill="{{config.c2}}" fill="#a3d9ef"><animate attributeName="cx" calcMode="linear" values="95;35" keyTimes="0;1" dur="0.8" begin="-0.264s" repeatCount="indefinite"></animate><animate attributeName="fill-opacity" calcMode="linear" values="0;1;1" keyTimes="0;0.2;1" dur="0.8" begin="-0.264s" repeatCount="indefinite"></animate></circle><circle cx="54.7405" cy="50" r="4" ng-attr-fill="{{config.c2}}" fill="#a3d9ef"><animate attributeName="cx" calcMode="linear" values="95;35" keyTimes="0;1" dur="0.8" begin="0s" repeatCount="indefinite"></animate><animate attributeName="fill-opacity" calcMode="linear" values="0;1;1" keyTimes="0;0.2;1" dur="0.8" begin="0s" repeatCount="indefinite"></animate></circle></g><g ng-attr-transform="translate({{config.showBeanOffset}} 0)" transform="translate(-15 0)"><path d="M50 50L20 50A30 30 0 0 0 80 50Z" ng-attr-fill="{{config.c1}}" fill="#82bbe4" transform="rotate(29.6108 50 50)"><animateTransform attributeName="transform" type="rotate" calcMode="linear" values="0 50 50;45 50 50;0 50 50" keyTimes="0;0.5;1" dur="0.8s" begin="0s" repeatCount="indefinite"></animateTransform></path><path d="M50 50L20 50A30 30 0 0 1 80 50Z" ng-attr-fill="{{config.c1}}" fill="#82bbe4" transform="rotate(-29.6108 50 50)"><animateTransform attributeName="transform" type="rotate" calcMode="linear" values="0 50 50;-45 50 50;0 50 50" keyTimes="0;0.5;1" dur="0.8s" begin="0s" repeatCount="indefinite"></animateTransform></path></g></svg>

Before

Width:  |  Height:  |  Size: 2.1 KiB

View File

@@ -445,6 +445,13 @@ $(function () {
})
}
/**
* lazyload
*/
if (GLOBAL_CONFIG.islazyload) {
window.lozad('img').observe()
}
/**
* 滾動處理
*/
@@ -532,9 +539,11 @@ $(function () {
}, 100)
}
// anchor
var isanchor = GLOBAL_CONFIG.isanchor
var updateAnchor = function (anchor) {
if (anchor !== window.location.hash) {
location.replace(window.location.href.split('#')[0] + anchor)
if (window.history.replaceState && anchor !== window.location.hash) {
window.history.replaceState(undefined, undefined, anchor)
}
}
@@ -565,7 +574,7 @@ $(function () {
var currentActive = $('.toc-link.active')
if (currentId && currentActive.attr('href') !== currentId) {
updateAnchor(currentId)
if (isanchor) updateAnchor(currentId)
$('.toc-link').removeClass('active')
@@ -711,11 +720,7 @@ $(function () {
$darkModeButtom.click(function () {
switchReadMode()
try {
utterancesTheme()
} catch (e) {
return false
}
if (typeof utterancesTheme === 'function') utterancesTheme()
})
/**