feat: 增加 post_pagination 配置(可關閉/配置分頁展示邏輯)

feat: 可配置最新評論的緩存時間
fix: 修復pjax下不會跳轉404頁面的bug
fix: 修復手持設備橫向翻轉時,menu 沒有進行判斷,而導致樣式錯亂的bug
fix: 修復文字點擊關閉random無效的bug
fix: 修復子目錄下,打賞圖片跳轉鏈接會錯誤的bug
improvement: 文章版權右上角改為 版權icon
improvement: pangu的操作範圍增大到 body-wrap裏的內容
improvement: pug 判斷優化
improvement: 最新評論js優化
remove: 移除 fragment_cache 配置(默認開啟)
remove: 移除百度推送(百度已棄用)和百度轉碼
This commit is contained in:
Jerry
2021-01-10 19:26:32 +08:00
parent 81fc48df40
commit 0eac648267
31 changed files with 130 additions and 176 deletions

View File

@@ -204,6 +204,13 @@ related_post:
# figcaption (圖片描述文字) # figcaption (圖片描述文字)
photofigcaption: false 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 # anchor
# when you scroll in post, the URL will update according to header id. # when you scroll in post, the URL will update according to header id.
anchor: false anchor: false
@@ -685,6 +692,7 @@ newest_comments:
enable: false enable: false
sort_order: # Don't modify the setting unless you know how it works sort_order: # Don't modify the setting unless you know how it works
limit: 6 limit: 6
storage: 10 # unit: mins, save data to localStorage
avatar: true avatar: true
# You can only choose one, or neither # You can only choose one, or neither
valine: false valine: false
@@ -802,9 +810,6 @@ snackbar:
bg_light: '#49b1f5' # The background color of Toast Notification in light mode bg_light: '#49b1f5' # The background color of Toast Notification in light mode
bg_dark: '#121212' # The background color of Toast Notification in dark mode bg_dark: '#121212' # The background color of Toast Notification in dark mode
# Baidu Push (百度推送)
baidu_push: false
# https://instant.page/ # https://instant.page/
# prefetch (預加載) # prefetch (預加載)
instantpage: false instantpage: false
@@ -832,16 +837,10 @@ lazyload:
# favicon_16_16: /image/pwa/16.png # favicon_16_16: /image/pwa/16.png
# mask_icon: /image/pwa/safari-pinned-tab.svg # mask_icon: /image/pwa/safari-pinned-tab.svg
# Disable Baidu transformation on mobile devices (禁止百度轉碼)
disable_baidu_transformation: true
# Open graph meta tags # Open graph meta tags
# https://developers.facebook.com/docs/sharing/webmasters/ # https://developers.facebook.com/docs/sharing/webmasters/
Open_Graph_meta: true 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 # Add the vendor prefixes to ensure compatibility
css_prefix: true css_prefix: true

View File

@@ -7,7 +7,7 @@ html(lang=config.language data-theme=theme.display_mode)
include includes/head.pug include includes/head.pug
body body
if theme.preloader if theme.preloader
!=partial('includes/loading/loading', {}, {cache:theme.fragment_cache}) !=partial('includes/loading/loading', {}, {cache: true})
if theme.fireworks && theme.fireworks.enable if theme.fireworks && theme.fireworks.enable
canvas.fireworks canvas.fireworks

View File

@@ -11,4 +11,4 @@ block content
#category #category
.article-sort-title= _p('page.category') + ' - ' + page.category .article-sort-title= _p('page.category') + ' - ' + page.category
+articleSort(page.posts) +articleSort(page.posts)
include includes/pagination.pug include includes/pagination.pug

View File

