From 16a3ac510dd5372adbff2e4ff4019c783fe5ab0d Mon Sep 17 00:00:00 2001 From: Jerry Date: Sat, 28 Mar 2020 03:13:30 +0800 Subject: [PATCH] =?UTF-8?q?:bookmark:=202.2.5=E7=99=BC=E4=BD=88=20?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=86=85=E5=AE=B9=E8=AB=8B=E7=9C=8B=20https:?= =?UTF-8?q?//github.com/jerryc127/hexo-theme-butterfly/releases?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- README_CN.md | 2 +- _config.yml | 13 +- languages/zh-TW.yml | 6 +- layout/404.pug | 82 ++--------- layout/includes/additional-js.pug | 2 +- layout/includes/head.pug | 19 ++- layout/includes/head/config.pug | 31 ++-- layout/includes/head/config_site.pug | 5 +- layout/includes/head/darkmode.pug | 16 +-- layout/includes/head/noscript.pug | 9 ++ .../{index-js.pug => head/subtitle.pug} | 48 +++---- layout/includes/header/header.pug | 19 +-- layout/includes/header/index.pug | 4 +- layout/includes/header/post-info.pug | 14 +- layout/includes/header/social.pug | 4 + layout/includes/layout.pug | 12 +- layout/includes/mixins/UI.pug | 18 ++- layout/includes/mixins/article-sort.pug | 2 +- layout/includes/recent-posts.pug | 18 ++- layout/includes/rightside.pug | 2 +- layout/includes/sidebar.pug | 24 ++-- layout/includes/widget/card_author.pug | 4 +- layout/includes/widget/card_recent_post.pug | 4 +- layout/includes/widget/card_webinfo.pug | 2 +- package.json | 2 +- scripts/filters/post-lazyload.js | 7 +- scripts/helpers/list-archives.js | 2 +- source/css/_global/index.styl | 23 +-- source/css/_layout/aside.styl | 4 - source/css/_layout/flink.styl | 3 + source/css/_layout/gallery.styl | 3 + source/css/_layout/head.styl | 135 +++++++++--------- source/css/_layout/page.styl | 1 + source/js/main.js | 130 ++++++++--------- 35 files changed, 322 insertions(+), 350 deletions(-) create mode 100644 layout/includes/head/noscript.pug rename layout/includes/{index-js.pug => head/subtitle.pug} (69%) create mode 100644 layout/includes/header/social.pug 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 -Version +Version Author Hexo node.js 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 -Version +Version Author Hexo node.js diff --git a/_config.yml b/_config.yml index 27c7668..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 @@ -170,6 +170,7 @@ post_meta: # Please see doc for more details: https://docs.jerryc.me/config.html#字數統計 wordcount: + enable: false post_wordcount: true min2read: true total_wordcount: true @@ -356,6 +357,10 @@ related_post: limit: 6 # 顯示推薦文章數目 date_type: created # or created or updated 文章日期顯示創建日或者更新日 +# figcaption +# 圖片描述文字 +photofigcaption: false + #### 美化/效果 #### #-------------------------------- diff --git a/languages/zh-TW.yml b/languages/zh-TW.yml index 166be03..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: 文章作者 @@ -78,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 88a8633..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 1737790..9f7a011 100644 --- a/layout/includes/header/post-info.pug +++ b/layout/includes/header/post-info.pug @@ -7,17 +7,19 @@ 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__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 | - i.fa.fa-history(aria-hidden="true") - =' '+_p('post.updated')+' '+date(page.updated, config.date_format) + 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 + 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) @@ -33,7 +35,7 @@ i.fa.fa-angle-right.post-meta__separator(aria-hidden="true") .meta-secondline - - let postWordcount = theme.wordcount.post_wordcount || theme.wordcount.min2read + - let postWordcount = theme.wordcount.enable && (theme.wordcount.post_wordcount || theme.wordcount.min2read) if (postWordcount) span.post-meta-wordcount if theme.wordcount.post_wordcount 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 b0e5001..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) 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 3eeaaf5..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) 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_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 6691f7b..5e0f852 100644 --- a/layout/includes/widget/card_webinfo.pug +++ b/layout/includes/widget/card_webinfo.pug @@ -12,7 +12,7 @@ .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.total_wordcount + 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) 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 += `
  • `; + result += `
  • `; result += `