diff --git a/README.md b/README.md
index 0da0b28..a788b3d 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# hexo-theme-butterfly
-
+
diff --git a/README_CN.md b/README_CN.md
index d36ea4d..0802850 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -1,6 +1,6 @@
# hexo-theme-butterfly
-
+
diff --git a/_config.yml b/_config.yml
index 29ba263..2226341 100644
--- a/_config.yml
+++ b/_config.yml
@@ -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
diff --git a/layout/flink.pug b/layout/flink.pug
index 254293b..a646413 100644
--- a/layout/flink.pug
+++ b/layout/flink.pug
@@ -8,8 +8,8 @@
each item in i.link_list
.md-links-item
a(href=url_for(item.link) title=item.name target="_blank")
- if theme.lazyload.enable
- img.lazyload(data-src=url_for(item.avatar) onerror=`this.onerror=null;this.src='` + url_for(theme.lodding_bg.flink) + `'` alt=item.name )
+ 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=url_for(item.avatar) onerror=`this.onerror=null;this.src='` + url_for(theme.lodding_bg.flink) + `'` alt=item.name )
.md-links-title= item.name
diff --git a/layout/includes/additional-js.pug b/layout/includes/additional-js.pug
index 57ec278..266af58 100644
--- a/layout/includes/additional-js.pug
+++ b/layout/includes/additional-js.pug
@@ -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
diff --git a/layout/includes/head/config.pug b/layout/includes/head/config.pug
index 63e854b..b4c0c6f 100644
--- a/layout/includes/head/config.pug
+++ b/layout/includes/head/config.pug
@@ -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}
}
diff --git a/layout/includes/mixins/post-ui.pug b/layout/includes/mixins/post-ui.pug
index 2814a68..0411e7c 100644
--- a/layout/includes/mixins/post-ui.pug
+++ b/layout/includes/mixins/post-ui.pug
@@ -9,8 +9,8 @@ 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=url_for(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=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)
diff --git a/layout/includes/pagination.pug b/layout/includes/pagination.pug
index 0ca84be..0abc22f 100644
--- a/layout/includes/pagination.pug
+++ b/layout/includes/pagination.pug
@@ -17,8 +17,8 @@ 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=url_for(pagination_cover) onerror=`onerror=null;src='${url_for(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=url_for(pagination_cover) onerror=`onerror=null;src='${url_for(theme.lodding_bg.post_page)}'` )
.pagination-info
@@ -30,8 +30,8 @@ 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=url_for(pagination_cover) onerror=`onerror=null;src='${url_for(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=url_for(pagination_cover) onerror=`onerror=null;src='${url_for(theme.lodding_bg.post_page)}'`)
.pagination-info
diff --git a/layout/includes/post/reward.pug b/layout/includes/post/reward.pug
index 8aefea4..48b6300 100644
--- a/layout/includes/post/reward.pug
+++ b/layout/includes/post/reward.pug
@@ -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
diff --git a/layout/includes/widget/card_recent_post.pug b/layout/includes/widget/card_recent_post.pug
index ead0954..321752d 100644
--- a/layout/includes/widget/card_recent_post.pug
+++ b/layout/includes/widget/card_recent_post.pug
@@ -15,8 +15,8 @@
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=url_for(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=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)
diff --git a/layout/post.pug b/layout/post.pug
index 0411099..56b1859 100644
--- a/layout/post.pug
+++ b/layout/post.pug
@@ -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)
diff --git a/package.json b/package.json
index a962bf1..603f4c3 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "hexo-theme-butterfly",
- "version": "2.3.0",
+ "version": "2.3.5",
"private": true,
"engines": {
"node": ">=8.10.0"
diff --git a/scripts/filters/post_lazyload.js b/scripts/filters/post_lazyload.js
index c1cab31..22c49ff 100644
--- a/scripts/filters/post_lazyload.js
+++ b/scripts/filters/post_lazyload.js
@@ -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(
- /
/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(/(
'
result +=
- '
li
+ &:before
+ margin-top: .2rem
+ width: w = 1.2rem
+ height: h = w
+ border-radius: .5 * w
+ content: counter(li)
+ counter-increment: li
+ text-align: center
+ font-size: .6rem
+ line-height: h
+ ul
+ > li
&:hover
&:before
- color: $light-blue
+ border-color: $theme-button-hover-color
- h1
- headStyle(1)
+ &:before
+ $w = .3rem
+ top: 10px
+ margin-left: .45rem
+ width: w = $w
+ height: h = w
+ border: .5 * w solid $light-blue
+ border-radius: w
+ background: transparent
+ content: ''
+ line-height: h
- h2
- headStyle(.9)
+no-beautify()
+ ol,
+ ul
+ margin-top: .4rem
- h3
- headStyle(.8)
-
- h4
- headStyle(.7)
-
- h5
- headStyle(.6)
-
- h6
- headStyle(.6)
+ p
+ margin: 0 0 .5rem
ol,
ul
- margin-top: .4rem
- padding: 0 0 0 .8rem
- list-style: none
- counter-reset: li
+ padding-left: .5rem
- p
- margin: 0 0 .5rem
+ li
+ position: relative
+ margin: .3rem 0
+ padding-left: .3rem
- ol,
- ul
- padding-left: .5rem
+#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()
- li
- position: relative
- margin: .2rem 0
- padding: .1rem .5rem .1rem 1.5rem
-
- &:hover
- &:before
- transform: rotate(360deg)
-
- &:before
- position: absolute
- top: 0
- left: 0
- background: $light-blue
- color: $card-bg
- cursor: pointer
- transition: all .3s ease-out
-
- ol
- > li
- &:before
- margin-top: .2rem
- width: w = 1.2rem
- height: h = w
- border-radius: .5 * w
- content: counter(li)
- counter-increment: li
- text-align: center
- font-size: .6rem
- line-height: h
-
- ul
- > li
- &:hover
- &:before
- border-color: $theme-button-hover-color
-
- &:before
- $w = .3rem
- top: 10px
- margin-left: .45rem
- width: w = $w
- height: h = w
- border: .5 * w solid $light-blue
- border-radius: w
- background: transparent
- content: ''
- line-height: h
+ &.post-content
+ beautify()
else
- ol,
- ul
- margin-top: .4rem
- counter-reset: li
-
- p
- margin: 0 0 .5rem
-
- ol,
- ul
- padding-left: .5rem
-
- li
- position: relative
- margin: .3rem 0
- padding-left: .3rem
+ no-beautify()
a
color: $a-link-color
diff --git a/source/img/avatar.png b/source/img/avatar.png
deleted file mode 100644
index 90fb856..0000000
Binary files a/source/img/avatar.png and /dev/null differ
diff --git a/source/img/comment_bg.png b/source/img/comment_bg.png
deleted file mode 100644
index 1ce3938..0000000
Binary files a/source/img/comment_bg.png and /dev/null differ
diff --git a/source/img/favicon.ico b/source/img/favicon.ico
deleted file mode 100644
index e07d73a..0000000
Binary files a/source/img/favicon.ico and /dev/null differ
diff --git a/source/img/favicon.png b/source/img/favicon.png
new file mode 100644
index 0000000..862ebe8
Binary files /dev/null and b/source/img/favicon.png differ
diff --git a/source/img/index.jpg b/source/img/index.jpg
deleted file mode 100644
index 6e18f89..0000000
Binary files a/source/img/index.jpg and /dev/null differ
diff --git a/source/img/post.jpg b/source/img/post.jpg
deleted file mode 100644
index 49a812c..0000000
Binary files a/source/img/post.jpg and /dev/null differ
diff --git a/source/img/post_loadding.svg b/source/img/post_loadding.svg
deleted file mode 100644
index ef01327..0000000
--- a/source/img/post_loadding.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/source/js/main.js b/source/js/main.js
index 52bdc28..98b3511 100644
--- a/source/js/main.js
+++ b/source/js/main.js
@@ -445,6 +445,13 @@ $(function () {
})
}
+ /**
+ * lazyload
+ */
+ if (GLOBAL_CONFIG.islazyload) {
+ window.lozad('img').observe()
+ }
+
/**
* 滾動處理
*/
@@ -532,11 +539,13 @@ $(function () {
}, 100)
}
- // function updateAnchor (anchor) {
- // if (window.history.replaceState && anchor !== window.location.hash) {
- // window.history.replaceState(null, null, anchor)
- // }
- // }
+ // anchor
+ var isanchor = GLOBAL_CONFIG.isanchor
+ var updateAnchor = function (anchor) {
+ if (window.history.replaceState && anchor !== window.location.hash) {
+ window.history.replaceState(undefined, undefined, anchor)
+ }
+ }
// find head position & add active class
// DOM Hierarchy:
@@ -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()
})
/**