From 0eac648267c0c968038fa1077b720f49ed1c3ae9 Mon Sep 17 00:00:00 2001 From: Jerry Date: Sun, 10 Jan 2021 19:26:32 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=20post=5Fpagination?= =?UTF-8?q?=20=E9=85=8D=E7=BD=AE(=E5=8F=AF=E9=97=9C=E9=96=89/=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=88=86=E9=A0=81=E5=B1=95=E7=A4=BA=E9=82=8F=E8=BC=AF?= =?UTF-8?q?)=20feat:=20=E5=8F=AF=E9=85=8D=E7=BD=AE=E6=9C=80=E6=96=B0?= =?UTF-8?q?=E8=A9=95=E8=AB=96=E7=9A=84=E7=B7=A9=E5=AD=98=E6=99=82=E9=96=93?= =?UTF-8?q?=20fix:=20=E4=BF=AE=E5=BE=A9pjax=E4=B8=8B=E4=B8=8D=E6=9C=83?= =?UTF-8?q?=E8=B7=B3=E8=BD=89404=E9=A0=81=E9=9D=A2=E7=9A=84bug=20fix:=20?= =?UTF-8?q?=E4=BF=AE=E5=BE=A9=E6=89=8B=E6=8C=81=E8=A8=AD=E5=82=99=E6=A9=AB?= =?UTF-8?q?=E5=90=91=E7=BF=BB=E8=BD=89=E6=99=82=EF=BC=8Cmenu=20=E6=B2=92?= =?UTF-8?q?=E6=9C=89=E9=80=B2=E8=A1=8C=E5=88=A4=E6=96=B7,=E8=80=8C?= =?UTF-8?q?=E5=B0=8E=E8=87=B4=E6=A8=A3=E5=BC=8F=E9=8C=AF=E4=BA=82=E7=9A=84?= =?UTF-8?q?bug=20fix:=20=E4=BF=AE=E5=BE=A9=E6=96=87=E5=AD=97=E9=BB=9E?= =?UTF-8?q?=E6=93=8A=E9=97=9C=E9=96=89random=E7=84=A1=E6=95=88=E7=9A=84bug?= =?UTF-8?q?=20fix:=20=E4=BF=AE=E5=BE=A9=E5=AD=90=E7=9B=AE=E9=8C=84?= =?UTF-8?q?=E4=B8=8B=EF=BC=8C=E6=89=93=E8=B3=9E=E5=9C=96=E7=89=87=E8=B7=B3?= =?UTF-8?q?=E8=BD=89=E9=8F=88=E6=8E=A5=E6=9C=83=E9=8C=AF=E8=AA=A4=E7=9A=84?= =?UTF-8?q?bug=20improvement:=20=E6=96=87=E7=AB=A0=E7=89=88=E6=AC=8A?= =?UTF-8?q?=E5=8F=B3=E4=B8=8A=E8=A7=92=E6=94=B9=E7=82=BA=20=E7=89=88?= =?UTF-8?q?=E6=AC=8Aicon=20improvement:=20pangu=E7=9A=84=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E7=AF=84=E5=9C=8D=E5=A2=9E=E5=A4=A7=E5=88=B0=20body-wrap?= =?UTF-8?q?=E8=A3=8F=E7=9A=84=E5=85=A7=E5=AE=B9=20improvement:=20pug=20?= =?UTF-8?q?=E5=88=A4=E6=96=B7=E5=84=AA=E5=8C=96=20improvement:=20=E6=9C=80?= =?UTF-8?q?=E6=96=B0=E8=A9=95=E8=AB=96js=E5=84=AA=E5=8C=96=20remove:=20?= =?UTF-8?q?=E7=A7=BB=E9=99=A4=20fragment=5Fcache=20=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=EF=BC=88=E9=BB=98=E8=AA=8D=E9=96=8B=E5=95=9F=EF=BC=89=20remove?= =?UTF-8?q?:=20=E7=A7=BB=E9=99=A4=E7=99=BE=E5=BA=A6=E6=8E=A8=E9=80=81?= =?UTF-8?q?=EF=BC=88=E7=99=BE=E5=BA=A6=E5=B7=B2=E6=A3=84=E7=94=A8=EF=BC=89?= =?UTF-8?q?=E5=92=8C=E7=99=BE=E5=BA=A6=E8=BD=89=E7=A2=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _config.yml | 17 +++++----- layout/404.pug | 2 +- layout/category.pug | 2 +- layout/includes/additional-js.pug | 33 +++++++++---------- layout/includes/head.pug | 18 ++++------ layout/includes/head/config.pug | 6 ++-- layout/includes/head/preconnect.pug | 5 +-- layout/includes/header/index.pug | 8 +++-- layout/includes/layout.pug | 8 ++--- layout/includes/loading/loading-js.pug | 2 +- layout/includes/pagination.pug | 22 +++++++------ layout/includes/post/reward.pug | 10 +++--- layout/includes/third-party/baidu_push.pug | 15 --------- layout/includes/third-party/comments/js.pug | 12 +++---- layout/includes/third-party/math/index.pug | 4 +-- .../newest-comments/disqus-comment.pug | 7 ++-- .../newest-comments/github-issues.pug | 7 ++-- .../newest-comments/twikoo-comment.pug | 7 ++-- .../third-party/newest-comments/valine.pug | 17 +++------- .../third-party/newest-comments/waline.pug | 7 ++-- layout/includes/third-party/pangu.pug | 4 +-- layout/includes/third-party/pjax.pug | 6 ++++ layout/includes/third-party/share/index.pug | 4 +-- layout/includes/widget/index.pug | 28 ++++++++-------- layout/page.pug | 2 +- layout/post.pug | 7 ++-- package.json | 2 +- source/css/_layout/pagination.styl | 2 +- source/css/_layout/post.styl | 23 ++++--------- source/css/_layout/relatedposts.styl | 2 +- source/js/main.js | 17 +++++----- 31 files changed, 130 insertions(+), 176 deletions(-) delete mode 100644 layout/includes/third-party/baidu_push.pug diff --git a/_config.yml b/_config.yml index aa44089..c8d391a 100644 --- a/_config.yml +++ b/_config.yml @@ -204,6 +204,13 @@ related_post: # figcaption (圖片描述文字) photofigcaption: false +# post_pagination (分頁) +# value: 1 || 2 || false +# 1: The 'next post' will link to old post +# 2: The 'next post' will link to new post +# false: disable pagination +post_pagination: 1 + # anchor # when you scroll in post, the URL will update according to header id. anchor: false @@ -685,6 +692,7 @@ newest_comments: enable: false sort_order: # Don't modify the setting unless you know how it works limit: 6 + storage: 10 # unit: mins, save data to localStorage avatar: true # You can only choose one, or neither valine: false @@ -802,9 +810,6 @@ snackbar: 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: false @@ -832,16 +837,10 @@ lazyload: # 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 - # Open graph meta tags # https://developers.facebook.com/docs/sharing/webmasters/ Open_Graph_meta: true -# Caches the contents in a fragment, speed up the generation (開啟hexo自帶的緩存,加快生成速度) -fragment_cache: true - # Add the vendor prefixes to ensure compatibility css_prefix: true diff --git a/layout/404.pug b/layout/404.pug index 4bd2553..e4b46e4 100644 --- a/layout/404.pug +++ b/layout/404.pug @@ -7,7 +7,7 @@ html(lang=config.language data-theme=theme.display_mode) include includes/head.pug body if theme.preloader - !=partial('includes/loading/loading', {}, {cache:theme.fragment_cache}) + !=partial('includes/loading/loading', {}, {cache: true}) if theme.fireworks && theme.fireworks.enable canvas.fireworks diff --git a/layout/category.pug b/layout/category.pug index 01ad990..5dc21d5 100644 --- a/layout/category.pug +++ b/layout/category.pug @@ -11,4 +11,4 @@ block content #category .article-sort-title= _p('page.category') + ' - ' + page.category +articleSort(page.posts) - include includes/pagination.pug \ No newline at end of file + include includes/pagination.pug \ No newline at end of file diff --git a/layout/includes/additional-js.pug b/layout/includes/additional-js.pug index 523655b..66286ca 100644 --- a/layout/includes/additional-js.pug +++ b/layout/includes/additional-js.pug @@ -2,7 +2,7 @@ div script(src=url_for(theme.CDN.utils)) script(src=url_for(theme.CDN.main)) - if theme.translate && theme.translate.enable + if theme.translate.enable script(src=url_for(theme.CDN.translate)) if theme.medium_zoom @@ -14,11 +14,11 @@ div if theme.lazyload.enable script(src=url_for(theme.CDN.lazyload)) - if (theme.snackbar && theme.snackbar.enable) + if theme.snackbar.enable script(src=url_for(theme.CDN.snackbar)) - if theme.pangu && theme.pangu.enable - !=partial('includes/third-party/pangu.pug', {}, {cache:theme.fragment_cache}) + if theme.pangu.enable + !=partial('includes/third-party/pangu.pug', {}, {cache: true}) //- search if theme.algolia_search.enable @@ -27,10 +27,10 @@ div script(src=url_for(theme.CDN.local_search)) if theme.preloader - !=partial('includes/loading/loading-js', {}, {cache:theme.fragment_cache}) + !=partial('includes/loading/loading-js', {}, {cache: true}) .js-pjax - if theme.subtitle.enable && is_home() && theme.index_img !== false + if loadSubJs include ./third-party/subtitle.pug include ./third-party/math/index.pug @@ -38,22 +38,19 @@ div if commentsJsLoad include ./third-party/comments/js.pug - if theme.busuanzi.site_uv || theme.busuanzi.site_pv || theme.busuanzi.page_pv - script(async src=url_for(theme.CDN.busuanzi)) - - !=partial('includes/third-party/prismjs', {}, {cache:theme.fragment_cache}) + !=partial('includes/third-party/prismjs', {}, {cache: true}) if theme.aside.enable && theme.newest_comments.enable if theme.pjax.enable - !=partial('includes/third-party/newest-comments/index', {}, {cache:theme.fragment_cache}) + !=partial('includes/third-party/newest-comments/index', {}, {cache: true}) else if (!is_post() && page.aside !== false) - !=partial('includes/third-party/newest-comments/index', {}, {cache:theme.fragment_cache}) + !=partial('includes/third-party/newest-comments/index', {}, {cache: true}) !=fragment_cache('injectBottom', function(){return injectHtml(theme.inject.bottom)}) - !=partial('includes/third-party/effect', {}, {cache:theme.fragment_cache}) + !=partial('includes/third-party/effect', {}, {cache: true}) - !=partial('includes/third-party/chat/index', {}, {cache:theme.fragment_cache}) + !=partial('includes/third-party/chat/index', {}, {cache: true}) if theme.aplayerInject && theme.aplayerInject.enable if theme.pjax.enable || theme.aplayerInject.per_page @@ -62,7 +59,7 @@ div include ./third-party/aplayer.pug if theme.pjax.enable - !=partial('includes/third-party/pjax', {}, {cache:theme.fragment_cache}) - - !=partial('includes/third-party/baidu_push', {}, {cache:theme.fragment_cache}) - \ No newline at end of file + !=partial('includes/third-party/pjax', {}, {cache: true}) + + if theme.busuanzi.site_uv || theme.busuanzi.site_pv || theme.busuanzi.page_pv + script(async data-pjax src=url_for(theme.CDN.busuanzi)) diff --git a/layout/includes/head.pug b/layout/includes/head.pug index 886053e..6d93a13 100644 --- a/layout/includes/head.pug +++ b/layout/includes/head.pug @@ -29,10 +29,6 @@ meta(name="copyright" content=pageCopyright) meta(name ="format-detection" content="telephone=no") meta(name="theme-color" content=themeColor) -if theme.disable_baidu_transformation - meta(http-equiv="Cache-Control" content="no-transform") - meta(http-equiv="Cache-Control" content="no-siteapp") - //- Open_Graph include ./head/Open_Graph.pug @@ -40,14 +36,14 @@ include ./head/Open_Graph.pug link(rel="canonical" href=urlNoIndex()) //- 預解析 -!=partial('includes/head/preconnect', {}, {cache:theme.fragment_cache}) +!=partial('includes/head/preconnect', {}, {cache: true}) //- 網站驗證 -!=partial('includes/head/site_verification', {}, {cache:theme.fragment_cache}) +!=partial('includes/head/site_verification', {}, {cache: true}) //- PWA if (theme.pwa && theme.pwa.enable) - !=partial('includes/head/pwa', {}, {cache:theme.fragment_cache}) + !=partial('includes/head/pwa', {}, {cache: true}) //- main css link(rel='stylesheet', href=url_for(theme.CDN.main_css)) @@ -61,21 +57,21 @@ if theme.algolia_search.enable script(src=url_for(theme.CDN.algolia_search) defer) //- google_adsense -!=partial('includes/head/google_adsense', {}, {cache:theme.fragment_cache}) +!=partial('includes/head/google_adsense', {}, {cache: true}) //- analytics -!=partial('includes/head/analytics', {}, {cache:theme.fragment_cache}) +!=partial('includes/head/analytics', {}, {cache: true}) //- font if theme.blog_title_font && theme.blog_title_font.font_link link(rel='stylesheet' href=url_for(theme.blog_title_font.font_link) media="print" onload="this.media='all'") //- global config -!=partial('includes/head/config', {}, {cache:theme.fragment_cache}) +!=partial('includes/head/config', {}, {cache: true}) include ./head/config_site.pug include ./head/noscript.pug -!=partial('includes/head/js', {}, {cache:theme.fragment_cache}) +!=partial('includes/head/js', {}, {cache: true}) !=fragment_cache('injectHead', function(){return injectHtml(theme.inject.head)}) \ No newline at end of file diff --git a/layout/includes/head/config.pug b/layout/includes/head/config.pug index 6ed3d8e..b8d2a9a 100644 --- a/layout/includes/head/config.pug +++ b/layout/includes/head/config.pug @@ -83,7 +83,7 @@ } script. - var GLOBAL_CONFIG = { + const GLOBAL_CONFIG = { root: '!{config.root}', algolia: !{algolia}, localSearch: !{localSearch}, @@ -126,8 +126,10 @@ script. isanchor: !{theme.anchor} }; - var saveToLocal = { + const saveToLocal = { + // ttl 單位是 天 set: function setWithExpiry(key, value, ttl) { + if (ttl === 0) return const now = new Date() const expiryDay = ttl * 86400000 const item = { diff --git a/layout/includes/head/preconnect.pug b/layout/includes/head/preconnect.pug index 98c5983..73231c7 100644 --- a/layout/includes/head/preconnect.pug +++ b/layout/includes/head/preconnect.pug @@ -22,7 +22,4 @@ if theme.blog_title_font && theme.blog_title_font.font_link && theme.blog_title_ link(rel="preconnect" href="//fonts.googleapis.com" crossorigin='') if theme.busuanzi.site_uv || theme.busuanzi.site_pv || theme.busuanzi.page_pv - link(rel="preconnect" href="//busuanzi.ibruce.info") - -if theme.baidu_push - link(rel="preconnect" href="//zz.bdstatic.com") + link(rel="preconnect" href="//busuanzi.ibruce.info") \ No newline at end of file diff --git a/layout/includes/header/index.pug b/layout/includes/header/index.pug index bb821f5..4efb3f9 100644 --- a/layout/includes/header/index.pug +++ b/layout/includes/header/index.pug @@ -29,15 +29,17 @@ else - var isHomeClass = 'no-top-img' header#page-header(class=isHomeClass style=bg_img) - !=partial('includes/header/nav', {}, {cache:theme.fragment_cache}) + !=partial('includes/header/nav', {}, {cache: true}) if top_img !== false if is_post() include ./post-info.pug else if is_home() #site-info h1#site-title=site_title - #site-subtitle - span#subtitle + if theme.subtitle.enable + - var loadSubJs = true + #site-subtitle + span#subtitle if(theme.social) #site_social_icons !=fragment_cache('social', function(){return partial('includes/header/social')}) diff --git a/layout/includes/layout.pug b/layout/includes/layout.pug index b264b15..6d2cc2c 100644 --- a/layout/includes/layout.pug +++ b/layout/includes/layout.pug @@ -8,12 +8,12 @@ html(lang=config.language data-theme=theme.display_mode class=htmlClassHideAside include ./head.pug body if theme.preloader - !=partial('includes/loading/loading', {}, {cache:theme.fragment_cache}) + !=partial('includes/loading/loading', {}, {cache: true}) if theme.background #web_bg - !=partial('includes/sidebar', {}, {cache:theme.fragment_cache}) + !=partial('includes/sidebar', {}, {cache: true}) #body-wrap(class=pageType) include ./header/index.pug @@ -36,8 +36,8 @@ html(lang=config.language data-theme=theme.display_mode class=htmlClassHideAside - var footer_bg = '' footer#footer(style=footer_bg) - !=partial('includes/footer', {}, {cache:theme.fragment_cache}) + !=partial('includes/footer', {}, {cache: true}) include ./rightside.pug - !=partial('includes/third-party/search/index', {}, {cache:theme.fragment_cache}) + !=partial('includes/third-party/search/index', {}, {cache: true}) include ./additional-js.pug \ No newline at end of file diff --git a/layout/includes/loading/loading-js.pug b/layout/includes/loading/loading-js.pug index 6bf7f2d..7e5f0d4 100644 --- a/layout/includes/loading/loading-js.pug +++ b/layout/includes/loading/loading-js.pug @@ -10,4 +10,4 @@ script. } } - window.addEventListener('load',()=> {preloader.endLoading()}) \ No newline at end of file + window.addEventListener('load',preloader.endLoading()) \ No newline at end of file diff --git a/layout/includes/pagination.pug b/layout/includes/pagination.pug index 488055c..86f0faf 100644 --- a/layout/includes/pagination.pug +++ b/layout/includes/pagination.pug @@ -11,29 +11,31 @@ if(!is_post()) div.pagination !=paginator(options) else + - let prev = theme.post_pagination === 1 ? page.prev : page.next + - let next = theme.post_pagination === 1 ? page.next : page.prev nav#pagination.pagination-post - if(page.prev) - - var hasPageNext = page.next ? 'pull-left' : 'pull-full' + if(prev) + - var hasPageNext = next ? 'pull-left' : 'pull-full' .prev-post(class=hasPageNext) - - var pagination_cover = page.prev.cover === false ? page.prev.randomcover : page.prev.cover - a(href=url_for(page.prev.path)) + - var pagination_cover = prev.cover === false ? prev.randomcover : prev.cover + a(href=url_for(prev.path)) if theme.lazyload.enable img.prev-cover(data-lazy-src=url_for(pagination_cover) onerror=`onerror=null;src='${url_for(theme.error_img.post_page)}'` alt='cover of previous post') else img.prev-cover(src=url_for(pagination_cover) onerror=`onerror=null;src='${url_for(theme.error_img.post_page)}'` alt='cover of previous post') .pagination-info .label=_p('pagination.prev') - .prev_info=page.prev.title + .prev_info=prev.title - if(page.next) - - var hasPagePrev = page.prev ? 'pull-right' : 'pull-full' - - var pagination_cover = page.next.cover == false ? page.next.randomcover : page.next.cover + if(next) + - var hasPagePrev = prev ? 'pull-right' : 'pull-full' + - var pagination_cover = next.cover == false ? next.randomcover : next.cover .next-post(class=hasPagePrev) - a(href=url_for(page.next.path)) + a(href=url_for(next.path)) if theme.lazyload.enable img.next-cover(data-lazy-src=url_for(pagination_cover) onerror=`onerror=null;src='${url_for(theme.error_img.post_page)}'` alt='cover of next post') else img.next-cover(src=url_for(pagination_cover) onerror=`onerror=null;src='${url_for(theme.error_img.post_page)}'` alt='cover of next post') .pagination-info .label=_p('pagination.next') - .next_info=page.next.title \ No newline at end of file + .next_info=next.title \ No newline at end of file diff --git a/layout/includes/post/reward.pug b/layout/includes/post/reward.pug index 1bf9381..33d8bee 100644 --- a/layout/includes/post/reward.pug +++ b/layout/includes/post/reward.pug @@ -5,12 +5,12 @@ .reward-main ul.reward-all each item in theme.reward.QR_code - - var clickTo = (item.itemlist||item).link ? (item.itemlist||item).link : (item.itemlist||item).img + - var clickTo = item.link ? item.link : item.img li.reward-item - a(href=clickTo target='_blank') + a(href=url_for(clickTo) target='_blank') if theme.lazyload.enable - img.post-qr-code-img(data-lazy-src=url_for((item.itemlist||item).img) alt=(item.itemlist||item).text) + img.post-qr-code-img(data-lazy-src=url_for(item.img) alt=item.text) else - 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 + img.post-qr-code-img(src=url_for(item.img) alt=item.text) + .post-qr-code-desc=item.text diff --git a/layout/includes/third-party/baidu_push.pug b/layout/includes/third-party/baidu_push.pug deleted file mode 100644 index ac87a7b..0000000 --- a/layout/includes/third-party/baidu_push.pug +++ /dev/null @@ -1,15 +0,0 @@ -if theme.baidu_push - script. - (function(){ - const bp = document.createElement('script'); - const curProtocol = window.location.protocol.split(':')[0]; - if (curProtocol === 'https') { - bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; - } - else{ - bp.src = 'http://push.zhanzhang.baidu.com/push.js'; - } - bp.dataset.pjax = '' - const s = document.getElementsByTagName("script")[0]; - s.parentNode.insertBefore(bp, s); - })() \ No newline at end of file diff --git a/layout/includes/third-party/comments/js.pug b/layout/includes/third-party/comments/js.pug index 404149b..0b04451 100644 --- a/layout/includes/third-party/comments/js.pug +++ b/layout/includes/third-party/comments/js.pug @@ -1,20 +1,20 @@ each name in theme.comments.use case name when 'Valine' - !=partial('includes/third-party/comments/valine', {}, {cache:theme.fragment_cache}) + !=partial('includes/third-party/comments/valine', {}, {cache: true}) when 'Disqus' include ./disqus.pug when 'Disqusjs' include ./disqusjs.pug when 'Livere' - !=partial('includes/third-party/comments/livere', {}, {cache:theme.fragment_cache}) + !=partial('includes/third-party/comments/livere', {}, {cache: true}) when 'Gitalk' include ./gitalk.pug when 'Utterances' - !=partial('includes/third-party/comments/utterances', {}, {cache:theme.fragment_cache}) + !=partial('includes/third-party/comments/utterances', {}, {cache: true}) when 'Twikoo' - !=partial('includes/third-party/comments/twikoo', {}, {cache:theme.fragment_cache}) + !=partial('includes/third-party/comments/twikoo', {}, {cache: true}) when 'Waline' - !=partial('includes/third-party/comments/waline', {}, {cache:theme.fragment_cache}) + !=partial('includes/third-party/comments/waline', {}, {cache: true}) when 'Facebook Comments' - !=partial('includes/third-party/comments/facebook_comments', {}, {cache:theme.fragment_cache}) + !=partial('includes/third-party/comments/facebook_comments', {}, {cache: true}) diff --git a/layout/includes/third-party/math/index.pug b/layout/includes/third-party/math/index.pug index 4ce6692..e91ca85 100644 --- a/layout/includes/third-party/math/index.pug +++ b/layout/includes/third-party/math/index.pug @@ -1,6 +1,6 @@ if theme.mathjax && theme.mathjax.enable if theme.mathjax.per_page - if(!is_tag() && !is_category() && !is_archive() && !is_home()) + if is_post() && is_page() include ./mathjax.pug else if page.mathjax @@ -8,7 +8,7 @@ if theme.mathjax && theme.mathjax.enable if theme.katex && theme.katex.enable if theme.katex.per_page - if(!is_tag() && !is_category() && !is_archive() && !is_home()) + if is_post() && is_page() include ./katex.pug else if page.katex diff --git a/layout/includes/third-party/newest-comments/disqus-comment.pug b/layout/includes/third-party/newest-comments/disqus-comment.pug index 5d900d9..e6a742a 100644 --- a/layout/includes/third-party/newest-comments/disqus-comment.pug +++ b/layout/includes/third-party/newest-comments/disqus-comment.pug @@ -27,7 +27,7 @@ script. } }) // set expiry to 10 min - saveToLocal.set('disqus-newest-comments', JSON.stringify(disqusArray), 10/(60*24)) + saveToLocal.set('disqus-newest-comments', JSON.stringify(disqusArray), !{theme.newest_comments.storage}/(60*24)) generateHtml(disqusArray) }).catch(e => { const $dom = document.querySelector('#card-newest-comments .aside-list') @@ -43,10 +43,7 @@ script. result += '
' if (!{theme.newest_comments.avatar}) { - let name = 'src' - if(!{theme.lazyload.enable}) { - name = 'data-lazy-src' - } + const name = '!{theme.lazyload.enable ? "data-lazy-src" : "src"}' result += `${array[i].nick}` } diff --git a/layout/includes/third-party/newest-comments/github-issues.pug b/layout/includes/third-party/newest-comments/github-issues.pug index 03bb331..a64908e 100644 --- a/layout/includes/third-party/newest-comments/github-issues.pug +++ b/layout/includes/third-party/newest-comments/github-issues.pug @@ -26,7 +26,7 @@ script. 'date': item.updated_at } }) - saveToLocal.set('github-newest-comments', JSON.stringify(githubArray), 10/(60*24)) + saveToLocal.set('github-newest-comments', JSON.stringify(githubArray), !{theme.newest_comments.storage}/(60*24)) generateHtml(githubArray) }).catch(e => { const $dom = document.querySelector('#card-newest-comments .aside-list') @@ -42,10 +42,7 @@ script. result += '
' if (!{theme.newest_comments.avatar}) { - let name = 'src' - if(!{theme.lazyload.enable}) { - name = 'data-lazy-src' - } + const name = '!{theme.lazyload.enable ? "data-lazy-src" : "src"}' result += `${array[i].nick}` } diff --git a/layout/includes/third-party/newest-comments/twikoo-comment.pug b/layout/includes/third-party/newest-comments/twikoo-comment.pug index 13fdea4..7cb7e02 100644 --- a/layout/includes/third-party/newest-comments/twikoo-comment.pug +++ b/layout/includes/third-party/newest-comments/twikoo-comment.pug @@ -21,7 +21,7 @@ script. pageSize: !{theme.newest_comments.limit}, includeReply: true }).then(function (res) { - saveToLocal.set('twikoo-newest-comments', JSON.stringify(res), 10/(60*24)) + saveToLocal.set('twikoo-newest-comments', JSON.stringify(res), !{theme.newest_comments.storage}/(60*24)) generateHtml(res) }).catch(function (err) { const $dom = document.querySelector('#card-newest-comments .aside-list') @@ -44,10 +44,7 @@ script. result += '
' if (!{theme.newest_comments.avatar}) { - let name = 'src' - if(!{theme.lazyload.enable}) { - name = 'data-lazy-src' - } + const name = '!{theme.lazyload.enable ? "data-lazy-src" : "src"}' result += `${array[i].nick}` } diff --git a/layout/includes/third-party/newest-comments/valine.pug b/layout/includes/third-party/newest-comments/valine.pug index 98c195d..1039ece 100644 --- a/layout/includes/third-party/newest-comments/valine.pug +++ b/layout/includes/third-party/newest-comments/valine.pug @@ -18,7 +18,6 @@ script. const getIcon = (icon, mail) => { if (icon) return icon - let defaultIcon = '!{ default_avatar ? `?d=${default_avatar}` : ''}' let iconUrl = `https://gravatar.loli.net/avatar/${md5(mail.toLowerCase()) + defaultIcon}` return iconUrl @@ -32,10 +31,7 @@ script. result += '
' if (!{theme.newest_comments.avatar}) { - let name = 'src' - if(!{theme.lazyload.enable}) { - name = 'data-lazy-src' - } + const name = '!{theme.lazyload.enable ? "data-lazy-src" : "src"}' result += `${array[i].nick}` } @@ -55,12 +51,7 @@ script. } const getComment = () => { - let serverURL = '' - if (!{Boolean(theme.valine.serverURLs)}) { - serverURL = '!{theme.valine.serverURLs}' - } else { - serverURL = 'https://!{theme.valine.appId.substring(0,8)}.api.lncldglobal.com' - } + const serverURL = '!{theme.valine.serverURLs || `https://${theme.valine.appId.substring(0,8)}.api.lncldglobal.com` }' var settings = { "method": "GET", @@ -84,7 +75,7 @@ script. 'date': e.createdAt, } }) - saveToLocal.set('leancloud-newest-comments', JSON.stringify(valineArray), 10/(60*24)) + saveToLocal.set('valine-newest-comments', JSON.stringify(valineArray), !{theme.newest_comments.storage}/(60*24)) generateHtml(valineArray) }).catch(e => { const $dom = document.querySelector('#card-newest-comments .aside-list') @@ -94,7 +85,7 @@ script. const newestCommentInit = () => { if (document.querySelector('#card-newest-comments .aside-list')) { - const data = saveToLocal.get('leancloud-newest-comments') + const data = saveToLocal.get('valine-newest-comments') if (data) { generateHtml(JSON.parse(data)) } else { diff --git a/layout/includes/third-party/newest-comments/waline.pug b/layout/includes/third-party/newest-comments/waline.pug index c99abc2..aaef3f3 100644 --- a/layout/includes/third-party/newest-comments/waline.pug +++ b/layout/includes/third-party/newest-comments/waline.pug @@ -29,10 +29,7 @@ script. result += '
' if (!{theme.newest_comments.avatar}) { - let name = 'src' - if(!{theme.lazyload.enable}) { - name = 'data-lazy-src' - } + const name = '!{theme.lazyload.enable ? "data-lazy-src" : "src"}' result += `${array[i].nick}` } @@ -67,7 +64,7 @@ script. 'date': e.createdAt, } }) - saveToLocal.set('waline-newest-comments', JSON.stringify(walineArray), 10/(60*24)) + saveToLocal.set('waline-newest-comments', JSON.stringify(walineArray), !{theme.newest_comments.storage}/(60*24)) generateHtml(walineArray) }).catch(e => { const $dom = document.querySelector('#card-newest-comments .aside-list') diff --git a/layout/includes/third-party/pangu.pug b/layout/includes/third-party/pangu.pug index e61305f..b5c82c9 100644 --- a/layout/includes/third-party/pangu.pug +++ b/layout/includes/third-party/pangu.pug @@ -1,10 +1,10 @@ script. function panguFn () { - if (typeof pangu === 'object') pangu.spacingElementById('content-inner') + if (typeof pangu === 'object') pangu.spacingElementById('body-wrap') else { getScript('!{url_for(theme.CDN.pangu)}') .then(() => { - pangu.spacingElementById('content-inner') + pangu.spacingElementById('body-wrap') }) } } diff --git a/layout/includes/third-party/pjax.pug b/layout/includes/third-party/pjax.pug index 0d41660..7df6de3 100644 --- a/layout/includes/third-party/pjax.pug +++ b/layout/includes/third-party/pjax.pug @@ -78,3 +78,9 @@ script. $bodyClassList.contains('read-mode') && $bodyClassList.remove('read-mode') }) + + document.addEventListener('pjax:error', (e) => { + if (e.request.status === 404) { + pjax.loadUrl('/404.html') + } + }) diff --git a/layout/includes/third-party/share/index.pug b/layout/includes/third-party/share/index.pug index 41892a6..f28ceab 100644 --- a/layout/includes/third-party/share/index.pug +++ b/layout/includes/third-party/share/index.pug @@ -1,7 +1,7 @@ .post_share if theme.addThis.enable - !=partial('includes/third-party/share/add-this', {}, {cache:theme.fragment_cache}) + !=partial('includes/third-party/share/add-this', {}, {cache: true}) else if theme.sharejs.enable include ./share-js.pug else if theme.addtoany.enable - !=partial('includes/third-party/share/addtoany', {}, {cache:theme.fragment_cache}) + !=partial('includes/third-party/share/addtoany', {}, {cache: true}) diff --git a/layout/includes/widget/index.pug b/layout/includes/widget/index.pug index 10dd161..a37b066 100644 --- a/layout/includes/widget/index.pug +++ b/layout/includes/widget/index.pug @@ -5,23 +5,23 @@ .sticky_layout include ./card_post_toc.pug else - !=partial('includes/widget/card_author', {}, {cache:theme.fragment_cache}) - !=partial('includes/widget/card_announcement', {}, {cache:theme.fragment_cache}) + !=partial('includes/widget/card_author', {}, {cache: true}) + !=partial('includes/widget/card_announcement', {}, {cache: true}) .sticky_layout if showToc include ./card_post_toc.pug - !=partial('includes/widget/card_recent_post', {}, {cache:theme.fragment_cache}) - !=partial('includes/widget/card_ad', {}, {cache:theme.fragment_cache}) + !=partial('includes/widget/card_recent_post', {}, {cache: true}) + !=partial('includes/widget/card_ad', {}, {cache: true}) else //- page - !=partial('includes/widget/card_author', {}, {cache:theme.fragment_cache}) - !=partial('includes/widget/card_announcement', {}, {cache:theme.fragment_cache}) + !=partial('includes/widget/card_author', {}, {cache: true}) + !=partial('includes/widget/card_announcement', {}, {cache: true}) .sticky_layout - !=partial('includes/widget/card_recent_post', {}, {cache:theme.fragment_cache}) - !=partial('includes/widget/card_ad', {}, {cache:theme.fragment_cache}) - !=partial('includes/widget/card_newest_comment', {}, {cache:theme.fragment_cache}) - !=partial('includes/widget/card_categories', {}, {cache:theme.fragment_cache}) - !=partial('includes/widget/card_tags', {}, {cache:theme.fragment_cache}) - !=partial('includes/widget/card_archives', {}, {cache:theme.fragment_cache}) - !=partial('includes/widget/card_webinfo', {}, {cache:theme.fragment_cache}) - !=partial('includes/widget/card_self', {}, {cache:theme.fragment_cache}) \ No newline at end of file + !=partial('includes/widget/card_recent_post', {}, {cache: true}) + !=partial('includes/widget/card_ad', {}, {cache: true}) + !=partial('includes/widget/card_newest_comment', {}, {cache: true}) + !=partial('includes/widget/card_categories', {}, {cache: true}) + !=partial('includes/widget/card_tags', {}, {cache: true}) + !=partial('includes/widget/card_archives', {}, {cache: true}) + !=partial('includes/widget/card_webinfo', {}, {cache: true}) + !=partial('includes/widget/card_self', {}, {cache: true}) \ No newline at end of file diff --git a/layout/page.pug b/layout/page.pug index 474580d..7287546 100644 --- a/layout/page.pug +++ b/layout/page.pug @@ -16,4 +16,4 @@ block content if page.comments !== false && theme.comments && theme.comments.use - var commentsJsLoad = true - !=partial('includes/third-party/comments/index', {}, {cache:theme.fragment_cache}) \ No newline at end of file + !=partial('includes/third-party/comments/index', {}, {cache: true}) \ No newline at end of file diff --git a/layout/post.pug b/layout/post.pug index 7249b9f..a5399b2 100644 --- a/layout/post.pug +++ b/layout/post.pug @@ -15,17 +15,18 @@ block content include includes/third-party/share/index.pug if theme.reward.enable - !=partial('includes/post/reward', {}, {cache:theme.fragment_cache}) + !=partial('includes/post/reward', {}, {cache: true}) //- ad if theme.ad && theme.ad.post .ads-wrap!=theme.ad.post - include includes/pagination.pug + if theme.post_pagination + include includes/pagination.pug if theme.related_post && theme.related_post.enable != related_posts(page,site.posts) if page.comments !== false && theme.comments && theme.comments.use - var commentsJsLoad = true - !=partial('includes/third-party/comments/index', {}, {cache:theme.fragment_cache}) + !=partial('includes/third-party/comments/index', {}, {cache: true}) \ No newline at end of file diff --git a/package.json b/package.json index f3dda9d..1551571 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hexo-theme-butterfly", - "version": "3.6.0-b1", + "version": "3.6.0-b2", "description": "A Simple and Card UI Design theme for Hexo", "main": "package.json", "scripts": { diff --git a/source/css/_layout/pagination.styl b/source/css/_layout/pagination.styl index b792a06..aee8aca 100644 --- a/source/css/_layout/pagination.styl +++ b/source/css/_layout/pagination.styl @@ -75,5 +75,5 @@ transform: scale(1.1) &.pagination-post - margin: 2rem 0 !important + margin-top: 2rem background: $dark-black \ No newline at end of file diff --git a/source/css/_layout/post.styl b/source/css/_layout/post.styl index 5c2ad25..cc5dd40 100644 --- a/source/css/_layout/post.styl +++ b/source/css/_layout/post.styl @@ -218,24 +218,13 @@ no-beautify() transition: box-shadow .3s ease-in-out &:before + @extend .fontawesomeIcon position: absolute - top: t = .5rem - right: t - width: w = .8rem - height: w - border-radius: w - background: $light-blue - content: '' - - &:after - position: absolute - top: t = .7rem - right: t - width: w = .4rem - height: w - border-radius: w - background: var(--card-bg) - content: '' + top: .1rem + right: .6rem + color: $theme-color + content: '\f1f9' + font-size: 1rem &:hover box-shadow: 0 0 8px 0 rgba(232, 237, 250, .6), 0 2px 4px 0 rgba(232, 237, 250, .5) diff --git a/source/css/_layout/relatedposts.styl b/source/css/_layout/relatedposts.styl index b296917..5d69ec5 100644 --- a/source/css/_layout/relatedposts.styl +++ b/source/css/_layout/relatedposts.styl @@ -1,5 +1,5 @@ .relatedPosts - margin-top: 1rem + margin-top: 2rem & > .headline margin-bottom: 5px diff --git a/source/js/main.js b/source/js/main.js index 08db8b6..1866cba 100644 --- a/source/js/main.js +++ b/source/js/main.js @@ -1,17 +1,16 @@ document.addEventListener('DOMContentLoaded', function () { - let blogNameWidth = document.getElementById('site-name').offsetWidth + const $blogName = document.getElementById('site-name') + let blogNameWidth = $blogName && $blogName.offsetWidth const $menusEle = document.querySelector('#menus .menus_items') let menusWidth = $menusEle && $menusEle.offsetWidth const $searchEle = document.querySelector('#search-button') let searchWidth = $searchEle && $searchEle.offsetWidth - let detectFontSizeChange = false - const adjustMenu = () => { - if (detectFontSizeChange) { - blogNameWidth = document.getElementById('site-name').offsetWidth + const adjustMenu = (change = false) => { + if (change) { + blogNameWidth = $blogName && $blogName.offsetWidth menusWidth = $menusEle && $menusEle.offsetWidth searchWidth = $searchEle && $searchEle.offsetWidth - detectFontSizeChange = false } const $nav = document.getElementById('nav') let t @@ -536,17 +535,16 @@ document.addEventListener('DOMContentLoaded', function () { adjustFontSize: (plus) => { const fontSizeVal = parseInt(window.getComputedStyle(document.documentElement).getPropertyValue('--global-font-size')) let newValue = '' - detectFontSizeChange = true if (plus) { if (fontSizeVal >= 20) return newValue = fontSizeVal + 1 document.documentElement.style.setProperty('--global-font-size', newValue + 'px') - !document.getElementById('nav').classList.contains('hide-menu') && adjustMenu() + !document.getElementById('nav').classList.contains('hide-menu') && adjustMenu(true) } else { if (fontSizeVal <= 10) return newValue = fontSizeVal - 1 document.documentElement.style.setProperty('--global-font-size', newValue + 'px') - document.getElementById('nav').classList.contains('hide-menu') && adjustMenu() + document.getElementById('nav').classList.contains('hide-menu') && adjustMenu(true) } saveToLocal.set('global-font-size', newValue, 2) @@ -798,6 +796,7 @@ document.addEventListener('DOMContentLoaded', function () { const unRefreshFn = function () { window.addEventListener('resize', adjustMenu) + window.addEventListener('orientationchange', () => { setTimeout(adjustMenu(true), 100) }) clickFnOfSubMenu() GLOBAL_CONFIG.islazyload && lazyloadImg()