From 16a3ac510dd5372adbff2e4ff4019c783fe5ab0d Mon Sep 17 00:00:00 2001 From: Jerry Date: Sat, 28 Mar 2020 03:13:30 +0800 Subject: [PATCH 01/24] =?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 += `' + return result +}) diff --git a/scripts/helpers/my-html.js b/scripts/helpers/my-html.js index d3debb9..9a928c5 100644 --- a/scripts/helpers/my-html.js +++ b/scripts/helpers/my-html.js @@ -1,23 +1,24 @@ -"use strict"; +/** + * Butterfly + * Generate js and css according to user setting + */ -hexo.extend.helper.register("my_html", function(type, data) { - var result = ""; - var tag = type === "css" ? "css" : "script"; +'use strict' + +hexo.extend.helper.register('my_html', function (type, data) { + var result = '' + var tag = type === 'css' ? 'css' : 'script' for (var i = 0; i < data.length; i++) { - var src = data[i].split("||")[0].trim(); - var other = data[i].split("||")[1] ? data[i].split("||")[1].trim() : ""; + var src = data[i].split('||')[0].trim() + var other = data[i].split('||')[1] ? data[i].split('||')[1].trim() : '' - if (tag === "css") { + if (tag === 'css') { result += - '"; + '' } else { result += - '"; + '' } } - return result; -}); + return result +}) diff --git a/scripts/helpers/related-post.js b/scripts/helpers/related-post.js index 455eff0..68e67a1 100644 --- a/scripts/helpers/related-post.js +++ b/scripts/helpers/related-post.js @@ -1,5 +1,13 @@ +/** + * Butterfly + * Related Posts + * According the tag + */ + +'use strict' + hexo.extend.helper.register('related_posts', function (currentPost, allPosts) { - var relatedPosts = []; + var relatedPosts = [] currentPost.tags.forEach(function (tag) { allPosts.forEach(function (post) { if (isTagRelated(tag.name, post.tags)) { @@ -11,80 +19,108 @@ hexo.extend.helper.register('related_posts', function (currentPost, allPosts) { weight: 1, updated: post.updated, created: post.date - }; - var index = findItem(relatedPosts, 'path', post.path); - if (index != -1) { - relatedPosts[index].weight += 1; + } + var index = findItem(relatedPosts, 'path', post.path) + if (index !== -1) { + relatedPosts[index].weight += 1 } else { - if (currentPost.path != post.path) { - relatedPosts.push(relatedPost); - }; - }; - }; - }); - }); - if (relatedPosts.length == 0) { + if (currentPost.path !== post.path) { + relatedPosts.push(relatedPost) + } + } + } + }) + }) + if (relatedPosts.length === 0) { return '' - }; - var result = ""; - const hexoConfig = hexo.theme.config.rootConfig; - const config = hexo.theme.config; + } + var result = '' + const hexoConfig = hexo.theme.config.rootConfig + const config = hexo.theme.config - var limit_num = config.related_post.limit || 6 - var date_type = config.related_post.date_type || 'created' - var headline_lang = this._p('post.recommend') - - relatedPosts = relatedPosts.sort(compare('weight')); - var lazy_src = config.lazyload.enable ? lazy_src = 'data-src' : lazy_src = 'src' - var lazy_class = config.lazyload.enable ? lazy_class = 'lazyload' : lazy_class = '' + 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' : '' + + relatedPosts = relatedPosts.sort(compare('weight')) if (relatedPosts.length > 0) { result += '
  • ' + + result += `` + result += `${cat.name}` + + if (showCount) { + result += `${cat.length}` + } + + result += '' + result += '
  • ' + + if (child) { + result += `
      ${child}
    ` + } + } + }) + } + + return [result, t] + } + + const list = hierarchicalList(limit, 0) + + var moreButton = function () { + var moreHtml = '' + if (categories.length <= limit) return '' + moreHtml += '
  • ' + moreHtml += `` + moreHtml += buttonLabel + moreHtml += '
  • ' + return moreHtml + } + + return `
      + ${list[0]} + ${moreButton()} +
    ` +}) diff --git a/source/css/_layout/aside.styl b/source/css/_layout/aside.styl index 6ed0ff5..a4c40d5 100644 --- a/source/css/_layout/aside.styl +++ b/source/css/_layout/aside.styl @@ -148,13 +148,13 @@ height: auto .card-archives ul.archive-list, - .card-categories ul.aside-category-item + .card-categories ul.aside-category-list margin: 0 padding: .2rem 0 0 list-style: none .card-archives ul.archive-list > .archive-list-item, - .card-categories ul.aside-category-item > .aside-category-list + .card-categories ul.aside-category-list > .aside-category-list-item padding: .2rem 1rem cursor: pointer transition: all .3s @@ -181,7 +181,7 @@ text-align: right .card-categories - .aside-category-item + .aside-category-list &.child padding: 0 0 0 1.2rem diff --git a/source/css/_mode/darkmode.styl b/source/css/_mode/darkmode.styl index ed12656..7f38f48 100644 --- a/source/css/_mode/darkmode.styl +++ b/source/css/_mode/darkmode.styl @@ -138,7 +138,7 @@ if hexo-config('darkmode.enable') || hexo-config('display_mode') == 'dark' border-top: 13px solid lighten(#121212, 10) !important .md-links-item:before, - .aside-category-list:hover, + .aside-category-list-item:hover, .archive-list-item:hover, #bookmark-it background-color: lighten(#121212, 10) !important @@ -156,9 +156,11 @@ if hexo-config('darkmode.enable') || hexo-config('display_mode') == 'dark' .headline, .length_num, .aside-post_title, - .aside-category-list_link, + .aside-category-list-link, .archive-list-link, - .social-icon + .social-icon, + .aside-category-list-item-more, + .archive-list-link-more color: alpha(#FFFFFF, .6) !important .button--animated:before From e81a81c9d1a51db72a1823a74776ba232fe3c432 Mon Sep 17 00:00:00 2001 From: Jerry Date: Tue, 7 Apr 2020 14:24:11 +0800 Subject: [PATCH 05/24] =?UTF-8?q?:sparkles:=20feat:=20=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E6=94=AF=E6=8C=81=E9=A1=AF=E7=A4=BA=E6=96=87?= =?UTF-8?q?=E7=AB=A0=E5=85=A7=E5=AE=B9=E5=92=8C=E9=AB=98=E4=BA=AEkeyword?= =?UTF-8?q?=20:bug:=20fix:=20=E4=BF=AE=E5=BE=A9=E6=90=9C=E7=B4=A2=E7=B5=90?= =?UTF-8?q?=E6=9E=9C=E5=9C=A8=E6=89=8B=E6=A9=9F=E7=AB=AF=E7=84=A1=E6=B3=95?= =?UTF-8?q?=E6=BB=BE=E5=8B=95=E7=9A=84bug=20:bug:=20fix:=20=E4=BF=AE?= =?UTF-8?q?=E5=BE=A9aside=20categories=20=E6=9F=A5=E7=9C=8B=E6=9B=B4?= =?UTF-8?q?=E5=A4=9A=E8=B7=B3=E8=BD=89=E5=88=B0tags=E9=A0=81=E9=9D=A2?= =?UTF-8?q?=E7=9A=84bug=20closes=20#188?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/helpers/aside_categories.js | 4 +- source/css/_search/index.styl | 3 +- source/css/_search/local-search.styl | 13 ++++++- source/css/var.styl | 1 + source/js/search/local-search.js | 58 +++++++++++++++++++++++++--- 5 files changed, 69 insertions(+), 10 deletions(-) diff --git a/scripts/helpers/aside_categories.js b/scripts/helpers/aside_categories.js index 8fa89d3..0bf44f5 100644 --- a/scripts/helpers/aside_categories.js +++ b/scripts/helpers/aside_categories.js @@ -18,7 +18,7 @@ hexo.extend.helper.register('aside_categories', function (categories, options) { const depth = options.depth ? parseInt(options.depth, 10) : 0 const orderby = options.orderby || 'name' const order = options.order || 1 - const tagDir = this.url_for(config.tag_dir) + const categoryDir = this.url_for(config.category_dir) const limit = options.limit === 0 ? categories.length : options.limit const buttonLabel = this._p('aside.more_button') const prepareQuery = parent => { @@ -74,7 +74,7 @@ hexo.extend.helper.register('aside_categories', function (categories, options) { var moreHtml = '' if (categories.length <= limit) return '' moreHtml += '
  • ' - moreHtml += `` + moreHtml += `` moreHtml += buttonLabel moreHtml += '
  • ' return moreHtml diff --git a/source/css/_search/index.styl b/source/css/_search/index.styl index bf3794e..79bb359 100644 --- a/source/css/_search/index.styl +++ b/source/css/_search/index.styl @@ -50,4 +50,5 @@ height: 100% .search-result-list - max-height: 100% !important + max-height: 75vh !important + padding-bottom: 2rem diff --git a/source/css/_search/local-search.styl b/source/css/_search/local-search.styl index e1861f9..534117f 100644 --- a/source/css/_search/local-search.styl +++ b/source/css/_search/local-search.styl @@ -18,7 +18,8 @@ .local-search__hit-item position: relative - padding-left: 1.5rem + padding-left: 1.3rem + line-height: 1.7 &:hover &:before @@ -27,7 +28,7 @@ &:before $w = .3rem position: absolute - top: .4rem + top: .3rem left: 0 width: w = $w height: h = w @@ -41,12 +42,20 @@ a display: block color: $font-black + font-weight: 600 font-size: 14px cursor: pointer &:hover color: $search-color + .search-result + margin: 0 0 .4rem + + .search-keyword + color: $search-keyword-highlight + font-weight: bold + .local-search-stats__hr display: none !important diff --git a/source/css/var.styl b/source/css/var.styl index 9be3e5d..49fb7d4 100644 --- a/source/css/var.styl +++ b/source/css/var.styl @@ -79,6 +79,7 @@ $reward-pop-up-color = #858585 // search $search-bg = #f6f8fa $search-color = $theme-color +$search-keyword-highlight = #F47466 //gallery $gallery-color = #fff // tag-hide diff --git a/source/js/search/local-search.js b/source/js/search/local-search.js index efcec8a..c2bee81 100644 --- a/source/js/search/local-search.js +++ b/source/js/search/local-search.js @@ -1,7 +1,10 @@ $(function () { var loadFlag = false $('a.social-icon.search').on('click', function () { - $('body').css({ width: '100%', overflow: 'hidden' }) + $('body').css({ + width: '100%', + overflow: 'hidden' + }) $('.search-dialog').css('display', 'block') $('#local-search-input input').focus() $('.search-mask').fadeIn() @@ -52,6 +55,7 @@ $(function () { url: $('url', this).text() } }).get() + var $input = $('#local-search-input input')[0] var $resultContent = $('#local-hits')[0] $input.addEventListener('input', function () { @@ -66,13 +70,17 @@ $(function () { // perform local searching datas.forEach(function (data) { var isMatch = true + if (!data.title || data.title.trim() === '') { + data.title = 'Untitled' + } var dataTitle = data.title.trim().toLowerCase() var dataContent = data.content.trim().replace(/<[^>]+>/g, '').toLowerCase() var dataUrl = data.url var indexTitle = -1 var indexContent = -1 + var firstOccur = -1 // only match artiles with not empty titles and contents - if (dataTitle !== '' && dataContent !== '') { + if (dataTitle !== '' || dataContent !== '') { keywords.forEach(function (keyword, i) { indexTitle = dataTitle.indexOf(keyword) indexContent = dataContent.indexOf(keyword) @@ -82,20 +90,60 @@ $(function () { if (indexContent < 0) { indexContent = 0 } + if (i === 0) { + firstOccur = indexContent + } } }) + } else { + isMatch = false } + // show search results if (isMatch) { - str += '' - count += 1 - $('.local-search-stats__hr').show() + var content = data.content.trim().replace(/<[^>]+>/g, '') + if (firstOccur >= 0) { + // cut out 130 characters + var start = firstOccur - 30 + var end = firstOccur + 100 + + if (start < 0) { + start = 0 + } + + if (start === 0) { + end = 100 + } + + if (end > content.length) { + end = content.length + } + + var matchContent = content.substring(start, end) + + // highlight all keywords + keywords.forEach(function (keyword) { + var regS = new RegExp(keyword, 'gi') + matchContent = matchContent.replace(regS, '' + keyword + '') + dataTitle = dataTitle.replace(regS, '' + keyword + '') + }) + + str += '
    ' + dataTitle + '' + count += 1 + $('.local-search-stats__hr').show() + + if (dataContent !== '') { + str += '

    ' + matchContent + '...

    ' + } + } + str += '
    ' } }) if (count === 0) { str += '
    ' + GLOBAL_CONFIG.localSearch.languages.hits_empty.replace(/\$\{query}/, this.value.trim()) + '
    ' } + str += '' $resultContent.innerHTML = str }) } From d62ec1b86656be7abf4b8f18f44e873621876814 Mon Sep 17 00:00:00 2001 From: Jerry <16351105+jerryc127@users.noreply.github.com> Date: Sun, 12 Apr 2020 02:40:54 +0800 Subject: [PATCH 06/24] =?UTF-8?q?:boom:=20=E6=94=B9cdn=5Fuse=E7=82=BAinjec?= =?UTF-8?q?t,=E5=8F=AF=E6=8F=92=E5=85=A5=E4=BB=A3=E7=A2=BC=E5=88=B0head?= =?UTF-8?q?=E6=88=96=E8=80=85bottom=20:boom:=20=E7=A7=BB=E9=99=A4=E5=B0=8D?= =?UTF-8?q?=E6=96=87=E7=AB=A0=E9=9A=B1=E8=97=8F=E7=9A=84=E6=94=AF=E6=8C=81?= =?UTF-8?q?=EF=BC=8C=E5=A6=82=E9=9C=80=E8=A6=81=EF=BC=8C=E8=AB=8B=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E6=8F=92=E4=BB=B6=EF=BC=8Chexo-hide-posts/hexo-genera?= =?UTF-8?q?tor-indexed=20:boom:=20=E7=A7=BB=E9=99=A4subtitle=E9=87=91?= =?UTF-8?q?=E5=B1=B1=E8=A9=9E=E9=9C=B8=E6=AF=8F=E6=97=A5=E4=B8=80=E5=8F=A5?= =?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=8A=A0=E6=90=8F=E5=A4=A9api=E7=9A=84?= =?UTF-8?q?=E9=9A=A8=E6=A9=9F=E8=AA=9E=E9=8C=84=20:sparkles:=20subtitle?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=82=BA=E7=B6=B2=E9=A0=81=E5=8A=A0=E8=BC=89?= =?UTF-8?q?=E5=AE=8C=E5=BE=8C=E5=86=8D=E5=8A=A0=E8=BC=89=EF=BC=8C=E9=98=B2?= =?UTF-8?q?=E6=AD=A2api=E5=9B=9E=E6=87=89=E9=81=8E=E6=85=A2=E8=80=8C?= =?UTF-8?q?=E9=98=BB=E7=A4=99=E7=B6=B2=E9=A0=81=E9=A1=AF=E7=A4=BA=20:spark?= =?UTF-8?q?les:=20=E9=81=A9=E9=85=8Dvaline=201.4.0,=20=E5=88=AA=E9=99=A4?= =?UTF-8?q?=E9=83=A8=E5=88=86valine=E5=A4=9C=E9=96=93=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E4=BB=A3=E7=A2=BC=20:sparkles:=20meta=E5=A2=9E=E5=8A=A0article?= =?UTF-8?q?:published=5Ftime=E5=92=8Carticle:modified=5Ftime=20:sparkles:?= =?UTF-8?q?=20=E7=95=B6=E6=B2=92=E6=9C=89=E8=A8=AD=E7=BD=AEDescription?= =?UTF-8?q?=E6=99=82=EF=BC=8C=E6=9C=83=E8=87=AA=E5=8B=95=E8=AE=80=E5=8F=96?= =?UTF-8?q?=E6=96=87=E7=AB=A0=E5=89=8D200=E5=80=8B=E6=96=87=E5=AD=97?= =?UTF-8?q?=E4=BD=9C=E7=82=BAmeta=20Description=20:sparkles:=20sidebar=20m?= =?UTF-8?q?enu=20=E5=A2=9E=E5=8A=A0=E9=A0=AD=E5=83=8F=E8=BD=89=E5=9C=88hov?= =?UTF-8?q?er=20:lipstick:=20=E8=AA=BF=E6=95=B4aside=E5=92=8Cmobile=20side?= =?UTF-8?q?bar=20=E7=B6=B2=E9=A0=81=E8=B3=87=E8=A8=8A=E4=BD=88=E5=B1=80?= =?UTF-8?q?=EF=BC=8C=E7=95=B6=E7=BC=BA=E5=B0=91=E4=B8=80=E5=80=8B=E6=99=82?= =?UTF-8?q?=EF=BC=8C=E5=AF=AC=E5=BA=A6=E4=BE=9D=E8=88=8A=E5=B9=B3=E5=88=86?= =?UTF-8?q?=20:bug:=20=E8=AA=BF=E6=95=B4=E5=AD=90=E7=9B=AE=E9=8C=84?= =?UTF-8?q?=E7=9A=84=E6=8E=92=E7=89=88=EF=BC=88=E5=90=91=E5=B7=A6=E5=B0=8D?= =?UTF-8?q?=E9=BD=8A=EF=BC=89=EF=BC=8C=E4=BF=AE=E5=BE=A9=E5=8F=AA=E8=83=BD?= =?UTF-8?q?=E9=BB=9E=E6=93=8A=E5=AD=90=E7=9B=AE=E9=8C=84=E6=96=87=E5=AD=97?= =?UTF-8?q?=E6=89=8D=E8=83=BD=E8=B7=B3=E8=BD=89=E7=9A=84bug=20:fire:=20pug?= =?UTF-8?q?=E7=B2=BE=E7=B0=A1=20=E5=88=AA=E9=99=A4recent-post.pug=20=20?= =?UTF-8?q?=E6=94=B9=E7=82=BA=E5=BC=95=E7=94=A8mixins/post-ui.pug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _config.yml | 34 ++-- languages/default.yml | 2 +- languages/en.yml | 2 +- layout/404.pug | 1 - layout/category.pug | 4 +- layout/includes/additional-js.pug | 8 +- layout/includes/comments/valine.pug | 5 +- layout/includes/head.pug | 12 +- layout/includes/head/Open_Graph.pug | 6 +- layout/includes/head/subtitle.pug | 192 ++++++++++-------- layout/includes/layout.pug | 4 - .../includes/mixins/{UI.pug => post-ui.pug} | 21 +- layout/includes/recent-posts.pug | 67 ------ layout/index.pug | 3 +- layout/tag.pug | 4 +- .../{replace-config.js => replace_config.js} | 0 scripts/filters/hide-post.js | 66 ------ .../{post-lazyload.js => post_lazyload.js} | 0 .../{random-cover.js => random_cover.js} | 0 scripts/helpers/my-html.js | 24 --- scripts/helpers/page.js | 31 +++ .../{related-post.js => related_post.js} | 0 scripts/tags/hide.js | 1 + source/css/_layout/aside.styl | 15 +- source/css/_layout/head.styl | 5 +- source/css/_layout/mobile-sidebar.styl | 17 +- source/css/_layout/post.styl | 6 +- source/css/_layout/third-party.styl | 16 +- source/css/_mode/darkmode.styl | 46 +---- 29 files changed, 223 insertions(+), 369 deletions(-) rename layout/includes/mixins/{UI.pug => post-ui.pug} (83%) delete mode 100644 layout/includes/recent-posts.pug rename scripts/events/{replace-config.js => replace_config.js} (100%) delete mode 100644 scripts/filters/hide-post.js rename scripts/filters/{post-lazyload.js => post_lazyload.js} (100%) rename scripts/filters/{random-cover.js => random_cover.js} (100%) delete mode 100644 scripts/helpers/my-html.js create mode 100644 scripts/helpers/page.js rename scripts/helpers/{related-post.js => related_post.js} (100%) diff --git a/_config.yml b/_config.yml index 6f77cae..3587be5 100644 --- a/_config.yml +++ b/_config.yml @@ -259,15 +259,14 @@ valine: enable: false # if you want use valine,please set this value is true appId: # leancloud application app id appKey: # leancloud application app key - notify: false # valine mail notify (true/false) https://github.com/xCss/Valine/wiki - verify: false # valine verify code (true/false) pageSize: 10 # comment list page size avatar: monsterid # gravatar style https://valine.js.org/#/avatar - lang: en # i18n: zh-cn/en + lang: en # i18n: zh-CN/zh-TW/en/ja placeholder: Please leave your footprints # valine comment input placeholder(like: Please leave your footprints ) guest_info: nick,mail,link #valine comment header info recordIP: false # Record reviewer IP serverURLs: # This configuration is suitable for domestic custom domain name users, overseas version will be automatically detected (no need to manually fill in) + mathjax: false bg: /img/comment_bg.png # valine background count: true # top_img顯示評論數 @@ -493,8 +492,8 @@ subtitle: loop: false # source調用第三方服務 # source: false 關閉調用 - # source: 1 調用金山詞霸的每日一句(簡體) - # source: 2 調用一言網的一句話(簡體) #https://hitokoto.cn/ + # source: 1 調用搏天api的隨機語錄(簡體) https://api.btstu.cn/ + # source: 2 調用一言網的一句話(簡體) https://hitokoto.cn/ # source: 3 調用一句網(簡體) http://yijuzhan.com/ # source: 4 調用今日詩詞(簡體) https://www.jinrishici.com/ # subtitle 會先顯示 source , 再顯示 sub 的內容 @@ -662,21 +661,23 @@ Open_Graph_meta: true # 開啟hexo自帶的緩存,加快生成速度 fragment_cache: true -# CDN -# 網站必須 -# 可根據需要自行添加js/css -CDN_USE: - css: - - /css/index.css - - js: - - https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js #/js/third-party/jquery.min.js - - /js/utils.js - - /js/main.js +# inject +# 插入代码到头部之前 和 尾部之前 +inject: + head: + # - + bottom: + # - # CDN # 非必要不要修改 CDN: + # main + main_css: /css/index.css + jquery: https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js + main: /js/main.js + utils: /js/utils.js + # comments blueimp_md5: https://cdn.jsdelivr.net/npm/blueimp-md5/js/md5.min.js gitalk: https://cdn.jsdelivr.net/npm/gitalk@latest/dist/gitalk.min.js @@ -738,4 +739,5 @@ CDN: fontawesome_v4: https://cdn.jsdelivr.net/npm/font-awesome@latest/css/font-awesome.min.css fontawesome_v5: https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css + # 簡繁轉換 translate: /js/tw_cn.js diff --git a/languages/default.yml b/languages/default.yml index 5aaaa66..565d6e4 100644 --- a/languages/default.yml +++ b/languages/default.yml @@ -61,7 +61,7 @@ aside: card_tags: Tags card_archives: Archives card_recent_post: Recent Post - card_bookmark: Add to bookmark + card_bookmark: Bookmark card_webinfo: headline: Info article_name: Article diff --git a/languages/en.yml b/languages/en.yml index 5aaaa66..565d6e4 100644 --- a/languages/en.yml +++ b/languages/en.yml @@ -61,7 +61,7 @@ aside: card_tags: Tags card_archives: Archives card_recent_post: Recent Post - card_bookmark: Add to bookmark + card_bookmark: Bookmark card_webinfo: headline: Info article_name: Article diff --git a/layout/404.pug b/layout/404.pug index 73d6f37..b41dbd4 100644 --- a/layout/404.pug +++ b/layout/404.pug @@ -18,5 +18,4 @@ html(lang=config.language data-theme=theme.display_mode) #error_subtitle= theme.error_404.subtitle include includes/rightside.pug !=partial('includes/search/index', {}, {cache:theme.fragment_cache}) - !=fragment_cache('my_js', function(){return my_html('js',theme.CDN_USE.js)}) include includes/additional-js.pug diff --git a/layout/category.pug b/layout/category.pug index c8b5cb3..01ad990 100644 --- a/layout/category.pug +++ b/layout/category.pug @@ -2,9 +2,9 @@ extends includes/layout.pug block content if theme.category_ui == 'index' - include ./includes/mixins/UI.pug + include ./includes/mixins/post-ui.pug #recent-posts.recent-posts.category_ui - +UI_NEW(page.posts) + +postUI include includes/pagination.pug else include ./includes/mixins/article-sort.pug diff --git a/layout/includes/additional-js.pug b/layout/includes/additional-js.pug index 4393e51..54537dd 100644 --- a/layout/includes/additional-js.pug +++ b/layout/includes/additional-js.pug @@ -1,3 +1,7 @@ +script(src=url_for(theme.CDN.jquery)) +script(src=url_for(theme.CDN.utils)) +script(src=url_for(theme.CDN.main)) + if theme.translate && theme.translate.enable script(src=url_for(theme.CDN.translate)) @@ -62,4 +66,6 @@ if theme.mermaid.enable include ./math/mermaid.pug if is_home() - include ./head/subtitle.pug \ No newline at end of file + include ./head/subtitle.pug + +!=fragment_cache('injectBottom', function(){return injectHtml(theme.inject.bottom)}) diff --git a/layout/includes/comments/valine.pug b/layout/includes/comments/valine.pug index 71a771c..3c756da 100644 --- a/layout/includes/comments/valine.pug +++ b/layout/includes/comments/valine.pug @@ -9,8 +9,6 @@ script. window.valine = new Valine({ el:'#vcomment', - notify: #{theme.valine.notify}, - verify: #{theme.valine.verify}, appId: '#{theme.valine.appId}', appKey: '#{theme.valine.appKey}', placeholder: '#{theme.valine.placeholder}', @@ -19,5 +17,6 @@ script. pageSize: '#{theme.valine.pageSize}', lang: '#{theme.valine.lang}', recordIP: #{theme.valine.recordIP}, - serverURLs: '#{theme.valine.serverURLs}' + serverURLs: '#{theme.valine.serverURLs}', + mathjax: #{theme.valine.mathjax} }); diff --git a/layout/includes/head.pug b/layout/includes/head.pug index cff8c92..57cdd92 100644 --- a/layout/includes/head.pug +++ b/layout/includes/head.pug @@ -10,7 +10,7 @@ - var isSubtitle = config.subtitle ? ' - ' + config.subtitle : '' - var tabTitle = is_home() || !pageTitle ? config.title + isSubtitle : pageTitle + ' | ' + config.title -- var pageDescription = page.description || page.title || config.description +- var pageDescription = page_description() - 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 @@ -22,7 +22,7 @@ meta(charset='UTF-8') meta(http-equiv="X-UA-Compatible" content="IE=edge") meta(name="viewport" content="width=device-width,initial-scale=1") title= tabTitle -meta(name="description" content=pageDescription) +meta(name="description" content!=pageDescription) if pageKeywords meta(name="keywords" content=pageKeywords) meta(name="author" content=pageAuthor) @@ -34,9 +34,6 @@ if theme.disable_baidu_transformation meta(http-equiv="Cache-Control" content="no-transform") meta(http-equiv="Cache-Control" content="no-siteapp") -if page.hide == true - meta(name="robots" content="noindex") - if theme.douban if theme.douban.meta && (is_current('/movies/', [strict]) || is_current('/books/', [strict]) || is_current('/games/', [strict])) meta(name="referrer" content="no-referrer") @@ -59,7 +56,8 @@ script(src=url_for(theme.CDN.js_cookies)) if theme.darkmode.enable !=partial('includes/head/darkmode', {}, {cache:theme.fragment_cache}) -!=fragment_cache('my_css', function(){return my_html('css',theme.CDN_USE.css)}) +//- main css +link(rel='stylesheet', href=url_for(theme.CDN.main_css)) if theme.fontawesome_v5 && theme.fontawesome_v5.enable link(rel='stylesheet', href=url_for(theme.CDN.fontawesome_v5)) @@ -102,3 +100,5 @@ if theme.blog_title_font.font_link include ./head/config_site.pug include ./head/noscript.pug + +!=fragment_cache('injectHead', function(){return injectHtml(theme.inject.head)}) \ No newline at end of file diff --git a/layout/includes/head/Open_Graph.pug b/layout/includes/head/Open_Graph.pug index ff4a39b..bd751d4 100644 --- a/layout/includes/head/Open_Graph.pug +++ b/layout/includes/head/Open_Graph.pug @@ -4,7 +4,7 @@ if theme.twitter_meta meta(name="twitter:card" content="summary") meta(name="twitter:title" content=pageTitle) - meta(name="twitter:description" content=pageDescription) + meta(name="twitter:description" content!=pageDescription) meta(name="twitter:image" content=full_url_for(page.cover || theme.avatar.img)) //- Open_Graph @@ -13,5 +13,7 @@ if theme.Open_Graph_meta meta(property="og:title" content=pageTitle) meta(property="og:url" content=without_html) meta(property="og:site_name" content=config.title) - meta(property="og:description" content=pageDescription) + meta(property="og:description" content!=pageDescription) meta(property="og:image" content=full_url_for(page.cover || theme.avatar.img)) + meta(property="article:published_time" content=date_xml(page.date)) + meta(property="article:modified_time" content=date_xml(page.updated)) diff --git a/layout/includes/head/subtitle.pug b/layout/includes/head/subtitle.pug index b216f0c..e3be0dc 100644 --- a/layout/includes/head/subtitle.pug +++ b/layout/includes/head/subtitle.pug @@ -7,103 +7,117 @@ if theme.subtitle.enable if source == '1' script. - var subtitleEffect = !{subtitleEffect} - fetch('https://api.ooopn.com/ciba/api.php',) - .then(function (res){ - return res.json(); - }) - .then(function (data) { - if (subtitleEffect){ - 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, - loop: !{theme.subtitle.loop}, - backSpeed: 50 - }); - }else{ - document.getElementById("subtitle").innerHTML = data['ciba-en'] - } - }) - .catch(function (err) { - console.error(err); - }) + var subtitleType = function () { + var subtitleEffect = !{ subtitleEffect } + fetch('https://api.btstu.cn/yan/api.php?charset=utf-8&encode=json',) + .then(function (res) { + return res.json() + }) + .then(function (data) { + if (subtitleEffect) { + var sub = '!{theme.subtitle.sub}'.length == 0 ? new Array() : '!{theme.subtitle.sub}'.split(',') + var both = sub.unshift(data.text) + var typed = new Typed('#subtitle', { + strings: sub, + startDelay: 300, + typeSpeed: 150, + loop: !{theme.subtitle.loop}, + backSpeed: 50, + }) + } else { + document.getElementById('subtitle').innerHTML = data.text + } + }) + .catch(function (err) { + console.error(err) + }) + } + window.addEventListener('load', subtitleType) else if source == '2' script. - var subtitleEffect = !{subtitleEffect} - fetch('https://v1.hitokoto.cn') - .then(function (res){ - return res.json(); - }) - .then(function (data) { - if (subtitleEffect){ - 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, - loop: !{theme.subtitle.loop}, - backSpeed: 50 - }); - }else{ - document.getElementById("subtitle").innerHTML = data.hitokoto - } - }) - .catch(function (err) { - console.error(err); - }) - - else if source == "3" - script(type="text/javascript" src="http://yijuzhan.com/api/word.php?m=js") - script. - var subtitleEffect = !{subtitleEffect} - var con = str[0]; - if (subtitleEffect){ - 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, - loop: !{theme.subtitle.loop}, - backSpeed: 50 - }); - }else{ - document.getElementById("subtitle").innerHTML = con + var subtitleType = function () { + var subtitleEffect = !{ subtitleEffect } + fetch('https://v1.hitokoto.cn') + .then(function (res) { + return res.json() + }) + .then(function (data) { + if (subtitleEffect) { + 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, + loop: !{theme.subtitle.loop}, + backSpeed: 50, + }) + } else { + document.getElementById('subtitle').innerHTML = data.hitokoto + } + }) + .catch(function (err) { + console.error(err) + }) } + window.addEventListener('load', subtitleType) + + else if source == '3' + script. + var subtitleType = function () { + loadScript('http://yijuzhan.com/api/word.php?m=js', function () { + var subtitleEffect = !{ subtitleEffect } + var con = str[0] + if (subtitleEffect) { + 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, + loop: !{theme.subtitle.loop}, + backSpeed: 50, + }) + } else { + document.getElementById('subtitle').innerHTML = con + } + }) + } + window.addEventListener('load', subtitleType) else if source == '4' - script(type="text/javascript" src="https://sdk.jinrishici.com/v2/browser/jinrishici.js" charset="utf-8") script. - var subtitleEffect = !{subtitleEffect} - jinrishici.load(function(result) { - if (subtitleEffect){ - 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, - loop: !{theme.subtitle.loop}, - backSpeed: 50 - }); - }else{ - document.getElementById("subtitle").innerHTML = result.data.content - } - }) + var subtitleType = function () { + loadScript('https://sdk.jinrishici.com/v2/browser/jinrishici.js',function () { + var subtitleEffect = !{ subtitleEffect } + jinrishici.load(function (result) { + if (subtitleEffect) { + 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, + loop: !{theme.subtitle.loop}, + backSpeed: 50, + }) + } else { + document.getElementById('subtitle').innerHTML = result.data.content + } + }) + } + ) + } + window.addEventListener('load', subtitleType) else - - var subtitle = theme.subtitle.sub[0] script. var subtitleEffect = !{subtitleEffect} - if (subtitleEffect){ + if (subtitleEffect) { var typed = new Typed("#subtitle", { strings: '!{theme.subtitle.sub}'.split(","), startDelay: 300, @@ -111,6 +125,6 @@ if theme.subtitle.enable loop: !{theme.subtitle.loop}, backSpeed: 50 }) - }else{ - document.getElementById("subtitle").innerHTML = '!{subtitle}' - } + } else { + document.getElementById("subtitle").innerHTML = '!{theme.subtitle.sub[0]}' + } diff --git a/layout/includes/layout.pug b/layout/includes/layout.pug index 891c053..cbd9ff9 100644 --- a/layout/includes/layout.pug +++ b/layout/includes/layout.pug @@ -38,9 +38,5 @@ html(lang=config.language data-theme=theme.display_mode) !=partial('includes/footer', {}, {cache:theme.fragment_cache}) include ./rightside.pug - !=partial('includes/search/index', {}, {cache:theme.fragment_cache}) - - !=fragment_cache('my_js', function(){return my_html('js',theme.CDN_USE.js)}) - include ./additional-js.pug \ No newline at end of file diff --git a/layout/includes/mixins/UI.pug b/layout/includes/mixins/post-ui.pug similarity index 83% rename from layout/includes/mixins/UI.pug rename to layout/includes/mixins/post-ui.pug index 5cedd81..4cca5ce 100644 --- a/layout/includes/mixins/UI.pug +++ b/layout/includes/mixins/post-ui.pug @@ -1,21 +1,26 @@ -mixin UI_NEW(posts) - - posts.each(function(article,index){ +mixin postUI(posts) + each article , index in page.posts.data .recent-post-item - var link = article.link || article.path - - var post_cover = article.cover - var title = article.title || _p('no_title') - var leftOrRight = index%2 == 0 ? 'left_radius' : 'right_radius' + - var post_cover = article.cover - var no_cover = article.cover === false || !theme.cover.index_enable ? 'no-cover' : '' if post_cover && theme.cover.index_enable .post_cover(class=leftOrRight) - a(href=url_for(link) title=title) + a(href=url_for(link) title=title) if theme.lazyload.enable - img.post_bg.lazyload(data-src=`${post_cover}` alt=title onerror=`this.onerror=null;this.src='`+ url_for(theme.lodding_bg.post_page) + `'`) + img.post_bg.lazyload(data-src=`${post_cover}` onerror=`this.onerror=null;this.src='`+ url_for(theme.lodding_bg.post_page) + `'` alt=title) else - img.post_bg(src=`${post_cover}` alt=title onerror=`this.onerror=null;this.src='`+ url_for(theme.lodding_bg.post_page) + `'`) + img.post_bg(src=`${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 + if (is_home() && (article.top || article.sticky > 0)) + span.article-meta + i.fa.fa-thumb-tack.article-meta__icon.sticky + span.sticky= _p('sticky') + span.article-meta__separator | if (theme.post_meta.page.date_type) if (theme.post_meta.page.date_type === 'both') time.post-meta__date @@ -57,9 +62,7 @@ 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/recent-posts.pug b/layout/includes/recent-posts.pug deleted file mode 100644 index 46fb9de..0000000 --- a/layout/includes/recent-posts.pug +++ /dev/null @@ -1,67 +0,0 @@ -each article , index in page.posts.data - .recent-post-item - - var link = article.link || article.path - - var title = article.title || _p('no_title') - - var leftOrRight = index%2 == 0 ? 'left_radius' : 'right_radius' - - var post_cover = article.cover - - var no_cover = article.cover === false || !theme.cover.index_enable ? 'no-cover' : '' - 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) - else - img.post_bg(src=`${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 - if (article.top) - span.article-meta - i.fa.fa-thumb-tack.article-meta__icon.sticky - span.sticky= _p('sticky') - span.article-meta__separator | - if (theme.post_meta.page.date_type) - if (theme.post_meta.page.date_type === 'both') - time.post-meta__date - 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 | - 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 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) - span.article-meta - span.article-meta__separator | - each item, index in article.categories.data - i.fa.fa-inbox.article-meta__icon(aria-hidden="true") - a(href=url_for(item.path)).article-meta__categories #[=item.name] - if (index < article.categories.data.length - 1) - i.fa.fa-angle-right(aria-hidden="true") - if (theme.post_meta.page.tags && article.tags.data.length > 0) - span.article-meta.tags - span.article-meta__separator | - each item, index in article.tags.data - i.fa.fa-tag.article-meta__icon(aria-hidden="true") - a(href=url_for(item.path)).article-meta__tags #[=item.name] - if (index < article.tags.data.length - 1) - span.article-meta__link - - if theme.auto_excerpt && theme.auto_excerpt.enable - - const content = strip_html(article.content) - - let expert = content.substring(0, theme.auto_excerpt.length) - - content.length > theme.auto_excerpt.length ? expert += ' ...' : '' - .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 diff --git a/layout/index.pug b/layout/index.pug index 36f6860..2655cb4 100644 --- a/layout/index.pug +++ b/layout/index.pug @@ -1,6 +1,7 @@ extends includes/layout.pug block content + include ./includes/mixins/post-ui.pug #recent-posts.recent-posts - include includes/recent-posts.pug + +postUI include includes/pagination.pug \ No newline at end of file diff --git a/layout/tag.pug b/layout/tag.pug index ec2e31b..9f39ff8 100644 --- a/layout/tag.pug +++ b/layout/tag.pug @@ -2,9 +2,9 @@ extends includes/layout.pug block content if theme.tag_ui == 'index' - include ./includes/mixins/UI.pug + include ./includes/mixins/post-ui.pug #recent-posts.recent-posts - +UI_NEW(page.posts) + +postUI include includes/pagination.pug else include ./includes/mixins/article-sort.pug diff --git a/scripts/events/replace-config.js b/scripts/events/replace_config.js similarity index 100% rename from scripts/events/replace-config.js rename to scripts/events/replace_config.js diff --git a/scripts/filters/hide-post.js b/scripts/filters/hide-post.js deleted file mode 100644 index 94703b4..0000000 --- a/scripts/filters/hide-post.js +++ /dev/null @@ -1,66 +0,0 @@ -/** - * global hexo - * from printempw/hexo-hide-posts - * modify by Jerry - */ - -'use strict' - -var public_generators = [] - -hexo.extend.filter.register('before_generate', function () { - this._bindLocals() - - const all_posts = this.locals.get('posts') - const hidden_posts = all_posts.find({ - hide: true - }) - const normal_posts = all_posts.filter(post => !post.hide) - - this.locals.set('all_posts', all_posts) - this.locals.set('hidden_posts', hidden_posts) - this.locals.set('posts', normal_posts) -}) - -hexo.extend.filter.register('after_init', function () { - const original = {} - for (const name in hexo.extend.generator.list()) { - original[name] = hexo.extend.generator.get(name) - } - - hexo.extend.generator.register('post', async function (locals) { - const fg = original.post.bind(this) - - const generated_public = await fg(locals) - const generated_hidden = await fg( - Object.assign({}, locals, { - posts: locals.hidden_posts - }) - ) - - // Remove post.prev and post.next for hidden posts - generated_hidden.forEach(ele => { - ele.data.prev = ele.data.next = null - }) - - return generated_public.concat(generated_hidden) - }) - - // Then we hack into other generators if necessary - public_generators - .filter(name => Object.keys(original).includes(name)) - .forEach(name => { - // Overwrite original generator - hexo.extend.generator.register(name, function (locals) { - const fg = original[name].bind(this) - - return fg( - Object.assign({}, locals, { - posts: new locals.posts.constructor( - locals.posts.data.concat(locals.hidden_posts.data) - ) - }) - ) - }) - }) -}) diff --git a/scripts/filters/post-lazyload.js b/scripts/filters/post_lazyload.js similarity index 100% rename from scripts/filters/post-lazyload.js rename to scripts/filters/post_lazyload.js diff --git a/scripts/filters/random-cover.js b/scripts/filters/random_cover.js similarity index 100% rename from scripts/filters/random-cover.js rename to scripts/filters/random_cover.js diff --git a/scripts/helpers/my-html.js b/scripts/helpers/my-html.js deleted file mode 100644 index 9a928c5..0000000 --- a/scripts/helpers/my-html.js +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Butterfly - * Generate js and css according to user setting - */ - -'use strict' - -hexo.extend.helper.register('my_html', function (type, data) { - var result = '' - var tag = type === 'css' ? 'css' : 'script' - for (var i = 0; i < data.length; i++) { - var src = data[i].split('||')[0].trim() - var other = data[i].split('||')[1] ? data[i].split('||')[1].trim() : '' - - if (tag === 'css') { - result += - '' - } else { - result += - '' - } - } - return result -}) diff --git a/scripts/helpers/page.js b/scripts/helpers/page.js new file mode 100644 index 0000000..41e30f4 --- /dev/null +++ b/scripts/helpers/page.js @@ -0,0 +1,31 @@ +/** + * Butterfly + * @example + * page_description() + * injectHtml(data) + */ + +'use strict' + +const { stripHTML } = require('hexo-util') + +hexo.extend.helper.register('page_description', function () { + const { config, page } = this + let description = page.description || page.excerpt || page.content || page.title || config.description + + if (description) { + description = stripHTML(description).substring(0, 200) + .trim() + .replace(/\n/g, ' ') + return description + } +}) + +hexo.extend.helper.register('injectHtml', function (data) { + let result = '' + if (!data) return '' + for (var i = 0; i < data.length; i++) { + result += data[i] + } + return result +}) diff --git a/scripts/helpers/related-post.js b/scripts/helpers/related_post.js similarity index 100% rename from scripts/helpers/related-post.js rename to scripts/helpers/related_post.js diff --git a/scripts/tags/hide.js b/scripts/tags/hide.js index 4062c83..41d7ec9 100644 --- a/scripts/tags/hide.js +++ b/scripts/tags/hide.js @@ -1,5 +1,6 @@ /** * Butterfly + * @example * hideInline * {% hideInline content,display,bg,color %} * content不能包含當引號,可用 ' diff --git a/source/css/_layout/aside.styl b/source/css/_layout/aside.styl index a4c40d5..c1e368b 100644 --- a/source/css/_layout/aside.styl +++ b/source/css/_layout/aside.styl @@ -16,14 +16,13 @@ .card-info img - display: inline-block width: 110px height: 110px border-radius: 70px - transition: all .3s + transition: all .5s &:hover - transform: rotate(540deg) + transform: rotate(360deg) .author-info &__name @@ -34,23 +33,24 @@ margin-top: -.3rem .card-info-data + display: table padding: .7rem 0 + width: 100% + table-layout: fixed & > .card-info-data-item - display: inline-block - width: 33.3% + display: table-cell a .headline - display: block overflow: hidden color: $font-black - // text-transform: uppercase text-overflow: ellipsis white-space: nowrap font-size: .7rem .length_num + margin-top: -.3rem color: $dark-black font-size: 1rem @@ -75,7 +75,6 @@ display: block background-color: $light-blue color: $button-color - text-transform: uppercase line-height: 1.6rem span diff --git a/source/css/_layout/head.styl b/source/css/_layout/head.styl index e21f68c..5069adc 100644 --- a/source/css/_layout/head.styl +++ b/source/css/_layout/head.styl @@ -246,14 +246,15 @@ content: '' li - padding: 1px 10px list-style: none - text-align: center &:hover background: $theme-color a + display: inline-block + padding: .3rem .7rem + width: 100% color: $font-black text-shadow: none diff --git a/source/css/_layout/mobile-sidebar.styl b/source/css/_layout/mobile-sidebar.styl index a8f6583..633fa70 100644 --- a/source/css/_layout/mobile-sidebar.styl +++ b/source/css/_layout/mobile-sidebar.styl @@ -27,19 +27,22 @@ text-align: center img - display: inline-block - padding: 0 width: 110px height: 110px border-radius: 70px - transition: all .3s + transition: all .5s + + &:hover + transform: rotate(360deg) .mobile_post_data + display: table padding: .6rem .5rem 0 + width: 100% + table-layout: fixed .mobile_data_item - display: inline-block - width: 33.3% + display: table-cell .mobile_data_link & > a > div @@ -54,15 +57,13 @@ .headline display: block color: $font-black - // text-transform: uppercase font-size: .7rem hr margin: 1rem auto .menus_items - margin-bottom: 5rem - padding: 0 .5rem + padding: 0 .5rem 2rem .site-page position: relative diff --git a/source/css/_layout/post.styl b/source/css/_layout/post.styl index c039034..bfc7199 100644 --- a/source/css/_layout/post.styl +++ b/source/css/_layout/post.styl @@ -163,9 +163,6 @@ a.fancybox width: 100% text-align: center -p - margin: 0 0 .8rem - img max-width: 100% transition: all .2s @@ -328,6 +325,9 @@ img img margin: 0 auto .8rem + p + margin: 0 0 .8rem + @media screen and (max-width: 1024px) .layout_post width: auto diff --git a/source/css/_layout/third-party.styl b/source/css/_layout/third-party.styl index e5e6519..31e5c1a 100644 --- a/source/css/_layout/third-party.styl +++ b/source/css/_layout/third-party.styl @@ -1,28 +1,25 @@ if hexo-config('valine.enable') - // valine #vcomment button - padding: .3rem 1rem + padding: .3rem .8rem border-color: $button-color background-color: $light-blue color: $button-color font-size: .7rem + transition: all .3s &:hover background-color: $theme-button-hover-color - textarea - if hexo-config('valine.bg') + if hexo-config('valine.bg') + textarea background: url(hexo-config('valine.bg')) 100% 100% no-repeat - .info - display: none - .vimg - border: 0 + transition: all .3s &:hover - transform: rotate(540deg) + transform: rotate(360deg) .vat padding: 0 .8rem @@ -30,6 +27,7 @@ if hexo-config('valine.enable') border-radius: 5px color: $light-blue font-size: .7125rem + transition: all .3s &:hover background-color: $light-blue diff --git a/source/css/_mode/darkmode.styl b/source/css/_mode/darkmode.styl index 7f38f48..4d0bd0c 100644 --- a/source/css/_mode/darkmode.styl +++ b/source/css/_mode/darkmode.styl @@ -270,61 +270,19 @@ if hexo-config('darkmode.enable') || hexo-config('display_mode') == 'dark' fill: alpha(#FFFFFF, .6) !important if hexo-config('valine') && hexo-config('valine.enable') - // 評論 #vcomment - p, - a, - textarea, - .vemoji-btn, - .vpreview-btn, - input, - path, - .vcount, - .vnum, - .vtime, - .vsys, - .vsys, - .vnick - color: alpha(#FFFFFF, .6) !important - .vsys - background: rgb(97, 106, 107) !important + background: #2c2c2c !important .vbtn, .vat border: 1px solid alpha(#FFFFFF, .6) - background: lighten(#121212, 5) !important + background: #121212 !important color: alpha(#FFFFFF, .6) !important &:hover background: lighten(#121212, 20) !important - .vwrap - border: 1px solid alpha(#FFFFFF, .6) - - input - border-bottom: 1px dashed #616a6b - - .vh - border-bottom: 1px dashed #616a6b - - pre - border: 1px solid alpha(#FFFFFF, .6) - background-color: #121212 - - code - background: transparent - - code - background-color: #2c2c2c - color: alpha(#FFFFFF, .6) - - .vcontent.expand:before - background: linear-gradient(180deg, hsla(0, 0, 0, 0), hsl(218, 8%, 19%)) - - .vcontent.expand:after - background: hsla(204, 5%, 22%, 1) - if hexo-config('local_search') && hexo-config('local_search.enable') #local-search background: #121212 From 84efd464040739d644d62e3226b5d111b49bffb8 Mon Sep 17 00:00:00 2001 From: horo <45343728+theWorkFsz@users.noreply.github.com> Date: Tue, 14 Apr 2020 18:46:13 +0800 Subject: [PATCH 07/24] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20articleSort?= =?UTF-8?q?=20=E8=AE=BE=E7=BD=AE=E6=96=87=E7=AB=A0=E5=B0=81=E9=9D=A2?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E4=B8=8D=E4=B8=80=E8=87=B4=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- layout/includes/mixins/article-sort.pug | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/layout/includes/mixins/article-sort.pug b/layout/includes/mixins/article-sort.pug index 25bf57a..696714d 100644 --- a/layout/includes/mixins/article-sort.pug +++ b/layout/includes/mixins/article-sort.pug @@ -11,10 +11,10 @@ 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=`${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") 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 + - }) From b512eb761daaf0cd99d6a29ba4d69bf521f733d0 Mon Sep 17 00:00:00 2001 From: Jerry <16351105+jerryc127@users.noreply.github.com> Date: Fri, 17 Apr 2020 19:48:07 +0800 Subject: [PATCH 08/24] =?UTF-8?q?:sparkles:=20feat:=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=A8=99=E7=B1=A4=E5=A4=96=E6=8E=9B=20tag-toggle=20:sparkles:?= =?UTF-8?q?=20feat:=20=E5=A2=9E=E5=8A=A0=E9=A0=81=E9=9D=A2=E5=8A=A0?= =?UTF-8?q?=E8=BC=89=E5=8B=95=E7=95=ABpreloader=20close=20#193=20:sparkles?= =?UTF-8?q?:=20feat:=20=E9=81=A9=E9=85=8Dhexo-generator-indexed=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=20:sparkles:=20feat:=20aside=20subtitle=E5=8F=AF?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=EF=BC=8C=E5=84=AA=E5=85=88=E9=A1=AF=E7=A4=BA?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=85=A7=E5=AE=B9=E3=80=81=E6=B2=92=E6=9C=89?= =?UTF-8?q?=E7=9A=84=E9=A1=AF=E7=A4=BA=E9=A0=81=E9=9D=A2subtitle=20close?= =?UTF-8?q?=20#191=20:sparkles:=20feat:=20aside=20card-tags=E5=8F=AF?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=98=AF=E5=90=A6=E9=A1=AF=E7=A4=BA=E9=A1=8F?= =?UTF-8?q?=E8=89=B2=20:sparkles:=20feat:=20algolia-search=20highligh?= =?UTF-8?q?=E6=96=87=E5=AD=97=E5=8A=A0=E6=B7=B1=20:sparkles:=20feat:=20?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=A0=81=E9=9D=A2keywords=E8=A8=AD=E7=BD=AE?= =?UTF-8?q?=20#191=20:sparkles:=20feat:=20darkmode=E5=92=8Creadmode?= =?UTF-8?q?=E9=85=8D=E8=89=B2=E5=BE=AE=E8=AA=BF=20:bug:=20fix:=20=E4=BF=AE?= =?UTF-8?q?=E5=BE=A9hide-block=20=E9=85=8D=E7=BD=AE=E9=A1=8F=E8=89=B2?= =?UTF-8?q?=E9=A1=AF=E7=A4=BA=E5=87=BA=E9=8C=AF=E7=9A=84bug=20:bug:=20fix:?= =?UTF-8?q?=20=E4=BF=AE=E6=AD=A3zh-TW=E9=83=A8=E5=88=86=E7=94=A8=E8=AA=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- README_CN.md | 2 +- _config.yml | 9 +- languages/default.yml | 1 + languages/en.yml | 1 + languages/zh-CN.yml | 1 + languages/zh-TW.yml | 34 +-- layout/404.pug | 3 + layout/includes/additional-js.pug | 3 + layout/includes/comments/valine.pug | 3 +- layout/includes/head.pug | 3 +- layout/includes/layout.pug | 3 + layout/includes/loading/loading-js.pug | 6 + layout/includes/loading/loading.pug | 9 + layout/includes/widget/card_author.pug | 2 +- layout/includes/widget/card_tags.pug | 7 +- layout/includes/widget/index.pug | 2 +- layout/page-tags.pug | 14 -- layout/page.pug | 9 +- package.json | 15 +- scripts/helpers/page.js | 15 +- scripts/tags/hide.js | 55 ++++- source/css/_global/index.styl | 28 --- source/css/_highlight/highlight.styl | 3 - source/css/_layout/aside.styl | 3 +- source/css/_layout/loadding.styl | 94 +++++++++ source/css/_layout/page.styl | 4 +- source/css/_mode/darkmode.styl | 100 +++++---- source/css/_mode/readmode.styl | 60 ++++-- source/css/_search/algolia.styl | 4 + source/css/{_layout => _tags}/gallery.styl | 9 +- source/css/_tags/hide.styl | 53 +++++ source/css/{_layout => _tags}/note.styl | 0 source/css/index.styl | 1 + source/css/var.styl | 5 +- source/js/main.js | 233 ++++++++++++--------- 36 files changed, 541 insertions(+), 255 deletions(-) create mode 100644 layout/includes/loading/loading-js.pug create mode 100644 layout/includes/loading/loading.pug delete mode 100644 layout/page-tags.pug create mode 100644 source/css/_layout/loadding.styl rename source/css/{_layout => _tags}/gallery.styl (94%) create mode 100644 source/css/_tags/hide.styl rename source/css/{_layout => _tags}/note.styl (100%) diff --git a/README.md b/README.md index 0707089..e093184 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Based on [hexo-theme-melody](https://github.com/Molunerfinn/hexo-theme-melody) t ## Installation -Stable branch: +Stable branch [recommend]: ``` git clone -b master https://github.com/jerryc127/hexo-theme-butterfly.git themes/Butterfly diff --git a/README_CN.md b/README_CN.md index 1ab85d3..c22aee7 100644 --- a/README_CN.md +++ b/README_CN.md @@ -14,7 +14,7 @@ JerryC: https://jerryc.me/ ## 安裝 -在你的博客根目錄裡 +在你的博客根目錄裡安裝穩定版【推薦】 ``` git clone -b master https://github.com/jerryc127/hexo-theme-butterfly.git themes/Butterfly diff --git a/_config.yml b/_config.yml index 3587be5..7649e8b 100644 --- a/_config.yml +++ b/_config.yml @@ -266,7 +266,6 @@ valine: guest_info: nick,mail,link #valine comment header info recordIP: false # Record reviewer IP serverURLs: # This configuration is suitable for domestic custom domain name users, overseas version will be automatically detected (no need to manually fill in) - mathjax: false bg: /img/comment_bg.png # valine background count: true # top_img顯示評論數 @@ -509,6 +508,9 @@ subtitle: fontawesome_v5: enable: false +# 加載動畫 Loading Animation +preloader: false + #### 側邊欄 #### #------------------------------------- # 側邊欄顯示設置 @@ -516,7 +518,9 @@ aside: enable: true mobile: true # 手機頁面( 顯示寬度 < 768px )是否顯示aside內容 position: right # left or right - card_author: true + card_author: + enable: true + description: card_announcement: enable: true content: This is my Blog @@ -529,6 +533,7 @@ aside: card_tags: enable: true limit: 40 # if set 0 will show all + color: false card_archives: enable: true type: monthly # yearly or monthly diff --git a/languages/default.yml b/languages/default.yml index 565d6e4..a8ff80b 100644 --- a/languages/default.yml +++ b/languages/default.yml @@ -105,3 +105,4 @@ Snackbar: night_to_day: Light Mode Activated Manually error_title: Page not found +loading: Loading... diff --git a/languages/en.yml b/languages/en.yml index 565d6e4..a8ff80b 100644 --- a/languages/en.yml +++ b/languages/en.yml @@ -105,3 +105,4 @@ Snackbar: night_to_day: Light Mode Activated Manually error_title: Page not found +loading: Loading... diff --git a/languages/zh-CN.yml b/languages/zh-CN.yml index 8298f12..21ce127 100644 --- a/languages/zh-CN.yml +++ b/languages/zh-CN.yml @@ -107,3 +107,4 @@ Snackbar: night_to_day: 你已切换为浅色模式 error_title: 页面没有找到 +loading: 加载中... \ No newline at end of file diff --git a/languages/zh-TW.yml b/languages/zh-TW.yml index dbdad40..95cb5d3 100644 --- a/languages/zh-TW.yml +++ b/languages/zh-TW.yml @@ -9,7 +9,7 @@ footer: copy: success: 複製成功 error: 複製錯誤 - noSupport: 瀏覽器不支持 + noSupport: 瀏覽器不支援 page: articles: 文章總覽 @@ -29,23 +29,23 @@ post: comments: 評論數 copyright: author: 文章作者 - link: 文章鏈接 + link: 文章連結 copyright_notice: 版權聲明 - copyright_content: '本博客所有文章除特別聲明外,均採用 + copyright_content: '本部落格所有文章除特別聲明外,均採用 %s 許可協議。轉載請註明來自 %s!' recommend: 相關推薦 -search: 搜索 +search: 搜尋 algolia_search: - input_placeholder: 搜索文章 + input_placeholder: 搜尋文章 hits_empty: "找不到您查詢的內容:${query}" hits_stats: "找到 ${hits} 條結果,用時 ${time} 毫秒" local_search: - label: 本地搜索 - input_placeholder: 搜索文章 + label: 本地搜尋 + input_placeholder: 搜尋文章 hits_empty: "找不到您查詢的內容:${query}" - powered: "提供支持" + powered: "提供支援" by: 由 pagination: @@ -67,35 +67,35 @@ aside: card_webinfo: headline: 網站資訊 article_name: 文章數目 - runtime_name: 已運行時間 + runtime_name: 已執行時間 site_wordcount: 本站總字數 site_uv_name: 本站訪客數 site_pv_name: 本站總訪問量 - more_button: 查看更多 + more_button: 檢視更多 donate: 打賞 share: 分享 bookmark: - title: 添加書籤 + title: 新增書籤 rightside: readmode_title: 閱讀模式 - font_plus_title: 放大字體 - font_minus_title: 縮小字體 + font_plus_title: 放大字型 + font_minus_title: 縮小字型 translate_title: 簡繁轉換 night_mode_title: 夜間模式 back_to_top: 回到頂部 toc: 目錄 scroll_to_comment: 直達評論 - setting: 設置 + setting: 設定 runtime_unit: 天 copy_copyright: author: 作者 - link: 鏈接 + link: 連結 source: 來源 - info: 著作權歸作者所有。商業轉載請聯繫作者獲得授權,非商業轉載請註明出處。 + info: 著作權歸作者所有。商業轉載請聯絡作者獲得授權,非商業轉載請註明出處。 Snackbar: bookmark: @@ -107,5 +107,5 @@ Snackbar: night_to_day: 你已切換為淺色模式 error_title: 頁面沒有找到 - +loading: 載入中... diff --git a/layout/404.pug b/layout/404.pug index b41dbd4..b6c2d8c 100644 --- a/layout/404.pug +++ b/layout/404.pug @@ -6,6 +6,9 @@ html(lang=config.language data-theme=theme.display_mode) head include includes/head.pug body + if theme.preloader + !=partial('includes/loading/loading', {}, {cache:theme.fragment_cache}) + if theme.fireworks && theme.fireworks.enable canvas.fireworks diff --git a/layout/includes/additional-js.pug b/layout/includes/additional-js.pug index 54537dd..57ec278 100644 --- a/layout/includes/additional-js.pug +++ b/layout/includes/additional-js.pug @@ -69,3 +69,6 @@ if is_home() include ./head/subtitle.pug !=fragment_cache('injectBottom', function(){return injectHtml(theme.inject.bottom)}) + +if theme.preloader + !=partial('includes/loading/loading-js', {}, {cache:theme.fragment_cache}) \ No newline at end of file diff --git a/layout/includes/comments/valine.pug b/layout/includes/comments/valine.pug index 3c756da..8d42a0e 100644 --- a/layout/includes/comments/valine.pug +++ b/layout/includes/comments/valine.pug @@ -17,6 +17,5 @@ script. pageSize: '#{theme.valine.pageSize}', lang: '#{theme.valine.lang}', recordIP: #{theme.valine.recordIP}, - serverURLs: '#{theme.valine.serverURLs}', - mathjax: #{theme.valine.mathjax} + serverURLs: '#{theme.valine.serverURLs}' }); diff --git a/layout/includes/head.pug b/layout/includes/head.pug index 57cdd92..59c9463 100644 --- a/layout/includes/head.pug +++ b/layout/includes/head.pug @@ -12,7 +12,8 @@ - var pageDescription = page_description() - var pageKeywords -- if (page.tags && page.tags.data) pageKeywords = page.tags.data.map(function(tag) {return tag.name;}).join(',') +- if (page.keywords) pageKeywords = Array.isArray(page.keywords) ? (page.keywords).join(',') : ([]).join(',') || page.keywords +- else if (page.tags && page.tags.length) 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 diff --git a/layout/includes/layout.pug b/layout/includes/layout.pug index cbd9ff9..134b02f 100644 --- a/layout/includes/layout.pug +++ b/layout/includes/layout.pug @@ -5,6 +5,9 @@ html(lang=config.language data-theme=theme.display_mode) head include ./head.pug body + if theme.preloader + !=partial('includes/loading/loading', {}, {cache:theme.fragment_cache}) + if theme.fireworks && theme.fireworks.enable canvas.fireworks diff --git a/layout/includes/loading/loading-js.pug b/layout/includes/loading/loading-js.pug new file mode 100644 index 0000000..93054c5 --- /dev/null +++ b/layout/includes/loading/loading-js.pug @@ -0,0 +1,6 @@ +script. + var endLoading = function () { + document.body.style.overflow = 'auto'; + document.getElementById('loading-box').classList.add("loaded") + } + window.addEventListener('load',endLoading) \ No newline at end of file diff --git a/layout/includes/loading/loading.pug b/layout/includes/loading/loading.pug new file mode 100644 index 0000000..2e4b65f --- /dev/null +++ b/layout/includes/loading/loading.pug @@ -0,0 +1,9 @@ +#loading-box + .loading-left-bg + .loading-right-bg + .spinner-box + .configure-border-1 + .configure-core + .configure-border-2 + .configure-core + .loading-word= _p('loading') diff --git a/layout/includes/widget/card_author.pug b/layout/includes/widget/card_author.pug index c138153..3a6b91f 100644 --- a/layout/includes/widget/card_author.pug +++ b/layout/includes/widget/card_author.pug @@ -3,7 +3,7 @@ .card-info-avatar.is-center img.avatar-img(src=url_for(theme.avatar.img) onerror=`this.onerror=null;this.src='` + url_for(theme.lodding_bg.flink) + `'` alt="avatar") .author-info__name= config.author - .author-info__description= config.description + .author-info__description= theme.aside.card_author.description || config.description .card-info-data if site.posts.length diff --git a/layout/includes/widget/card_tags.pug b/layout/includes/widget/card_tags.pug index 0032471..4330b63 100644 --- a/layout/includes/widget/card_tags.pug +++ b/layout/includes/widget/card_tags.pug @@ -4,6 +4,9 @@ if site.tags.length .item-headline i.fa.fa-tags(aria-hidden="true") span= _p('aside.card_tags') - + - let tagLimit = theme.aside.card_tags.limit === 0 ? 0 : theme.aside.card_tags.limit || 40 - .card-tag-cloud!= tagcloud({min_font: 16, max_font: 24, amount: tagLimit , color: true, start_color: '#999', end_color: '#99a9bf'}) + if theme.aside.card_tags.color + .card-tag-cloud!=cloudTags(site.tags,16,22,tagLimit) + else + .card-tag-cloud!= tagcloud({min_font: 16, max_font: 24, amount: tagLimit , color: true, start_color: '#999', end_color: '#99a9bf'}) diff --git a/layout/includes/widget/index.pug b/layout/includes/widget/index.pug index ae4c986..f37e6c5 100644 --- a/layout/includes/widget/index.pug +++ b/layout/includes/widget/index.pug @@ -1,7 +1,7 @@ if theme.aside.enable if page.aside !== false #aside_content.aside_content - if theme.aside.card_author + if theme.aside.card_author.enable !=partial('includes/widget/card_author', {}, {cache:theme.fragment_cache}) if theme.aside.card_announcement.enable !=partial('includes/widget/card_announcement', {}, {cache:theme.fragment_cache}) diff --git a/layout/page-tags.pug b/layout/page-tags.pug deleted file mode 100644 index 47c569b..0000000 --- a/layout/page-tags.pug +++ /dev/null @@ -1,14 +0,0 @@ -.tag-cloud - .tag-cloud__title= _p('page.tag') - | - - span.tag-cloud__amount= site.tags.length - .tag-cloud-tags - - site.tags.sort('path').each(function (tags){ - - var fontSize = Math.floor(Math.random() * 15 + 15) + "px"; //15 ~ 30 - - var color = "rgb(" + Math.floor(Math.random() * 201) + ", " + Math.floor(Math.random() * 201) +", " + Math.floor(Math.random() * 201) +")"; // 0,0,0 -> 200,200,200 - a(href=url_for(tags.path) style='font-size:' + fontSize + ';color:' + color)=tags.name - -}) - if page.comments !== false - include includes/comments/index.pug - - diff --git a/layout/page.pug b/layout/page.pug index 19411b1..d01ef3d 100644 --- a/layout/page.pug +++ b/layout/page.pug @@ -2,7 +2,14 @@ extends includes/layout.pug block content if page.type === 'tags' - include page-tags.pug + .tag-cloud + .tag-cloud__title= _p('page.tag') + | - + span.tag-cloud__amount= site.tags.length + .tag-cloud-tags + !=cloudTags(site.tags,15,30,0) + if page.comments !== false + include includes/comments/index.pug else if page.type === 'link' include flink.pug else if page.type === 'categories' diff --git a/package.json b/package.json index 4fdd627..90f8d11 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,18 @@ { "name": "hexo-theme-butterfly", "version": "2.2.5", - "description": "A Hexo Theme: Butterfly" + "private": true, + "engines": { + "node": ">=8.10.0" + }, + "description": "A Simple and Card UI Design theme for Hexo", + "keywords": [ + "hexo", + "theme", + "butterfly", + "Card UI Design" + ], + "repository": "https://github.com/jerryc127/hexo-theme-butterfly.git", + "author": "Jerry ", + "license": "MIT" } \ No newline at end of file diff --git a/scripts/helpers/page.js b/scripts/helpers/page.js index 41e30f4..02b935a 100644 --- a/scripts/helpers/page.js +++ b/scripts/helpers/page.js @@ -3,6 +3,7 @@ * @example * page_description() * injectHtml(data) + * cloudTags(source, minfontsize, maxfontsize, limit) */ 'use strict' @@ -11,7 +12,7 @@ const { stripHTML } = require('hexo-util') hexo.extend.helper.register('page_description', function () { const { config, page } = this - let description = page.description || page.excerpt || page.content || page.title || config.description + let description = page.description || page.content || page.title || config.description if (description) { description = stripHTML(description).substring(0, 200) @@ -29,3 +30,15 @@ hexo.extend.helper.register('injectHtml', function (data) { } return result }) + +hexo.extend.helper.register('cloudTags', function (source, minfontsize, maxfontsize, limit) { + const env = this + let result = '' + const tagLimit = limit === 0 ? source.length : limit + source.sort('name').limit(tagLimit).forEach(function (tags) { + var fontSize = Math.floor(Math.random() * (maxfontsize - minfontsize) + minfontsize) + 'px' + var color = 'rgb(' + Math.floor(Math.random() * 201) + ', ' + Math.floor(Math.random() * 201) + ', ' + Math.floor(Math.random() * 201) + ')' // 0,0,0 -> 200,200,200 + result += `${tags.name}` + }) + return result +}) diff --git a/scripts/tags/hide.js b/scripts/tags/hide.js index 41d7ec9..7dd89c0 100644 --- a/scripts/tags/hide.js +++ b/scripts/tags/hide.js @@ -8,29 +8,64 @@ * {% hideBlock display,bg,color %} * content * {% endhideBlock %} + * hideToggle + * {% hideToggle display,bg,color %} + * content + * {% endhideToggle %} */ 'use strict' function hideInline (args) { args = args.join(' ').split(',') - const content = args[0].trim() - const display = args[1] || 'Click' - const bg = args[2] === '' || typeof args[2] === 'undefined' ? '' : `background-color:${args[2]}` - const color = args[3] || '#fff' - return `${display} - ${content}` + var content = args[0] + var display = args[1] || 'Click' + var bg = args[2] || false + var color = args[3] || false + var group = 'style="' + + if (bg) group += `background-color: ${bg};` + if (color) group += `color: ${color}` + group += '"' + + return `${display} + ${content}` } function hideBlock (args, content) { args = args.join(' ').split(',') - const display = args[0] || 'Click' - const bg = args[1] === '' || typeof args[2] === 'undefined' ? '' : `background-color:${args[2]}` - const color = args[2] || '#fff' + var display = args[0] || 'Click' + var bg = args[1] || false + var color = args[2] || false + var group = 'style="' - return `
    ${display} + if (bg) group += `background-color: ${bg};` + if (color) group += `color: ${color}` + group += '"' + + return `
    ${display} ${hexo.render.renderSync({ text: content, engine: 'markdown' }).split('\n').join('')}
    ` } +function hideToggle (args, content) { + args = args.join(' ').split(',') + var display = args[0] + var bg = args[1] || false + var color = args[2] || false + var group = 'style="' + var border = '' + + if (bg) { + border = `style="border: 1px solid ${bg}"` + group += `background-color: ${bg};` + } + if (color) group += `color: ${color}` + group += '"' + + return `
    ${display}
    +
    ${hexo.render.renderSync({ text: content, engine: 'markdown' }).split('\n').join('')}
    ` +} + hexo.extend.tag.register('hideInline', hideInline) hexo.extend.tag.register('hideBlock', hideBlock, { ends: true }) +hexo.extend.tag.register('hideToggle', hideToggle, { ends: true }) diff --git a/source/css/_global/index.styl b/source/css/_global/index.styl index 3903e0e..ff3b105 100644 --- a/source/css/_global/index.styl +++ b/source/css/_global/index.styl @@ -209,34 +209,6 @@ img:not([src]) width: 100% height: 100% -// tag-hide -.hide-inline, -.hide-block - & > .hide-button - position: relative - z-index: 1 - display: inline-block - padding: 0 1rem - background: $tag-hide-bg - text-align: center - cursor: pointer - - &:hover - text-decoration: none !important - - & > .hide-content - display: none - -.hide-inline - & > .hide-button - margin: 0 .3rem - - & > .hide-content - margin: 0 .3rem - -.hide-block - margin: 0 0 .8rem - .comment_headling margin-bottom: 10px font-weight: 700 diff --git a/source/css/_highlight/highlight.styl b/source/css/_highlight/highlight.styl index 12c81df..b6dba71 100644 --- a/source/css/_highlight/highlight.styl +++ b/source/css/_highlight/highlight.styl @@ -271,6 +271,3 @@ blockquote background: darken($highlight-background, 5) color: $highlight-foreground font-size: 14px - -.highlight-close - height: 0 !important \ No newline at end of file diff --git a/source/css/_layout/aside.styl b/source/css/_layout/aside.styl index c1e368b..411a5b1 100644 --- a/source/css/_layout/aside.styl +++ b/source/css/_layout/aside.styl @@ -91,7 +91,8 @@ .card-tag-cloud a - word-break: keep-all + display: inline-block + padding: 0 .1rem &:hover color: $light-blue !important diff --git a/source/css/_layout/loadding.styl b/source/css/_layout/loadding.styl new file mode 100644 index 0000000..6b4aa1d --- /dev/null +++ b/source/css/_layout/loadding.styl @@ -0,0 +1,94 @@ +if hexo-config('preloader') + loading-bg() + position: fixed + z-index: 1000 + width: 50% + height: 100% + background-color: $preloader-bg + transition: all .5s + + #loading-box + .loading-left-bg + loading-bg() + + .loading-right-bg + loading-bg() + right: 0 + + .spinner-box + position: fixed + z-index: 1001 + display: flex + justify-content: center + align-items: center + width: 100% + height: 100vh + + .configure-border-1 + position: absolute + padding: 3px + width: 115px + height: 115px + background: #ffab91 + animation: configure-clockwise 3s ease-in-out 0s infinite alternate + + .configure-border-2 + left: -115px + padding: 3px + width: 115px + height: 115px + background: rgb(63, 249, 220) + transform: rotate(45deg) + animation: configure-xclockwise 3s ease-in-out 0s infinite alternate + + .loading-word + position: absolute + color: $white + font-size: .8rem + + .configure-core + width: 100% + height: 100% + background-color: $preloader-bg + + &.loaded + .loading-left-bg + transform: translate(-100%, 0) + + .loading-right-bg + transform: translate(100%, 0) + + .spinner-box + display: none + + @keyframes configure-clockwise + 0% + transform: rotate(0) + + 25% + transform: rotate(90deg) + + 50% + transform: rotate(180deg) + + 75% + transform: rotate(270deg) + + 100% + transform: rotate(360deg) + + @keyframes configure-xclockwise + 0% + transform: rotate(45deg) + + 25% + transform: rotate(-45deg) + + 50% + transform: rotate(-135deg) + + 75% + transform: rotate(-225deg) + + 100% + transform: rotate(-315deg) diff --git a/source/css/_layout/page.styl b/source/css/_layout/page.styl index 1ef3e48..56d8de0 100644 --- a/source/css/_layout/page.styl +++ b/source/css/_layout/page.styl @@ -270,7 +270,7 @@ -webkit-box-orient: vertical &:hover - color: $light-blue + color: $light-blue !important transform: translateX(20px) &__img @@ -381,7 +381,7 @@ & > div:first-child:not(.recent-posts) width: 100% !important -//ie10-ios11使用 +// ie10-ios11使用 @media all and (-ms-high-contrast: none), (-ms-high-contrast: active) .recent-post-info .content diff --git a/source/css/_mode/darkmode.styl b/source/css/_mode/darkmode.styl index 4d0bd0c..480cde2 100644 --- a/source/css/_mode/darkmode.styl +++ b/source/css/_mode/darkmode.styl @@ -39,25 +39,43 @@ if hexo-config('darkmode.enable') || hexo-config('display_mode') == 'dark' .article-title color: alpha(#FFFFFF, .8) !important - #page-header - &.fixed - background: alpha(#121212, .8) - box-shadow: 0 5px 6px -5px rgba(133, 133, 133, 0) + // 頭部 + #nav + &:before + position: absolute + top: 0 + right: 0 + bottom: 0 + left: 0 + background-color: alpha($dark-black, .7) + content: '' - .toggle-menu, - #site-name, + & > #page-header a - color: alpha(#FFFFFF, .8) + color: alpha(#FFFFFF, .8) !important - .menus_item_child - background-color: lighten(#121212, 5) !important - - li - &:hover - background: lighten(#121212, 20) + &.fixed + background: alpha(#121212, .8) + box-shadow: 0 5px 6px -5px rgba(133, 133, 133, 0) + .toggle-menu, + #site-name, a - color: alpha(#FFFFFF, .6) + color: alpha(#FFFFFF, .8) + + .menus_item_child + background-color: lighten(#121212, 5) !important + + li + &:hover + background: lighten(#121212, 20) !important + + a + color: alpha(#FFFFFF, .8) + + #site_subtitle + & > span + color: alpha(#FFFFFF, .6) // 代碼框 #article-container pre, @@ -109,6 +127,9 @@ if hexo-config('darkmode.enable') || hexo-config('display_mode') == 'dark' .post-copyright-info color: alpha(#FFFFFF, .6) + &:after + background: #121212 + // 音樂播放器 .aplayer filter: brightness(.7) @@ -120,11 +141,11 @@ if hexo-config('darkmode.enable') || hexo-config('display_mode') == 'dark' & > i, & > a, & > div - background-color: lighten(#121212, 5) !important - color: alpha(#FFFFFF, .6) !important + background-color: lighten(#121212, 5) + color: alpha(#FFFFFF, .6) &:hover - background: lighten(#121212, 20) !important + background: lighten(#121212, 20) // 打賞按鈕 .post-reward @@ -164,23 +185,8 @@ if hexo-config('darkmode.enable') || hexo-config('display_mode') == 'dark' color: alpha(#FFFFFF, .6) !important .button--animated:before - background: lighten(#121212, 20) !important + background: lighten(#121212, 20) - // 頭部 - #nav - &:before - position: absolute - top: 0 - right: 0 - bottom: 0 - left: 0 - background-color: alpha($dark-black, .7) - content: '' - - #nav span, - #nav i, - #page-header a, - #page-header .toggle-menu, #post-meta, #post-meta a, #footer-wrap, @@ -217,11 +223,13 @@ if hexo-config('darkmode.enable') || hexo-config('display_mode') == 'dark' color: alpha(#FFFFFF, .8) !important // 時間軸界面 - .article-sort-item__title - color: alpha(#FFFFFF, .6) + .article-sort + &-item__title + color: alpha(#FFFFFF, .6) - &:hover - color: #49b1f5 + &-item:before, + &-title:before + background: #121212 // 手機 MENU,TOC #mobile-sidebar @@ -247,6 +255,10 @@ if hexo-config('darkmode.enable') || hexo-config('display_mode') == 'dark' filter: brightness(.7) color: #4c4948 + // hide-tags + .hide-button + filter: brightness(.7) + // 第三方 // 插件 hexo-blog-encrypt #hexo-blog-encrypt @@ -257,6 +269,9 @@ if hexo-config('darkmode.enable') || hexo-config('display_mode') == 'dark' input background-color: #121212 + .mermaid + filter: brightness(.7) + if hexo-config('gitalk') && hexo-config('gitalk.enable') #gitalk-container .gt-header-textarea, @@ -326,5 +341,12 @@ if hexo-config('darkmode.enable') || hexo-config('display_mode') == 'dark' blockquote color: alpha(#FFFFFF, .6) - .mermaid - filter: brightness(.7) + if hexo-config('preloader') + #loading-box + .loading-left-bg, + .loading-right-bg, + .configure-core + background-color: darken(#121212, 2) + + .loading-word + color: alpha(#FFFFFF, .6) diff --git a/source/css/_mode/readmode.styl b/source/css/_mode/readmode.styl index fd62e8c..c22519f 100644 --- a/source/css/_mode/readmode.styl +++ b/source/css/_mode/readmode.styl @@ -1,7 +1,9 @@ if hexo-config('readmode') && hexo-config('readmode.enable') [data-theme='light'] + $light-redmode-bg = #fff + .read-mode - background: #fff + background: $light-redmode-bg #nav.post-bg a @@ -17,12 +19,12 @@ if hexo-config('readmode') && hexo-config('readmode.enable') blockquote border-left: .2rem solid #ddd - background-color: transparent + background-color: $light-redmode-bg ol, li &:before - background: transparent + background: $light-redmode-bg color: #4c4948 ul @@ -32,27 +34,40 @@ if hexo-config('readmode') && hexo-config('readmode.enable') hr border: 2px dashed #d6dbdf - background: transparent + background: $light-redmode-bg &:before color: darken(#d6dbdf, 10) + .hide-toggle + border: 1px solid darken(#d6dbdf, 10) !important + .hide-button - background: darken(#d6dbdf, 10) !important + background: $light-redmode-bg !important + color: #4c4948 !important + + .hide-inline, + .hide-block + & >.hide-button + border: 1px solid darken(#d6dbdf, 10) + + & > .button--animated:before + background: $light-redmode-bg .note border: 2px solid #eee - background-color: transparent + background-color: $light-redmode-bg - #mobile-sidebar-menus, - #rightside i, + #rightside i:not(.fa-cog), #rightside a, #rightside #rightside_config - background: darken(#d6dbdf, 10) !important + background: darken(#d6dbdf, 20) !important [data-theme='dark'] + $dark-readmode-bg = #0d0d0d + .read-mode - background: #0d0d0d + background: $dark-readmode-bg #article-container code @@ -60,12 +75,12 @@ if hexo-config('readmode') && hexo-config('readmode.enable') blockquote border-left: .2rem solid rgba(255, 255, 255, .6) - background-color: transparent + background-color: $dark-readmode-bg ol, li &:before - background: transparent + background: $dark-readmode-bg color: rgba(255, 255, 255, .6) ul @@ -73,15 +88,28 @@ if hexo-config('readmode') && hexo-config('readmode.enable') &:before border: .15rem solid rgba(255, 255, 255, .6) + .hide-toggle + border: 1px solid rgba(255, 255, 255, .6) !important + + .hide-button + background: $dark-readmode-bg !important + filter: none + color: rgba(255, 255, 255, .6) !important + + .hide-inline, + .hide-block + & >.hide-button + border: 1px solid rgba(255, 255, 255, .6) + + & > .button--animated:before + background: $dark-readmode-bg !important + .note border: 2px solid rgba(255, 255, 255, .6) filter: none - background-color: transparent + background-color: $dark-readmode-bg color: rgba(255, 255, 255, .6) - .hide-button - background: #1f1f1f !important - .read-mode #body-wrap padding-left: 0 !important diff --git a/source/css/_search/algolia.styl b/source/css/_search/algolia.styl index 6dab083..5531882 100644 --- a/source/css/_search/algolia.styl +++ b/source/css/_search/algolia.styl @@ -45,6 +45,10 @@ &:hover color: $search-color + em + color: $search-keyword-highlight + font-weight: bold + .ais-pagination.pagination margin: .8rem 0 0 padding: 0 diff --git a/source/css/_layout/gallery.styl b/source/css/_tags/gallery.styl similarity index 94% rename from source/css/_layout/gallery.styl rename to source/css/_tags/gallery.styl index 6c3b6f5..2325b49 100644 --- a/source/css/_layout/gallery.styl +++ b/source/css/_tags/gallery.styl @@ -9,6 +9,9 @@ figure.gallery-group background: $dark-black -webkit-transform: translate3d(0, 0, 0) + @media screen and (max-width: 600px) + width: calc(100% - .4rem) + &:hover img opacity: .4 @@ -105,8 +108,4 @@ figure.gallery-group .fancybox width: auto - text-align: inherit - -@media screen and (max-width: 600px) - figure.gallery-group - width: calc(100% - .4rem) \ No newline at end of file + text-align: inherit \ No newline at end of file diff --git a/source/css/_tags/hide.styl b/source/css/_tags/hide.styl new file mode 100644 index 0000000..a012749 --- /dev/null +++ b/source/css/_tags/hide.styl @@ -0,0 +1,53 @@ +// tag-hide +.hide-inline, +.hide-block + & > a.hide-button + position: relative + z-index: 1 + display: inline-block + padding: 0 1rem + background: $tag-hide-bg + color: $white !important + text-align: center + cursor: pointer + + &:hover + text-decoration: none !important + + &.open + display: none + + & > .hide-content + display: none + +.hide-inline + & > .hide-button + margin: 0 .3rem + + & > .hide-content + margin: 0 .3rem + +.hide-block + margin: 0 0 .8rem + +.hide-toggle + margin-bottom: 1rem + border: 1px solid $tag-hide-toggle-bg + + & > .hide-button + padding: .3rem .5rem + background: $tag-hide-toggle-bg + color: $font-color + cursor: pointer + + & > i + font-size: 1.2em + transition: all .3s + + &.open + i + transform: rotate(90deg) + + & > .hide-content + display: none + margin: 1.5rem 1.2rem diff --git a/source/css/_layout/note.styl b/source/css/_tags/note.styl similarity index 100% rename from source/css/_layout/note.styl rename to source/css/_tags/note.styl diff --git a/source/css/index.styl b/source/css/index.styl index a7df530..2333ce6 100644 --- a/source/css/index.styl +++ b/source/css/index.styl @@ -5,6 +5,7 @@ @import '_global' @import '_highlight/highlight' @import '_layout/*' +@import '_tags/*' @import '_mode/*' // search diff --git a/source/css/var.styl b/source/css/var.styl index 49fb7d4..f35bda7 100644 --- a/source/css/var.styl +++ b/source/css/var.styl @@ -84,8 +84,9 @@ $search-keyword-highlight = #F47466 $gallery-color = #fff // tag-hide $tag-hide-bg = $theme-color - - +$tag-hide-toggle-bg = #f0f0f0 +//preloader +$preloader-bg = #37474f // Note colors // -------------------------------------------------- diff --git a/source/js/main.js b/source/js/main.js index 7ce6704..03fdbfd 100644 --- a/source/js/main.js +++ b/source/js/main.js @@ -247,121 +247,128 @@ $(function () { /** * 代碼 + * 只適用於Hexo默認的代碼渲染 */ - const isHighlightCopy = GLOBAL_CONFIG.highlightCopy - const isHighlightLang = GLOBAL_CONFIG.highlightLang - const isHighlightShrink = GLOBAL_CONFIG.highlightShrink const $figureHighlight = $('figure.highlight') - if (isHighlightCopy || isHighlightLang || isHighlightShrink !== 'none') { - $figureHighlight.wrap('
    ').before('
    ') - } - /** + if ($figureHighlight.length) { + const isHighlightCopy = GLOBAL_CONFIG.highlightCopy + const isHighlightLang = GLOBAL_CONFIG.highlightLang + const isHighlightShrink = GLOBAL_CONFIG.highlightShrink + + if (isHighlightCopy || isHighlightLang || isHighlightShrink !== 'none') { + $figureHighlight.wrap('
    ').before('
    ') + } + + /** * 代碼收縮 */ - const $highlightTools = $('.highlight-tools') - if (isHighlightShrink === 'true') { - $highlightTools.append('') - } else if (isHighlightShrink === 'false') { - $highlightTools.append('') - } - - $(document).on('click', '.highlight-tools >.code-expand', function () { - var $table = $(this).parent().next() - if ($(this).hasClass('code-closed')) { - $table.css('display', 'block') - $(this).removeClass('code-closed') - } else { - $table.css('display', 'none') - $(this).addClass('code-closed') + const $highlightTools = $('.highlight-tools') + if (isHighlightShrink === 'true') { + $highlightTools.append('') + } else if (isHighlightShrink === 'false') { + $highlightTools.append('') } - }) - /** + $(document).on('click', '.highlight-tools >.code-expand', function () { + var $table = $(this).parent().next() + if ($(this).hasClass('code-closed')) { + $table.css('display', 'block') + $(this).removeClass('code-closed') + } else { + $table.css('display', 'none') + $(this).addClass('code-closed') + } + }) + + /** * 代碼語言 */ - if (isHighlightLang) { - var langNameIndex, langName - $figureHighlight.each(function () { - langNameIndex = langName = $(this).attr('class').split(' ')[1] - if (langNameIndex === 'plain') langName = 'Code' - $(this).prev().append('
    ' + langName + '
    ') - }) - } - /** + if (isHighlightLang) { + var langNameIndex, langName + $figureHighlight.each(function () { + langNameIndex = langName = $(this).attr('class').split(' ')[1] + if (langNameIndex === 'plain') langName = 'Code' + $(this).prev().append('
    ' + langName + '
    ') + }) + } + /** * 代碼copy * copy function */ - if (isHighlightCopy) { - $highlightTools.append('
    ') - var copy = function (text, ctx) { - if (document.queryCommandSupported && document.queryCommandSupported('copy')) { - try { - document.execCommand('copy') // Security exception may be thrown by some browsers. - if (isSnackbar) { - snackbarShow(GLOBAL_CONFIG.copy.success) - } else { - $(ctx).prev('.copy-notice') - .text(GLOBAL_CONFIG.copy.success) - .animate({ - opacity: 1, - right: 30 - }, 450, function () { - setTimeout(function () { - $(ctx).prev('.copy-notice').animate({ - opacity: 0, - right: 0 - }, 650) - }, 400) - }) + if (isHighlightCopy) { + $highlightTools.append('
    ') + var copy = function (text, ctx) { + if (document.queryCommandSupported && document.queryCommandSupported('copy')) { + try { + document.execCommand('copy') // Security exception may be thrown by some browsers. + if (isSnackbar) { + snackbarShow(GLOBAL_CONFIG.copy.success) + } else { + $(ctx).prev('.copy-notice') + .text(GLOBAL_CONFIG.copy.success) + .animate({ + opacity: 1, + right: 30 + }, 450, function () { + setTimeout(function () { + $(ctx).prev('.copy-notice').animate({ + opacity: 0, + right: 0 + }, 650) + }, 400) + }) + } + } catch (ex) { + if (isSnackbar) { + snackbarShow(GLOBAL_CONFIG.copy.success) + } else { + $(ctx).prev('.copy-notice') + .text(GLOBAL_CONFIG.copy.error) + .animate({ + opacity: 1, + right: 30 + }, 650, function () { + setTimeout(function () { + $(ctx).prev('.copy-notice').animate({ + opacity: 0, + right: 0 + }, 650) + }, 400) + }) + return false + } } - } catch (ex) { - if (isSnackbar) { - snackbarShow(GLOBAL_CONFIG.copy.success) - } else { - $(ctx).prev('.copy-notice') - .text(GLOBAL_CONFIG.copy.error) - .animate({ - opacity: 1, - right: 30 - }, 650, function () { - setTimeout(function () { - $(ctx).prev('.copy-notice').animate({ - opacity: 0, - right: 0 - }, 650) - }, 400) - }) - return false - } - } - } else { - if (isSnackbar) { - snackbarShow(GLOBAL_CONFIG.copy.noSupport) } else { - $(ctx).prev('.copy-notice').text(GLOBAL_CONFIG.copy.noSupport) + if (isSnackbar) { + snackbarShow(GLOBAL_CONFIG.copy.noSupport) + } else { + $(ctx).prev('.copy-notice').text(GLOBAL_CONFIG.copy.noSupport) + } } } - } - // click events - $(document).on('click', '.highlight-tools>.fa-clipboard', function () { - var selection = window.getSelection() - var range = document.createRange() - range.selectNodeContents($(this).parent().next().find('.code pre')[0]) - selection.removeAllRanges() - selection.addRange(range) - var text = selection.toString() - copy(text, this) - selection.removeAllRanges() - }) + // click events + $(document).on('click', '.highlight-tools>.fa-clipboard', function () { + var selection = window.getSelection() + var range = document.createRange() + range.selectNodeContents($(this).parent().next().find('.code pre')[0]) + selection.removeAllRanges() + selection.addRange(range) + var text = selection.toString() + copy(text, this) + selection.removeAllRanges() + }) + } } /** * justified-gallery 圖庫排版 */ var $justifiedGallery = $('.justified-gallery') + var isJustifiedGallery = false if ($justifiedGallery.length) { + isJustifiedGallery = true var $imgList = $justifiedGallery.find('img') $imgList.unwrap() if ($imgList.length) { @@ -372,11 +379,19 @@ $(function () { } $('head').append('') loadScript('https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js', function () { - $justifiedGallery.not($('.hide-content .justified-gallery')).justifiedGallery({ - rowHeight: 220, - margins: 4 - }) + initJustifiedGallery($justifiedGallery) }) + + var initJustifiedGallery = function (selector) { + selector.each(function (i, o) { + if ($(this).is(':visible')) { + $(this).justifiedGallery({ + rowHeight: 220, + margins: 4 + }) + } + }) + } } /** @@ -708,6 +723,9 @@ $(function () { interval = setInterval(showDateTime, 10000) } + /** + * 百度推送 + */ if (GLOBAL_CONFIG.baiduPush) { (function () { var bp = document.createElement('script') @@ -726,17 +744,24 @@ $(function () { * tag-hide */ var $hideInline = $('.hide-button') - $hideInline.on('click', function (e) { - e.preventDefault() - $(this).hide() - var $hideContent = $(this).next('.hide-content') - $hideContent.show() - $hideContent.find('.justified-gallery').justifiedGallery({ - rowHeight: 220, - margins: 4 + if ($hideInline.length) { + $hideInline.on('click', function (e) { + e.preventDefault() + var $this = $(this) + var $hideContent = $(this).next('.hide-content') + $this.toggleClass('open') + $hideContent.toggle() + if ($this.hasClass('open')) { + if (isJustifiedGallery && $hideContent.find('.justified-gallery').length > 0) { + initJustifiedGallery($hideContent.find('.justified-gallery')) + } + } }) - }) + } + /** + * PhotoFigcaption + */ function addPhotoFigcaption () { var images = $('#article-container img') images.each(function (i, o) { From 8953e2e1aa7723eab0164fb6d4924ec255f6628a Mon Sep 17 00:00:00 2001 From: Jerry <16351105+jerryc127@users.noreply.github.com> Date: Sun, 19 Apr 2020 16:05:47 +0800 Subject: [PATCH 09/24] =?UTF-8?q?:sparkles:=20=E5=A2=9E=E5=8A=A0facebook?= =?UTF-8?q?=20comments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _config.yml | 15 +++++++- .../includes/comments/facebook_comments.pug | 12 ++++++ layout/includes/comments/index.pug | 7 +++- layout/includes/head.pug | 3 +- layout/includes/head/Open_Graph.pug | 2 +- layout/includes/head/comment.pug | 6 +++ layout/includes/header/header.pug | 3 +- layout/includes/header/index.pug | 2 +- layout/includes/header/menu_item.pug | 37 ++++++++++--------- layout/includes/header/post-info.pug | 7 ++++ .../includes/mobile-sidebar/mobile-menus.pug | 3 +- layout/includes/widget/card_author.pug | 2 +- scripts/helpers/page.js | 9 +++++ source/css/_layout/head.styl | 2 +- source/css/_search/local-search.styl | 1 + 15 files changed, 79 insertions(+), 32 deletions(-) create mode 100644 layout/includes/comments/facebook_comments.pug diff --git a/_config.yml b/_config.yml index 7649e8b..92a67d6 100644 --- a/_config.yml +++ b/_config.yml @@ -280,6 +280,17 @@ utterances: light_theme: github-light dark_theme: photon-dark +# Facebook Comments Plugin +# https://developers.facebook.com/docs/plugins/comments/ +facebook_comments: + enable: false + app_id: + user_id: # optional + pageSize: 10 # The number of comments to show + order_by: social # social/time/reverse_time + lang: en_US # Language en_US/zh_CN/zh_TW and so on + count: true + ##### Footer Settings #### # ------------------------------------ since: 2020 @@ -518,7 +529,7 @@ aside: enable: true mobile: true # 手機頁面( 顯示寬度 < 768px )是否顯示aside內容 position: right # left or right - card_author: + card_author: enable: true description: card_announcement: @@ -670,7 +681,7 @@ fragment_cache: true # 插入代码到头部之前 和 尾部之前 inject: head: - # - + # - bottom: # - diff --git a/layout/includes/comments/facebook_comments.pug b/layout/includes/comments/facebook_comments.pug new file mode 100644 index 0000000..50f8838 --- /dev/null +++ b/layout/includes/comments/facebook_comments.pug @@ -0,0 +1,12 @@ +#fb-root +script(async defer crossorigin="anonymous" src=`https://connect.facebook.net/${theme.facebook_comments.lang}/sdk.js#xfbml=1&version=v6.0`) +.fb-comments(data-colorscheme = theme.display_mode === 'dark' ? 'dark' : 'light' + data-href=urlNoIndex() + data-numposts= theme.facebook_comments.pageSize || 10 + data-order-by= theme.facebook_comments.order_by || 'social' + data-width="100%") + +if theme.darkmode.enable + script. + var themeNow = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'light' + document.getElementsByClassName('fb-comments')[0].setAttribute('data-colorscheme',themeNow) diff --git a/layout/includes/comments/index.pug b/layout/includes/comments/index.pug index 030ae23..61c1042 100644 --- a/layout/includes/comments/index.pug +++ b/layout/includes/comments/index.pug @@ -4,7 +4,8 @@ - var gt = theme.gitalk && theme.gitalk.enable - var v = theme.valine && theme.valine.enable - var u = theme.utterances && theme.utterances.enable -- var isComment = d || dj || l || gt || v || u +- var fb = theme.facebook_comments && theme.facebook_comments.enable +- var isComment = d || dj || l || gt || v || u || fb if isComment hr @@ -23,4 +24,6 @@ if isComment else if v include ./valine.pug else if u - include ./utterances.pug \ No newline at end of file + include ./utterances.pug + else if fb + include ./facebook_comments.pug \ No newline at end of file diff --git a/layout/includes/head.pug b/layout/includes/head.pug index 59c9463..92a66d5 100644 --- a/layout/includes/head.pug +++ b/layout/includes/head.pug @@ -17,7 +17,6 @@ - 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', '') meta(charset='UTF-8') meta(http-equiv="X-UA-Compatible" content="IE=edge") @@ -72,7 +71,7 @@ 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) + link(rel="canonical" href=urlNoIndex()) if is_post() if(page.prev) diff --git a/layout/includes/head/Open_Graph.pug b/layout/includes/head/Open_Graph.pug index bd751d4..5e8da5f 100644 --- a/layout/includes/head/Open_Graph.pug +++ b/layout/includes/head/Open_Graph.pug @@ -11,7 +11,7 @@ if theme.twitter_meta if theme.Open_Graph_meta meta(property="og:type" content=contentType) meta(property="og:title" content=pageTitle) - meta(property="og:url" content=without_html) + meta(property="og:url" content=urlNoIndex()) meta(property="og:site_name" content=config.title) meta(property="og:description" content!=pageDescription) meta(property="og:image" content=full_url_for(page.cover || theme.avatar.img)) diff --git a/layout/includes/head/comment.pug b/layout/includes/head/comment.pug index 91d5cf0..3597780 100644 --- a/layout/includes/head/comment.pug +++ b/layout/includes/head/comment.pug @@ -1,3 +1,9 @@ +if (theme.facebook_comments.enable && page.comments !== false && !is_tag() && !is_category() && !is_archive() && !is_home()) + if theme.facebook_comments.app_id + meta(property="fb:app_id" content=theme.facebook_comments.app_id ) + if theme.facebook_comments.user_id + meta(property="fb:admins" content=theme.facebook_comments.user_id) + if (theme.disqusjs && theme.disqusjs.enable && page.comments !== false && !is_tag() && !is_category() && !is_archive() && !is_home()) link(rel="stylesheet" type="text/css" href=url_for(theme.CDN.disqusjs_css)) diff --git a/layout/includes/header/header.pug b/layout/includes/header/header.pug index e6a22cc..3737e76 100644 --- a/layout/includes/header/header.pug +++ b/layout/includes/header/header.pug @@ -8,8 +8,7 @@ a.site-page.social-icon.search i.fa.fa-search.fa-fw span=' '+_p('search') - .menus_items - include ./menu_item.pug + !=fragment_cache('menus', function(){return partial('includes/header/menu_item')}) span.toggle-menu.close a.site-page diff --git a/layout/includes/header/index.pug b/layout/includes/header/index.pug index 3198591..2c6ede4 100644 --- a/layout/includes/header/index.pug +++ b/layout/includes/header/index.pug @@ -33,7 +33,7 @@ if theme.douban span#subtitle if(theme.social) #site_social_icons - !=partial('includes/header/social', {}, {cache:theme.fragment_cache}) + !=fragment_cache('social', function(){return partial('includes/header/social')}) #scroll_down i.fa.fa-angle-down.scroll-down-effects else if is_post() diff --git a/layout/includes/header/menu_item.pug b/layout/includes/header/menu_item.pug index cb7c719..81c6f6c 100644 --- a/layout/includes/header/menu_item.pug +++ b/layout/includes/header/menu_item.pug @@ -1,18 +1,19 @@ -each value, label in theme.menu - if !Array.isArray(value) - .menus_item - a.site-page(href=url_for(trim(value.split('||')[0]))) - i.fa-fw(class=trim(value.split('||')[1])) - span=' '+label - else - .menus_item - a.site-page - 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") - ul.menus_item_child - each i in value - li - a.site-page(href=url_for(trim(i.split('||')[1]))) - i.fa-fw(class=trim(i.split('||')[2])) - span=' '+trim(i.split('||')[0]) \ No newline at end of file +.menus_items + each value, label in theme.menu + if !Array.isArray(value) + .menus_item + a.site-page(href=url_for(trim(value.split('||')[0]))) + i.fa-fw(class=trim(value.split('||')[1])) + span=' '+label + else + .menus_item + a.site-page + 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") + ul.menus_item_child + each i in value + li + a.site-page(href=url_for(trim(i.split('||')[1]))) + i.fa-fw(class=trim(i.split('||')[2])) + span=' '+trim(i.split('||')[0]) \ No newline at end of file diff --git a/layout/includes/header/post-info.pug b/layout/includes/header/post-info.pug index 3964283..7bee8bc 100644 --- a/layout/includes/header/post-info.pug +++ b/layout/includes/header/post-info.pug @@ -82,3 +82,10 @@ span= _p('post.comments') + ':' a(href=url_for(page.path) + '#post-comment') span.gitalk-comment-count.comment-count + else if theme.facebook_comments.enable && theme.facebook_comments.count && page.comments !== false + if (postWordcount || theme.busuanzi.page_pv) + span.post-meta__separator | + i.post-meta__icon(class=commentCount aria-hidden="true") + span= _p('post.comments') + ':' + a.comment-count(href=url_for(page.path) + '#post-comment') + span.fb-comments-count(data-href=urlNoIndex()) \ No newline at end of file diff --git a/layout/includes/mobile-sidebar/mobile-menus.pug b/layout/includes/mobile-sidebar/mobile-menus.pug index 55580ec..2a88aec 100644 --- a/layout/includes/mobile-sidebar/mobile-menus.pug +++ b/layout/includes/mobile-sidebar/mobile-menus.pug @@ -23,5 +23,4 @@ .headline= _p('aside.categories') .length_num= site.categories.length hr - .menus_items - include ../header/menu_item.pug + !=fragment_cache('menus', function(){return partial('includes/header/menu_item')}) diff --git a/layout/includes/widget/card_author.pug b/layout/includes/widget/card_author.pug index 3a6b91f..3cae470 100644 --- a/layout/includes/widget/card_author.pug +++ b/layout/includes/widget/card_author.pug @@ -31,4 +31,4 @@ if(theme.social) .card-info-social-icons.is-center - include ../header/social.pug + !=fragment_cache('social', function(){return partial('includes/header/social')}) diff --git a/scripts/helpers/page.js b/scripts/helpers/page.js index 02b935a..fc21c87 100644 --- a/scripts/helpers/page.js +++ b/scripts/helpers/page.js @@ -42,3 +42,12 @@ hexo.extend.helper.register('cloudTags', function (source, minfontsize, maxfonts }) return result }) + +hexo.extend.helper.register('urlNoIndex', function () { + const { permalink } = hexo.config + let url = this.url.replace(/index\.html$/, '') + if (!permalink.endsWith('.html')) { + url = url.replace(/\.html$/, '') + } + return url +}) diff --git a/source/css/_layout/head.styl b/source/css/_layout/head.styl index 5069adc..8a92ab5 100644 --- a/source/css/_layout/head.styl +++ b/source/css/_layout/head.styl @@ -43,7 +43,7 @@ margin: 0 .5rem color: $light-grey text-shadow: .1rem .1rem .2rem rgba(0, 0, 0, .15) - font-size: .9rem + font-size: 1rem cursor: pointer #scroll_down diff --git a/source/css/_search/local-search.styl b/source/css/_search/local-search.styl index 534117f..e0b3c5f 100644 --- a/source/css/_search/local-search.styl +++ b/source/css/_search/local-search.styl @@ -51,6 +51,7 @@ .search-result margin: 0 0 .4rem + word-break: break-all .search-keyword color: $search-keyword-highlight From 796b8e6df46056f41c82d2ba74c552558aa3e833 Mon Sep 17 00:00:00 2001 From: Jerry <16351105+jerryc127@users.noreply.github.com> Date: Tue, 21 Apr 2020 21:36:21 +0800 Subject: [PATCH 10/24] =?UTF-8?q?:sparkles:=20=E9=81=A9=E9=85=8D=20valine?= =?UTF-8?q?=201.4.5,=20=E5=A2=9E=E5=8A=A0emojiCDN=E5=92=8CemojiMaps?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _config.yml | 3 +++ layout/includes/comments/valine.pug | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/_config.yml b/_config.yml index 92a67d6..266b3e2 100644 --- a/_config.yml +++ b/_config.yml @@ -259,6 +259,8 @@ valine: enable: false # if you want use valine,please set this value is true appId: # leancloud application app id appKey: # leancloud application app key + notify: false # valine mail notify (true/false) Deprecated in v1.4.0+ + verify: false # valine verify code (true/false) Deprecated in v1.4.0+ pageSize: 10 # comment list page size avatar: monsterid # gravatar style https://valine.js.org/#/avatar lang: en # i18n: zh-CN/zh-TW/en/ja @@ -266,6 +268,7 @@ valine: guest_info: nick,mail,link #valine comment header info recordIP: false # Record reviewer IP serverURLs: # This configuration is suitable for domestic custom domain name users, overseas version will be automatically detected (no need to manually fill in) + emojiCDN: # emoji CDN bg: /img/comment_bg.png # valine background count: true # top_img顯示評論數 diff --git a/layout/includes/comments/valine.pug b/layout/includes/comments/valine.pug index 8d42a0e..faad2da 100644 --- a/layout/includes/comments/valine.pug +++ b/layout/includes/comments/valine.pug @@ -1,3 +1,7 @@ +- let emojiMaps = '""' +if site.data.valine + - emojiMaps = JSON.stringify(site.data.valine) + #vcomment.vcomment script(src=url_for(theme.CDN.valine)) script. @@ -11,11 +15,15 @@ script. el:'#vcomment', appId: '#{theme.valine.appId}', appKey: '#{theme.valine.appKey}', + notify: #{theme.valine.notify}, + verify: #{theme.valine.verify}, placeholder: '#{theme.valine.placeholder}', avatar: '#{theme.valine.avatar}', meta: guest_info, pageSize: '#{theme.valine.pageSize}', lang: '#{theme.valine.lang}', recordIP: #{theme.valine.recordIP}, - serverURLs: '#{theme.valine.serverURLs}' + serverURLs: '#{theme.valine.serverURLs}', + emojiCDN: '#{theme.valine.emojiCDN}', + emojiMaps: !{emojiMaps} }); From 0d56db50e4503907dac83f35bd0d83517b1ff7f2 Mon Sep 17 00:00:00 2001 From: Jerry <16351105+jerryc127@users.noreply.github.com> Date: Sun, 26 Apr 2020 23:29:38 +0800 Subject: [PATCH 11/24] =?UTF-8?q?:label:=202.3.0=E7=99=BC=E4=BD=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 ++-- README_CN.md | 7 ++--- _config.yml | 19 +++++++----- layout/includes/comments/valine.pug | 22 +++++++++----- layout/includes/head/dns_prefetch.pug | 6 ++++ layout/includes/mixins/article-sort.pug | 2 +- layout/includes/widget/card_tags.pug | 4 +-- layout/page.pug | 2 +- package.json | 2 +- scripts/helpers/aside_archives.js | 15 +++++----- scripts/helpers/aside_categories.js | 40 +++++++++++++++---------- scripts/helpers/page.js | 7 ++++- source/css/_global/index.styl | 4 +++ source/css/_layout/aside.styl | 26 +++++++++++----- source/css/_mode/darkmode.styl | 18 +++++------ source/js/main.js | 34 ++++++++++----------- 16 files changed, 127 insertions(+), 87 deletions(-) diff --git a/README.md b/README.md index e093184..fdcdc58 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,11 @@ # hexo-theme-butterfly -Version +Version Author Hexo node.js -Demo: https://demo.jerryc.me/ - -JerryC: https://jerryc.me/ +Demo: 👍 [Butterfly](https://demo.jerryc.me/) || 🤞 [JerryC](https://jerryc.me/) Based on [hexo-theme-melody](https://github.com/Molunerfinn/hexo-theme-melody) theme. diff --git a/README_CN.md b/README_CN.md index c22aee7..2357f7e 100644 --- a/README_CN.md +++ b/README_CN.md @@ -1,14 +1,11 @@ # hexo-theme-butterfly -Version +Version Author Hexo node.js -Demo: https://demo.jerryc.me/ - -JerryC: https://jerryc.me/ - +Demo: 👍 [Butterfly](https://demo.jerryc.me/) || 🤞 [JerryC](https://jerryc.me/) 一款基於[hexo-theme-melody](https://github.com/Molunerfinn/hexo-theme-melody)修改的主題 diff --git a/_config.yml b/_config.yml index 266b3e2..29ba263 100644 --- a/_config.yml +++ b/_config.yml @@ -221,7 +221,7 @@ addtoany: disqus: enable: false shortname: - count: false # top_img顯示評論數 + count: false # dispaly comment count in top_img # Disqus.js版評論系統,應對大陸長城的折中方案,兼容原版:https://github.com/SukkaW/DisqusJS # API 申請地址:https://disqus.com/api/applications/ @@ -234,7 +234,7 @@ disqusjs: api: https://disqus.skk.moe/disqus/ #一般情況下無需修改 API 地址 admin: adminLabel: - count: true # top_img顯示評論數 + count: false # dispaly comment count in top_img laibili: enable: false @@ -252,7 +252,7 @@ gitalk: distractionFreeMode: false # Facebook-like distraction free mode. pagerDirection: last # Comment sorting direction, available values are last and first. createIssueManually: false # Gitalk will create a corresponding github issue for your every single page automatically - count: true # top_img顯示評論數 + count: false # dispaly comment count in top_img # valine comment system. https://valine.js.org valine: @@ -268,9 +268,11 @@ valine: guest_info: nick,mail,link #valine comment header info recordIP: false # Record reviewer IP serverURLs: # This configuration is suitable for domestic custom domain name users, overseas version will be automatically detected (no need to manually fill in) - emojiCDN: # emoji CDN + 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 - count: true # top_img顯示評論數 + count: false # dispaly comment count in top_img # utterances # https://utteranc.es/ @@ -292,7 +294,7 @@ facebook_comments: pageSize: 10 # The number of comments to show order_by: social # social/time/reverse_time lang: en_US # Language en_US/zh_CN/zh_TW and so on - count: true + count: false ##### Footer Settings #### # ------------------------------------ @@ -463,8 +465,9 @@ click_heart: ClickShowText: enable: false text: - - 本人 - - 超帥 + - I + - LOVE + - YOU fontSize: 15px # 網站顯示模式 diff --git a/layout/includes/comments/valine.pug b/layout/includes/comments/valine.pug index faad2da..ac70878 100644 --- a/layout/includes/comments/valine.pug +++ b/layout/includes/comments/valine.pug @@ -5,11 +5,17 @@ if site.data.valine #vcomment.vcomment script(src=url_for(theme.CDN.valine)) script. - var GUEST_INFO = ['nick','mail','link']; - var guest_info = '#{ theme.valine.guest_info }'.split(',').filter(function(item){ - return GUEST_INFO.indexOf(item) > -1 - }); - guest_info = guest_info.length == 0 ? GUEST_INFO :guest_info; + var requestSetting = function (from,set) { + var from = from + var setting = set.split(',').filter(function(item){ + return from.indexOf(item) > -1 + }); + setting = setting.length == 0 ? from :setting; + return setting + } + + var guestInfo = requestSetting(['nick','mail','link'],'#{ theme.valine.guest_info }') + var requiredFields = requestSetting(['nick','mail','link'],'#{ theme.valine.requiredFields }') window.valine = new Valine({ el:'#vcomment', @@ -19,11 +25,13 @@ script. verify: #{theme.valine.verify}, placeholder: '#{theme.valine.placeholder}', avatar: '#{theme.valine.avatar}', - meta: guest_info, + meta: guestInfo, pageSize: '#{theme.valine.pageSize}', lang: '#{theme.valine.lang}', recordIP: #{theme.valine.recordIP}, serverURLs: '#{theme.valine.serverURLs}', emojiCDN: '#{theme.valine.emojiCDN}', - emojiMaps: !{emojiMaps} + emojiMaps: !{emojiMaps}, + enableQQ: #{theme.valine.enableQQ}, + requiredFields: requiredFields }); diff --git a/layout/includes/head/dns_prefetch.pug b/layout/includes/head/dns_prefetch.pug index 1bfccf7..e5faf44 100644 --- a/layout/includes/head/dns_prefetch.pug +++ b/layout/includes/head/dns_prefetch.pug @@ -1,16 +1,22 @@ link(rel="preconnect" href="//cdn.jsdelivr.net") +link(rel="dns-prefetch" href="//cdn.jsdelivr.net") if theme.google_analytics link(rel="preconnect" href="https://www.google-analytics.com" crossorigin) + link(rel="dns-prefetch" href="https://www.google-analytics.com") if theme.baidu_analytics link(rel="preconnect" href="https://hm.baidu.com") + link(rel="dns-prefetch" href="https://hm.baidu.com") if theme.tencent_analytics link(rel="preconnect" href="http://ta.qq.com") + link(rel="dns-prefetch" href="http://ta.qq.com") if theme.blog_title_font.font_link link(rel="preconnect" href="https://fonts.googleapis.com" crossorigin) + link(rel="dns-prefetch" href="https://fonts.googleapis.com") if theme.busuanzi.site_uv || theme.busuanzi.site_pv || theme.busuanzi.page_pv link(rel="preconnect" href="//busuanzi.ibruce.info") + link(rel="dns-prefetch" href="//busuanzi.ibruce.info") diff --git a/layout/includes/mixins/article-sort.pug b/layout/includes/mixins/article-sort.pug index 25bf57a..53dd896 100644 --- a/layout/includes/mixins/article-sort.pug +++ b/layout/includes/mixins/article-sort.pug @@ -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=`${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") diff --git a/layout/includes/widget/card_tags.pug b/layout/includes/widget/card_tags.pug index 4330b63..1cd68c9 100644 --- a/layout/includes/widget/card_tags.pug +++ b/layout/includes/widget/card_tags.pug @@ -7,6 +7,6 @@ if site.tags.length - let tagLimit = theme.aside.card_tags.limit === 0 ? 0 : theme.aside.card_tags.limit || 40 if theme.aside.card_tags.color - .card-tag-cloud!=cloudTags(site.tags,16,22,tagLimit) + .card-tag-cloud!=cloudTags({source: site.tags, minfontsize: 16, maxfontsize: 22, limit: tagLimit}) else - .card-tag-cloud!= tagcloud({min_font: 16, max_font: 24, amount: tagLimit , color: true, start_color: '#999', end_color: '#99a9bf'}) + .card-tag-cloud!= tagcloud({min_font: 16, max_font: 22, amount: tagLimit , color: true, start_color: '#999', end_color: '#99a9bf'}) diff --git a/layout/page.pug b/layout/page.pug index d01ef3d..ff3aa6f 100644 --- a/layout/page.pug +++ b/layout/page.pug @@ -7,7 +7,7 @@ block content | - span.tag-cloud__amount= site.tags.length .tag-cloud-tags - !=cloudTags(site.tags,15,30,0) + !=cloudTags({source: site.tags, minfontsize: 15, maxfontsize: 30, limit: 0}) if page.comments !== false include includes/comments/index.pug else if page.type === 'link' diff --git a/package.json b/package.json index 90f8d11..a962bf1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hexo-theme-butterfly", - "version": "2.2.5", + "version": "2.3.0", "private": true, "engines": { "node": ">=8.10.0" diff --git a/scripts/helpers/aside_archives.js b/scripts/helpers/aside_archives.js index fcfed7c..9daf0c3 100644 --- a/scripts/helpers/aside_archives.js +++ b/scripts/helpers/aside_archives.js @@ -67,7 +67,7 @@ hexo.extend.helper.register('aside_archives', function (options = {}) { return this.url_for(url) } - result += '
      ' + result += '' return result diff --git a/scripts/helpers/aside_categories.js b/scripts/helpers/aside_categories.js index 0bf44f5..332005f 100644 --- a/scripts/helpers/aside_categories.js +++ b/scripts/helpers/aside_categories.js @@ -6,7 +6,10 @@ 'use strict' hexo.extend.helper.register('aside_categories', function (categories, options) { - if (!options && (!categories || !Object.prototype.hasOwnProperty.call(categories, 'length'))) { + if ( + !options && + (!categories || !Object.prototype.hasOwnProperty.call(categories, 'length')) + ) { options = categories categories = this.site.categories } @@ -14,23 +17,28 @@ hexo.extend.helper.register('aside_categories', function (categories, options) { if (!categories || !categories.length) return '' options = options || {} const { config } = this - const showCount = Object.prototype.hasOwnProperty.call(options, 'show_count') ? options.show_count : true + const showCount = Object.prototype.hasOwnProperty.call(options, 'show_count') + ? options.show_count + : true const depth = options.depth ? parseInt(options.depth, 10) : 0 const orderby = options.orderby || 'name' const order = options.order || 1 const categoryDir = this.url_for(config.category_dir) const limit = options.limit === 0 ? categories.length : options.limit const buttonLabel = this._p('aside.more_button') - const prepareQuery = parent => { + const prepareQuery = (parent) => { const query = {} if (parent) { query.parent = parent } else { query.parent = { - $exists: false + $exists: false, } } - return categories.find(query).sort(orderby, order).filter(cat => cat.length) + return categories + .find(query) + .sort(orderby, order) + .filter((cat) => cat.length) } const hierarchicalList = (t, level, parent) => { @@ -46,20 +54,22 @@ hexo.extend.helper.register('aside_categories', function (categories, options) { t = childList[1] } - result += '
    • ' + result += '
    • ' - result += `` - result += `${cat.name}` + result += `` + result += `${cat.name}` if (showCount) { - result += `${cat.length}` + result += `${cat.length}` } result += '' result += '
    • ' if (child) { - result += `
        ${child}
      ` + result += `
        ${child}
      ` } } }) @@ -73,14 +83,14 @@ hexo.extend.helper.register('aside_categories', function (categories, options) { var moreButton = function () { var moreHtml = '' if (categories.length <= limit) return '' - moreHtml += '
    • ' - moreHtml += `` - moreHtml += buttonLabel - moreHtml += '
    • ' + moreHtml += '
    • ' + moreHtml += ` + ${buttonLabel}
    • ` + return moreHtml } - return `
        + return `
          ${list[0]} ${moreButton()}
        ` diff --git a/scripts/helpers/page.js b/scripts/helpers/page.js index fc21c87..c6360d5 100644 --- a/scripts/helpers/page.js +++ b/scripts/helpers/page.js @@ -31,8 +31,13 @@ hexo.extend.helper.register('injectHtml', function (data) { return result }) -hexo.extend.helper.register('cloudTags', function (source, minfontsize, maxfontsize, limit) { +hexo.extend.helper.register('cloudTags', function (options = {}) { const env = this + const source = options.source + const minfontsize = options.minfontsize + const maxfontsize = options.maxfontsize + const limit = options.limit || 8 + let result = '' const tagLimit = limit === 0 ? source.length : limit source.sort('name').limit(tagLimit).forEach(function (tags) { diff --git a/source/css/_global/index.styl b/source/css/_global/index.styl index ff3b105..834e24a 100644 --- a/source/css/_global/index.styl +++ b/source/css/_global/index.styl @@ -192,6 +192,10 @@ img:not([src]) .img-alt margin: -.5rem 0 .5rem + color: $font-black + + &:hover + text-decoration: none !important // hexo tag video .video-container diff --git a/source/css/_layout/aside.styl b/source/css/_layout/aside.styl index 411a5b1..66297c4 100644 --- a/source/css/_layout/aside.styl +++ b/source/css/_layout/aside.styl @@ -147,20 +147,20 @@ .aside-post_title height: auto - .card-archives ul.archive-list, - .card-categories ul.aside-category-list + .card-archives ul.card-archive-list, + .card-categories ul.card-category-list margin: 0 padding: .2rem 0 0 list-style: none - .card-archives ul.archive-list > .archive-list-item, - .card-categories ul.aside-category-list > .aside-category-list-item - padding: .2rem 1rem + .card-archives ul.card-archive-list > .card-archive-list-item, + .card-categories ul.card-category-list > .card-category-list-item + padding: .15rem 1rem cursor: pointer - transition: all .3s + transition: all .5s &:hover - padding: .2rem .85rem + padding: .15rem .85rem background-color: $light-blue a @@ -180,8 +180,18 @@ width: 20% text-align: right + &.more + span + padding-right: .3rem + width: auto !important + transition: .5s + + &:hover + span + padding-right: .6rem + .card-categories - .aside-category-list + .card-category-list &.child padding: 0 0 0 1.2rem diff --git a/source/css/_mode/darkmode.styl b/source/css/_mode/darkmode.styl index 480cde2..a0f459d 100644 --- a/source/css/_mode/darkmode.styl +++ b/source/css/_mode/darkmode.styl @@ -159,8 +159,8 @@ if hexo-config('darkmode.enable') || hexo-config('display_mode') == 'dark' border-top: 13px solid lighten(#121212, 10) !important .md-links-item:before, - .aside-category-list-item:hover, - .archive-list-item:hover, + .card-category-list-item:hover, + .card-archive-list-item:hover, #bookmark-it background-color: lighten(#121212, 10) !important @@ -177,11 +177,11 @@ if hexo-config('darkmode.enable') || hexo-config('display_mode') == 'dark' .headline, .length_num, .aside-post_title, - .aside-category-list-link, - .archive-list-link, + .card-category-list-link, + .card-archive-list-link, .social-icon, - .aside-category-list-item-more, - .archive-list-link-more + .card-category-list-link-more, + .card-archive-list-link-more color: alpha(#FFFFFF, .6) !important .button--animated:before @@ -190,7 +190,8 @@ if hexo-config('darkmode.enable') || hexo-config('display_mode') == 'dark' #post-meta, #post-meta a, #footer-wrap, - #footer-wrap a + #footer-wrap a, + .img-alt color: alpha(#FFFFFF, .6) !important .posttitle, @@ -286,9 +287,6 @@ if hexo-config('darkmode.enable') || hexo-config('display_mode') == 'dark' if hexo-config('valine') && hexo-config('valine.enable') #vcomment - .vsys - background: #2c2c2c !important - .vbtn, .vat border: 1px solid alpha(#FFFFFF, .6) diff --git a/source/js/main.js b/source/js/main.js index 03fdbfd..8f05040 100644 --- a/source/js/main.js +++ b/source/js/main.js @@ -362,6 +362,21 @@ $(function () { } } + /** + * PhotoFigcaption + */ + function addPhotoFigcaption () { + var images = $('#article-container img') + images.each(function (i, o) { + var $this = $(o) + if ($this.attr('alt')) { + var t = $('
        ' + $this.attr('alt') + '
        ') + $this.after(t) + } + }) + } + if (GLOBAL_CONFIG.isPhotoFigcaption) addPhotoFigcaption() + /** * justified-gallery 圖庫排版 */ @@ -518,8 +533,8 @@ $(function () { } var updateAnchor = function (anchor) { - if (window.history.replaceState && anchor !== window.location.hash) { - window.history.replaceState(undefined, undefined, anchor) + if (anchor !== window.location.hash) { + location.replace(window.location.href.split('#')[0] + anchor) } } @@ -758,19 +773,4 @@ $(function () { } }) } - - /** - * PhotoFigcaption - */ - function addPhotoFigcaption () { - var images = $('#article-container img') - images.each(function (i, o) { - var $this = $(o) - if ($this.attr('alt')) { - var t = $('
        ' + $this.attr('alt') + '
        ') - $this.after(t) - } - }) - } - if (GLOBAL_CONFIG.isPhotoFigcaption) addPhotoFigcaption() }) From 6cf59387c8f2a73b3faa396366985c27e81b296b Mon Sep 17 00:00:00 2001 From: Jerry <16351105+jerryc127@users.noreply.github.com> Date: Sun, 26 Apr 2020 23:31:39 +0800 Subject: [PATCH 12/24] =?UTF-8?q?:label:=202.3.0=20=E7=99=BC=E4=BD=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- layout/includes/mixins/article-sort.pug | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layout/includes/mixins/article-sort.pug b/layout/includes/mixins/article-sort.pug index 696714d..53dd896 100644 --- a/layout/includes/mixins/article-sort.pug +++ b/layout/includes/mixins/article-sort.pug @@ -17,4 +17,4 @@ mixin articleSort(posts) i.fa.fa-clock-o(aria-hidden="true") 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 From 92111f3c324e83edba545bca42d3a661905697d7 Mon Sep 17 00:00:00 2001 From: Jerry <16351105+jerryc127@users.noreply.github.com> Date: Mon, 27 Apr 2020 02:37:20 +0800 Subject: [PATCH 13/24] =?UTF-8?q?:bug:=20fix:=20=E4=BF=AE=E5=BE=A9?= =?UTF-8?q?=E7=95=B6menu=E6=B2=92=E8=A8=AD=E7=BD=AE=E5=9C=96=E6=A8=99?= =?UTF-8?q?=E6=99=82=EF=BC=8C=E6=9C=83=E5=A0=B1Cannot=20read=20property=20?= =?UTF-8?q?'trim'=20of=20undefined=20=E7=9A=84bug=20:bug:=20fix:=20?= =?UTF-8?q?=E4=BF=AE=E5=BE=A9meta=20description=20=E8=87=AA=E5=8B=95?= =?UTF-8?q?=E7=94=9F=E6=88=90=E6=96=87=E7=AB=A0=E5=89=8D200=E6=96=87?= =?UTF-8?q?=E5=AD=97=E6=99=82=E9=83=A8=E5=88=86=E6=B2=92=E6=9C=89=E8=BD=89?= =?UTF-8?q?=E7=BE=A9=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- layout/includes/header/menu_item.pug | 9 ++++++--- scripts/helpers/page.js | 6 +++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/layout/includes/header/menu_item.pug b/layout/includes/header/menu_item.pug index 81c6f6c..983bcec 100644 --- a/layout/includes/header/menu_item.pug +++ b/layout/includes/header/menu_item.pug @@ -3,17 +3,20 @@ if !Array.isArray(value) .menus_item a.site-page(href=url_for(trim(value.split('||')[0]))) - i.fa-fw(class=trim(value.split('||')[1])) + if value.split('||')[1] + i.fa-fw(class=trim(value.split('||')[1])) span=' '+label else .menus_item a.site-page - i.fa-fw(class=trim(label.split('||')[1]) aria-hidden="true") + 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") ul.menus_item_child each i in value li a.site-page(href=url_for(trim(i.split('||')[1]))) - i.fa-fw(class=trim(i.split('||')[2])) + if i.split('||')[2] + i.fa-fw(class=trim(i.split('||')[2])) span=' '+trim(i.split('||')[0]) \ No newline at end of file diff --git a/scripts/helpers/page.js b/scripts/helpers/page.js index c6360d5..d877e28 100644 --- a/scripts/helpers/page.js +++ b/scripts/helpers/page.js @@ -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 } }) From 91d285391d4d3788ee8d7e07a041bbc1a0b8751b Mon Sep 17 00:00:00 2001 From: Jerry <16351105+jerryc127@users.noreply.github.com> Date: Mon, 27 Apr 2020 14:44:25 +0800 Subject: [PATCH 14/24] =?UTF-8?q?:bug:=20=E4=BF=AE=E5=BE=A9tags=E9=A0=81?= =?UTF-8?q?=E6=A8=99=E7=B1=A4=E5=8F=AA=E9=A1=AF=E7=A4=BA8=E5=80=8B?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/helpers/page.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/helpers/page.js b/scripts/helpers/page.js index d877e28..74e7674 100644 --- a/scripts/helpers/page.js +++ b/scripts/helpers/page.js @@ -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 From 250181c569a3da1fa0e6423c1f362b5b83d3620b Mon Sep 17 00:00:00 2001 From: Jerry <16351105+jerryc127@users.noreply.github.com> Date: Tue, 28 Apr 2020 15:31:14 +0800 Subject: [PATCH 15/24] =?UTF-8?q?:bug:=20=E4=BF=AE=E5=BE=A9=E7=95=B6?= =?UTF-8?q?=E5=8D=9A=E5=AE=A2root=E4=B8=8D=E6=98=AF'/'=E6=99=82,=E5=BC=95?= =?UTF-8?q?=E7=94=A8=E6=9C=AC=E5=9C=B0=E5=9C=96=E7=89=87=E6=9C=83=E9=A1=AF?= =?UTF-8?q?=E7=A4=BA=E4=B8=8D=E5=87=BA=E7=9A=84bug=20close=20#211?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 10 +++++++++- README_CN.md | 7 +++++++ layout/404.pug | 2 +- layout/flink.pug | 6 +++--- layout/includes/header/index.pug | 2 +- layout/includes/mixins/article-sort.pug | 2 +- layout/includes/mixins/post-ui.pug | 4 ++-- layout/includes/pagination.pug | 8 ++++---- layout/includes/share/share-js.pug | 2 +- layout/includes/widget/card_recent_post.pug | 4 ++-- 10 files changed, 31 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index fdcdc58..0da0b28 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/README_CN.md b/README_CN.md index 2357f7e..d36ea4d 100644 --- a/README_CN.md +++ b/README_CN.md @@ -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) diff --git a/layout/404.pug b/layout/404.pug index b6c2d8c..a088390 100644 --- a/layout/404.pug +++ b/layout/404.pug @@ -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) diff --git a/layout/flink.pug b/layout/flink.pug index d443ea3..254293b 100644 --- a/layout/flink.pug +++ b/layout/flink.pug @@ -7,11 +7,11 @@ .md-links each item in i.link_list .md-links-item - a(href=item.link title=item.name target="_blank") + a(href=url_for(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 ) + img.lazyload(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 diff --git a/layout/includes/header/index.pug b/layout/includes/header/index.pug index 2c6ede4..b728808 100644 --- a/layout/includes/header/index.pug +++ b/layout/includes/header/index.pug @@ -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 diff --git a/layout/includes/mixins/article-sort.pug b/layout/includes/mixins/article-sort.pug index 53dd896..d0a793b 100644 --- a/layout/includes/mixins/article-sort.pug +++ b/layout/includes/mixins/article-sort.pug @@ -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") diff --git a/layout/includes/mixins/post-ui.pug b/layout/includes/mixins/post-ui.pug index 4cca5ce..2814a68 100644 --- a/layout/includes/mixins/post-ui.pug +++ b/layout/includes/mixins/post-ui.pug @@ -10,9 +10,9 @@ mixin postUI(posts) .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) + 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) 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 diff --git a/layout/includes/pagination.pug b/layout/includes/pagination.pug index 33bf9ae..0ca84be 100644 --- a/layout/includes/pagination.pug +++ b/layout/includes/pagination.pug @@ -18,9 +18,9 @@ else - 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}'` ) + img.prev_cover.lazyload(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 @@ -31,9 +31,9 @@ else .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}'`) + img.next_cover.lazyload(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 \ No newline at end of file diff --git a/layout/includes/share/share-js.pug b/layout/includes/share/share-js.pug index ec12a88..85f84dd 100644 --- a/layout/includes/share/share-js.pug +++ b/layout/includes/share/share-js.pug @@ -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)) \ No newline at end of file diff --git a/layout/includes/widget/card_recent_post.pug b/layout/includes/widget/card_recent_post.pug index 29a1ddf..ead0954 100644 --- a/layout/includes/widget/card_recent_post.pug +++ b/layout/includes/widget/card_recent_post.pug @@ -16,9 +16,9 @@ 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) + 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) 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)] From e8a47d040aec075e5825a53f6fed5e46e83e574b Mon Sep 17 00:00:00 2001 From: Jerry <16351105+jerryc127@users.noreply.github.com> Date: Thu, 30 Apr 2020 00:32:43 +0800 Subject: [PATCH 16/24] =?UTF-8?q?:bug:=20=E4=BF=AE=E5=BE=A9=E4=B8=8A?= =?UTF-8?q?=E6=AC=A1=E6=9B=B4=E6=96=B0=E5=B0=8E=E8=87=B4=E9=A0=81=E9=9D=A2?= =?UTF-8?q?=E8=B7=B3=E5=8B=95=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/js/main.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/source/js/main.js b/source/js/main.js index 8f05040..52bdc28 100644 --- a/source/js/main.js +++ b/source/js/main.js @@ -532,11 +532,11 @@ $(function () { }, 100) } - var updateAnchor = function (anchor) { - if (anchor !== window.location.hash) { - location.replace(window.location.href.split('#')[0] + anchor) - } - } + // function updateAnchor (anchor) { + // if (window.history.replaceState && anchor !== window.location.hash) { + // window.history.replaceState(null, null, anchor) + // } + // } // find head position & add active class // DOM Hierarchy: @@ -565,7 +565,7 @@ $(function () { var currentActive = $('.toc-link.active') if (currentId && currentActive.attr('href') !== currentId) { - updateAnchor(currentId) + // updateAnchor(currentId) $('.toc-link').removeClass('active') From a0655a37c81ab343bec8d97151905ed4f84c5133 Mon Sep 17 00:00:00 2001 From: Jerry <16351105+jerryc127@users.noreply.github.com> Date: Fri, 1 May 2020 18:58:09 +0800 Subject: [PATCH 17/24] =?UTF-8?q?:label:=20=E6=9B=B4=E6=96=B02.3.5=20?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=85=A7=E5=AE=B9=E6=9F=A5=E7=9C=8B=20https:?= =?UTF-8?q?//github.com/jerryc127/hexo-theme-butterfly/releases/tag/2.3.5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- README_CN.md | 2 +- _config.yml | 26 +- layout/flink.pug | 4 +- layout/includes/additional-js.pug | 4 +- layout/includes/head/config.pug | 4 +- layout/includes/mixins/post-ui.pug | 4 +- layout/includes/pagination.pug | 8 +- layout/includes/post/reward.pug | 2 +- layout/includes/widget/card_recent_post.pug | 4 +- layout/post.pug | 2 +- package.json | 2 +- scripts/filters/post_lazyload.js | 25 +- scripts/helpers/related_post.js | 7 +- source/css/_layout/post.styl | 254 ++++++++++---------- source/img/avatar.png | Bin 77735 -> 0 bytes source/img/comment_bg.png | Bin 6157 -> 0 bytes source/img/favicon.ico | Bin 15086 -> 0 bytes source/img/favicon.png | Bin 0 -> 323 bytes source/img/index.jpg | Bin 252852 -> 0 bytes source/img/post.jpg | Bin 53571 -> 0 bytes source/img/post_loadding.svg | 1 - source/js/main.js | 27 ++- 23 files changed, 189 insertions(+), 189 deletions(-) delete mode 100644 source/img/avatar.png delete mode 100644 source/img/comment_bg.png delete mode 100644 source/img/favicon.ico create mode 100644 source/img/favicon.png delete mode 100644 source/img/index.jpg delete mode 100644 source/img/post.jpg delete mode 100644 source/img/post_loadding.svg 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 -Version +Version Author Hexo node.js 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 -Version +Version Author Hexo node.js 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 += - ' \ 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() }) /** From 0ad2c01fc988f011fb4cbfb846adf75c45269c6a Mon Sep 17 00:00:00 2001 From: Jerry <16351105+jerryc127@users.noreply.github.com> Date: Thu, 21 May 2020 16:27:44 +0800 Subject: [PATCH 18/24] =?UTF-8?q?:bug:=20fix:=20=E4=BF=AE=E5=BE=A9?= =?UTF-8?q?=E5=9B=A0instantpage=E6=96=B0=E7=89=88=E6=9C=ACbugs=E8=80=8C?= =?UTF-8?q?=E5=B0=8E=E8=87=B4fancybox=E5=92=8C=E7=B0=A1=E7=B9=81=E8=BD=89?= =?UTF-8?q?=E6=8F=9B=E7=84=A1=E6=B3=95=E6=AD=A3=E5=B8=B8=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=E7=9A=84bugs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_config.yml b/_config.yml index 2226341..7061c75 100644 --- a/_config.yml +++ b/_config.yml @@ -740,7 +740,7 @@ CDN: canvas_nest: /js/third-party/canvas-nest.js lazyload: https://cdn.jsdelivr.net/npm/lozad/dist/lozad.min.js - instantpage: https://cdn.jsdelivr.net/npm/instant.page@latest/instantpage.min.js + instantpage: https://cdn.jsdelivr.net/npm/instant.page@3/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 pangu: https://cdn.jsdelivr.net/npm/pangu/dist/browser/pangu.min.js From aa8c509b9629be5468a6a745f57b4d03aa19d3f0 Mon Sep 17 00:00:00 2001 From: Jerry <16351105+jerryc127@users.noreply.github.com> Date: Tue, 16 Jun 2020 18:37:22 +0800 Subject: [PATCH 19/24] =?UTF-8?q?:label:=20=E6=9B=B4=E6=96=B0=E8=87=B33.0.?= =?UTF-8?q?0-RC-1=20close=20#189,=20close=20#192,=20close=20#223,=20close?= =?UTF-8?q?=20#224,=20close=20#229,=20close=20232,=20close=20#240?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 14 +- README_CN.md | 14 +- _config.yml | 649 ++++++++++-------- languages/default.yml | 25 +- languages/en.yml | 25 +- languages/zh-CN.yml | 18 +- languages/zh-TW.yml | 16 +- layout/404.pug | 22 +- layout/flink.pug | 26 +- layout/includes/additional-js.pug | 18 +- layout/includes/chat/chatra.pug | 30 + layout/includes/chat/daovoice.pug | 37 + layout/includes/chat/gitter.pug | 28 + layout/includes/chat/index.pug | 8 + layout/includes/chat/tidio.pug | 39 ++ layout/includes/comments/disqusjs.pug | 3 +- layout/includes/comments/index.pug | 6 +- .../comments/{laibili.pug => livere.pug} | 2 +- layout/includes/comments/valine.pug | 4 +- layout/includes/footer.pug | 2 +- layout/includes/head.pug | 26 +- layout/includes/head/Open_Graph.pug | 9 +- layout/includes/head/aplayer.pug | 3 + layout/includes/head/config.pug | 20 +- layout/includes/head/config_site.pug | 14 +- layout/includes/head/darkmode.pug | 75 +- layout/includes/head/dns_prefetch.pug | 22 - layout/includes/head/noscript.pug | 2 +- layout/includes/head/preconnect.pug | 19 + layout/includes/head/subtitle.pug | 10 +- layout/includes/header/index.pug | 6 +- layout/includes/header/menu_item.pug | 4 +- .../includes/header/{header.pug => nav.pug} | 10 +- layout/includes/header/post-info.pug | 29 +- layout/includes/header/social.pug | 4 +- layout/includes/layout.pug | 7 +- layout/includes/mixins/article-sort.pug | 4 +- layout/includes/mixins/post-ui.pug | 46 +- .../includes/mobile-sidebar/mobile-menus.pug | 2 +- layout/includes/pagination.pug | 22 +- layout/includes/post/reward.pug | 7 +- layout/includes/rightside.pug | 39 +- layout/includes/search/algolia.pug | 2 +- layout/includes/search/local-search.pug | 2 +- layout/includes/sidebar.pug | 12 +- layout/includes/third-party/pangu.pug | 15 +- layout/includes/widget/card_announcement.pug | 2 +- layout/includes/widget/card_archives.pug | 2 +- layout/includes/widget/card_author.pug | 8 +- layout/includes/widget/card_categories.pug | 4 +- layout/includes/widget/card_recent_post.pug | 8 +- layout/includes/widget/card_tags.pug | 2 +- layout/includes/widget/card_webinfo.pug | 5 +- scripts/filters/post_lazyload.js | 7 +- scripts/helpers/aside_archives.js | 2 +- scripts/helpers/aside_categories.js | 41 +- scripts/helpers/related_post.js | 10 +- scripts/tags/button.js | 28 + scripts/tags/hide.js | 10 +- scripts/tags/tabs.js | 62 ++ source/css/_global/function.styl | 18 + source/css/_global/index.styl | 107 ++- source/css/_highlight/diff.styl | 79 ++- source/css/_highlight/highlight.styl | 223 +++--- source/css/_highlight/theme.styl | 61 +- source/css/_layout/404.styl | 104 ++- source/css/_layout/aside.styl | 53 +- source/css/_layout/chat.styl | 8 + source/css/_layout/flink.styl | 147 ++-- source/css/_layout/head.styl | 28 +- source/css/_layout/mobile-sidebar.styl | 42 +- source/css/_layout/page.styl | 28 +- source/css/_layout/pagination.styl | 14 +- source/css/_layout/post.styl | 75 +- source/css/_layout/relatedposts.styl | 34 +- source/css/_layout/reward.styl | 31 +- source/css/_layout/rightside.styl | 12 +- source/css/_layout/third-party.styl | 5 +- source/css/_mode/darkmode.styl | 107 ++- source/css/_mode/readmode.styl | 106 ++- source/css/_search/index.styl | 2 +- source/css/_tags/button.styl | 60 ++ source/css/_tags/gallery.styl | 8 +- source/css/_tags/hexo.styl | 30 + source/css/_tags/hide.styl | 9 +- source/css/_tags/note.styl | 248 +------ source/css/_tags/tabs.styl | 71 ++ source/css/index.styl | 2 +- source/css/var.styl | 56 +- source/js/main.js | 201 +++--- source/js/search/algolia.js | 10 +- source/js/tw_cn.js | 159 ++--- source/js/utils.js | 31 +- 93 files changed, 2109 insertions(+), 1648 deletions(-) create mode 100644 layout/includes/chat/chatra.pug create mode 100644 layout/includes/chat/daovoice.pug create mode 100644 layout/includes/chat/gitter.pug create mode 100644 layout/includes/chat/index.pug create mode 100644 layout/includes/chat/tidio.pug rename layout/includes/comments/{laibili.pug => livere.pug} (85%) create mode 100644 layout/includes/head/aplayer.pug delete mode 100644 layout/includes/head/dns_prefetch.pug create mode 100644 layout/includes/head/preconnect.pug rename layout/includes/header/{header.pug => nav.pug} (72%) create mode 100644 scripts/tags/button.js create mode 100644 scripts/tags/tabs.js create mode 100644 source/css/_global/function.styl create mode 100644 source/css/_layout/chat.styl create mode 100644 source/css/_tags/button.styl create mode 100644 source/css/_tags/hexo.styl create mode 100644 source/css/_tags/tabs.styl diff --git a/README.md b/README.md index a788b3d..1aea826 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # hexo-theme-butterfly -Version +Version Author Hexo node.js @@ -14,20 +14,20 @@ Based on [hexo-theme-melody](https://github.com/Molunerfinn/hexo-theme-melody) t Stable branch [recommend]: ``` -git clone -b master https://github.com/jerryc127/hexo-theme-butterfly.git themes/Butterfly +git clone -b master https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterfly ``` Dev branch: ``` -git clone -b dev https://github.com/jerryc127/hexo-theme-butterfly.git themes/Butterfly +git clone -b dev https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterfly ``` ## Configuration Set theme in the hexo work folder's root config file `_config.yml`: -> theme: Butterfly +> theme: butterfly If you don't have pug & stylus renderer, try this: @@ -35,13 +35,13 @@ 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` and `zh-CN` +Find in [Butterfly Docs](https://demo.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 QQ Group [recommend]](https://jq.qq.com/?_wv=1027&k=5KI3Jqb) -[ 💬 Join Telegram Group](https://t.me/hexo_butterfly) +[💬 Join Telegram Group](https://t.me/hexo_butterfly) diff --git a/README_CN.md b/README_CN.md index 0802850..c951209 100644 --- a/README_CN.md +++ b/README_CN.md @@ -1,6 +1,6 @@ # hexo-theme-butterfly -Version +Version Author Hexo node.js @@ -14,33 +14,33 @@ Demo: 👍 [Butterfly](https://demo.jerryc.me/) || 🤞 [JerryC](https://jer 在你的博客根目錄裡安裝穩定版【推薦】 ``` -git clone -b master https://github.com/jerryc127/hexo-theme-butterfly.git themes/Butterfly +git clone -b master https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterfly ``` 如果想要安裝比較新的dev分支,可以 ``` -git clone -b dev https://github.com/jerryc127/hexo-theme-butterfly.git themes/Butterfly +git clone -b dev https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterfly ``` ## 應用主題 修改hexo配置文件`_config.yml`,把主題改為`Butterfly` ``` -theme: Butterfly +theme: butterfly ``` >如果你沒有pug以及stylus的渲染器,請下載安裝: npm install hexo-renderer-pug hexo-renderer-stylus --save or yarn add hexo-renderer-pug hexo-renderer-stylus ## 文檔 -可查看[hexo-theme-butterfly docs](https://docs.jerryc.me) 和 [JerryC](https://jerryc.me/posts/21cfbf15) +可查看[Butterfly Docs](https://demo.jerryc.me/posts/21cfbf15/) 你也可以加入群組 -[ 💬 QQ群 [推薦]](https://jq.qq.com/?_wv=1027&k=5KI3Jqb) +[ 💬 QQ群 [推薦]](https://jq.qq.com/?_wv=1027&k=5KI3Jqb) -[ 💬Telegram群](https://t.me/hexo_butterfly) +[ 💬 Telegram群](https://t.me/hexo_butterfly) ## 截圖 diff --git a/_config.yml b/_config.yml index 7061c75..ff041a8 100644 --- a/_config.yml +++ b/_config.yml @@ -1,60 +1,48 @@ -# Main menu navigation -# --------------- -# format: xxx: 連結 || icon +# Main menu navigation (導航目錄) +# -------------------------------------- + +# format: name: link || icon # sub-menu -# xxx || icon: -# xxx || 連結 || icon +# name || icon: +# name || link || icon + menu: - Home: / || fa fa-home - Archives: /archives/ || fa fa-archive - Tags: /tags/ || fa fa-tags - Categories: /categories/ || fa fa-folder-open - Link: /link/ || fa fa-link - About: /about/ || fa fa-heart - List||fa fa-list: - - Music || /music/ || fa fa-music - - Movie || /movies/ || fa fa-film + Home: / || fas fa-home + Archives: /archives/ || fas fa-archive + Tags: /tags/ || fas fa-tags + Categories: /categories/ || fas fa-folder-open + List||fas fa-list: + - Music || /music/ || fas fa-music + - Movie || /movies/ || fas fa-video + Link: /link/ || fas fa-link + About: /about/ || fas fa-heart -# PWA -# See https://github.com/JLHwung/hexo-offline -# --------------- -# pwa: -# enable: true -# manifest: /img/pwa/manifest.json -# theme_color: "#fff" -# apple_touch_icon: /img/pwa/apple-touch-icon.png -# favicon_32_32: /img/pwa/32.png -# favicon_16_16: /img/pwa/16.png -# mask_icon: /img/pwa/safari-pinned-tab.svg - -# Highlight theme -# --------------- -highlight_theme: light # default / darker / pale night / light / ocean -highlight_copy: true #代碼複製按鈕 -highlight_lang: true #代碼語言顯示 -highlight_shrink: false # true 全部代碼框不展開,需點擊 '>' 打開 / false 代碼框展開,有'>'點擊按鈕 | none 代碼框展開,不顯示 '>' 按鈕 +# Code Blocks (代碼相關) +# -------------------------------------- +highlight_theme: light # default / darker / pale night / light / ocean / mac / false +highlight_copy: true # copy button +highlight_lang: true # show the code language +highlight_shrink: false # true: shrink the code blocks / false: expand the code blocks | none: expand code blocks and hide the button code_word_wrap: false -# copy setting -# 是否禁止複製(如果禁止,highlight_copy的功能將無效) -# copyright 複製的內容後面加上版權信息 +# copy settings +# copyright: Add the copyright information after copied content (複製的內容後面加上版權信息) copy: - enable: true # true 開啟 / false 禁止 + enable: true copyright: false -# social settings +# social settings (社交圖標設置) # formal: # icon: link || the description -# --------------- social: - fa fa-github: https://github.com/jerryc127 || Github - fa fa-envelope: mailto:xxxxxxx@gmail.com || Email - fa fa-rss: /atom.xml || RSS + fab fa-github: https://github.com/xxxxx || Github + fas fa-envelope: mailto:xxxxxx@gmail.com || Email + +# search (搜索) +# -------------------------------------- -#### search #### # Algolia search -# --------------- algolia_search: enable: false hits: @@ -66,51 +54,42 @@ algolia_search: hits_stats: '${hits} results found in ${time} ms' # Local search -# Please see doc for more details: https://docs.jerryc.me/config.html#本地搜索 -# --------------- local_search: enable: false labels: input_placeholder: Search for Posts hits_empty: "We didn't find any results for the search: ${query}" # if there are no result +# Math (數學) +# -------------------------------------- +# About the per_page +# if you set it to true, it will load mathjax/katex script in each page (true 表示每一頁都加載js) +# if you set it to false, it will load mathjax/katex script according to your setting (add the 'mathjax: true' in page's front-matter) +# (false 需要時加載,須在使用的 Markdown Front-matter 加上 mathjax: true) + # MathJax -# Please see doc for more details: https://docs.jerryc.me/config.html#mathjax -# --------------- mathjax: enable: false - # true 表示每一頁都加載mathjax.js - # false 需要時加載,須在使用的Markdown Front-matter 加上 mathjax: true per_page: false # KaTeX -# --------------- katex: enable: false - # true 表示每一頁都加載katex.js - # false 需要時加載,須在使用的Markdown Front-matter 加上 katex: true per_page: false hide_scrollbar: true -# mermaid -# see https://github.com/knsv/mermaid -# ------------------------------- -mermaid: - enable: false - # built-in themes: default/forest/dark/neutral - theme: default +# Image (圖片設置) +# -------------------------------------- -# Favicon -# --------------- +# Favicon(網站圖標) favicon: /img/favicon.png -# Post info settings -# --------------- +# Avatar (頭像) avatar: img: /img/avatar.png - effect: false # 頭像會一直轉圈 + effect: false -# the banner image of index +# the banner image of home page index_img: # if the banner of page not setting,it will show the top_img @@ -127,7 +106,7 @@ tag_img: # category page, look like https://xxxxxxxxx.com/categories/butterfly category_img: -# 如果你有使用hexo-douban,可配置這個 +# If you are using hexo-douban, you can configure it (如果你有使用 hexo-douban,可配置這個) # douban: # meta: false # movies_img: @@ -135,31 +114,30 @@ category_img: # games_img: cover: - # 是否顯示文章封面 + # display the cover or not (是否顯示文章封面) index_enable: true aside_enable: true archives_enable: true - # 封面顯示的位置 - # 三個值可配置 left , right , both + # the position of cover in home page (封面顯示的位置) + # left/right/both position: both - # 當沒有設置cover時,默認的封面顯示 - default_cover: + # When cover is not set, the default cover is displayed (當沒有設置cover時,默認的封面顯示) + default_cover: - https://i.loli.net/2020/05/01/gkihqEjXxJ5UZ1C.jpg -# if the photo link cannot connect,it will show that -lodding_bg: - flink: /img/friend_404.gif #404後圖片 - post_page: /img/404.jpg #404後圖片 -# post: /img/loading.gif ##加載動畫 +# Replace Broken Images (替換無法顯示的圖片) +error_img: + flink: /img/friend_404.gif + post_page: /img/404.jpg # A simple 404 page error_404: enable: false subtitle: 'Page Not Found' - background: + background: https://i.loli.net/2020/05/19/aKOcLiyPl2JQdFD.png post_meta: - page: + page: # Home Page date_type: created # created or updated or both 主頁文章日期是創建日或者更新日或都顯示 categories: true # true or false 主頁是否顯示分類 tags: false # true or false 主頁是否顯示標籤 @@ -168,20 +146,29 @@ post_meta: categories: true # true or false 文章頁是否顯示分類 tags: true # true or false 文章頁是否顯示標籤 -# Please see doc for more details: https://docs.jerryc.me/config.html#字數統計 +# wordcount (字數統計) wordcount: enable: false post_wordcount: true min2read: true total_wordcount: true +# Display the article introduction on homepage +# 1: description +# 2: both (if the description exists, it will show description. or show the auto_excerpt) +# 3: auto_excerpt (default) +index_post_content: + method: 3 + length: 500 # if you set method to 2 or 3, the length need to config + +# Post +# -------------------------------------- + +# toc (目錄) toc: enable: true number: true - -# auto open the sidebar in 'post' -auto_open_sidebar: - enable: true + auto_open: true # auto open the sidebar post_copyright: enable: true @@ -189,21 +176,46 @@ post_copyright: license: CC BY-NC-SA 4.0 license_url: https://creativecommons.org/licenses/by-nc-sa/4.0/ -# 自動節選 -auto_excerpt: - enable: true - length: 150 +# Sponsor/reward +reward: + enable: false + QR_code: + - img: /img/wechat.jpg + link: + text: wechat + - img: /img/alipay.jpg + link: + text: alipay -#### Share System #### -# ----------------------------------------- +# Related Articles +related_post: + enable: true + limit: 6 # Number of posts displayed + date_type: created # or created or updated 文章日期顯示創建日或者更新日 + +# figcaption (圖片描述文字) +photofigcaption: false + +# anchor +# when you scroll in post, the URL will update according to header id. +anchor: false + +# Share System (分享功能) +# -------------------------------------- + +# AddThis +# https://www.addthis.com/ addThis: enable: false pubid: +# Share.js +# https://github.com/overtrue/share.js sharejs: enable: true sites: facebook,twitter,wechat,weibo,qq +# AddToAny # https://www.addtoany.com/ addtoany: enable: false @@ -216,30 +228,38 @@ addtoany: - email - copy_link -#### Comments System #### -# ------------------------------------ +# Comments System +# -------------------------------------- + +# disqus +# https://disqus.com/ disqus: enable: false shortname: count: false # dispaly comment count in top_img -# Disqus.js版評論系統,應對大陸長城的折中方案,兼容原版:https://github.com/SukkaW/DisqusJS -# API 申請地址:https://disqus.com/api/applications/ -# 與 disqus 共用樣式 +# Alternative Disqus - Render comments with Disqus API +# DisqusJS評論系統,可以實現在網路審查地區載入 Disqus 評論列表,兼容原版 +# https://github.com/SukkaW/DisqusJS disqusjs: enable: false shortname: siteName: apikey: - api: https://disqus.skk.moe/disqus/ #一般情況下無需修改 API 地址 + api: + nocomment: # display when a blog post or an article has no comment attached admin: adminLabel: count: false # dispaly comment count in top_img -laibili: +# livere(來必力) +# https://www.livere.com/ +livere: enable: false uid: +# gitalk +# https://github.com/gitalk/gitalk gitalk: enable: false client_id: @@ -247,31 +267,30 @@ gitalk: repo: owner: admin: - language: zh-CN # en , zh-CN , zh-TW + language: en # en, zh-CN, zh-TW, es-ES, fr, ru perPage: 10 # Pagination size, with maximum 100. distractionFreeMode: false # Facebook-like distraction free mode. pagerDirection: last # Comment sorting direction, available values are last and first. createIssueManually: false # Gitalk will create a corresponding github issue for your every single page automatically count: false # dispaly comment count in top_img -# valine comment system. https://valine.js.org +# valine +# https://valine.js.org valine: enable: false # if you want use valine,please set this value is true appId: # leancloud application app id appKey: # leancloud application app key - notify: false # valine mail notify (true/false) Deprecated in v1.4.0+ - verify: false # valine verify code (true/false) Deprecated in v1.4.0+ pageSize: 10 # comment list page size avatar: monsterid # gravatar style https://valine.js.org/#/avatar lang: en # i18n: zh-CN/zh-TW/en/ja placeholder: Please leave your footprints # valine comment input placeholder(like: Please leave your footprints ) - guest_info: nick,mail,link #valine comment header info + guest_info: nick,mail,link #valine comment header info (nick/mail/link) recordIP: false # Record reviewer IP serverURLs: # This configuration is suitable for domestic custom domain name users, overseas version will be automatically detected (no need to manually fill in) + bg: # valine background 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: # valine background + requiredFields: nick,mail # required fields (nick/mail) count: false # dispaly comment count in top_img # utterances @@ -279,9 +298,9 @@ valine: utterances: enable: false repo: - # 可選 pathname/url/title/og:title + # Issue Mapping: pathname/url/title/og:title issue_term: pathname - # 可選 github-light/github-dark/github-dark-orange/icy-dark/dark-blue/photon-dark + # Theme: github-light/github-dark/github-dark-orange/icy-dark/dark-blue/photon-dark light_theme: github-light dark_theme: photon-dark @@ -296,14 +315,48 @@ facebook_comments: lang: en_US # Language en_US/zh_CN/zh_TW and so on count: false -##### Footer Settings #### -# ------------------------------------ +# Chat Services +# -------------------------------------- + +# Chat Button [recommend] +# It will create a button in the bottom right corner of website, and hide the origin button +chat_btn: false + +# The origin chat button is displayed when scrolling up, and the button is hidden when scrolling down +chat_hide_show: false + +# chatra +# https://chatra.io/ +chatra: + enable: false + id: + +# tidio +# https://www.tidio.com/ +tidio: + enable: false + public_key: + +# daovoice +# http://daovoice.io/ +daovoice: + enable: false + app_id: + +# gitter +# https://gitter.im/ +gitter: + enable: false + room: + +# Footer Settings +# -------------------------------------- + since: 2020 footer_custom_text: -footer_copyright: - enable: true +footer_copyright: true ICP: enable: false @@ -311,33 +364,37 @@ ICP: text: icon: /img/icp.png -#### Analysis #### -# --------------- +# Analysis +# -------------------------------------- + +# Baidu Analytics baidu_analytics: # Google Analytics google_analytics: -# Tencent_analytics ID +# Tencent Analytics ID tencent_analytics: -# Ads -# --------------- -# Google Adsense +# Advertisement +# -------------------------------------- + +# Google Adsense (谷歌廣告) google_adsense: enable: false js: https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js client: enable_page_level_ads: true -# 廣告插入位置 -# 適用於開啓手動廣告的配置 +# Insert ads manually (手動插入廣告) # ad: # index: # aside: # post: -#### 站長驗證 #### +# Verification (站長驗證) +# -------------------------------------- + # Google Webmaster tools verification setting # See: https://www.google.com/webmasters/ google_site_verification: @@ -354,37 +411,12 @@ baidu_site_verification: # see http://zhanzhang.so.com/ qihu_site_verification: -# 打賞按鈕 -reward: - enable: true - QR_code: - - itemlist: - img: /img/wechat.jpg - text: 微信 - - itemlist: - img: /img/alipay.jpg - text: 支付寶 - -# 推薦文章 -related_post: - enable: true - limit: 6 # 顯示推薦文章數目 - date_type: created # or created or updated 文章日期顯示創建日或者更新日 - -# figcaption -# 圖片描述文字 -photofigcaption: false - -# anchor -# when you scroll in post, the url will update according to header id. -anchor: false - -#### 美化/效果 #### -#-------------------------------- +# Beautify/Effect (美化/效果) +# -------------------------------------- # Theme color for customize # Notice: color value must in double quotes like "#000" or may cause error! -# --------------- + # theme_color: # enable: true # main: "#49B1F5" @@ -400,31 +432,36 @@ anchor: false # blockquote_padding_color: "#49b1f5" # blockquote_background_color: "#49b1f5" -# 主頁設置 -# 默認top_img全屏,site_info在中間 -# 使用默認, 都無需填寫(建議默認) -index_site_info_top: # 主頁標題距離頂部距離 例如 300px/300em/300rem/10% -index_top_img_height: # 主頁top_img高度 例如 300px/300em/300rem 不能使用百分比 +# The top_img settings of home page +# default: top img - full screen, site info - middle (默認top_img全屏,site_info在中間) +# The positon of site info, eg: 300px/300em/300rem/10% (主頁標題距離頂部距離) +index_site_info_top: +# The height of top_img, eg: 300px/300em/300rem (主頁top_img高度) +index_top_img_height: -# category和tag頁的UI設置 -# index 值代表 UI將與首頁的UI一樣 -# 默認跟archives頁面UI一樣 -category_ui: # 留空或index -tag_ui: # 留空或index +# The user interface setting of category and tag page (category和tag頁的UI設置) +# index - same as Homepage UI (index 值代表 UI將與首頁的UI一樣) +# default - same as archives UI 默認跟archives頁面UI一樣 +category_ui: # 留空或 index +tag_ui: # 留空或 index -# 設置網站背景 -# 可設置圖片 或者 顔色 -# 圖片格式 background: url(http://xxxxxx.com/xxx.jpg) -# 顔色 background: '#49B202' -# 留空 顯示白色 +# Website Background (設置網站背景) +# can set it to color or image (可設置圖片 或者 顔色) +# The formal of color: '#49B202' +# The formal of image: url(http://xxxxxx.com/xxx.jpg) +# White color will be shown as default background: -# footer是否顯示圖片背景(與top_img一致) +# Show the footer background image (same as top_img) footer_bg: false -# 背景特效 -# 避免卡頓,建議只開啟一個 -# canvas_ribbon 禁止彩帶背景 +# the position of bottom right button/default unit: px (右下角按鈕距離底部的距離/默認單位為px) +rightside-bottom: + +# Background effects (背景特效) +# -------------------------------------- + +# canvas_ribbon (靜止彩帶背景) # See: https://github.com/hustcc/ribbon.js canvas_ribbon: enable: false @@ -432,12 +469,12 @@ canvas_ribbon: alpha: 0.6 zIndex: -1 click_to_change: false - mobile: false # false 手機端不顯示 true 手機端顯示 + mobile: false -# 動態彩帶 +# Dynamic ribbon (動態彩帶) canvas_ribbon_piao: enable: false - mobile: false # false 手機端不顯示 true 手機端顯示 + mobile: false # canvas_nest # https://github.com/hustcc/canvas-nest.js @@ -447,25 +484,24 @@ canvas_nest: opacity: 0.7 # the opacity of line (0~1), default: 0.5. zIndex: -1 # z-index property of the background, default: -1. count: 99 # the number of lines, default: 99. - mobile: false # false 手機端不顯示 true 手機端顯示 + mobile: false -# 打字效果 +# Typewriter Effect (打字效果) +# https://github.com/disjukr/activate-power-mode activate_power_mode: enable: false - colorful: true # 冒光特效 - shake: true # 抖動特效 + colorful: true # open particle animation (冒光特效) + shake: true # open shake (抖動特效) -# 鼠標點擊效果 -# 避免卡頓,建議只開啟一個 -# 點擊煙火特效 +# Mouse click effects: fireworks (鼠標點擊效果: 煙火特效) fireworks: enable: false + zIndex: 9999 # -1 or 9999 -# 點擊出現愛心 -click_heart: - enable: false +# Mouse click effects: Heart symbol (鼠標點擊效果: 愛心) +click_heart: false -# 點擊出現文字,文字可自行修改 +# Mouse click effects: words (鼠標點擊效果: 文字) ClickShowText: enable: false text: @@ -474,43 +510,42 @@ ClickShowText: - YOU fontSize: 15px -# 網站顯示模式 -# light 默認模式 -# dark 黑暗模式(不建議) +# Default display mode (網站默認的顯示模式) +# light (default) / dark display_mode: light -# 美化頁面顯示 +# Beautify (美化頁面顯示) beautify: enable: false field: post # site/post title-prefix-icon: '\f0c1' title-prefix-icon-color: '#F47466' -# 全局字體 +# Global font settings +# Don't modify the following settings unless you know how they work (非必要不要修改) font: - enable: false - font-family: Lato, Helvetica Neue For Number, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, PingFang SC, Hiragino Sans GB, MicrMicrosoft YaHei", Helvetica Neue, Helvetica, Arial, sans-serif - code-font: consolas, Menlo, "PingFang SC", "Microsoft YaHei", monospace, Helvetica Neue For Number + font-family: + code-font: -# 網站名字字體 +# Font settings for the site title and site subtitle # 左上角網站名字 主頁居中網站名字 blog_title_font: - font_link: https://fonts.googleapis.com/css?family=Titillium+Web #字體鏈接 - font-family: Titillium Web, PingFang SC, Hiragino Sans GB, "Microsoft YaHei", Helvetica Neue, Helvetica, Arial, sans-serif + font_link: https://fonts.googleapis.com/css?family=Titillium+Web&display=swap + font-family: Titillium Web, 'PingFang SC', 'Hiragino Sans GB', Microsoft YaHei', sans-serif -# 水平分隔綫 -hr: - enable: false - icon: '\f21c' #fontawesome上圖標的Unicode - icon-top: -20px +# The setting of divider icon (水平分隔線圖標設置) +hr_icon: + enable: true + icon: # the unicode value of Font Awesome icon + icon-top: -# 主頁subtitle +# the subtitle on homepage (主頁subtitle) subtitle: enable: true - # 打字效果 + # Typewriter Effect (打字效果) effect: true - # 循環或者只打字一次 - loop: false + # loop (循環打字) + loop: true # source調用第三方服務 # source: false 關閉調用 # source: 1 調用搏天api的隨機語錄(簡體) https://api.btstu.cn/ @@ -519,26 +554,23 @@ subtitle: # source: 4 調用今日詩詞(簡體) https://www.jinrishici.com/ # subtitle 會先顯示 source , 再顯示 sub 的內容 source: false - # (如果有英文逗號' , ',請使用轉義字符 ,) + # 如果有英文逗號' , ',請使用轉義字元 , + # 如果有英文雙引號' " ',請使用轉義字元 " + # 開頭不允許轉義字元,如需要,請把整個句子用雙引號包住 # 如果關閉打字效果,subtitle只會顯示sub的第一行文字 sub: - 今日事,今日畢 - Never put off till tomorrow what you can do today -# fontawesome圖標 -# 默認使用的是 fontawesome v4版本的圖標 -fontawesome_v5: - enable: false - -# 加載動畫 Loading Animation +# Loading Animation (加載動畫) preloader: false -#### 側邊欄 #### -#------------------------------------- -# 側邊欄顯示設置 +# aside (側邊欄) +# -------------------------------------- + aside: enable: true - mobile: true # 手機頁面( 顯示寬度 < 768px )是否顯示aside內容 + mobile: true # display on mobile position: right # left or right card_author: enable: true @@ -552,6 +584,7 @@ aside: card_categories: enable: true limit: 8 # if set 0 will show all + expand: none # none/true/false card_tags: enable: true limit: 40 # if set 0 will show all @@ -571,88 +604,66 @@ busuanzi: site_pv: true page_pv: true -# 網頁開通時間 -# 格式: 月/日/年 時間 -# 也可以寫成 年/月/日 時間 +# Time difference between publish date and now (網頁運行時間) +# Formal: Month/Day/Year Time or Year/Month/Day Time runtimeshow: - enable: true - start_date: 6/7/2018 00:00:00 + enable: false + publish_date: -#### 右下角按鈕 #### -#---------------------------------------------- -# 簡繁轉換 +# Bottom right button (右下角按鈕) +# -------------------------------------- + +# Conversion between Traditional and Simplified Chinese (簡繁轉換) translate: enable: true - # 默認按鈕顯示文字 + # The text of a button default: 繁 - #網站默認語言,1: 繁體中文, 2: 簡體中文 + # the language of website (1 - Traditional Chinese/ 2 - Simplified Chinese) defaultEncoding: 2 - #延遲時間,若不在前, 要設定延遲翻譯時間, 如100表示100ms,默認為0 + # Time delay translateDelay: 0 - #博客網址 - cookieDomain: 'https://xxx/' - #當文字是簡體時,按鈕顯示的文字 + # The text of the button when the language is Simplified Chinese msgToTraditionalChinese: '繁' - #當文字是繁體時,按鈕顯示的文字 + # The text of the button when the language is Traditional Chinese msgToSimplifiedChinese: '簡' -#閲讀模式 -readmode: - enable: true +# Read Mode (閲讀模式) +readmode: true # dark mode darkmode: enable: true - # dark mode和 light mode切換按鈕 + # Toggle Button to switch dark/light mode button: true - # 自動切換 dark mode和 light mode - # autoChangeMode: 1 跟隨系統而變化,不支持的瀏覽器/系統將按照時間晚上6點到早上6點之間切換為 dark mode - # autoChangeMode: 2 只按照時間晚上6點到早上6點之間切換為 dark mode - # autoChangeMode: false 取消自動切換 - autoChangeMode: 1 + # Switch dark/light mode automatically (自動切換 dark mode和 light mode) + # autoChangeMode: 1 Following System Settings, if the system doesn't support dark mode, it will switch dark mode between 6 pm to 6 am + # autoChangeMode: 2 Switch dark mode between 6 pm to 6 am + # autoChangeMode: false + autoChangeMode: false -#### other #### -#------------------------------------------------ +# Lightbox (圖片大圖查看模式) +# -------------------------------------- +# You can only choose one, or neither (只能選擇一個 或者 兩個都不選) -# 圖片大圖查看模式 -# 可選 medium_zoom 或者 fancybox -# 只選一個 或者 兩個都不選 -#-------------------------------------------- -# medium_zoom https://github.com/francoischalifour/medium-zoom -medium_zoom: +# medium-zoom +# https://github.com/francoischalifour/medium-zoom +medium_zoom: false + +# fancybox +# http://fancyapps.com/fancybox/3/ +fancybox: true + +# Tag Plugins settings (標籤外掛) +# -------------------------------------- + +# mermaid +# see https://github.com/knsv/mermaid +mermaid: enable: false - -# fancybox http://fancyapps.com/fancybox/3/ -fancybox: - enable: true - -# Snackbar 彈窗 -# https://github.com/polonel/SnackBar -# position 彈窗位置 -# 可選 top-left / top-center / top-right / bottom-left / bottom-center / bottom-right -snackbar: - enable: false - position: bottom-left - bg_light: '#49b1f5' #light mode時彈窗背景 - bg_dark: '#2d3035' #dark mode時彈窗背景 - -#百度推送 -baidu_push: - enable: false - -# https://instant.page/ -# prefetch預加載 -instantpage: - enable: true - -# https://github.com/vinta/pangu.js -# 中英文之間添加空格 -pangu: - enable: false - field: page # page/post + # built-in themes: default/forest/dark/neutral + theme: default # Note (Bootstrap Callout) -# https://muse.theme-next.org/docs/tag-plugins/note note: # Note tag style values: # - simple bs-callout old alert style. Default. @@ -666,37 +677,72 @@ note: # Offset also applied to label tag variables. This option can work with disabled note tag. light_bg_offset: 0 -# 圖片懶加載 -# https://github.com/ApoorvSaxena/lozad.js -lazyload: false +# other +# -------------------------------------- -# 避免重複網址分散seo -canonical: true +# Snackbar (Toast Notification 彈窗) +# https://github.com/polonel/SnackBar +# position 彈窗位置 +# 可選 top-left / top-center / top-right / bottom-left / bottom-center / bottom-right +snackbar: + enable: false + position: bottom-left + bg_light: '#49b1f5' # The background color of Toast Notification in light mode + bg_dark: '#121212' # The background color of Toast Notification in dark mode -# 禁止百度轉碼 +# Baidu Push (百度推送) +baidu_push: false + +# https://instant.page/ +# prefetch (預加載) +instantpage: true + +# https://github.com/vinta/pangu.js +# Insert a space between Chinese character and English character (中英文之間添加空格) +pangu: + enable: false + field: site # site/post + +# Lazyload (圖片懶加載) +# https://github.com/verlok/lazyload +lazyload: + enable: true + post: /img/loading.gif + +# PWA +# See https://github.com/JLHwung/hexo-offline +# --------------- +# pwa: +# enable: false +# manifest: /image/pwa/manifest.json +# theme_color: "#fff" +# apple_touch_icon: /image/pwa/apple-touch-icon.png +# favicon_32_32: /image/pwa/32.png +# favicon_16_16: /image/pwa/16.png +# mask_icon: /image/pwa/safari-pinned-tab.svg + +# Disable Baidu transformation on mobile devices (禁止百度轉碼) disable_baidu_transformation: true -# twitter分享自動帶上樣式 -# https://i.loli.net/2019/09/08/qm3RfvUCKbct1Wz.png -twitter_meta: true - -# facebook QQ 等 分享自動帶上樣式 -# https://i.loli.net/2019/09/08/2wbFJEKloisRvhj.png +# Open graph meta tags +# https://developers.facebook.com/docs/sharing/webmasters/ Open_Graph_meta: true -# 開啟hexo自帶的緩存,加快生成速度 +# Caches the contents in a fragment, speed up the generation (開啟hexo自帶的緩存,加快生成速度) fragment_cache: true -# inject -# 插入代码到头部之前 和 尾部之前 +# Inject +# Insert the code to head (before '' tag) and the bottom (before '' tag) +# 插入代码到头部 之前 和 底部 之前 inject: head: - # - + # - bottom: # - # CDN -# 非必要不要修改 +# Don't modify the following settings unless you know how they work +# 非必要請不要修改 CDN: # main main_css: /css/index.css @@ -709,8 +755,8 @@ CDN: gitalk: https://cdn.jsdelivr.net/npm/gitalk@latest/dist/gitalk.min.js gitalk_css: https://cdn.jsdelivr.net/npm/gitalk/dist/gitalk.min.css valine: https://cdn.jsdelivr.net/npm/valine/dist/Valine.min.js - disqusjs: https://cdn.jsdelivr.net/npm/disqusjs@1.2/dist/disqus.js - disqusjs_css: https://cdn.jsdelivr.net/npm/disqusjs@1.2/dist/disqusjs.css + disqusjs: https://cdn.jsdelivr.net/npm/disqusjs@1/dist/disqus.js + disqusjs_css: https://cdn.jsdelivr.net/npm/disqusjs@1/dist/disqusjs.css utterances: https://utteranc.es/client.js # share @@ -739,10 +785,9 @@ CDN: canvas_ribbon_piao: /js/third-party/piao.js canvas_nest: /js/third-party/canvas-nest.js - lazyload: https://cdn.jsdelivr.net/npm/lozad/dist/lozad.min.js - instantpage: https://cdn.jsdelivr.net/npm/instant.page@3/instantpage.min.js + lazyload: https://cdn.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.iife.min.js + instantpage: https://cdn.jsdelivr.net/npm/instant.page/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 pangu: https://cdn.jsdelivr.net/npm/pangu/dist/browser/pangu.min.js # photo @@ -754,7 +799,7 @@ CDN: snackbar_css: https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.css snackbar: https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.js - # 鼠標點擊特效 + # effect anime: https://cdn.jsdelivr.net/npm/animejs@latest/anime.min.js activate_power_mode: /js/third-party/activate-power-mode.js fireworks: /js/third-party/fireworks.js @@ -762,8 +807,16 @@ CDN: ClickShowText: /js/third-party/ClickShowText.js # fontawesome - fontawesome_v4: https://cdn.jsdelivr.net/npm/font-awesome@latest/css/font-awesome.min.css - fontawesome_v5: https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css + fontawesome: https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css - # 簡繁轉換 + # Conversion between Traditional and Simplified Chinese translate: /js/tw_cn.js + + # justifiedGallery + justifiedGallery_js: https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js + justifiedGallery_css: https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css + + # aplayer + aplayer_css: https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css + aplayer_js: https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js + meting_js: https://cdn.jsdelivr.net/npm/meting@1.2.0/dist/Meting.min.js diff --git a/languages/default.yml b/languages/default.yml index a8ff80b..6c601af 100644 --- a/languages/default.yml +++ b/languages/default.yml @@ -24,7 +24,7 @@ post: created: Created updated: Updated wordcount: Word count - min2read: "Reading time: %s min" + min2read: 'Reading time: %s min' page_pv: Post View comments: Comments copyright: @@ -32,13 +32,13 @@ post: link: Link copyright_notice: Copyright Notice copyright_content: 'All articles in this blog are licensed under %s unless stating additionally.' - recommend: Recommend + recommend: Related Articles search: Search algolia_search: input_placeholder: Search for Posts hits_empty: "We didn't find any results for the search: ${query}." - hits_stats: "${hits} results found in ${time} ms" + hits_stats: '${hits} results found in ${time} ms' local_search: label: Local search @@ -78,13 +78,13 @@ bookmark: rightside: readmode_title: Read Mode - font_plus_title: Increase font size - font_minus_title: Decrease font size - translate_title: Traditional Chinese and Simplified Chinese Conversion - night_mode_title: Dark Mode - back_to_top: Back to top - toc: Table of Contents - scroll_to_comment: Scroll to comment + font_plus_title: Increase Font Size + font_minus_title: Decrease Font Size + translate_title: Switch Between Traditional Chinese And Simplified Chinese + night_mode_title: Switch Between Light And Dark Mode + back_to_top: Back To Top + toc: Table Of Contents + scroll_to_comment: Scroll To Comments setting: Setting runtime_unit: days @@ -104,5 +104,8 @@ Snackbar: day_to_night: Dark Mode Activated Manually night_to_day: Light Mode Activated Manually -error_title: Page not found loading: Loading... + +error404: + error_title: Page not found + back_button: Go back home diff --git a/languages/en.yml b/languages/en.yml index a8ff80b..6c601af 100644 --- a/languages/en.yml +++ b/languages/en.yml @@ -24,7 +24,7 @@ post: created: Created updated: Updated wordcount: Word count - min2read: "Reading time: %s min" + min2read: 'Reading time: %s min' page_pv: Post View comments: Comments copyright: @@ -32,13 +32,13 @@ post: link: Link copyright_notice: Copyright Notice copyright_content: 'All articles in this blog are licensed under %s unless stating additionally.' - recommend: Recommend + recommend: Related Articles search: Search algolia_search: input_placeholder: Search for Posts hits_empty: "We didn't find any results for the search: ${query}." - hits_stats: "${hits} results found in ${time} ms" + hits_stats: '${hits} results found in ${time} ms' local_search: label: Local search @@ -78,13 +78,13 @@ bookmark: rightside: readmode_title: Read Mode - font_plus_title: Increase font size - font_minus_title: Decrease font size - translate_title: Traditional Chinese and Simplified Chinese Conversion - night_mode_title: Dark Mode - back_to_top: Back to top - toc: Table of Contents - scroll_to_comment: Scroll to comment + font_plus_title: Increase Font Size + font_minus_title: Decrease Font Size + translate_title: Switch Between Traditional Chinese And Simplified Chinese + night_mode_title: Switch Between Light And Dark Mode + back_to_top: Back To Top + toc: Table Of Contents + scroll_to_comment: Scroll To Comments setting: Setting runtime_unit: days @@ -104,5 +104,8 @@ Snackbar: day_to_night: Dark Mode Activated Manually night_to_day: Light Mode Activated Manually -error_title: Page not found loading: Loading... + +error404: + error_title: Page not found + back_button: Go back home diff --git a/languages/zh-CN.yml b/languages/zh-CN.yml index 21ce127..d66990e 100644 --- a/languages/zh-CN.yml +++ b/languages/zh-CN.yml @@ -24,7 +24,7 @@ post: created: 发表于 updated: 更新于 wordcount: 字数总计 - min2read: "阅读时长: %s 分钟" + min2read: '阅读时长: %s 分钟' page_pv: 阅读量 comments: 评论数 copyright: @@ -38,14 +38,14 @@ post: search: 搜索 algolia_search: input_placeholder: 搜索文章 - hits_empty: "找不到您查询的内容:${query}" - hits_stats: "找到 ${hits} 条结果,用时 ${time} 毫秒" + hits_empty: '找不到您查询的内容:${query}' + hits_stats: '找到 ${hits} 条结果,用时 ${time} 毫秒' local_search: label: 本地搜索 input_placeholder: 搜索文章 - hits_empty: "找不到您查询的内容:${query}" - powered: "提供支持" + hits_empty: '找不到您查询的内容:${query}' + powered: '提供支持' by: 由 pagination: @@ -83,7 +83,7 @@ rightside: font_plus_title: 放大字体 font_minus_title: 缩小字体 translate_title: 简繁转换 - night_mode_title: 夜间模式 + night_mode_title: 浅色和深色模式转换 back_to_top: 回到顶部 toc: 目录 scroll_to_comment: 直达评论 @@ -107,4 +107,8 @@ Snackbar: night_to_day: 你已切换为浅色模式 error_title: 页面没有找到 -loading: 加载中... \ No newline at end of file +loading: 加载中... + +error404: + error_title: 页面没有找到 + back_button: 回到主页 diff --git a/languages/zh-TW.yml b/languages/zh-TW.yml index 95cb5d3..0e73531 100644 --- a/languages/zh-TW.yml +++ b/languages/zh-TW.yml @@ -24,7 +24,7 @@ post: created: 發表於 updated: 更新於 wordcount: 字數總計 - min2read: "閱讀時長: %s 分鐘" + min2read: '閱讀時長: %s 分鐘' page_pv: 閱讀量 comments: 評論數 copyright: @@ -38,14 +38,14 @@ post: search: 搜尋 algolia_search: input_placeholder: 搜尋文章 - hits_empty: "找不到您查詢的內容:${query}" - hits_stats: "找到 ${hits} 條結果,用時 ${time} 毫秒" + hits_empty: '找不到您查詢的內容:${query}' + hits_stats: '找到 ${hits} 條結果,用時 ${time} 毫秒' local_search: label: 本地搜尋 input_placeholder: 搜尋文章 - hits_empty: "找不到您查詢的內容:${query}" - powered: "提供支援" + hits_empty: '找不到您查詢的內容:${query}' + powered: '提供支援' by: 由 pagination: @@ -83,7 +83,7 @@ rightside: font_plus_title: 放大字型 font_minus_title: 縮小字型 translate_title: 簡繁轉換 - night_mode_title: 夜間模式 + night_mode_title: 淺色和深色模式轉換 back_to_top: 回到頂部 toc: 目錄 scroll_to_comment: 直達評論 @@ -106,6 +106,8 @@ Snackbar: day_to_night: 你已切換為深色模式 night_to_day: 你已切換為淺色模式 -error_title: 頁面沒有找到 loading: 載入中... +error404: + error_title: 頁面沒有找到 + back_button: 回到主頁 diff --git a/layout/404.pug b/layout/404.pug index a088390..2de0d72 100644 --- a/layout/404.pug +++ b/layout/404.pug @@ -11,14 +11,20 @@ html(lang=config.language data-theme=theme.display_mode) if theme.fireworks && theme.fireworks.enable canvas.fireworks + + if theme.background + - var is_photo = theme.background.startsWith('url') ? 'photo':'color' + #web_bg(data-type=is_photo) - 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/rightside.pug + #error-wrap + .error-content + .error-img(style=bg_img) + .error-info + h1.error_title= '404' + .error_subtitle= theme.error_404.subtitle + a.button--animated(href=url_for(config.root)) + i.fas.fa-rocket + = _p('error404.back_button') + !=partial('includes/search/index', {}, {cache:theme.fragment_cache}) include includes/additional-js.pug diff --git a/layout/flink.pug b/layout/flink.pug index a646413..178f683 100644 --- a/layout/flink.pug +++ b/layout/flink.pug @@ -2,18 +2,20 @@ .flink#article-container if site.data.link each i in site.data.link - h2= i.class_name - .post-cards - .md-links - each item in i.link_list - .md-links-item - 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=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 + if i.class_name + h2!= i.class_name + if i.class_desc + .flink-desc!=i.class_desc + .flink-list + each item in i.link_list + .flink-list-item + a(href=url_for(item.link) title=item.name target="_blank") + if theme.lazyload.enable + img(data-src=url_for(item.avatar) onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.flink) + `'` alt=item.name ) + else + img(src=url_for(item.avatar) onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.flink) + `'` alt=item.name ) + .flink-item-name= item.name + .flink-item-desc= item.descr != page.content if page.comments !== false include includes/comments/index.pug diff --git a/layout/includes/additional-js.pug b/layout/includes/additional-js.pug index 266af58..effa64e 100644 --- a/layout/includes/additional-js.pug +++ b/layout/includes/additional-js.pug @@ -5,10 +5,10 @@ script(src=url_for(theme.CDN.main)) if theme.translate && theme.translate.enable script(src=url_for(theme.CDN.translate)) -if (theme.medium_zoom && theme.medium_zoom.enable) +if theme.medium_zoom script(src=url_for(theme.CDN.medium_zoom)) -if (theme.fancybox && theme.fancybox.enable) +if theme.fancybox script(src=url_for(theme.CDN.fancybox)) include ./math/index.pug @@ -39,14 +39,14 @@ if theme.activate_power_mode.enable if theme.busuanzi.site_uv || theme.busuanzi.site_pv || theme.busuanzi.page_pv script(async src=url_for(theme.CDN.busuanzi)) -if theme.instantpage.enable - script(src=url_for(theme.CDN.instantpage) type="module") +if theme.instantpage + script(src=url_for(theme.CDN.instantpage) type="module" defer) -if theme.lazyload - script(src=url_for(theme.CDN.lazyload)) +if theme.lazyload.enable + script(src=url_for(theme.CDN.lazyload) async) //- 鼠標特效 -if theme.click_heart && theme.click_heart.enable +if theme.click_heart script(src=url_for(theme.CDN.click_heart)) if theme.ClickShowText && theme.ClickShowText.enable @@ -71,4 +71,6 @@ if is_home() !=fragment_cache('injectBottom', function(){return injectHtml(theme.inject.bottom)}) if theme.preloader - !=partial('includes/loading/loading-js', {}, {cache:theme.fragment_cache}) \ No newline at end of file + !=partial('includes/loading/loading-js', {}, {cache:theme.fragment_cache}) + +!=partial('includes/chat/index', {}, {cache:theme.fragment_cache}) diff --git a/layout/includes/chat/chatra.pug b/layout/includes/chat/chatra.pug new file mode 100644 index 0000000..0566392 --- /dev/null +++ b/layout/includes/chat/chatra.pug @@ -0,0 +1,30 @@ +//- https://chatra.io/help/api/ +script. + (function(d, w, c) { + w.ChatraID = '#{theme.chatra.id}'; + var s = d.createElement('script'); + w[c] = w[c] || function() { + (w[c].q = w[c].q || []).push(arguments); + }; + s.async = true; + s.src = 'https://call.chatra.io/chatra.js'; + if (d.head) d.head.appendChild(s); + })(document, window, 'Chatra'); + + if (!{theme.chat_btn}) { + var chatBtn = document.getElementById("chat_btn") + chatBtn.addEventListener("click", function(){ + Chatra('openChat') + }); + } else { + if (!{theme.chat_hide_show}) { + function chatBtnHide () { + Chatra('hide') + } + function chatBtnShow () { + Chatra('show') + } + } + } + + diff --git a/layout/includes/chat/daovoice.pug b/layout/includes/chat/daovoice.pug new file mode 100644 index 0000000..dd0e047 --- /dev/null +++ b/layout/includes/chat/daovoice.pug @@ -0,0 +1,37 @@ +//- https://guide.daocloud.io/daovoice/javascript-api-5869833.html +script. + (function(i,s,o,g,r,a,m){i["DaoVoiceObject"]=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;a.charset="utf-8";m.parentNode.insertBefore(a,m)})(window,document,"script",('https:' == document.location.protocol ? 'https:' : 'http:') + "//widget.daovoice.io/widget/!{theme.daovoice.app_id}.js","daovoice") + +script. + var isChatBtn = !{theme.chat_btn} + daovoice('init', { + app_id: '!{theme.daovoice.app_id}',},{ + launcher: { + disableLauncherIcon: isChatBtn // 悬浮 ICON 是否显示 + }, + }); + daovoice('update'); + + if (isChatBtn) { + var chatBtn = document.getElementById("chat_btn") + chatBtn.addEventListener("click", function(){ + daovoice('show') + }); + } else { + if (!{theme.chat_hide_show}) { + function chatBtnHide () { + daovoice('update', {},{ + launcher: { + disableLauncherIcon: true // 悬浮 ICON 是否显示 + }, + }); + } + function chatBtnShow () { + daovoice('update', {},{ + launcher: { + disableLauncherIcon: false // 悬浮 ICON 是否显示 + }, + }); + } + } + } \ No newline at end of file diff --git a/layout/includes/chat/gitter.pug b/layout/includes/chat/gitter.pug new file mode 100644 index 0000000..51cdc0a --- /dev/null +++ b/layout/includes/chat/gitter.pug @@ -0,0 +1,28 @@ +//- https://sidecar.gitter.im/ +script. + var isChatBtn = !{theme.chat_btn} + + if (isChatBtn) { + ((window.gitter = {}).chat = {}).options = { + room: '#{theme.gitter.room}', + activationElement: '#chat_btn' + }; + } else { + ((window.gitter = {}).chat = {}).options = { + room: '#{theme.gitter.room}', + }; + + if (!{theme.chat_hide_show}) { + var gitterBtn = document.getElementsByClassName('gitter-open-chat-button') + + function chatBtnHide () { + gitterBtn[0].style.display= 'none' + } + + function chatBtnShow () { + gitterBtn[0].style.display= 'block' + } + } + } + +script(src="https://sidecar.gitter.im/dist/sidecar.v1.js" async defer) \ No newline at end of file diff --git a/layout/includes/chat/index.pug b/layout/includes/chat/index.pug new file mode 100644 index 0000000..48b8585 --- /dev/null +++ b/layout/includes/chat/index.pug @@ -0,0 +1,8 @@ +if theme.chatra && theme.chatra.enable + include ./chatra.pug +else if theme.tidio && theme.tidio.enable + include ./tidio.pug +else if theme.daovoice && theme.daovoice.enable + include ./daovoice.pug +else if theme.gitter && theme.gitter.enable + include ./gitter.pug \ No newline at end of file diff --git a/layout/includes/chat/tidio.pug b/layout/includes/chat/tidio.pug new file mode 100644 index 0000000..90270a7 --- /dev/null +++ b/layout/includes/chat/tidio.pug @@ -0,0 +1,39 @@ +script(src=`//code.tidio.co/${theme.tidio.public_key}.js` async) + +if theme.chat_btn + script. + (function() { + function onTidioChatApiReady() { + window.tidioChatApi.hide(); + window.tidioChatApi.on("close", function() { + window.tidioChatApi.hide(); + }); + } + if (window.tidioChatApi) { + window.tidioChatApi.on("ready", onTidioChatApiReady); + } else { + document.addEventListener("tidioChat-ready", onTidioChatApiReady); + } + + document.getElementById("chat_btn").addEventListener("click", function(){ + window.tidioChatApi.show(); + window.tidioChatApi.open(); + }); + })(); +else if theme.chat_hide_show + script. + function chatBtnHide () { + if (window.tidioChatApi) { + window.tidioChatApi.hide(); + //- document.getElementById('tidio-chat').style.display= 'none' + } + } + + function chatBtnShow () { + if (window.tidioChatApi) { + window.tidioChatApi.show(); + //- document.getElementById('tidio-chat').style.display= 'block' + } + } + + diff --git a/layout/includes/comments/disqusjs.pug b/layout/includes/comments/disqusjs.pug index d1ddd2f..7d670d2 100644 --- a/layout/includes/comments/disqusjs.pug +++ b/layout/includes/comments/disqusjs.pug @@ -3,12 +3,13 @@ script(src=url_for(theme.CDN.disqusjs)) script. var dsqjs = new DisqusJS({ shortname: '!{theme.disqusjs.shortname}', - siteName: "!{theme.disqusjs.siteName}", + siteName: '!{theme.disqusjs.siteName}', identifier: '!{ page.path }', url: '!{ page.permalink }', title: '!{ page.title }', api: '!{theme.disqusjs.api}', apikey: '!{theme.disqusjs.apikey}', + nocomment: '!{theme.disqusjs.nocomment}', admin: '!{theme.disqusjs.admin}', adminLabel: '!{theme.disqusjs.adminLabel}' }); diff --git a/layout/includes/comments/index.pug b/layout/includes/comments/index.pug index 61c1042..a8d1a92 100644 --- a/layout/includes/comments/index.pug +++ b/layout/includes/comments/index.pug @@ -1,6 +1,6 @@ - var d = theme.disqus && theme.disqus.enable - var dj = theme.disqusjs && theme.disqusjs.enable -- var l = theme.laibili && theme.laibili.enable +- var l = theme.livere && theme.livere.enable - var gt = theme.gitalk && theme.gitalk.enable - var v = theme.valine && theme.valine.enable - var u = theme.utterances && theme.utterances.enable @@ -11,14 +11,14 @@ if isComment hr #post-comment .comment_headling - i.fa.fa-comments.fa-fw(aria-hidden="true") + i.fas.fa-comments.fa-fw span= ' ' + _p('comment') if d include ./disqus.pug else if dj include ./disqusjs.pug else if l - include ./laibili.pug + include ./livere.pug else if gt include ./gitalk.pug else if v diff --git a/layout/includes/comments/laibili.pug b/layout/includes/comments/livere.pug similarity index 85% rename from layout/includes/comments/laibili.pug rename to layout/includes/comments/livere.pug index cd0fc75..f530901 100644 --- a/layout/includes/comments/laibili.pug +++ b/layout/includes/comments/livere.pug @@ -1,4 +1,4 @@ -#lv-container(data-id="city" data-uid=theme.laibili.uid) +#lv-container(data-id="city" data-uid=theme.livere.uid) script. (function(d, s) { var j, e = d.getElementsByTagName(s)[0]; diff --git a/layout/includes/comments/valine.pug b/layout/includes/comments/valine.pug index ac70878..d5c7493 100644 --- a/layout/includes/comments/valine.pug +++ b/layout/includes/comments/valine.pug @@ -15,14 +15,12 @@ script. } var guestInfo = requestSetting(['nick','mail','link'],'#{ theme.valine.guest_info }') - var requiredFields = requestSetting(['nick','mail','link'],'#{ theme.valine.requiredFields }') + var requiredFields = requestSetting(['nick','mail'],'#{ theme.valine.requiredFields }') window.valine = new Valine({ el:'#vcomment', appId: '#{theme.valine.appId}', appKey: '#{theme.valine.appKey}', - notify: #{theme.valine.notify}, - verify: #{theme.valine.verify}, placeholder: '#{theme.valine.placeholder}', avatar: '#{theme.valine.avatar}', meta: guestInfo, diff --git a/layout/includes/footer.pug b/layout/includes/footer.pug index 30b238f..c1e710d 100644 --- a/layout/includes/footer.pug +++ b/layout/includes/footer.pug @@ -5,7 +5,7 @@ .copyright!= `©${theme.since} - ${nowYear} By ${config.author}` else .copyright!= `©${nowYear} By ${config.author}` - if theme.footer_copyright.enable + if theme.footer_copyright .framework-info span= _p('footer.driven') + ' ' a(href='https://hexo.io') diff --git a/layout/includes/head.pug b/layout/includes/head.pug index 92a66d5..bb40a6c 100644 --- a/layout/includes/head.pug +++ b/layout/includes/head.pug @@ -4,7 +4,7 @@ - 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 if (is_current('/404.html', [strict])) pageTitle = _p('error404.error_title') - else pageTitle = page.title || config.title || '' - var isSubtitle = config.subtitle ? ' - ' + config.subtitle : '' @@ -29,6 +29,7 @@ meta(name="author" content=pageAuthor) meta(name="copyright" content=pageCopyright) meta(name ="format-detection" content="telephone=no") !=favicon_tag(theme.favicon || config.favicon) +link(rel="canonical" href=urlNoIndex()) if theme.disable_baidu_transformation meta(http-equiv="Cache-Control" content="no-transform") @@ -39,7 +40,7 @@ if theme.douban meta(name="referrer" content="no-referrer") //- 預解析 -!=partial('includes/head/dns_prefetch', {}, {cache:theme.fragment_cache}) +!=partial('includes/head/preconnect', {}, {cache:theme.fragment_cache}) //- 網站驗證 !=partial('includes/head/site_verification', {}, {cache:theme.fragment_cache}) @@ -51,28 +52,19 @@ include ./head/Open_Graph.pug if (theme.pwa && theme.pwa.enable) !=partial('includes/head/pwa', {}, {cache:theme.fragment_cache}) -script(src=url_for(theme.CDN.js_cookies)) - if theme.darkmode.enable !=partial('includes/head/darkmode', {}, {cache:theme.fragment_cache}) //- main css link(rel='stylesheet', href=url_for(theme.CDN.main_css)) +link(rel='stylesheet', href=url_for(theme.CDN.fontawesome)) -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.fancybox && theme.fancybox.enable) +if theme.fancybox link(rel='stylesheet', href=url_for(theme.CDN.fancybox_css)) if (theme.snackbar && theme.snackbar.enable) link(rel='stylesheet', href=url_for(theme.CDN.snackbar_css)) -if theme.canonical - link(rel="canonical" href=urlNoIndex()) - if is_post() if(page.prev) link(rel="prev" title=page.prev.title href=url_for(page.prev.permalink) ) @@ -92,8 +84,9 @@ include ./head/comment.pug //- analytics !=partial('includes/head/analytics', {}, {cache:theme.fragment_cache}) +//- font if theme.blog_title_font.font_link - link(rel='stylesheet', href=url_for(theme.blog_title_font.font_link)) + link(rel='stylesheet' href=url_for(theme.blog_title_font.font_link)) //- global config !=partial('includes/head/config', {}, {cache:theme.fragment_cache}) @@ -101,4 +94,7 @@ if theme.blog_title_font.font_link include ./head/config_site.pug include ./head/noscript.pug -!=fragment_cache('injectHead', function(){return injectHtml(theme.inject.head)}) \ No newline at end of file +!=fragment_cache('injectHead', function(){return injectHtml(theme.inject.head)}) + +if page.aplayer + include ./head/aplayer.pug \ No newline at end of file diff --git a/layout/includes/head/Open_Graph.pug b/layout/includes/head/Open_Graph.pug index 5e8da5f..78d04c8 100644 --- a/layout/includes/head/Open_Graph.pug +++ b/layout/includes/head/Open_Graph.pug @@ -1,13 +1,5 @@ - var contentType = is_post() ? 'article' : 'website' -//- twitter meta -if theme.twitter_meta - meta(name="twitter:card" content="summary") - meta(name="twitter:title" content=pageTitle) - meta(name="twitter:description" content!=pageDescription) - meta(name="twitter:image" content=full_url_for(page.cover || theme.avatar.img)) - -//- Open_Graph if theme.Open_Graph_meta meta(property="og:type" content=contentType) meta(property="og:title" content=pageTitle) @@ -17,3 +9,4 @@ if theme.Open_Graph_meta meta(property="og:image" content=full_url_for(page.cover || theme.avatar.img)) meta(property="article:published_time" content=date_xml(page.date)) meta(property="article:modified_time" content=date_xml(page.updated)) + meta(name="twitter:card" content="summary") diff --git a/layout/includes/head/aplayer.pug b/layout/includes/head/aplayer.pug new file mode 100644 index 0000000..c7aa010 --- /dev/null +++ b/layout/includes/head/aplayer.pug @@ -0,0 +1,3 @@ +link(rel='stylesheet' href=url_for(theme.CDN.aplayer_css)) +script(src=url_for(theme.CDN.aplayer_js)) +script(src=url_for(theme.CDN.meting_js)) \ No newline at end of file diff --git a/layout/includes/head/config.pug b/layout/includes/head/config.pug index b4c0c6f..3ffe6d2 100644 --- a/layout/includes/head/config.pug +++ b/layout/includes/head/config.pug @@ -31,7 +31,6 @@ translate = JSON.stringify({ defaultEncoding: theme.translate.defaultEncoding, translateDelay: theme.translate.translateDelay, - cookieDomain: theme.translate.cookieDomain, msgToTraditionalChinese: theme.translate.msgToTraditionalChinese, msgToSimplifiedChinese: theme.translate.msgToSimplifiedChinese }) @@ -60,7 +59,7 @@ var Snackbar = 'undefined'; if (theme.snackbar && theme.snackbar.enable) { - Snackbar = JSON.stringify({ + Snackbar = JSON.stringify({ bookmark: { message_prev: _p("Snackbar.bookmark.message_prev"), message_next: _p("Snackbar.bookmark.message_next") @@ -94,17 +93,18 @@ script. runtime: !{theme.runtimeshow.enable}, copyright: !{copyright}, ClickShowText: !{ClickShowText}, - medium_zoom: !{theme.medium_zoom.enable}, - fancybox: !{theme.fancybox.enable}, + medium_zoom: !{theme.medium_zoom}, + fancybox: !{theme.fancybox}, Snackbar: !{Snackbar}, - baiduPush: !{theme.baidu_push && theme.baidu_push.enable}, + justifiedGallery: { + js: '!{theme.CDN.justifiedGallery_js}', + css: '!{theme.CDN.justifiedGallery_css}' + }, + baiduPush: !{theme.baidu_push}, highlightCopy: !{theme.highlight_copy}, highlightLang: !{theme.highlight_lang}, - highlightShrink: '!{theme.highlight_shrink}', - isFontAwesomeV5: !{theme.fontawesome_v5 && theme.fontawesome_v5.enable}, isPhotoFigcaption: !{theme.photofigcaption}, - islazyload: !{theme.lazyload}, - isanchor: !{theme.anchor} - + islazyload: !{theme.lazyload.enable}, + isanchor: !{theme.anchor} } diff --git a/layout/includes/head/config_site.pug b/layout/includes/head/config_site.pug index 1d7ae99..01417ab 100644 --- a/layout/includes/head/config_site.pug +++ b/layout/includes/head/config_site.pug @@ -1,7 +1,17 @@ +- + let isHighlightShrink + if (theme.highlight_shrink == 'none') isHighlightShrink = 'undefined' + else if (page.highlight_shrink !== undefined) isHighlightShrink = page.highlight_shrink + else isHighlightShrink = theme.highlight_shrink + + const pageToc = page.toc !== undefined ? page.toc : theme.toc.enable + const showToc = is_post() && pageToc && (toc(page.content) !== '' || page.encrypt == true ) +- + script. var GLOBAL_CONFIG_SITE = { isPost: !{is_post()}, isHome: !{is_home()}, - isSidebar: !{is_post() && page.toc !== false && theme.toc.enable && (toc(page.content) !== '' || page.encrypt == true )} + isHighlightShrink: !{isHighlightShrink}, + isSidebar: !{showToc} } - diff --git a/layout/includes/head/darkmode.pug b/layout/includes/head/darkmode.pug index bd5961f..cc1a27b 100644 --- a/layout/includes/head/darkmode.pug +++ b/layout/includes/head/darkmode.pug @@ -1,47 +1,56 @@ script. + var activateDarkMode = function () { + document.documentElement.setAttribute('data-theme', 'dark') + if (document.querySelector('meta[name="theme-color"]') !== null) { + document.querySelector('meta[name="theme-color"]').setAttribute('content', '#000') + } + } + var activateLightMode = function () { + document.documentElement.setAttribute('data-theme', 'light') + if (document.querySelector('meta[name="theme-color"]') !== null) { + document.querySelector('meta[name="theme-color"]').setAttribute('content', '#fff') + } + } + + var getCookies = function (name) { + const value = `; ${document.cookie}` + const parts = value.split(`; ${name}=`) + if (parts.length === 2) return parts.pop().split(';').shift() + } + var autoChangeMode = '#{theme.darkmode.autoChangeMode}' - var t = Cookies.get("theme") - if (autoChangeMode == '1'){ - 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 t = getCookies('theme') + if (autoChangeMode === '1') { + 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 (t === undefined) { if (isLightMode) activateLightMode() else if (isDarkMode) activateDarkMode() - else if (isNotSpecified || hasNoSupport){ + 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.') var now = new Date() var hour = now.getHours() - var isNight = hour < 6 || hour >= 18 + var isNight = hour <= 6 || hour >= 18 isNight ? activateDarkMode() : activateLightMode() - } - } else if (t == 'light') activateLightMode() + } + window.matchMedia('(prefers-color-scheme: dark)').addListener(function (e) { + if (Cookies.get('theme') === undefined) { + e.matches ? activateDarkMode() : activateLightMode() + } + }) + } else if (t === 'light') activateLightMode() else activateDarkMode() - - } else if (autoChangeMode == '2'){ - now = new Date(); - hour = now.getHours(); - isNight = hour < 6 || hour >= 18 - if(t === undefined) isNight? activateDarkMode() : activateLightMode() + } else if (autoChangeMode === '2') { + now = new Date() + hour = now.getHours() + isNight = hour <= 6 || hour >= 18 + if (t === undefined) isNight ? activateDarkMode() : activateLightMode() else if (t === 'light') activateLightMode() - else activateDarkMode() + else activateDarkMode() } else { - if ( t == 'dark' ) activateDarkMode() - else if ( t == 'light') activateLightMode() + if (t === 'dark') activateDarkMode() + else if (t === 'light') activateLightMode() } - - function activateDarkMode(){ - document.documentElement.setAttribute('data-theme', 'dark') - if (document.querySelector('meta[name="theme-color"]') !== null){ - document.querySelector('meta[name="theme-color"]').setAttribute('content','#000') - } - } - function activateLightMode(){ - document.documentElement.setAttribute('data-theme', 'light') - if (document.querySelector('meta[name="theme-color"]') !== null){ - document.querySelector('meta[name="theme-color"]').setAttribute('content','#fff') - } - } - diff --git a/layout/includes/head/dns_prefetch.pug b/layout/includes/head/dns_prefetch.pug deleted file mode 100644 index e5faf44..0000000 --- a/layout/includes/head/dns_prefetch.pug +++ /dev/null @@ -1,22 +0,0 @@ -link(rel="preconnect" href="//cdn.jsdelivr.net") -link(rel="dns-prefetch" href="//cdn.jsdelivr.net") - -if theme.google_analytics - link(rel="preconnect" href="https://www.google-analytics.com" crossorigin) - link(rel="dns-prefetch" href="https://www.google-analytics.com") - -if theme.baidu_analytics - link(rel="preconnect" href="https://hm.baidu.com") - link(rel="dns-prefetch" href="https://hm.baidu.com") - -if theme.tencent_analytics - link(rel="preconnect" href="http://ta.qq.com") - link(rel="dns-prefetch" href="http://ta.qq.com") - -if theme.blog_title_font.font_link - link(rel="preconnect" href="https://fonts.googleapis.com" crossorigin) - link(rel="dns-prefetch" href="https://fonts.googleapis.com") - -if theme.busuanzi.site_uv || theme.busuanzi.site_pv || theme.busuanzi.page_pv - link(rel="preconnect" href="//busuanzi.ibruce.info") - link(rel="dns-prefetch" href="//busuanzi.ibruce.info") diff --git a/layout/includes/head/noscript.pug b/layout/includes/head/noscript.pug index de8a2d8..761826c 100644 --- a/layout/includes/head/noscript.pug +++ b/layout/includes/head/noscript.pug @@ -1,6 +1,6 @@ noscript.