@@ -2,7 +2,7 @@ div
script(src=url_for(theme.CDN.utils)) script(src=url_for(theme.CDN.utils))
script(src=url_for(theme.CDN.main)) script(src=url_for(theme.CDN.main))
if theme.translate && theme.translate.enable if theme.translate.enable
script(src=url_for(theme.CDN.translate)) script(src=url_for(theme.CDN.translate))
if theme.medium_zoom if theme.medium_zoom
@@ -14,11 +14,11 @@ div
if theme.lazyload.enable if theme.lazyload.enable
script(src=url_for(theme.CDN.lazyload)) script(src=url_for(theme.CDN.lazyload))
if (theme.snackbar && theme.snackbar.enable) if theme.snackbar.enable
script(src=url_for(theme.CDN.snackbar)) script(src=url_for(theme.CDN.snackbar))
if theme.pangu && theme.pangu.enable if theme.pangu.enable
!=partial('includes/third-party/pangu.pug', {}, {cache:theme.fragment_cache}) !=partial('includes/third-party/pangu.pug', {}, {cache: true})
//- search //- search
if theme.algolia_search.enable if theme.algolia_search.enable
@@ -27,10 +27,10 @@ div
script(src=url_for(theme.CDN.local_search)) script(src=url_for(theme.CDN.local_search))
if theme.preloader if theme.preloader
!=partial('includes/loading/loading-js', {}, {cache:theme.fragment_cache}) !=partial('includes/loading/loading-js', {}, {cache: true})
.js-pjax .js-pjax
if theme.subtitle.enable && is_home() && theme.index_img !== false if loadSubJs
include ./third-party/subtitle.pug include ./third-party/subtitle.pug
include ./third-party/math/index.pug include ./third-party/math/index.pug
@@ -38,22 +38,19 @@ div
if commentsJsLoad if commentsJsLoad
include ./third-party/comments/js.pug include ./third-party/comments/js.pug
if theme.busuanzi.site_uv || theme.busuanzi.site_pv || theme.busuanzi.page_pv !=partial('includes/third-party/prismjs', {}, {cache: true})
script(async src=url_for(theme.CDN.busuanzi))
!=partial('includes/third-party/prismjs', {}, {cache:theme.fragment_cache})
if theme.aside.enable && theme.newest_comments.enable if theme.aside.enable && theme.newest_comments.enable
if theme.pjax.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) 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)}) !=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.aplayerInject && theme.aplayerInject.enable
if theme.pjax.enable || theme.aplayerInject.per_page if theme.pjax.enable || theme.aplayerInject.per_page
@@ -62,7 +59,7 @@ div
include ./third-party/aplayer.pug include ./third-party/aplayer.pug
if theme.pjax.enable if theme.pjax.enable
!=partial('includes/third-party/pjax', {}, {cache:theme.fragment_cache}) !=partial('includes/third-party/pjax', {}, {cache: true})
!=partial('includes/third-party/baidu_push', {}, {cache:theme.fragment_cache}) if theme.busuanzi.site_uv || theme.busuanzi.site_pv || theme.busuanzi.page_pv
script(async data-pjax src=url_for(theme.CDN.busuanzi))

View File

@@ -29,10 +29,6 @@ meta(name="copyright" content=pageCopyright)
meta(name ="format-detection" content="telephone=no") meta(name ="format-detection" content="telephone=no")
meta(name="theme-color" content=themeColor) 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 //- Open_Graph
include ./head/Open_Graph.pug include ./head/Open_Graph.pug
@@ -40,14 +36,14 @@ include ./head/Open_Graph.pug
link(rel="canonical" href=urlNoIndex()) 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 //- PWA
if (theme.pwa && theme.pwa.enable) if (theme.pwa && theme.pwa.enable)
!=partial('includes/head/pwa', {}, {cache:theme.fragment_cache}) !=partial('includes/head/pwa', {}, {cache: true})
//- main css //- main css
link(rel='stylesheet', href=url_for(theme.CDN.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) script(src=url_for(theme.CDN.algolia_search) defer)
//- google_adsense //- google_adsense
!=partial('includes/head/google_adsense', {}, {cache:theme.fragment_cache}) !=partial('includes/head/google_adsense', {}, {cache: true})
//- analytics //- analytics
!=partial('includes/head/analytics', {}, {cache:theme.fragment_cache}) !=partial('includes/head/analytics', {}, {cache: true})
//- font //- font
if theme.blog_title_font && theme.blog_title_font.font_link 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'") link(rel='stylesheet' href=url_for(theme.blog_title_font.font_link) media="print" onload="this.media='all'")
//- global config //- global config
!=partial('includes/head/config', {}, {cache:theme.fragment_cache}) !=partial('includes/head/config', {}, {cache: true})
include ./head/config_site.pug include ./head/config_site.pug
include ./head/noscript.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)}) !=fragment_cache('injectHead', function(){return injectHtml(theme.inject.head)})

