diff --git a/README.md b/README.md
index 2486840..0707089 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 295d892..1ab85d3 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 a60630f..2ae3fc3 100644
--- a/_config.yml
+++ b/_config.yml
@@ -49,12 +49,12 @@ copy:
# social settings
# formal:
-# icon: link
+# icon: link || the description
# ---------------
social:
- fa fa-github: https://github.com/jerryc127
- fa fa-envelope: mailto:xxxxxxxx@gmail.com
- fa fa-rss: /atom.xml
+ fa fa-github: https://github.com/jerryc127 || Github
+ fa fa-envelope: mailto:xxxxxxx@gmail.com || Email
+ fa fa-rss: /atom.xml || RSS
#### search ####
# Algolia search
@@ -70,7 +70,7 @@ algolia_search:
hits_stats: "${hits} results found in ${time} ms"
# Local search
-# Please see doc for more details: https://jerryc.me/posts/21cfbf15/#本地搜索
+# Please see doc for more details: https://docs.jerryc.me/config.html#本地搜索
# ---------------
local_search:
enable: false
@@ -79,7 +79,7 @@ local_search:
hits_empty: "We didn't find any results for the search: ${query}" # if there are no result
# MathJax
-# Please see doc for more details: https://jerryc.me/posts/21cfbf15/#MathJax
+# Please see doc for more details: https://docs.jerryc.me/config.html#mathjax
# ---------------
mathjax:
enable: false
@@ -168,9 +168,12 @@ post_meta:
categories: true # true or false 文章頁是否顯示分類
tags: true # true or false 文章頁是否顯示標籤
-# Please see doc for more details: https://jerryc.me/posts/21cfbf15/#字數統計
+# Please see doc for more details: https://docs.jerryc.me/config.html#字數統計
wordcount:
enable: false
+ post_wordcount: true
+ min2read: true
+ total_wordcount: true
toc:
enable: true
@@ -313,6 +316,13 @@ google_adsense:
client:
enable_page_level_ads: true
+# 廣告插入位置
+# 適用於開啓手動廣告的配置
+# ad:
+# index:
+# aside:
+# post:
+
#### 站長驗證 ####
# Google Webmaster tools verification setting
# See: https://www.google.com/webmasters/
@@ -347,6 +357,10 @@ related_post:
limit: 6 # 顯示推薦文章數目
date_type: created # or created or updated 文章日期顯示創建日或者更新日
+# figcaption
+# 圖片描述文字
+photofigcaption: false
+
#### 美化/效果 ####
#--------------------------------
diff --git a/languages/default.yml b/languages/default.yml
index 29894f9..441e6d5 100644
--- a/languages/default.yml
+++ b/languages/default.yml
@@ -66,6 +66,7 @@ aside:
headline: Info
article_name: Article
runtime_name: Run time
+ site_wordcount: Total Count
site_uv_name: UV
site_pv_name: PV
diff --git a/languages/en.yml b/languages/en.yml
index 29894f9..441e6d5 100644
--- a/languages/en.yml
+++ b/languages/en.yml
@@ -66,6 +66,7 @@ aside:
headline: Info
article_name: Article
runtime_name: Run time
+ site_wordcount: Total Count
site_uv_name: UV
site_pv_name: PV
diff --git a/languages/zh-CN.yml b/languages/zh-CN.yml
index 9b4e224..a78d07e 100644
--- a/languages/zh-CN.yml
+++ b/languages/zh-CN.yml
@@ -68,6 +68,7 @@ aside:
headline: 网站资讯
article_name: 文章数目
runtime_name: 已运行时间
+ site_wordcount: 本站总字数
site_uv_name: 本站访客数
site_pv_name: 本站总访问量
diff --git a/languages/zh-TW.yml b/languages/zh-TW.yml
index 8aad902..bbdf11a 100644
--- a/languages/zh-TW.yml
+++ b/languages/zh-TW.yml
@@ -24,8 +24,8 @@ post:
created: 發表於
updated: 更新於
wordcount: 字數總計
- min2read: "閲讀時長: %s 分鐘"
- page_pv: 閲讀量
+ min2read: "閱讀時長: %s 分鐘"
+ page_pv: 閱讀量
comments: 評論數
copyright:
author: 文章作者
@@ -68,6 +68,7 @@ aside:
headline: 網站資訊
article_name: 文章數目
runtime_name: 已運行時間
+ site_wordcount: 本站總字數
site_uv_name: 本站訪客數
site_pv_name: 本站總訪問量
@@ -77,7 +78,7 @@ bookmark:
title: 添加書籤
rightside:
- readmode_title: 閲讀模式
+ readmode_title: 閱讀模式
font_plus_title: 放大字體
font_minus_title: 縮小字體
translate_title: 簡繁轉換
diff --git a/layout/404.pug b/layout/404.pug
index 8ae9438..4dc3c92 100644
--- a/layout/404.pug
+++ b/layout/404.pug
@@ -1,87 +1,23 @@
+- var top_img = theme.error_404.background || theme.default_top_img
+- var bg_img = `background-image: url(${top_img})`
+
doctype html
html(lang=config.language data-theme=theme.display_mode)
head
- - var pageTitle = _p('error_title')
- - var tabTitle = pageTitle + ' | ' + config.title
- - var pageDescription = page.description || page.title || config.description
- - var pageKeywords = Array.isArray(config.keywords) ? (config.keywords).join(','): ([]).join(',') || config.keywords
- - var pageAuthor = config.email ? config.author + ',' + config.email : config.author
- - var pageCopyright = config.copyright || config.author
- - var without_html = url.replace('index.html', '')
- - var top_img = theme.error_404.background || theme.default_top_img
- - var bg_img = `background-image: url(${top_img})`
-
-
- meta(charset='UTF-8')
- meta(http-equiv="X-UA-Compatible" content="IE=edge")
- meta(name="viewport" content="width=device-width, initial-scale=1, maximum-scale=5")
- title= tabTitle
- meta(name="description" content=pageDescription)
- if pageKeywords
- meta(name="keywords" content=pageKeywords)
- meta(name="author" content=pageAuthor)
- meta(name="copyright" content=pageCopyright)
- meta(name ="format-detection" content="telephone=no")
- !=favicon_tag(theme.favicon || config.favicon)
- //- 預解析
- include includes/head/dns_prefetch.pug
- //- 網站驗證
- include includes/head/site_verification.pug
- //- Open_Graph
- include includes/head/Open_Graph.pug
- //- PWA
- if (theme.pwa && theme.pwa.enable)
- include includes/head/pwa
-
- script(src=url_for(theme.CDN.js_cookies))
-
- if theme.darkmode.enable
- include includes/head/darkmode.pug
-
- each item in theme.CDN_USE.css
- link(rel='stylesheet', href=url_for(item))
-
- if theme.fontawesome_v5 && theme.fontawesome_v5.enable
- link(rel='stylesheet', href=url_for(theme.CDN.fontawesome_v5))
- else
- link(rel='stylesheet', href=url_for(theme.CDN.fontawesome_v4))
-
- if (theme.snackbar && theme.snackbar.enable)
- link(rel='stylesheet', href=url_for(theme.CDN.snackbar_css))
-
- if theme.canonical
- link(rel="canonical" href=without_html)
-
- if theme.algolia_search.enable
- link(rel="stylesheet" type="text/css" href=url_for(theme.CDN.algolia_search_css))
- script(src=url_for(theme.CDN.algolia_search) defer)
-
- //- google_adsense
- include includes/head/google_adsense.pug
-
- //- analytics
- include includes/head/analytics.pug
-
- if theme.blog_title_font.font_link
- link(rel='stylesheet', href=url_for(theme.blog_title_font.font_link))
-
- include includes/head/config.pug
- include includes/head/config_site.pug
-
+ include includes/head.pug
body
if theme.fireworks && theme.fireworks.enable
canvas.fireworks
+
+ include includes/mobile-sidebar/index.pug
+
nav#nav.error-no-found(style=bg_img)
include includes/header/header.pug
#error_info.is-center
h1#error_title= '404'
- #error_subtitle= theme.error_404.subtitle
- include includes/mobile-sidebar/index.pug
+ #error_subtitle= theme.error_404.subtitle
include includes/rightside.pug
+ include includes/search/index.pug
each item in theme.CDN_USE.js
script(src=url_for(item))
include includes/additional-js.pug
- include includes/search/index.pug
-
-
-
diff --git a/layout/includes/additional-js.pug b/layout/includes/additional-js.pug
index 9f7804a..4393e51 100644
--- a/layout/includes/additional-js.pug
+++ b/layout/includes/additional-js.pug
@@ -62,4 +62,4 @@ if theme.mermaid.enable
include ./math/mermaid.pug
if is_home()
- include index-js.pug
\ No newline at end of file
+ include ./head/subtitle.pug
\ No newline at end of file
diff --git a/layout/includes/head.pug b/layout/includes/head.pug
index 696306f..febb1ee 100644
--- a/layout/includes/head.pug
+++ b/layout/includes/head.pug
@@ -1,16 +1,19 @@
-- var pageTitle = page.title || config.title || ''
+- var pageTitle
- if (is_archive()) pageTitle = _p('page.archives')
-- if (is_tag()) pageTitle = _p('page.tag') + ': ' + page.tag
-- if (is_category()) pageTitle = _p('page.category') + ': ' + page.category
-- if (is_month()) pageTitle += ': ' + page.month + '/' + page.year
-- if (is_year()) pageTitle += ': ' + page.year
+- else if (is_tag()) pageTitle = _p('page.tag') + ': ' + page.tag
+- else if (is_category()) pageTitle = _p('page.category') + ': ' + page.category
+- else if (is_month()) pageTitle += ': ' + page.month + '/' + page.year
+- else if (is_year()) pageTitle += ': ' + page.year
+- else if (is_current('/404.html', [strict])) pageTitle = _p('error_title')
+- else pageTitle = page.title || config.title || ''
+
- var isSubtitle = config.subtitle ? ' - ' + config.subtitle : ''
- var tabTitle = is_home() || !pageTitle ? config.title + isSubtitle : pageTitle + ' | ' + config.title
-- pageTitle ? '' : pageTitle = config.title || ''
- var pageDescription = page.description || page.title || config.description
-- var pageKeywords = Array.isArray(config.keywords) ? (config.keywords).join(','): ([]).join(',') || config.keywords
+- var pageKeywords
- if (page.tags && page.tags.data) pageKeywords = page.tags.data.map(function(tag) {return tag.name;}).join(',')
+- else pageKeywords = Array.isArray(config.keywords) ? (config.keywords).join(','): ([]).join(',') || config.keywords
- var pageAuthor = config.email ? config.author + ',' + config.email : config.author
- var pageCopyright = config.copyright || config.author
- var without_html = url.replace('index.html', '')
@@ -97,4 +100,6 @@ if theme.blog_title_font.font_link
//- global config
!=partial('includes/head/config', {}, {cache:theme.fragment_cache})
+
include ./head/config_site.pug
+include ./head/noscript.pug
diff --git a/layout/includes/head/config.pug b/layout/includes/head/config.pug
index 74e4b91..63e854b 100644
--- a/layout/includes/head/config.pug
+++ b/layout/includes/head/config.pug
@@ -42,7 +42,7 @@
copyright = JSON.stringify({
languages: {
author: _p("copy_copyright.author") + ': ' + config.author,
- link: _p("copy_copyright.link") + ': ' + without_html,
+ link: _p("copy_copyright.link") + ': ',
source: _p("copy_copyright.source") + ': ' + config.title,
info: _p("copy_copyright.info")
}
@@ -62,7 +62,6 @@
if (theme.snackbar && theme.snackbar.enable) {
Snackbar = JSON.stringify({
bookmark: {
- title: _p("Snackbar.bookmark.title"),
message_prev: _p("Snackbar.bookmark.message_prev"),
message_next: _p("Snackbar.bookmark.message_next")
},
@@ -76,16 +75,6 @@
})
}
- var highlightCopy = theme.highlight_copy
- var highlightLang = theme.highlight_lang
- var highlightShrink = theme.highlight_shrink
- var runtime = theme.runtimeshow.enable
- var fancybox = theme.fancybox.enable
- var medium_zoom = theme.medium_zoom.enable
- var baiduPush = theme.baidu_push && theme.baidu_push.enable
- var isFontAwesomeV5 = theme.fontawesome_v5 && theme.fontawesome_v5.enable
-
-
script.
var GLOBAL_CONFIG = {
root: '!{config.root}',
@@ -98,22 +87,22 @@ script.
noSupport: '!{_p("copy.noSupport")}'
},
bookmark: {
- title: '!{_p("Snackbar.bookmark.title")}',
message_prev: '!{_p("Snackbar.bookmark.message_prev")}',
message_next: '!{_p("Snackbar.bookmark.message_next")}'
},
runtime_unit: '!{_p("runtime_unit")}',
- runtime: !{runtime},
+ runtime: !{theme.runtimeshow.enable},
copyright: !{copyright},
ClickShowText: !{ClickShowText},
- medium_zoom: !{medium_zoom},
- fancybox: !{fancybox},
+ medium_zoom: !{theme.medium_zoom.enable},
+ fancybox: !{theme.fancybox.enable},
Snackbar: !{Snackbar},
- baiduPush: !{baiduPush},
- highlightCopy: !{highlightCopy},
- highlightLang: !{highlightLang},
- highlightShrink: '!{highlightShrink}',
- isFontAwesomeV5: !{isFontAwesomeV5}
+ baiduPush: !{theme.baidu_push && theme.baidu_push.enable},
+ highlightCopy: !{theme.highlight_copy},
+ highlightLang: !{theme.highlight_lang},
+ highlightShrink: '!{theme.highlight_shrink}',
+ isFontAwesomeV5: !{theme.fontawesome_v5 && theme.fontawesome_v5.enable},
+ isPhotoFigcaption: !{theme.photofigcaption}
}
diff --git a/layout/includes/head/config_site.pug b/layout/includes/head/config_site.pug
index 1e5ed9e..1d7ae99 100644
--- a/layout/includes/head/config_site.pug
+++ b/layout/includes/head/config_site.pug
@@ -1,6 +1,7 @@
script.
var GLOBAL_CONFIG_SITE = {
isPost: !{is_post()},
- isHome: !{is_home()}
- }
+ isHome: !{is_home()},
+ isSidebar: !{is_post() && page.toc !== false && theme.toc.enable && (toc(page.content) !== '' || page.encrypt == true )}
+ }
diff --git a/layout/includes/head/darkmode.pug b/layout/includes/head/darkmode.pug
index e6adeab..bd5961f 100644
--- a/layout/includes/head/darkmode.pug
+++ b/layout/includes/head/darkmode.pug
@@ -1,20 +1,20 @@
script.
- const autoChangeMode = '#{theme.darkmode.autoChangeMode}'
+ var autoChangeMode = '#{theme.darkmode.autoChangeMode}'
var t = Cookies.get("theme")
if (autoChangeMode == '1'){
- const isDarkMode = window.matchMedia("(prefers-color-scheme: dark)").matches
- const isLightMode = window.matchMedia("(prefers-color-scheme: light)").matches
- const isNotSpecified = window.matchMedia("(prefers-color-scheme: no-preference)").matches
- const hasNoSupport = !isDarkMode && !isLightMode && !isNotSpecified
+ var isDarkMode = window.matchMedia("(prefers-color-scheme: dark)").matches
+ var isLightMode = window.matchMedia("(prefers-color-scheme: light)").matches
+ var isNotSpecified = window.matchMedia("(prefers-color-scheme: no-preference)").matches
+ var hasNoSupport = !isDarkMode && !isLightMode && !isNotSpecified
if (t === undefined){
if (isLightMode) activateLightMode()
else if (isDarkMode) activateDarkMode()
else if (isNotSpecified || hasNoSupport){
console.log('You specified no preference for a color scheme or your browser does not support it. I Schedule dark mode during night time.')
- now = new Date();
- hour = now.getHours();
- isNight = hour < 6 || hour >= 18
+ var now = new Date()
+ var hour = now.getHours()
+ var isNight = hour < 6 || hour >= 18
isNight ? activateDarkMode() : activateLightMode()
}
} else if (t == 'light') activateLightMode()
diff --git a/layout/includes/head/noscript.pug b/layout/includes/head/noscript.pug
new file mode 100644
index 0000000..de8a2d8
--- /dev/null
+++ b/layout/includes/head/noscript.pug
@@ -0,0 +1,9 @@
+noscript.
+
\ No newline at end of file
diff --git a/layout/includes/index-js.pug b/layout/includes/head/subtitle.pug
similarity index 69%
rename from layout/includes/index-js.pug
rename to layout/includes/head/subtitle.pug
index cdbb734..b216f0c 100644
--- a/layout/includes/index-js.pug
+++ b/layout/includes/head/subtitle.pug
@@ -1,22 +1,22 @@
if theme.subtitle.enable
- - let source = theme.subtitle.source
- - let subtitleEffect = theme.subtitle.effect
+ - var source = theme.subtitle.source
+ - var subtitleEffect = theme.subtitle.effect
if subtitleEffect
script(src=url_for(theme.CDN.typed))
if source == '1'
script.
- let subtitleEffect = !{subtitleEffect}
+ var subtitleEffect = !{subtitleEffect}
fetch('https://api.ooopn.com/ciba/api.php',)
.then(function (res){
return res.json();
})
.then(function (data) {
if (subtitleEffect){
- let sub = '!{theme.subtitle.sub}'.length == 0 ? new Array() : '!{theme.subtitle.sub}'.split(",");
- let both = sub.unshift(data['ciba-en'],data.ciba)
- let typed = new Typed("#subtitle", {
+ var sub = '!{theme.subtitle.sub}'.length == 0 ? new Array() : '!{theme.subtitle.sub}'.split(",");
+ var both = sub.unshift(data['ciba-en'],data.ciba)
+ var typed = new Typed("#subtitle", {
strings: sub,
startDelay: 300,
typeSpeed: 150,
@@ -33,17 +33,17 @@ if theme.subtitle.enable
else if source == '2'
script.
- let subtitleEffect = !{subtitleEffect}
+ var subtitleEffect = !{subtitleEffect}
fetch('https://v1.hitokoto.cn')
.then(function (res){
return res.json();
})
.then(function (data) {
if (subtitleEffect){
- let from = '出自 ' + data.from
- let sub = '!{theme.subtitle.sub}'.length == 0 ? new Array() : '!{theme.subtitle.sub}'.split(",");
- let both = sub.unshift(data.hitokoto,from)
- let typed = new Typed("#subtitle", {
+ var from = '出自 ' + data.from
+ var sub = '!{theme.subtitle.sub}'.length == 0 ? new Array() : '!{theme.subtitle.sub}'.split(",");
+ var both = sub.unshift(data.hitokoto,from)
+ var typed = new Typed("#subtitle", {
strings: sub,
startDelay: 300,
typeSpeed: 150,
@@ -61,13 +61,13 @@ if theme.subtitle.enable
else if source == "3"
script(type="text/javascript" src="http://yijuzhan.com/api/word.php?m=js")
script.
- let subtitleEffect = !{subtitleEffect}
- let con = str[0];
+ var subtitleEffect = !{subtitleEffect}
+ var con = str[0];
if (subtitleEffect){
- let from = "出自 " + str[1];
- let sub = '!{theme.subtitle.sub}'.length == 0 ? new Array() : '!{theme.subtitle.sub}'.split(",");
- let both = sub.unshift(con,from)
- let typed = new Typed("#subtitle", {
+ var from = "出自 " + str[1];
+ var sub = '!{theme.subtitle.sub}'.length == 0 ? new Array() : '!{theme.subtitle.sub}'.split(",");
+ var both = sub.unshift(con,from)
+ var typed = new Typed("#subtitle", {
strings: sub,
startDelay: 300,
typeSpeed: 150,
@@ -81,13 +81,13 @@ if theme.subtitle.enable
else if source == '4'
script(type="text/javascript" src="https://sdk.jinrishici.com/v2/browser/jinrishici.js" charset="utf-8")
script.
- let subtitleEffect = !{subtitleEffect}
+ var subtitleEffect = !{subtitleEffect}
jinrishici.load(function(result) {
if (subtitleEffect){
- let sub = '!{theme.subtitle.sub}'.length == 0 ? new Array() : '!{theme.subtitle.sub}'.split(",");
- let content = result.data.content;
- let both = sub.unshift(content)
- let typed = new Typed("#subtitle", {
+ var sub = '!{theme.subtitle.sub}'.length == 0 ? new Array() : '!{theme.subtitle.sub}'.split(",");
+ var content = result.data.content;
+ var both = sub.unshift(content)
+ var typed = new Typed("#subtitle", {
strings: sub,
startDelay: 300,
typeSpeed: 150,
@@ -102,9 +102,9 @@ if theme.subtitle.enable
else
- var subtitle = theme.subtitle.sub[0]
script.
- let subtitleEffect = !{subtitleEffect}
+ var subtitleEffect = !{subtitleEffect}
if (subtitleEffect){
- let typed = new Typed("#subtitle", {
+ var typed = new Typed("#subtitle", {
strings: '!{theme.subtitle.sub}'.split(","),
startDelay: 300,
typeSpeed: 150,
diff --git a/layout/includes/header/header.pug b/layout/includes/header/header.pug
index 9346dd0..e6a22cc 100644
--- a/layout/includes/header/header.pug
+++ b/layout/includes/header/header.pug
@@ -1,15 +1,18 @@
#page-header
span#blog_name.pull_left
a#site-name.blog_title(href=url_for('/')) #[=config.title]
- span.toggle-menu.pull_right.close
- a.site-page
- i.fa.fa-bars.fa-fw(aria-hidden="true")
+
span.pull_right.menus
+ if (theme.algolia_search.enable || theme.local_search && theme.local_search.enable)
+ #search_button
+ a.site-page.social-icon.search
+ i.fa.fa-search.fa-fw
+ span=' '+_p('search')
.menus_items
include ./menu_item.pug
- if (theme.algolia_search.enable || theme.local_search && theme.local_search.enable)
- span#search_button.pull_right
- a.site-page.social-icon.search
- i.fa.fa-search.fa-fw
- span=' '+_p('search')
+ span.toggle-menu.close
+ a.site-page
+ i.fa.fa-bars.fa-fw(aria-hidden="true")
+
+
diff --git a/layout/includes/header/index.pug b/layout/includes/header/index.pug
index b3c9d9d..3198591 100644
--- a/layout/includes/header/index.pug
+++ b/layout/includes/header/index.pug
@@ -33,9 +33,7 @@ if theme.douban
span#subtitle
if(theme.social)
#site_social_icons
- each url, icon in theme.social
- a.social-icon(href=url target="_blank")
- i(class=icon aria-hidden="true")
+ !=partial('includes/header/social', {}, {cache:theme.fragment_cache})
#scroll_down
i.fa.fa-angle-down.scroll-down-effects
else if is_post()
diff --git a/layout/includes/header/post-info.pug b/layout/includes/header/post-info.pug
index fd533d8..9f7a011 100644
--- a/layout/includes/header/post-info.pug
+++ b/layout/includes/header/post-info.pug
@@ -1,51 +1,65 @@
#post-info
#post-title
.posttitle= page.title || _p('no_title')
+
#post-meta
- if (theme.post_meta.post.date_type)
- if (theme.post_meta.post.date_type === 'both')
- time.post-meta__date
- i.fa.fa-calendar(aria-hidden="true")
- =' '+_p('post.created')+' '+date(page.date, config.date_format)
- span.post-meta__separator |
- i.fa.fa-history(aria-hidden="true")
- =' '+_p('post.updated')+' '+date(page.updated, config.date_format)
- else
- - var data_type_update = theme.post_meta.post.date_type === 'updated'
- - var date_type = data_type_update ? 'updated' : 'date'
- - var date_icon = data_type_update ? 'fa-history' :'fa-calendar'
- - var data_info = data_type_update ? _p('post.updated') : _p('post.created')
- time.post-meta__date
- i.fa(class=date_icon aria-hidden="true")
- =' ' + data_info + ' ' + date(page[date_type], config.date_format)
-
- if (theme.post_meta.post.categories && page.categories.data.length > 0)
+ .meta-firstline
if (theme.post_meta.post.date_type)
- span.post-meta__separator |
- span
- each item, index in page.categories.data
- i.fa.fa-inbox.post-meta__icon(aria-hidden="true")
- a(href=url_for(item.path)).post-meta__categories #[=item.name]
- if (index < page.categories.data.length - 1)
- i.fa.fa-angle-right.post-meta__separator(aria-hidden="true")
- .post-meta-wordcount
- if (theme.wordcount && theme.wordcount.enable)
- - var wordCountIcon = theme.fontawesome_v5 && theme.fontawesome_v5.enable ? 'far fa-file-word' : 'fa fa-file-word-o'
- i.post-meta__icon(class=wordCountIcon aria-hidden="true")
- span= _p('post.wordcount') + ':'
- span.word-count= wordcount(page.content)
- span.post-meta__separator |
- - var readCountIcon = theme.fontawesome_v5 && theme.fontawesome_v5.enable ? 'far fa-clock' : 'fa fa-clock-o'
- i.post-meta__icon(class=readCountIcon aria-hidden="true")
- span= _p('post.min2read', min2read(page.content, {cn: 350, en: 160}))
- .post-meta-pv-cv
- if (theme.wordcount && theme.wordcount.enable && theme.busuanzi.page_pv)
+ if (theme.post_meta.post.date_type === 'both')
+ time.post-meta__date
+ span.post-meta__date-created(title= _p('post.created')+' '+full_date(page.date))
+ i.fa.fa-calendar(aria-hidden="true")
+ =' '+_p('post.created')+' '+date(page.date, config.date_format)
+ span.post-meta__separator |
+ span.post-meta__date-updated(title= _p('post.updated')+' '+full_date(page.updated))
+ i.fa.fa-history(aria-hidden="true")
+ =' '+_p('post.updated')+' '+date(page.updated, config.date_format)
+ else
+ - var data_type_update = theme.post_meta.post.date_type === 'updated'
+ - var date_type = data_type_update ? 'updated' : 'date'
+ - var date_icon = data_type_update ? 'fa-history' :'fa-calendar'
+ - var data_info = data_type_update ? _p('post.updated') : _p('post.created')
+ time.post-meta__date(title=data_info + ' ' + full_date(page[date_type]))
+ i.fa(class=date_icon aria-hidden="true")
+ =' ' + data_info + ' ' + date(page[date_type], config.date_format)
+
+ if (theme.post_meta.post.categories && page.categories.data.length > 0)
+ span.post-meta__categories
+ if (theme.post_meta.post.date_type)
+ span.post-meta__separator |
+
+ each item, index in page.categories.data
+ i.fa.fa-inbox.post-meta__icon(aria-hidden="true")
+ a(href=url_for(item.path)).post-meta__categories #[=item.name]
+ if (index < page.categories.data.length - 1)
+ i.fa.fa-angle-right.post-meta__separator(aria-hidden="true")
+
+ .meta-secondline
+ - let postWordcount = theme.wordcount.enable && (theme.wordcount.post_wordcount || theme.wordcount.min2read)
+ if (postWordcount)
+ span.post-meta-wordcount
+ if theme.wordcount.post_wordcount
+ - var wordCountIcon = theme.fontawesome_v5 && theme.fontawesome_v5.enable ? 'far fa-file-word' : 'fa fa-file-word-o'
+ i.post-meta__icon(class=wordCountIcon aria-hidden="true")
+ span= _p('post.wordcount') + ':'
+ span.word-count= wordcount(page.content)
+ if theme.wordcount.min2read
+ span.post-meta__separator |
+ if theme.wordcount.min2read
+ - var readCountIcon = theme.fontawesome_v5 && theme.fontawesome_v5.enable ? 'far fa-clock' : 'fa fa-clock-o'
+ i.post-meta__icon(class=readCountIcon aria-hidden="true")
+ span= _p('post.min2read', min2read(page.content, {cn: 350, en: 160}))
+
+ .meta-thirdline
+ span.post-meta-pv-cv
+ if (postWordcount && theme.busuanzi.page_pv)
span.post-meta__separator |
if theme.busuanzi.page_pv
i.fa.fa-eye.post-meta__icon(aria-hidden="true")
span=_p('post.page_pv') + ':'
span#busuanzi_value_page_pv
-
+
+ span.post-meta-commentcount
- var commentCount = theme.fontawesome_v5 && theme.fontawesome_v5.enable ? 'far fa-comments' : 'fa fa-comment-o'
if ((theme.disqus && theme.disqus.enable && theme.disqus.count && page.comments !== false) || (theme.disqusjs && theme.disqusjs.enable && theme.disqusjs.count && page.comments !== false))
if (theme.busuanzi && theme.busuanzi.page_pv)
@@ -54,14 +68,14 @@
span= _p('post.comments') + ':'
span.disqus-comment-count.comment-count
a(href=full_url_for(page.path) + '#disqus_thread')
- if (theme.valine && theme.valine.enable && theme.valine.count && page.comments !== false)
+ else if (theme.valine && theme.valine.enable && theme.valine.count && page.comments !== false)
if (theme.busuanzi && theme.busuanzi.page_pv)
span.post-meta__separator |
i.post-meta__icon(class=commentCount aria-hidden="true")
span= _p('post.comments') + ':'
a(href=url_for(page.path) + '#post-comment' itemprop="discussionUrl")
span.valine-comment-count.comment-count(data-xid=url_for(page.path) itemprop="commentCount")
- if (theme.gitalk && theme.gitalk.enable && theme.gitalk.count && page.comments !== false)
+ else if (theme.gitalk && theme.gitalk.enable && theme.gitalk.count && page.comments !== false)
if (theme.busuanzi && theme.busuanzi.page_pv)
span.post-meta__separator |
i.post-meta__icon(class=commentCount aria-hidden="true")
diff --git a/layout/includes/header/social.pug b/layout/includes/header/social.pug
new file mode 100644
index 0000000..6c0a49e
--- /dev/null
+++ b/layout/includes/header/social.pug
@@ -0,0 +1,4 @@
+each url, icon in theme.social
+ a.social-icon(href=trim(url.split('||')[0]) target="_blank"
+ title=url.split('||')[1] === undefined ? '' : trim(url.split('||')[1]))
+ i(class=icon aria-hidden="true")
\ No newline at end of file
diff --git a/layout/includes/layout.pug b/layout/includes/layout.pug
index a56961d..e86899c 100644
--- a/layout/includes/layout.pug
+++ b/layout/includes/layout.pug
@@ -1,5 +1,4 @@
- var hideAside = !theme.aside.enable || page.aside === false ? 'hide-aside' : ''
-- var autoOpenSidebar = theme.auto_open_sidebar.enable === true ? 'on' : ''
doctype html
html(lang=config.language data-theme=theme.display_mode)
@@ -8,10 +7,11 @@ html(lang=config.language data-theme=theme.display_mode)
body
if theme.fireworks && theme.fireworks.enable
canvas.fireworks
+
!=partial('includes/mobile-sidebar/index', {}, {cache:theme.fragment_cache})
- if (is_post() && page.toc != false && theme.toc.enable)
- i.fa.fa-arrow-right#toggle-sidebar(aria-hidden="true" class=autoOpenSidebar)
- include ./sidebar.pug
+
+ include ./sidebar.pug
+
#body-wrap
if theme.background
- var is_photo = theme.background.substring(3,0) === 'url' ? 'photo':'color'
@@ -36,10 +36,14 @@ html(lang=config.language data-theme=theme.display_mode)
- var is_bg = theme.footer_bg == false ? 'color' : 'photo'
footer#footer(style=footer_bg data-type=is_bg)
!=partial('includes/footer', {}, {cache:theme.fragment_cache})
+
include ./rightside.pug
+
!=partial('includes/search/index', {}, {cache:theme.fragment_cache})
+
each item in theme.CDN_USE.js
script(src=url_for(item))
+
include ./additional-js.pug
diff --git a/layout/includes/mixins/UI.pug b/layout/includes/mixins/UI.pug
index be072ec..5cedd81 100644
--- a/layout/includes/mixins/UI.pug
+++ b/layout/includes/mixins/UI.pug
@@ -19,15 +19,19 @@ mixin UI_NEW(posts)
if (theme.post_meta.page.date_type)
if (theme.post_meta.page.date_type === 'both')
time.post-meta__date
- i.fa.fa-calendar(aria-hidden="true")
- =date(article.date, config.date_format)
+ span.post-meta__date-created(title=_p('post.created') + ' ' + full_date(article.date))
+ i.fa.fa-calendar(aria-hidden="true")
+ =date(article.date, config.date_format)
span.article-meta__separator |
- i.fa.fa-history(aria-hidden="true")
- =date(article.updated, config.date_format)
+ span.post-meta__date-updated(title=_p('post.updated') + ' ' + full_date(article.updated))
+ i.fa.fa-history(aria-hidden="true")
+ =date(article.updated, config.date_format)
else
- - var date_type = theme.post_meta.page.date_type === 'updated' ? 'updated' : 'date'
- - var date_icon = theme.post_meta.page.date_type === 'updated' ? 'fa-history' :'fa-calendar'
- time.post-meta__date
+ - var data_type_updated = theme.post_meta.page.date_type === 'updated'
+ - var date_type = data_type_updated ? 'updated' : 'date'
+ - var date_icon = data_type_updated ? 'fa-history' :'fa-calendar'
+ - var date_title = data_type_updated ? _p('post.updated') : _p('post.created')
+ time.post-meta__date(title=date_title + ' ' + full_date(article[date_type]))
i.fa(class=date_icon aria-hidden="true")
=date(article[date_type], config.date_format)
if (theme.post_meta.page.categories && article.categories.data.length > 0)
@@ -53,4 +57,9 @@ mixin UI_NEW(posts)
.content!= expert
else
.content!= article.description
+
+ if theme.ad && theme.ad.index
+ if (index + 1) % 3 == 0
+ .recent-post-item.ad_height!=theme.ad.index
+
- })
\ No newline at end of file
diff --git a/layout/includes/mixins/article-sort.pug b/layout/includes/mixins/article-sort.pug
index 41801d1..25bf57a 100644
--- a/layout/includes/mixins/article-sort.pug
+++ b/layout/includes/mixins/article-sort.pug
@@ -15,6 +15,6 @@ mixin articleSort(posts)
.article-sort-post
a.article-sort-item__post(href=url_for(article.path))
i.fa.fa-clock-o(aria-hidden="true")
- time.article-sort-item__time= date(article.date)
+ time.article-sort-item__time(title=_p('post.created') + ' ' + full_date(article.date))= date(article.date, config.date_format)
.article-sort-item__title= article.title || 'No Title'
- })
\ No newline at end of file
diff --git a/layout/includes/recent-posts.pug b/layout/includes/recent-posts.pug
index b5a27bd..46fb9de 100644
--- a/layout/includes/recent-posts.pug
+++ b/layout/includes/recent-posts.pug
@@ -23,15 +23,19 @@ each article , index in page.posts.data
if (theme.post_meta.page.date_type)
if (theme.post_meta.page.date_type === 'both')
time.post-meta__date
- i.fa.fa-calendar(aria-hidden="true")
- =date(article.date, config.date_format)
+ span.post-meta__date-created(title=_p('post.created') + ' ' + full_date(article.date))
+ i.fa.fa-calendar(aria-hidden="true")
+ =date(article.date, config.date_format)
span.article-meta__separator |
- i.fa.fa-history(aria-hidden="true")
- =date(article.updated, config.date_format)
+ span.post-meta__date-updated(title=_p('post.updated') + ' ' + full_date(article.updated))
+ i.fa.fa-history(aria-hidden="true")
+ =date(article.updated, config.date_format)
else
- - var date_type = theme.post_meta.page.date_type === 'updated' ? 'updated' : 'date'
- - var date_icon = theme.post_meta.page.date_type === 'updated' ? 'fa-history' :'fa-calendar'
- time.post-meta__date
+ - var data_type_updated = theme.post_meta.page.date_type === 'updated'
+ - var date_type = data_type_updated ? 'updated' : 'date'
+ - var date_icon = data_type_updated ? 'fa-history' :'fa-calendar'
+ - var date_title = data_type_updated ? _p('post.updated') : _p('post.created')
+ time.post-meta__date(title=date_title + ' ' + full_date(article[date_type]))
i.fa(class=date_icon aria-hidden="true")
=date(article[date_type], config.date_format)
if (theme.post_meta.page.categories && article.categories.data.length > 0)
@@ -56,4 +60,8 @@ each article , index in page.posts.data
- content.length > theme.auto_excerpt.length ? expert += ' ...' : ''
.content!= expert
else
- .content!= article.description
\ No newline at end of file
+ .content!= article.description
+
+ if theme.ad && theme.ad.index
+ if (index + 1) % 3 == 0
+ .recent-post-item.ad_height!=theme.ad.index
diff --git a/layout/includes/rightside.pug b/layout/includes/rightside.pug
index 0c64a3e..88b1ad8 100644
--- a/layout/includes/rightside.pug
+++ b/layout/includes/rightside.pug
@@ -18,6 +18,6 @@ section#rightside.rightside
if is_post() && page.comments !== false && isComment
a#to_comment(href="#post-comment" title=_p("rightside.scroll_to_comment"))
i.scroll_to_comment.fa.fa-comments
- if is_post() && page.toc != false && theme.toc.enable
+ if is_post() && page.toc !== false && theme.toc.enable && (toc(page.content) !== '' || page.encrypt == true )
i#mobile-toc-button.fa.fa-list-ul.close(title=_p("rightside.toc") aria-hidden="true")
i.fa.fa-arrow-up#go-up(title=_p("rightside.back_to_top") aria-hidden="true")
diff --git a/layout/includes/sidebar.pug b/layout/includes/sidebar.pug
index ac6d5be..435c73a 100644
--- a/layout/includes/sidebar.pug
+++ b/layout/includes/sidebar.pug
@@ -1,12 +1,16 @@
-#sidebar
- - const showToc = is_post() && page.toc != false && theme.toc.enable
- -
- let tocNumber
- if (page.toc_number !== undefined) tocNumber = page.toc_number
- else if (theme.toc.number !== undefined) tocNumber = theme.toc.number
- else tocNumber = true
- -
- if(showToc)
+- let showToc = is_post() && page.toc !== false && theme.toc.enable && (toc(page.content) !== '' || page.encrypt == true )
+- let autoOpenSidebar = theme.auto_open_sidebar.enable === true ? 'on' : ''
+
+-
+ let tocNumber
+ if (page.toc_number !== undefined) tocNumber = page.toc_number
+ else if (theme.toc.number !== undefined) tocNumber = theme.toc.number
+ else tocNumber = true
+-
+
+if(showToc)
+ i.fa.fa-arrow-right#toggle-sidebar(aria-hidden="true" class=autoOpenSidebar)
+ #sidebar
.sidebar-toc
div.sidebar-toc__title= _p('sidebar.catalog')
div.sidebar-toc__progress
@@ -18,4 +22,4 @@
div.sidebar-toc__content.toc-div-class(style="display:none")!=toc(page.origin, {list_number: tocNumber})
else
div.sidebar-toc__content!=toc(page.content, {list_number: tocNumber})
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/layout/includes/widget/card_ad.pug b/layout/includes/widget/card_ad.pug
new file mode 100644
index 0000000..c05f774
--- /dev/null
+++ b/layout/includes/widget/card_ad.pug
@@ -0,0 +1,2 @@
+.card-widget.card-ad
+ != theme.ad.aside
diff --git a/layout/includes/widget/card_author.pug b/layout/includes/widget/card_author.pug
index 426697d..c138153 100644
--- a/layout/includes/widget/card_author.pug
+++ b/layout/includes/widget/card_author.pug
@@ -31,6 +31,4 @@
if(theme.social)
.card-info-social-icons.is-center
- each url, icon in theme.social
- a.social-icon(href=url target="_blank")
- i(class=icon aria-hidden="true")
+ include ../header/social.pug
diff --git a/layout/includes/widget/card_recent_post.pug b/layout/includes/widget/card_recent_post.pug
index d82fa17..3408887 100644
--- a/layout/includes/widget/card_recent_post.pug
+++ b/layout/includes/widget/card_recent_post.pug
@@ -20,8 +20,6 @@
img.aside-post-bg(src=`${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')
- if (theme.post_meta.page.date_type)
- - var date_type = theme.post_meta.page.date_type == 'updated' ? 'updated' : 'date'
- time.aside-post_meta.post-meta__date #[=date(article[date_type], config.date_format)]
+ time.aside-post_meta.post-meta__date(title=_p('post.created') + ' ' + full_date(article.date)) #[=date(article.date, config.date_format)]
- })
diff --git a/layout/includes/widget/card_webinfo.pug b/layout/includes/widget/card_webinfo.pug
index 17903af..5e0f852 100644
--- a/layout/includes/widget/card_webinfo.pug
+++ b/layout/includes/widget/card_webinfo.pug
@@ -12,6 +12,10 @@
.webinfo-item
.webinfo-runtime-name= _p('aside.card_webinfo.runtime_name') + " :"
#webinfo-runtime-count.webinfo-runtime-count(start_date=theme.runtimeshow.start_date)
+ if theme.wordcount.enable && theme.wordcount.total_wordcount
+ .webinfo-item
+ .webinfo-site-wordcount-name=_p('aside.card_webinfo.site_wordcount') + " :"
+ .webinfo-site-wordcount=totalcount(site)
if theme.busuanzi.site_uv
.webinfo-item
.webinfo-site-uv-name= _p('aside.card_webinfo.site_uv_name') + " :"
diff --git a/layout/includes/widget/index.pug b/layout/includes/widget/index.pug
index 1bd1b48..dc789d4 100644
--- a/layout/includes/widget/index.pug
+++ b/layout/includes/widget/index.pug
@@ -7,6 +7,8 @@ if theme.aside.enable
!=partial('includes/widget/card_announcement', {}, {cache:theme.fragment_cache})
if theme.aside.card_recent_post
!=partial('includes/widget/card_recent_post', {}, {cache:theme.fragment_cache})
+ if theme.ad && theme.ad.aside
+ !=partial('includes/widget/card_ad', {}, {cache:theme.fragment_cache})
if theme.aside.card_categories
!=partial('includes/widget/card_categories', {}, {cache:theme.fragment_cache})
if theme.aside.card_tags
diff --git a/layout/post.pug b/layout/post.pug
index b76c765..0411099 100644
--- a/layout/post.pug
+++ b/layout/post.pug
@@ -8,13 +8,17 @@ block content
if (theme.post_meta.post.tags)
.post-meta__tag-list
each item, index in page.tags.data
- a(href=url_for(item.path)).post-meta__tags #[=item.name]
+ a(href=url_for(item.path)).post-meta__tags #[=item.name]
!=partial('includes/share/index', {}, {cache:theme.fragment_cache})
if theme.reward.enable
!=partial('includes/post/reward', {}, {cache:theme.fragment_cache})
+
+ //- ad
+ if theme.ad && theme.ad.post
+ .post-ad!=theme.ad.post
+
include includes/pagination.pug
-
if theme.related_post && theme.related_post.enable
!= related_posts(page,site.posts)
if page.comments !== false
diff --git a/package.json b/package.json
index e4c0363..4fdd627 100644
--- a/package.json
+++ b/package.json
@@ -1,5 +1,5 @@
{
"name": "hexo-theme-butterfly",
- "version": "2.2.0",
+ "version": "2.2.5",
"description": "A Hexo Theme: Butterfly"
}
\ No newline at end of file
diff --git a/scripts/filters/post-lazyload.js b/scripts/filters/post-lazyload.js
index e3c8177..c0a6624 100644
--- a/scripts/filters/post-lazyload.js
+++ b/scripts/filters/post-lazyload.js
@@ -1,11 +1,10 @@
'use strict';
-const fs = require('hexo-fs');
const url_for = 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) => {
+ return htmlContent.replace(/
/gi, (str, p1, p2, p3) => {
if (/data-src/gi.test(str)) {
return str;
}
@@ -14,10 +13,10 @@ function lazyProcess(htmlContent) {
return classStr.replace(p1, `${p1} lazyload`);
})
str = str.replace(p2, `${bg}`)
- return str.replace(p3, `${p3} data-src="${p2}"`);
+ return str.replace('>', ` data-src="${p2}">`);
}
str = str.replace(p2, `${bg}`)
- return str.replace(p3, `${p3} class="lazyload" data-src="${p2}"`);
+ return str.replace(p3, ` class="lazyload" data-src="${p2}" ${p3}`);
});
}
diff --git a/scripts/helpers/list-archives.js b/scripts/helpers/list-archives.js
index 10738bc..534d4fe 100644
--- a/scripts/helpers/list-archives.js
+++ b/scripts/helpers/list-archives.js
@@ -89,7 +89,7 @@ hexo.extend.helper.register("list_archives", function(options = {}) {
}
if (data.length > limit) {
- result += `