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 += '