View File

@@ -83,7 +83,7 @@
} }
script. script.
var GLOBAL_CONFIG = { const GLOBAL_CONFIG = {
root: '!{config.root}', root: '!{config.root}',
algolia: !{algolia}, algolia: !{algolia},
localSearch: !{localSearch}, localSearch: !{localSearch},
@@ -126,8 +126,10 @@ script.
isanchor: !{theme.anchor} isanchor: !{theme.anchor}
}; };
var saveToLocal = { const saveToLocal = {
// ttl 單位是 天
set: function setWithExpiry(key, value, ttl) { set: function setWithExpiry(key, value, ttl) {
if (ttl === 0) return
const now = new Date() const now = new Date()
const expiryDay = ttl * 86400000 const expiryDay = ttl * 86400000
const item = { const item = {

View File

@@ -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='') link(rel="preconnect" href="//fonts.googleapis.com" crossorigin='')
if theme.busuanzi.site_uv || theme.busuanzi.site_pv || theme.busuanzi.page_pv if theme.busuanzi.site_uv || theme.busuanzi.site_pv || theme.busuanzi.page_pv
link(rel="preconnect" href="//busuanzi.ibruce.info") link(rel="preconnect" href="//busuanzi.ibruce.info")
if theme.baidu_push
link(rel="preconnect" href="//zz.bdstatic.com")

View File

@@ -29,15 +29,17 @@ else
- var isHomeClass = 'no-top-img' - var isHomeClass = 'no-top-img'
header#page-header(class=isHomeClass style=bg_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 top_img !== false
if is_post() if is_post()
include ./post-info.pug include ./post-info.pug
else if is_home() else if is_home()
#site-info #site-info
h1#site-title=site_title h1#site-title=site_title
#site-subtitle if theme.subtitle.enable
span#subtitle - var loadSubJs = true
#site-subtitle
span#subtitle
if(theme.social) if(theme.social)
#site_social_icons #site_social_icons
!=fragment_cache('social', function(){return partial('includes/header/social')}) !=fragment_cache('social', function(){return partial('includes/header/social')})

View File

@@ -8,12 +8,12 @@ html(lang=config.language data-theme=theme.display_mode class=htmlClassHideAside
include ./head.pug include ./head.pug
body body
if theme.preloader if theme.preloader
!=partial('includes/loading/loading', {}, {cache:theme.fragment_cache}) !=partial('includes/loading/loading', {}, {cache: true})
if theme.background if theme.background
#web_bg #web_bg
!=partial('includes/sidebar', {}, {cache:theme.fragment_cache}) !=partial('includes/sidebar', {}, {cache: true})
#body-wrap(class=pageType) #body-wrap(class=pageType)
include ./header/index.pug include ./header/index.pug
@@ -36,8 +36,8 @@ html(lang=config.language data-theme=theme.display_mode class=htmlClassHideAside
- var footer_bg = '' - var footer_bg = ''
footer#footer(style=footer_bg) footer#footer(style=footer_bg)
!=partial('includes/footer', {}, {cache:theme.fragment_cache}) !=partial('includes/footer', {}, {cache: true})
include ./rightside.pug 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 include ./additional-js.pug

View File

@@ -10,4 +10,4 @@ script.
} }
} }
window.addEventListener('load',()=> {preloader.endLoading()}) window.addEventListener('load',preloader.endLoading())

View File

@@ -11,29 +11,31 @@ if(!is_post())
div.pagination div.pagination
!=paginator(options) !=paginator(options)
else 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 nav#pagination.pagination-post
if(page.prev) if(prev)
- var hasPageNext = page.next ? 'pull-left' : 'pull-full' - var hasPageNext = next ? 'pull-left' : 'pull-full'
.prev-post(class=hasPageNext) .prev-post(class=hasPageNext)
- var pagination_cover = page.prev.cover === false ? page.prev.randomcover : page.prev.cover - var pagination_cover = prev.cover === false ? prev.randomcover : prev.cover
a(href=url_for(page.prev.path)) a(href=url_for(prev.path))
if theme.lazyload.enable 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') 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 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') 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 .pagination-info
.label=_p('pagination.prev') .label=_p('pagination.prev')
.prev_info=page.prev.title .prev_info=prev.title
if(page.next) if(next)
- var hasPagePrev = page.prev ? 'pull-right' : 'pull-full' - var hasPagePrev = prev ? 'pull-right' : 'pull-full'
- var pagination_cover = page.next.cover == false ? page.next.randomcover : page.next.cover - var pagination_cover = next.cover == false ? next.randomcover : next.cover
.next-post(class=hasPagePrev) .next-post(class=hasPagePrev)
a(href=url_for(page.next.path)) a(href=url_for(next.path))
if theme.lazyload.enable 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') 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 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') 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 .pagination-info
.label=_p('pagination.next') .label=_p('pagination.next')
.next_info=page.next.title .next_info=next.title

View File

@@ -5,12 +5,12 @@
.reward-main .reward-main
ul.reward-all ul.reward-all
each item in theme.reward.QR_code 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 li.reward-item
a(href=clickTo target='_blank') a(href=url_for(clickTo) target='_blank')
if theme.lazyload.enable 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 else
img.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.img) alt=item.text)
.post-qr-code-desc=(item.itemlist||item).text .post-qr-code-desc=item.text

