mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-12 14:07:06 +08:00
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:
17
_config.yml
17
_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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -11,4 +11,4 @@ block content
|
||||
#category
|
||||
.article-sort-title= _p('page.category') + ' - ' + page.category
|
||||
+articleSort(page.posts)
|
||||
include includes/pagination.pug
|
||||
include includes/pagination.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})
|
||||
|
||||
!=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))
|
||||
|
||||
@@ -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)})
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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")
|
||||
@@ -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')})
|
||||
|
||||
@@ -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
|
||||
@@ -10,4 +10,4 @@ script.
|
||||
|
||||
}
|
||||
}
|
||||
window.addEventListener('load',()=> {preloader.endLoading()})
|
||||
window.addEventListener('load',preloader.endLoading())
|
||||
@@ -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
|
||||
.next_info=next.title
|
||||
@@ -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
|
||||
|
||||
|
||||
15
layout/includes/third-party/baidu_push.pug
vendored
15
layout/includes/third-party/baidu_push.pug
vendored
@@ -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);
|
||||
})()
|
||||
12
layout/includes/third-party/comments/js.pug
vendored
12
layout/includes/third-party/comments/js.pug
vendored
@@ -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})
|
||||
|
||||
4
layout/includes/third-party/math/index.pug
vendored
4
layout/includes/third-party/math/index.pug
vendored
@@ -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
|
||||
|
||||
@@ -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 += '<div class=\'aside-list-item\'>'
|
||||
|
||||
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 += `<a href='${array[i].url}' class='thumbnail'><img ${name}='${array[i].avatar}' alt='${array[i].nick}'></a>`
|
||||
}
|
||||
|
||||
|
||||
@@ -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 += '<div class=\'aside-list-item\'>'
|
||||
|
||||
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 += `<a href='${array[i].url}' class="thumbnail"><img ${name}='${array[i].avatar}' alt='${array[i].nick}'></a>`
|
||||
}
|
||||
|
||||
|
||||
@@ -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 += '<div class=\'aside-list-item\'>'
|
||||
|
||||
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 += `<a href='${array[i].url + '#' + array[i].id}' class='thumbnail'><img ${name}='${array[i].avatar}' alt='${array[i].nick}'></a>`
|
||||
}
|
||||
|
||||
|
||||
@@ -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 += '<div class=\'aside-list-item\'>'
|
||||
|
||||
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 += `<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 = () => {
|
||||
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 {
|
||||
|
||||
@@ -29,10 +29,7 @@ script.
|
||||
result += '<div class=\'aside-list-item\'>'
|
||||
|
||||
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 += `<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,
|
||||
}
|
||||
})
|
||||
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')
|
||||
|
||||
4
layout/includes/third-party/pangu.pug
vendored
4
layout/includes/third-party/pangu.pug
vendored
@@ -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')
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
6
layout/includes/third-party/pjax.pug
vendored
6
layout/includes/third-party/pjax.pug
vendored
@@ -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')
|
||||
}
|
||||
})
|
||||
|
||||
4
layout/includes/third-party/share/index.pug
vendored
4
layout/includes/third-party/share/index.pug
vendored
@@ -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})
|
||||
|
||||
@@ -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})
|
||||
!=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})
|
||||
@@ -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})
|
||||
!=partial('includes/third-party/comments/index', {}, {cache: true})
|
||||
@@ -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})
|
||||
|
||||
@@ -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": {
|
||||
|
||||
@@ -75,5 +75,5 @@
|
||||
transform: scale(1.1)
|
||||
|
||||
&.pagination-post
|
||||
margin: 2rem 0 !important
|
||||
margin-top: 2rem
|
||||
background: $dark-black
|
||||
@@ -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)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
.relatedPosts
|
||||
margin-top: 1rem
|
||||
margin-top: 2rem
|
||||
|
||||
& > .headline
|
||||
margin-bottom: 5px
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user