View File

@@ -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);
})()

View File

@@ -1,20 +1,20 @@
each name in theme.comments.use each name in theme.comments.use
case name case name
when 'Valine' when 'Valine'
!=partial('includes/third-party/comments/valine', {}, {cache:theme.fragment_cache}) !=partial('includes/third-party/comments/valine', {}, {cache: true})
when 'Disqus' when 'Disqus'
include ./disqus.pug include ./disqus.pug
when 'Disqusjs' when 'Disqusjs'
include ./disqusjs.pug include ./disqusjs.pug
when 'Livere' when 'Livere'
!=partial('includes/third-party/comments/livere', {}, {cache:theme.fragment_cache}) !=partial('includes/third-party/comments/livere', {}, {cache: true})
when 'Gitalk' when 'Gitalk'
include ./gitalk.pug include ./gitalk.pug
when 'Utterances' when 'Utterances'
!=partial('includes/third-party/comments/utterances', {}, {cache:theme.fragment_cache}) !=partial('includes/third-party/comments/utterances', {}, {cache: true})
when 'Twikoo' when 'Twikoo'
!=partial('includes/third-party/comments/twikoo', {}, {cache:theme.fragment_cache}) !=partial('includes/third-party/comments/twikoo', {}, {cache: true})
when 'Waline' when 'Waline'
!=partial('includes/third-party/comments/waline', {}, {cache:theme.fragment_cache}) !=partial('includes/third-party/comments/waline', {}, {cache: true})
when 'Facebook Comments' when 'Facebook Comments'
!=partial('includes/third-party/comments/facebook_comments', {}, {cache:theme.fragment_cache}) !=partial('includes/third-party/comments/facebook_comments', {}, {cache: true})

View File

@@ -1,6 +1,6 @@
if theme.mathjax && theme.mathjax.enable if theme.mathjax && theme.mathjax.enable
if theme.mathjax.per_page if theme.mathjax.per_page
if(!is_tag() && !is_category() && !is_archive() && !is_home()) if is_post() && is_page()
include ./mathjax.pug include ./mathjax.pug
else else
if page.mathjax if page.mathjax
@@ -8,7 +8,7 @@ if theme.mathjax && theme.mathjax.enable
if theme.katex && theme.katex.enable if theme.katex && theme.katex.enable
if theme.katex.per_page if theme.katex.per_page
if(!is_tag() && !is_category() && !is_archive() && !is_home()) if is_post() && is_page()
include ./katex.pug include ./katex.pug
else else
if page.katex if page.katex

View File

@@ -27,7 +27,7 @@ script.
} }
}) })
// set expiry to 10 min // 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) generateHtml(disqusArray)
}).catch(e => { }).catch(e => {
const $dom = document.querySelector('#card-newest-comments .aside-list') const $dom = document.querySelector('#card-newest-comments .aside-list')
@@ -43,10 +43,7 @@ script.
result += '<div class=\'aside-list-item\'>' result += '<div class=\'aside-list-item\'>'
if (!{theme.newest_comments.avatar}) { if (!{theme.newest_comments.avatar}) {
let name = 'src' const name = '!{theme.lazyload.enable ? "data-lazy-src" : "src"}'
if(!{theme.lazyload.enable}) {
name = 'data-lazy-src'
}
result += `<a href='${array[i].url}' class='thumbnail'><img ${name}='${array[i].avatar}' alt='${array[i].nick}'></a>` result += `<a href='${array[i].url}' class='thumbnail'><img ${name}='${array[i].avatar}' alt='${array[i].nick}'></a>`
} }

View File

@@ -26,7 +26,7 @@ script.
'date': item.updated_at '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) generateHtml(githubArray)
}).catch(e => { }).catch(e => {
const $dom = document.querySelector('#card-newest-comments .aside-list') const $dom = document.querySelector('#card-newest-comments .aside-list')
@@ -42,10 +42,7 @@ script.
result += '<div class=\'aside-list-item\'>' result += '<div class=\'aside-list-item\'>'
if (!{theme.newest_comments.avatar}) { if (!{theme.newest_comments.avatar}) {
let name = 'src' const name = '!{theme.lazyload.enable ? "data-lazy-src" : "src"}'
if(!{theme.lazyload.enable}) {
name = 'data-lazy-src'
}
result += `<a href='${array[i].url}' class="thumbnail"><img ${name}='${array[i].avatar}' alt='${array[i].nick}'></a>` result += `<a href='${array[i].url}' class="thumbnail"><img ${name}='${array[i].avatar}' alt='${array[i].nick}'></a>`
} }

View File

@@ -21,7 +21,7 @@ script.
pageSize: !{theme.newest_comments.limit}, pageSize: !{theme.newest_comments.limit},
includeReply: true includeReply: true
}).then(function (res) { }).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) generateHtml(res)
}).catch(function (err) { }).catch(function (err) {
const $dom = document.querySelector('#card-newest-comments .aside-list') const $dom = document.querySelector('#card-newest-comments .aside-list')
@@ -44,10 +44,7 @@ script.
result += '<div class=\'aside-list-item\'>' result += '<div class=\'aside-list-item\'>'
if (!{theme.newest_comments.avatar}) { if (!{theme.newest_comments.avatar}) {
let name = 'src' const name = '!{theme.lazyload.enable ? "data-lazy-src" : "src"}'
if(!{theme.lazyload.enable}) {
name = 'data-lazy-src'
}
result += `<a href='${array[i].url + '#' + array[i].id}' class='thumbnail'><img ${name}='${array[i].avatar}' alt='${array[i].nick}'></a>` result += `<a href='${array[i].url + '#' + array[i].id}' class='thumbnail'><img ${name}='${array[i].avatar}' alt='${array[i].nick}'></a>`
} }

View File

@@ -18,7 +18,6 @@ script.
const getIcon = (icon, mail) => { const getIcon = (icon, mail) => {
if (icon) return icon if (icon) return icon
let defaultIcon = '!{ default_avatar ? `?d=${default_avatar}` : ''}' let defaultIcon = '!{ default_avatar ? `?d=${default_avatar}` : ''}'
let iconUrl = `https://gravatar.loli.net/avatar/${md5(mail.toLowerCase()) + defaultIcon}` let iconUrl = `https://gravatar.loli.net/avatar/${md5(mail.toLowerCase()) + defaultIcon}`
return iconUrl return iconUrl
@@ -32,10 +31,7 @@ script.
result += '<div class=\'aside-list-item\'>' result += '<div class=\'aside-list-item\'>'
if (!{theme.newest_comments.avatar}) { if (!{theme.newest_comments.avatar}) {
let name = 'src' const name = '!{theme.lazyload.enable ? "data-lazy-src" : "src"}'
if(!{theme.lazyload.enable}) {
name = 'data-lazy-src'
}
result += `<a href='${array[i].url}' class="thumbnail"><img ${name}='${getIcon(array[i].avatar, array[i].mail)}' alt='${array[i].nick}'></a>` result += `<a href='${array[i].url}' class="thumbnail"><img ${name}='${getIcon(array[i].avatar, array[i].mail)}' alt='${array[i].nick}'></a>`
} }
@@ -55,12 +51,7 @@ script.
} }
const getComment = () => { const getComment = () => {
let serverURL = '' const serverURL = '!{theme.valine.serverURLs || `https://${theme.valine.appId.substring(0,8)}.api.lncldglobal.com` }'
if (!{Boolean(theme.valine.serverURLs)}) {
serverURL = '!{theme.valine.serverURLs}'
} else {
serverURL = 'https://!{theme.valine.appId.substring(0,8)}.api.lncldglobal.com'
}
var settings = { var settings = {
"method": "GET", "method": "GET",
@@ -84,7 +75,7 @@ script.
'date': e.createdAt, '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) generateHtml(valineArray)
}).catch(e => { }).catch(e => {
const $dom = document.querySelector('#card-newest-comments .aside-list') const $dom = document.querySelector('#card-newest-comments .aside-list')
@@ -94,7 +85,7 @@ script.
const newestCommentInit = () => { const newestCommentInit = () => {
if (document.querySelector('#card-newest-comments .aside-list')) { if (document.querySelector('#card-newest-comments .aside-list')) {
const data = saveToLocal.get('leancloud-newest-comments') const data = saveToLocal.get('valine-newest-comments')
if (data) { if (data) {
generateHtml(JSON.parse(data)) generateHtml(JSON.parse(data))
} else { } else {

View File

@@ -29,10 +29,7 @@ script.
result += '<div class=\'aside-list-item\'>' result += '<div class=\'aside-list-item\'>'
if (!{theme.newest_comments.avatar}) { if (!{theme.newest_comments.avatar}) {
let name = 'src' const name = '!{theme.lazyload.enable ? "data-lazy-src" : "src"}'
if(!{theme.lazyload.enable}) {
name = 'data-lazy-src'
}
result += `<a href='${array[i].url}' class="thumbnail"><img ${name}='${getIcon(array[i].mail)}' alt='${array[i].nick}'></a>` result += `<a href='${array[i].url}' class="thumbnail"><img ${name}='${getIcon(array[i].mail)}' alt='${array[i].nick}'></a>`
} }
@@ -67,7 +64,7 @@ script.
'date': e.createdAt, '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) generateHtml(walineArray)
}).catch(e => { }).catch(e => {
const $dom = document.querySelector('#card-newest-comments .aside-list') const $dom = document.querySelector('#card-newest-comments .aside-list')

View File

@@ -1,10 +1,10 @@
script. script.
function panguFn () { function panguFn () {
if (typeof pangu === 'object') pangu.spacingElementById('content-inner') if (typeof pangu === 'object') pangu.spacingElementById('body-wrap')
else { else {
getScript('!{url_for(theme.CDN.pangu)}') getScript('!{url_for(theme.CDN.pangu)}')
.then(() => { .then(() => {
pangu.spacingElementById('content-inner') pangu.spacingElementById('body-wrap')
}) })
} }
} }

View File

@@ -78,3 +78,9 @@ script.
$bodyClassList.contains('read-mode') && $bodyClassList.remove('read-mode') $bodyClassList.contains('read-mode') && $bodyClassList.remove('read-mode')
}) })
document.addEventListener('pjax:error', (e) => {
if (e.request.status === 404) {
pjax.loadUrl('/404.html')
}
})

View File

@@ -1,7 +1,7 @@
.post_share .post_share
if theme.addThis.enable 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 else if theme.sharejs.enable
include ./share-js.pug include ./share-js.pug
else if theme.addtoany.enable else if theme.addtoany.enable
!=partial('includes/third-party/share/addtoany', {}, {cache:theme.fragment_cache}) !=partial('includes/third-party/share/addtoany', {}, {cache: true})

View File

@@ -5,23 +5,23 @@
.sticky_layout .sticky_layout
include ./card_post_toc.pug include ./card_post_toc.pug
else else
!=partial('includes/widget/card_author', {}, {cache:theme.fragment_cache}) !=partial('includes/widget/card_author', {}, {cache: true})
!=partial('includes/widget/card_announcement', {}, {cache:theme.fragment_cache}) !=partial('includes/widget/card_announcement', {}, {cache: true})
.sticky_layout .sticky_layout
if showToc if showToc
include ./card_post_toc.pug include ./card_post_toc.pug
!=partial('includes/widget/card_recent_post', {}, {cache:theme.fragment_cache}) !=partial('includes/widget/card_recent_post', {}, {cache: true})
!=partial('includes/widget/card_ad', {}, {cache:theme.fragment_cache}) !=partial('includes/widget/card_ad', {}, {cache: true})
else else
//- page //- page
!=partial('includes/widget/card_author', {}, {cache:theme.fragment_cache}) !=partial('includes/widget/card_author', {}, {cache: true})
!=partial('includes/widget/card_announcement', {}, {cache:theme.fragment_cache}) !=partial('includes/widget/card_announcement', {}, {cache: true})
.sticky_layout .sticky_layout
!=partial('includes/widget/card_recent_post', {}, {cache:theme.fragment_cache}) !=partial('includes/widget/card_recent_post', {}, {cache: true})
!=partial('includes/widget/card_ad', {}, {cache:theme.fragment_cache}) !=partial('includes/widget/card_ad', {}, {cache: true})
!=partial('includes/widget/card_newest_comment', {}, {cache:theme.fragment_cache}) !=partial('includes/widget/card_newest_comment', {}, {cache: true})
!=partial('includes/widget/card_categories', {}, {cache:theme.fragment_cache}) !=partial('includes/widget/card_categories', {}, {cache: true})
!=partial('includes/widget/card_tags', {}, {cache:theme.fragment_cache}) !=partial('includes/widget/card_tags', {}, {cache: true})
!=partial('includes/widget/card_archives', {}, {cache:theme.fragment_cache}) !=partial('includes/widget/card_archives', {}, {cache: true})
!=partial('includes/widget/card_webinfo', {}, {cache:theme.fragment_cache}) !=partial('includes/widget/card_webinfo', {}, {cache: true})
!=partial('includes/widget/card_self', {}, {cache:theme.fragment_cache}) !=partial('includes/widget/card_self', {}, {cache: true})

View File

@@ -16,4 +16,4 @@ block content
if page.comments !== false && theme.comments && theme.comments.use if page.comments !== false && theme.comments && theme.comments.use
- var commentsJsLoad = true - var commentsJsLoad = true
!=partial('includes/third-party/comments/index', {}, {cache:theme.fragment_cache}) !=partial('includes/third-party/comments/index', {}, {cache: true})

View File

@@ -15,17 +15,18 @@ block content
include includes/third-party/share/index.pug include includes/third-party/share/index.pug
if theme.reward.enable if theme.reward.enable
!=partial('includes/post/reward', {}, {cache:theme.fragment_cache}) !=partial('includes/post/reward', {}, {cache: true})
//- ad //- ad
if theme.ad && theme.ad.post if theme.ad && theme.ad.post
.ads-wrap!=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 if theme.related_post && theme.related_post.enable
!= related_posts(page,site.posts) != related_posts(page,site.posts)
if page.comments !== false && theme.comments && theme.comments.use if page.comments !== false && theme.comments && theme.comments.use
- var commentsJsLoad = true - var commentsJsLoad = true
!=partial('includes/third-party/comments/index', {}, {cache:theme.fragment_cache}) !=partial('includes/third-party/comments/index', {}, {cache: true})

View File

@@ -1,6 +1,6 @@
{ {
"name": "hexo-theme-butterfly", "name": "hexo-theme-butterfly",
"version": "3.6.0-b1", "version": "3.6.0-b2",
"description": "A Simple and Card UI Design theme for Hexo", "description": "A Simple and Card UI Design theme for Hexo",
"main": "package.json", "main": "package.json",
"scripts": { "scripts": {

View File

@@ -75,5 +75,5 @@
transform: scale(1.1) transform: scale(1.1)
&.pagination-post &.pagination-post
margin: 2rem 0 !important margin-top: 2rem
background: $dark-black background: $dark-black

View File

@@ -218,24 +218,13 @@ no-beautify()
transition: box-shadow .3s ease-in-out transition: box-shadow .3s ease-in-out
&:before &:before
@extend .fontawesomeIcon
position: absolute position: absolute
top: t = .5rem top: .1rem
right: t right: .6rem
width: w = .8rem color: $theme-color
height: w content: '\f1f9'
border-radius: w font-size: 1rem
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: ''
&:hover &:hover
box-shadow: 0 0 8px 0 rgba(232, 237, 250, .6), 0 2px 4px 0 rgba(232, 237, 250, .5) box-shadow: 0 0 8px 0 rgba(232, 237, 250, .6), 0 2px 4px 0 rgba(232, 237, 250, .5)

View File

@@ -1,5 +1,5 @@
.relatedPosts .relatedPosts
margin-top: 1rem margin-top: 2rem
& > .headline & > .headline
margin-bottom: 5px margin-bottom: 5px

View File

@@ -1,17 +1,16 @@
document.addEventListener('DOMContentLoaded', function () { 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') const $menusEle = document.querySelector('#menus .menus_items')
let menusWidth = $menusEle && $menusEle.offsetWidth let menusWidth = $menusEle && $menusEle.offsetWidth
const $searchEle = document.querySelector('#search-button') const $searchEle = document.querySelector('#search-button')
let searchWidth = $searchEle && $searchEle.offsetWidth let searchWidth = $searchEle && $searchEle.offsetWidth
let detectFontSizeChange = false
const adjustMenu = () => { const adjustMenu = (change = false) => {
if (detectFontSizeChange) { if (change) {
blogNameWidth = document.getElementById('site-name').offsetWidth blogNameWidth = $blogName && $blogName.offsetWidth
menusWidth = $menusEle && $menusEle.offsetWidth menusWidth = $menusEle && $menusEle.offsetWidth
searchWidth = $searchEle && $searchEle.offsetWidth searchWidth = $searchEle && $searchEle.offsetWidth
detectFontSizeChange = false
} }
const $nav = document.getElementById('nav') const $nav = document.getElementById('nav')
let t let t
@@ -536,17 +535,16 @@ document.addEventListener('DOMContentLoaded', function () {
adjustFontSize: (plus) => { adjustFontSize: (plus) => {
const fontSizeVal = parseInt(window.getComputedStyle(document.documentElement).getPropertyValue('--global-font-size')) const fontSizeVal = parseInt(window.getComputedStyle(document.documentElement).getPropertyValue('--global-font-size'))
let newValue = '' let newValue = ''
detectFontSizeChange = true
if (plus) { if (plus) {
if (fontSizeVal >= 20) return if (fontSizeVal >= 20) return
newValue = fontSizeVal + 1 newValue = fontSizeVal + 1
document.documentElement.style.setProperty('--global-font-size', newValue + 'px') 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 { } else {
if (fontSizeVal <= 10) return if (fontSizeVal <= 10) return
newValue = fontSizeVal - 1 newValue = fontSizeVal - 1
document.documentElement.style.setProperty('--global-font-size', newValue + 'px') 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) saveToLocal.set('global-font-size', newValue, 2)
@@ -798,6 +796,7 @@ document.addEventListener('DOMContentLoaded', function () {
const unRefreshFn = function () { const unRefreshFn = function () {
window.addEventListener('resize', adjustMenu) window.addEventListener('resize', adjustMenu)
window.addEventListener('orientationchange', () => { setTimeout(adjustMenu(true), 100) })
clickFnOfSubMenu() clickFnOfSubMenu()
GLOBAL_CONFIG.islazyload && lazyloadImg() GLOBAL_CONFIG.islazyload && lazyloadImg()