mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-12 22:17:06 +08:00
improvements: 代碼名全大寫
improvements: 補全card-categories和card-archives的 '查看更多‘鏈接 close #337 fix: 修復comments沒設置時,報Unexpected token ')'的bugs close #344 improvements: 優化js和html fix: 修復toc 滾動百分比不準的Bugs
This commit is contained in:
@@ -2,9 +2,8 @@
|
|||||||
|
|
||||||

|

|
||||||

|

|
||||||

|

|
||||||

|

|
||||||

|
|
||||||

|

|
||||||
|
|
||||||
Demo: 👍 [Butterfly](https://demo.jerryc.me/) || 🤞 [JerryC](https://jerryc.me/)
|
Demo: 👍 [Butterfly](https://demo.jerryc.me/) || 🤞 [JerryC](https://jerryc.me/)
|
||||||
|
|||||||
@@ -2,9 +2,8 @@
|
|||||||
|
|
||||||

|

|
||||||

|

|
||||||

|

|
||||||

|

|
||||||

|
|
||||||

|

|
||||||
|
|
||||||
|
|
||||||
|
|||||||
17
_config.yml
17
_config.yml
@@ -91,14 +91,14 @@ favicon: /img/favicon.png
|
|||||||
|
|
||||||
# Avatar (頭像)
|
# Avatar (頭像)
|
||||||
avatar:
|
avatar:
|
||||||
img: /img/avatar.png
|
img:
|
||||||
effect: false
|
effect: false
|
||||||
|
|
||||||
# the banner image of home page
|
# the banner image of home page
|
||||||
index_img:
|
index_img:
|
||||||
|
|
||||||
# if the banner of page not setting, it will show the top_img
|
# if the banner of page not setting, it will show the top_img
|
||||||
default_top_img: https://i.loli.net/2020/05/01/IuWi8QbHvzjlOPw.jpg
|
default_top_img:
|
||||||
|
|
||||||
# the banner image of archive page
|
# the banner image of archive page
|
||||||
archive_img:
|
archive_img:
|
||||||
@@ -557,9 +557,10 @@ font:
|
|||||||
|
|
||||||
# Font settings for the site title and site subtitle
|
# Font settings for the site title and site subtitle
|
||||||
# 左上角網站名字 主頁居中網站名字
|
# 左上角網站名字 主頁居中網站名字
|
||||||
blog_title_font:
|
|
||||||
font_link: https://fonts.googleapis.com/css?family=Titillium+Web&display=swap
|
# blog_title_font:
|
||||||
font-family: Titillium Web, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif
|
# font_link: https://fonts.googleapis.com/css?family=Titillium+Web&display=swap
|
||||||
|
# font-family: Titillium Web, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif
|
||||||
|
|
||||||
# The setting of divider icon (水平分隔線圖標設置)
|
# The setting of divider icon (水平分隔線圖標設置)
|
||||||
hr_icon:
|
hr_icon:
|
||||||
@@ -654,7 +655,7 @@ newest_comments:
|
|||||||
appId: # leancloud application app id
|
appId: # leancloud application app id
|
||||||
appKey: # leancloud application app key
|
appKey: # leancloud application app key
|
||||||
serverURL: # This configuration is suitable for domestic custom domain name users, overseas version will be automatically detected (no need to manually fill in)
|
serverURL: # This configuration is suitable for domestic custom domain name users, overseas version will be automatically detected (no need to manually fill in)
|
||||||
default_avatar: mp # mp/identicon/monsterid/wavatar/retro/robohash/blank
|
default_avatar: # mp/identicon/monsterid/wavatar/retro/robohash/blank
|
||||||
github_issues:
|
github_issues:
|
||||||
enable: false
|
enable: false
|
||||||
repo:
|
repo:
|
||||||
@@ -762,7 +763,7 @@ baidu_push: false
|
|||||||
|
|
||||||
# https://instant.page/
|
# https://instant.page/
|
||||||
# prefetch (預加載)
|
# prefetch (預加載)
|
||||||
instantpage: true
|
instantpage: false
|
||||||
|
|
||||||
# https://github.com/vinta/pangu.js
|
# https://github.com/vinta/pangu.js
|
||||||
# Insert a space between Chinese character and English character (中英文之間添加空格)
|
# Insert a space between Chinese character and English character (中英文之間添加空格)
|
||||||
@@ -773,7 +774,7 @@ pangu:
|
|||||||
# Lazyload (圖片懶加載)
|
# Lazyload (圖片懶加載)
|
||||||
# https://github.com/verlok/lazyload
|
# https://github.com/verlok/lazyload
|
||||||
lazyload:
|
lazyload:
|
||||||
enable: true
|
enable: false
|
||||||
post: /img/loading.gif
|
post: /img/loading.gif
|
||||||
|
|
||||||
# PWA
|
# PWA
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ div
|
|||||||
script(src=url_for(theme.CDN.instantpage) type="module" defer)
|
script(src=url_for(theme.CDN.instantpage) type="module" defer)
|
||||||
|
|
||||||
if theme.lazyload.enable
|
if theme.lazyload.enable
|
||||||
script(src=url_for(theme.CDN.lazyload) async)
|
script(src=url_for(theme.CDN.lazyload))
|
||||||
|
|
||||||
if (theme.snackbar && theme.snackbar.enable)
|
if (theme.snackbar && theme.snackbar.enable)
|
||||||
script(src=url_for(theme.CDN.snackbar))
|
script(src=url_for(theme.CDN.snackbar))
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ if theme.algolia_search.enable
|
|||||||
!=partial('includes/head/analytics', {}, {cache:theme.fragment_cache})
|
!=partial('includes/head/analytics', {}, {cache:theme.fragment_cache})
|
||||||
|
|
||||||
//- font
|
//- font
|
||||||
if 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))
|
link(rel='stylesheet' href=url_for(theme.blog_title_font.font_link))
|
||||||
|
|
||||||
//- global config
|
//- global config
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ if theme.darkmode.enable
|
|||||||
if (isLightMode) activateLightMode()
|
if (isLightMode) activateLightMode()
|
||||||
else if (isDarkMode) activateDarkMode()
|
else if (isDarkMode) activateDarkMode()
|
||||||
else if (isNotSpecified || hasNoSupport) {
|
else if (isNotSpecified || hasNoSupport) {
|
||||||
console.log('You specified no preference for a color scheme or your browser does not support it. I Schedule dark mode during night time.')
|
|
||||||
var now = new Date()
|
var now = new Date()
|
||||||
var hour = now.getHours()
|
var hour = now.getHours()
|
||||||
var isNight = hour <= 6 || hour >= 18
|
var isNight = hour <= 6 || hour >= 18
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ if theme.tencent_analytics
|
|||||||
if theme.cnzz_analytics
|
if theme.cnzz_analytics
|
||||||
link(rel="preconnect" href="//s4.cnzz.com")
|
link(rel="preconnect" href="//s4.cnzz.com")
|
||||||
|
|
||||||
if theme.blog_title_font.font_link && theme.blog_title_font.font_link.indexOf('//fonts.googleapis.com') != -1
|
if theme.blog_title_font && theme.blog_title_font.font_link && theme.blog_title_font.font_link.indexOf('//fonts.googleapis.com') != -1
|
||||||
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
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ nav#nav
|
|||||||
span#blog_name
|
span#blog_name
|
||||||
a#site-name(href=url_for('/')) #[=config.title]
|
a#site-name(href=url_for('/')) #[=config.title]
|
||||||
|
|
||||||
span.menus
|
span#menus
|
||||||
if (theme.algolia_search.enable || theme.local_search.enable)
|
if (theme.algolia_search.enable || theme.local_search.enable)
|
||||||
#search_button
|
#search_button
|
||||||
a.site-page.social-icon.search
|
a.site-page.social-icon.search
|
||||||
@@ -10,7 +10,7 @@ nav#nav
|
|||||||
span=' '+_p('search')
|
span=' '+_p('search')
|
||||||
!=fragment_cache('menus', function(){return partial('includes/header/menu_item')})
|
!=fragment_cache('menus', function(){return partial('includes/header/menu_item')})
|
||||||
|
|
||||||
span.toggle-menu.close
|
span#toggle-menu.close
|
||||||
a.site-page
|
a.site-page
|
||||||
i.fas.fa-bars.fa-fw
|
i.fas.fa-bars.fa-fw
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ script.
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ('!{theme.comments.use[0]}' === 'Disqus' || !!{theme.comments.lazyload}) {
|
if ('!{theme.comments.use[0]}' === 'Disqus' || !!{theme.comments.lazyload}) {
|
||||||
if (!{theme.comments.lazyload}) loadComment(document.getElementById('disqus_thread'), loadDisqus)
|
if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('disqus_thread'), loadDisqus)
|
||||||
else loadDisqus()
|
else loadDisqus()
|
||||||
} else {
|
} else {
|
||||||
function loadOtherComment () {
|
function loadOtherComment () {
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ script.
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ('!{theme.comments.use[0]}' === 'Disqusjs' || !!{theme.comments.lazyload}) {
|
if ('!{theme.comments.use[0]}' === 'Disqusjs' || !!{theme.comments.lazyload}) {
|
||||||
if (!{theme.comments.lazyload}) loadComment(document.getElementById('disqus_thread'), loadDisqusjs)
|
if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('disqus_thread'), loadDisqusjs)
|
||||||
else loadDisqusjs()
|
else loadDisqusjs()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ script.
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ('!{theme.comments.use[0]}' === 'Facebook Comments' || !!{theme.comments.lazyload}) {
|
if ('!{theme.comments.use[0]}' === 'Facebook Comments' || !!{theme.comments.lazyload}) {
|
||||||
if (!{theme.comments.lazyload}) loadComment(document.querySelector('#post-comment .fb-comments'), loadFBComment)
|
if (!{theme.comments.lazyload}) btf.loadComment(document.querySelector('#post-comment .fb-comments'), loadFBComment)
|
||||||
else loadFBComment()
|
else loadFBComment()
|
||||||
} else {
|
} else {
|
||||||
function loadOtherComment () {
|
function loadOtherComment () {
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ script.
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ('!{theme.comments.use[0]}' === 'Gitalk' || !!{theme.comments.lazyload}) {
|
if ('!{theme.comments.use[0]}' === 'Gitalk' || !!{theme.comments.lazyload}) {
|
||||||
if (!{theme.comments.lazyload}) loadComment(document.getElementById('gitalk-container'), loadGitalk)
|
if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('gitalk-container'), loadGitalk)
|
||||||
else loadGitalk()
|
else loadGitalk()
|
||||||
} else {
|
} else {
|
||||||
function loadOtherComment () {
|
function loadOtherComment () {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ script.
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ('!{theme.comments.use[0]}' === 'Livere' || !!{theme.comments.lazyload}) {
|
if ('!{theme.comments.use[0]}' === 'Livere' || !!{theme.comments.lazyload}) {
|
||||||
if (!{theme.comments.lazyload}) loadComment(document.getElementById('lv-container'), loadLivere)
|
if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('lv-container'), loadLivere)
|
||||||
else loadLivere()
|
else loadLivere()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ script.
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ('!{theme.comments.use[0]}' === 'Utterances' || !!{theme.comments.lazyload}) {
|
if ('!{theme.comments.use[0]}' === 'Utterances' || !!{theme.comments.lazyload}) {
|
||||||
if (!{theme.comments.lazyload}) loadComment(document.getElementById('utterances-wrap'), loadUtterances)
|
if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('utterances-wrap'), loadUtterances)
|
||||||
else loadUtterances()
|
else loadUtterances()
|
||||||
} else {
|
} else {
|
||||||
function loadOtherComment () {
|
function loadOtherComment () {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ script.
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ('!{theme.comments.use[0]}' === 'Valine' || !!{theme.comments.lazyload}) {
|
if ('!{theme.comments.use[0]}' === 'Valine' || !!{theme.comments.lazyload}) {
|
||||||
if (!{theme.comments.lazyload}) loadComment(document.querySelector('#vcomment'),loadValine)
|
if (!{theme.comments.lazyload}) btf.loadComment(document.querySelector('#vcomment'),loadValine)
|
||||||
else setTimeout(() => loadValine(), 0)
|
else setTimeout(() => loadValine(), 0)
|
||||||
} else {
|
} else {
|
||||||
function loadOtherComment () {
|
function loadOtherComment () {
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ script.
|
|||||||
|
|
||||||
result += `<div class='content'>
|
result += `<div class='content'>
|
||||||
<a class='comment' href='${array[i].url}'>${array[i].content}</a>
|
<a class='comment' href='${array[i].url}'>${array[i].content}</a>
|
||||||
<div class='name'><span>${array[i].nick}</span><time> / ${diffDate(array[i].date, true)}</time></div>
|
<div class='name'><span>${array[i].nick}</span><time> / ${btf.diffDate(array[i].date, true)}</time></div>
|
||||||
</div></div>`
|
</div></div>`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ script.
|
|||||||
|
|
||||||
result += `<div class='content'>
|
result += `<div class='content'>
|
||||||
<a class='comment' href='${array[i].url}'>${array[i].content}</a>
|
<a class='comment' href='${array[i].url}'>${array[i].content}</a>
|
||||||
<div class='name'><span>${array[i].nick}</span><time> / ${diffDate(array[i].date, true)}</time></div>
|
<div class='name'><span>${array[i].nick}</span><time> / ${btf.diffDate(array[i].date, true)}</time></div>
|
||||||
</div></div>`
|
</div></div>`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ script.
|
|||||||
|
|
||||||
const getIcon = (icon, mail) => {
|
const getIcon = (icon, mail) => {
|
||||||
if (icon) return icon
|
if (icon) return icon
|
||||||
let defaultIcon = '!{theme.newest_comments.leancloud.default_avatar}' || '404'
|
let defaultIcon = '!{ theme.newest_comments.leancloud.default_avatar ? `?d=${theme.newest_comments.leancloud.default_avatar}` : ''}'
|
||||||
let iconUrl = `https://gravatar.loli.net/avatar/${md5(mail.toLowerCase())}?d=${defaultIcon}`
|
let iconUrl = `https://gravatar.loli.net/avatar/${md5(mail.toLowerCase()) + defaultIcon}`
|
||||||
return iconUrl
|
return iconUrl
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ script.
|
|||||||
|
|
||||||
result += `<div class='content'>
|
result += `<div class='content'>
|
||||||
<a class='comment' href='${array[i].url}'>${array[i].content}</a>
|
<a class='comment' href='${array[i].url}'>${array[i].content}</a>
|
||||||
<div class='name'><span>${array[i].nick}</span><time> / ${diffDate(array[i].date, true)}</time></div>
|
<div class='name'><span>${array[i].nick}</span><time> / ${btf.diffDate(array[i].date, true)}</time></div>
|
||||||
</div></div>`
|
</div></div>`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
6
layout/includes/third-party/pjax.pug
vendored
6
layout/includes/third-party/pjax.pug
vendored
@@ -15,7 +15,7 @@ script.
|
|||||||
'.js-pjax'
|
'.js-pjax'
|
||||||
]
|
]
|
||||||
|
|
||||||
if (!{theme.Open_Graph_meta && theme.comments.use && theme.comments.use.includes('Livere')}) {
|
if (!{Boolean(theme.Open_Graph_meta && theme.comments.use && theme.comments.use.includes('Livere'))}) {
|
||||||
pjaxSelectors.unshift('meta[property="og:image"]', 'meta[property="og:title"]', 'meta[property="og:url"]')
|
pjaxSelectors.unshift('meta[property="og:image"]', 'meta[property="og:title"]', 'meta[property="og:url"]')
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,13 +28,13 @@ script.
|
|||||||
})
|
})
|
||||||
|
|
||||||
document.addEventListener('pjax:complete', function () {
|
document.addEventListener('pjax:complete', function () {
|
||||||
refreshFn()
|
window.refreshFn()
|
||||||
|
|
||||||
$('script[data-pjax]').each(function () {
|
$('script[data-pjax]').each(function () {
|
||||||
$(this).parent().append($(this).remove())
|
$(this).parent().append($(this).remove())
|
||||||
})
|
})
|
||||||
|
|
||||||
GLOBAL_CONFIG.islazyload && lazyLoadInstance.update()
|
GLOBAL_CONFIG.islazyload && window.lazyLoadInstance.update()
|
||||||
|
|
||||||
typeof chatBtnFn === 'function' && chatBtnFn()
|
typeof chatBtnFn === 'function' && chatBtnFn()
|
||||||
typeof panguInit === 'function' && panguInit()
|
typeof panguInit === 'function' && panguInit()
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ hexo.extend.helper.register('aside_archives', function (options = {}) {
|
|||||||
|
|
||||||
if (len > Judge) {
|
if (len > Judge) {
|
||||||
result += '<li class="card-archive-list-item more is-center">'
|
result += '<li class="card-archive-list-item more is-center">'
|
||||||
result += `<a class="card-archive-list-link-more" href="${this.url_for(archiveDir)}">
|
result += `<a class="card-archive-list-link-more" href="${this.url_for(archiveDir)}/">
|
||||||
<span>${moreButton}</span><i class="fas fa-angle-right" ></i></a></li>`
|
<span>${moreButton}</span><i class="fas fa-angle-right" ></i></a></li>`
|
||||||
}
|
}
|
||||||
result += '</ul>'
|
result += '</ul>'
|
||||||
|
|||||||
@@ -83,13 +83,13 @@ hexo.extend.helper.register('aside_categories', function (categories, options) {
|
|||||||
let moreHtml = ''
|
let moreHtml = ''
|
||||||
if (categories.length <= limit) return ''
|
if (categories.length <= limit) return ''
|
||||||
moreHtml += '<li class="card-category-list-item more is-center">'
|
moreHtml += '<li class="card-category-list-item more is-center">'
|
||||||
moreHtml += `<a class="card-category-list-link-more" href="${categoryDir}">
|
moreHtml += `<a class="card-category-list-link-more" href="${categoryDir}/">
|
||||||
<span>${buttonLabel}</span><i class="fas fa-angle-right"></i></a></li>`
|
<span>${buttonLabel}</span><i class="fas fa-angle-right"></i></a></li>`
|
||||||
|
|
||||||
return moreHtml
|
return moreHtml
|
||||||
}
|
}
|
||||||
|
|
||||||
return `<ul class="card-category-list">
|
return `<ul class="card-category-list" id="aside-cat-list">
|
||||||
${list[0]}
|
${list[0]}
|
||||||
${moreButton()}
|
${moreButton()}
|
||||||
</ul>`
|
</ul>`
|
||||||
|
|||||||
@@ -48,11 +48,11 @@ hexo.extend.helper.register('related_posts', function (currentPost, allPosts) {
|
|||||||
if (relatedPosts.length > 0) {
|
if (relatedPosts.length > 0) {
|
||||||
result += '<div class="relatedPosts">'
|
result += '<div class="relatedPosts">'
|
||||||
result +=
|
result +=
|
||||||
'<div class="relatedPosts_headline"><i class="fas fa-thumbs-up fa-fw"></i><span>' +
|
'<div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>' +
|
||||||
' ' +
|
' ' +
|
||||||
headlineLang +
|
headlineLang +
|
||||||
'</span></div>'
|
'</span></div>'
|
||||||
result += '<div class="relatedPosts_list">'
|
result += '<div class="relatedPosts-list">'
|
||||||
|
|
||||||
for (let i = 0; i < Math.min(relatedPosts.length, limitNum); i++) {
|
for (let i = 0; i < Math.min(relatedPosts.length, limitNum); i++) {
|
||||||
const cover =
|
const cover =
|
||||||
@@ -60,33 +60,33 @@ hexo.extend.helper.register('related_posts', function (currentPost, allPosts) {
|
|||||||
? relatedPosts[i].randomcover
|
? relatedPosts[i].randomcover
|
||||||
: relatedPosts[i].cover
|
: relatedPosts[i].cover
|
||||||
result +=
|
result +=
|
||||||
'<div class="relatedPosts_item"><a href="' +
|
'<div><a href="' +
|
||||||
hexoConfig.root +
|
hexoConfig.root +
|
||||||
relatedPosts[i].path +
|
relatedPosts[i].path +
|
||||||
'" title="' +
|
'" title="' +
|
||||||
relatedPosts[i].title +
|
relatedPosts[i].title +
|
||||||
'">'
|
'">'
|
||||||
result +=
|
result +=
|
||||||
'<img class="relatedPosts_cover" ' +
|
'<img class="cover" ' +
|
||||||
lazySrc +
|
lazySrc +
|
||||||
'="' +
|
'="' +
|
||||||
this.url_for(cover) +
|
this.url_for(cover) +
|
||||||
'">'
|
'">'
|
||||||
if (dateType === 'created') {
|
if (dateType === 'created') {
|
||||||
result +=
|
result +=
|
||||||
'<div class="relatedPosts_main is-center"><div class="relatedPosts_date"><i class="far fa-calendar-alt fa-fw"></i>' +
|
'<div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i>' +
|
||||||
' ' +
|
' ' +
|
||||||
this.date(relatedPosts[i].created, hexoConfig.date_format) +
|
this.date(relatedPosts[i].created, hexoConfig.date_format) +
|
||||||
'</div>'
|
'</div>'
|
||||||
} else {
|
} else {
|
||||||
result +=
|
result +=
|
||||||
'<div class="relatedPosts_main is-center"><div class="relatedPosts_date"><i class="fas fa-history fa-fw"></i>' +
|
'<div class="content is-center"><div class="date"><i class="fas fa-history fa-fw"></i>' +
|
||||||
' ' +
|
' ' +
|
||||||
this.date(relatedPosts[i].updated, hexoConfig.date_format) +
|
this.date(relatedPosts[i].updated, hexoConfig.date_format) +
|
||||||
'</div>'
|
'</div>'
|
||||||
}
|
}
|
||||||
result +=
|
result +=
|
||||||
'<div class="relatedPosts_title">' + relatedPosts[i].title + '</div>'
|
'<div class="title">' + relatedPosts[i].title + '</div>'
|
||||||
result += '</div></a></div>'
|
result += '</div></a></div>'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ blockquote
|
|||||||
.code-lang
|
.code-lang
|
||||||
position: absolute
|
position: absolute
|
||||||
left: .7rem
|
left: .7rem
|
||||||
text-transform: capitalize
|
text-transform: uppercase
|
||||||
font-weight: bold
|
font-weight: bold
|
||||||
font-size: 1.15em
|
font-size: 1.15em
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// For diff highlight
|
|
||||||
figure.highlight
|
figure.highlight
|
||||||
table
|
table
|
||||||
&::-webkit-scrollbar-thumb
|
&::-webkit-scrollbar-thumb
|
||||||
|
|||||||
@@ -116,3 +116,4 @@ if $highlight_theme == false
|
|||||||
color: $highlight-foreground,
|
color: $highlight-foreground,
|
||||||
bg-color: darken($highlight-background, 5)
|
bg-color: darken($highlight-background, 5)
|
||||||
}
|
}
|
||||||
|
$highlight-scrollbar = darken($highlight-background, 8)
|
||||||
|
|||||||
@@ -87,6 +87,10 @@
|
|||||||
span
|
span
|
||||||
margin-left: .5rem
|
margin-left: .5rem
|
||||||
|
|
||||||
|
& + div,
|
||||||
|
& + ul
|
||||||
|
padding: .3rem 0 0
|
||||||
|
|
||||||
.sticky_layout
|
.sticky_layout
|
||||||
+minWidth900()
|
+minWidth900()
|
||||||
position: sticky
|
position: sticky
|
||||||
@@ -102,8 +106,6 @@
|
|||||||
color: $text-hover !important
|
color: $text-hover !important
|
||||||
|
|
||||||
.aside-list
|
.aside-list
|
||||||
margin: 10px 0 -15px
|
|
||||||
|
|
||||||
& > span
|
& > span
|
||||||
display: block
|
display: block
|
||||||
margin-bottom: .5rem
|
margin-bottom: .5rem
|
||||||
@@ -121,7 +123,7 @@
|
|||||||
border-bottom: 1px dashed #f5f5f5
|
border-bottom: 1px dashed #f5f5f5
|
||||||
|
|
||||||
&:last-child
|
&:last-child
|
||||||
margin-bottom: .3rem
|
padding-bottom: 0
|
||||||
|
|
||||||
.thumbnail
|
.thumbnail
|
||||||
overflow: hidden
|
overflow: hidden
|
||||||
@@ -173,7 +175,6 @@
|
|||||||
.card-archives ul.card-archive-list,
|
.card-archives ul.card-archive-list,
|
||||||
.card-categories ul.card-category-list
|
.card-categories ul.card-category-list
|
||||||
margin: 0
|
margin: 0
|
||||||
padding: .2rem 0 0
|
|
||||||
list-style: none
|
list-style: none
|
||||||
|
|
||||||
.card-archives ul.card-archive-list > .card-archive-list-item,
|
.card-archives ul.card-archive-list > .card-archive-list-item,
|
||||||
@@ -241,12 +242,10 @@
|
|||||||
|
|
||||||
.card-webinfo
|
.card-webinfo
|
||||||
.webinfo
|
.webinfo
|
||||||
padding: .2rem .5rem
|
|
||||||
|
|
||||||
.webinfo-item
|
.webinfo-item
|
||||||
display: flex
|
display: flex
|
||||||
align-items: center
|
align-items: center
|
||||||
padding: 4px 0 0
|
padding: .1rem .5rem 0
|
||||||
|
|
||||||
div
|
div
|
||||||
&:first-child
|
&:first-child
|
||||||
|
|||||||
@@ -188,13 +188,13 @@ _:future,
|
|||||||
padding: 0 16px
|
padding: 0 16px
|
||||||
|
|
||||||
&:not(.fixed)
|
&:not(.fixed)
|
||||||
.menus
|
#menus
|
||||||
padding-right: 0 !important
|
padding-right: 0 !important
|
||||||
|
|
||||||
#blog_name
|
#blog_name
|
||||||
flex: 1
|
flex: 1
|
||||||
|
|
||||||
.toggle-menu
|
#toggle-menu
|
||||||
display: none
|
display: none
|
||||||
padding: .1rem 0 0 .3rem
|
padding: .1rem 0 0 .3rem
|
||||||
vertical-align: top
|
vertical-align: top
|
||||||
@@ -218,7 +218,7 @@ _:future,
|
|||||||
|
|
||||||
a,
|
a,
|
||||||
#site-name,
|
#site-name,
|
||||||
.toggle-menu
|
#toggle-menu
|
||||||
color: var(--font-color)
|
color: var(--font-color)
|
||||||
text-shadow: none
|
text-shadow: none
|
||||||
|
|
||||||
@@ -302,7 +302,7 @@ _:future,
|
|||||||
text-shadow: none
|
text-shadow: none
|
||||||
|
|
||||||
&.hide-menu
|
&.hide-menu
|
||||||
.toggle-menu
|
#toggle-menu
|
||||||
display: inline-block !important
|
display: inline-block !important
|
||||||
|
|
||||||
.site-page
|
.site-page
|
||||||
|
|||||||
@@ -1,53 +1,54 @@
|
|||||||
.relatedPosts
|
.relatedPosts
|
||||||
margin-top: 1rem
|
margin-top: 1rem
|
||||||
|
|
||||||
.relatedPosts_headline
|
& > .headline
|
||||||
margin-bottom: 5px
|
margin-bottom: 5px
|
||||||
font-weight: 700
|
font-weight: 700
|
||||||
font-size: 1.43em
|
font-size: 1.43em
|
||||||
|
|
||||||
.relatedPosts_item
|
& > .relatedPosts-list
|
||||||
position: relative
|
& > div
|
||||||
display: inline-block
|
position: relative
|
||||||
overflow: hidden
|
display: inline-block
|
||||||
margin: 3px
|
overflow: hidden
|
||||||
width: calc(33.333% - 6px)
|
margin: 3px
|
||||||
height: 200px
|
width: calc(33.333% - 6px)
|
||||||
background: $dark-black
|
height: 200px
|
||||||
vertical-align: bottom
|
background: $dark-black
|
||||||
|
vertical-align: bottom
|
||||||
|
|
||||||
&:hover
|
&:hover
|
||||||
.relatedPosts_cover
|
.cover
|
||||||
opacity: .8
|
opacity: .8
|
||||||
transform: scale(1.1)
|
transform: scale(1.1)
|
||||||
|
|
||||||
+maxWidth768()
|
+maxWidth768()
|
||||||
margin: 2px
|
margin: 2px
|
||||||
width: calc(50% - 4px)
|
width: calc(50% - 4px)
|
||||||
height: 150px
|
height: 150px
|
||||||
|
|
||||||
+maxWidth600()
|
+maxWidth600()
|
||||||
width: calc(100% - 4px)
|
width: calc(100% - 4px)
|
||||||
|
|
||||||
.relatedPosts_cover
|
.cover
|
||||||
width: 100%
|
width: 100%
|
||||||
height: 100%
|
height: 100%
|
||||||
opacity: .4
|
opacity: .4
|
||||||
transition: all .6s
|
transition: all .6s
|
||||||
object-fit: cover
|
object-fit: cover
|
||||||
|
|
||||||
.relatedPosts_main
|
.content
|
||||||
position: absolute
|
position: absolute
|
||||||
top: 50%
|
top: 50%
|
||||||
padding: 0 1rem
|
padding: 0 1rem
|
||||||
width: 100%
|
width: 100%
|
||||||
transform: translate(0, -50%)
|
transform: translate(0, -50%)
|
||||||
|
|
||||||
.relatedPosts_date
|
.date
|
||||||
color: var(--light-grey)
|
color: var(--light-grey)
|
||||||
font-size: 90%
|
font-size: 90%
|
||||||
|
|
||||||
.relatedPosts_title
|
.title
|
||||||
@extend .limit-more-line
|
@extend .limit-more-line
|
||||||
color: var(--white)
|
color: var(--white)
|
||||||
-webkit-line-clamp: 2
|
-webkit-line-clamp: 2
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ if hexo-config('darkmode.enable') || hexo-config('display_mode') == 'dark'
|
|||||||
.gist,
|
.gist,
|
||||||
.aplayer
|
.aplayer
|
||||||
filter: brightness(.7)
|
filter: brightness(.7)
|
||||||
|
|
||||||
#aside_content .aside-list > .aside-list-item:not(:last-child)
|
#aside_content .aside-list > .aside-list-item:not(:last-child)
|
||||||
border-bottom: 1px dashed alpha(#FFFFFF, .1)
|
border-bottom: 1px dashed alpha(#FFFFFF, .1)
|
||||||
|
|
||||||
|
|||||||
1319
source/js/main.js
1319
source/js/main.js
File diff suppressed because it is too large
Load Diff
2
source/js/third-party/fireworks.js
vendored
2
source/js/third-party/fireworks.js
vendored
@@ -9,7 +9,7 @@ if (canvasEl) {
|
|||||||
var tap = 'mousedown'
|
var tap = 'mousedown'
|
||||||
var colors = ['#FF1461', '#18FF92', '#5A87FF', '#FBF38C']
|
var colors = ['#FF1461', '#18FF92', '#5A87FF', '#FBF38C']
|
||||||
|
|
||||||
var setCanvasSize = debounce(function () {
|
var setCanvasSize = btf.debounce(function () {
|
||||||
canvasEl.width = window.innerWidth
|
canvasEl.width = window.innerWidth
|
||||||
canvasEl.height = window.innerHeight
|
canvasEl.height = window.innerHeight
|
||||||
canvasEl.style.width = window.innerWidth + 'px'
|
canvasEl.style.width = window.innerWidth + 'px'
|
||||||
|
|||||||
@@ -50,14 +50,14 @@
|
|||||||
translateButtonObject.innerHTML = msgToTraditionalChinese
|
translateButtonObject.innerHTML = msgToTraditionalChinese
|
||||||
saveToLocal.set(targetEncodingCookie, targetEncoding, 2)
|
saveToLocal.set(targetEncodingCookie, targetEncoding, 2)
|
||||||
translateBody()
|
translateBody()
|
||||||
if (isSnackbar) snackbarShow(snackbarData.cht_to_chs)
|
if (isSnackbar) btf.snackbarShow(snackbarData.cht_to_chs)
|
||||||
} else if (targetEncoding === 2) {
|
} else if (targetEncoding === 2) {
|
||||||
currentEncoding = 2
|
currentEncoding = 2
|
||||||
targetEncoding = 1
|
targetEncoding = 1
|
||||||
translateButtonObject.innerHTML = msgToSimplifiedChinese
|
translateButtonObject.innerHTML = msgToSimplifiedChinese
|
||||||
saveToLocal.set(targetEncodingCookie, targetEncoding, 2)
|
saveToLocal.set(targetEncodingCookie, targetEncoding, 2)
|
||||||
translateBody()
|
translateBody()
|
||||||
if (isSnackbar) snackbarShow(snackbarData.chs_to_cht)
|
if (isSnackbar) btf.snackbarShow(snackbarData.chs_to_cht)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function JTPYStr () {
|
function JTPYStr () {
|
||||||
|
|||||||
@@ -1,134 +1,136 @@
|
|||||||
/* eslint-disable no-unused-vars */
|
/* eslint-disable no-unused-vars */
|
||||||
|
|
||||||
function debounce (func, wait, immediate) {
|
var btf = {
|
||||||
let timeout
|
debounce: function (func, wait, immediate) {
|
||||||
return function () {
|
let timeout
|
||||||
const context = this
|
return function () {
|
||||||
const args = arguments
|
const context = this
|
||||||
const later = function () {
|
const args = arguments
|
||||||
timeout = null
|
const later = function () {
|
||||||
if (!immediate) func.apply(context, args)
|
|
||||||
}
|
|
||||||
const callNow = immediate && !timeout
|
|
||||||
clearTimeout(timeout)
|
|
||||||
timeout = setTimeout(later, wait)
|
|
||||||
if (callNow) func.apply(context, args)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function throttle (func, wait, options) {
|
|
||||||
let timeout, context, args
|
|
||||||
let previous = 0
|
|
||||||
if (!options) options = {}
|
|
||||||
|
|
||||||
const later = function () {
|
|
||||||
previous = options.leading === false ? 0 : new Date().getTime()
|
|
||||||
timeout = null
|
|
||||||
func.apply(context, args)
|
|
||||||
if (!timeout) context = args = null
|
|
||||||
}
|
|
||||||
|
|
||||||
const throttled = function () {
|
|
||||||
const now = new Date().getTime()
|
|
||||||
if (!previous && options.leading === false) previous = now
|
|
||||||
const remaining = wait - (now - previous)
|
|
||||||
context = this
|
|
||||||
args = arguments
|
|
||||||
if (remaining <= 0 || remaining > wait) {
|
|
||||||
if (timeout) {
|
|
||||||
clearTimeout(timeout)
|
|
||||||
timeout = null
|
timeout = null
|
||||||
|
if (!immediate) func.apply(context, args)
|
||||||
}
|
}
|
||||||
previous = now
|
const callNow = immediate && !timeout
|
||||||
|
clearTimeout(timeout)
|
||||||
|
timeout = setTimeout(later, wait)
|
||||||
|
if (callNow) func.apply(context, args)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
throttle: function (func, wait, options) {
|
||||||
|
let timeout, context, args
|
||||||
|
let previous = 0
|
||||||
|
if (!options) options = {}
|
||||||
|
|
||||||
|
const later = function () {
|
||||||
|
previous = options.leading === false ? 0 : new Date().getTime()
|
||||||
|
timeout = null
|
||||||
func.apply(context, args)
|
func.apply(context, args)
|
||||||
if (!timeout) context = args = null
|
if (!timeout) context = args = null
|
||||||
} else if (!timeout && options.trailing !== false) {
|
|
||||||
timeout = setTimeout(later, remaining)
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return throttled
|
const throttled = function () {
|
||||||
}
|
const now = new Date().getTime()
|
||||||
|
if (!previous && options.leading === false) previous = now
|
||||||
function sidebarPaddingR () {
|
const remaining = wait - (now - previous)
|
||||||
const innerWidth = window.innerWidth
|
context = this
|
||||||
const clientWidth = document.body.clientWidth
|
args = arguments
|
||||||
const paddingRight = innerWidth - clientWidth
|
if (remaining <= 0 || remaining > wait) {
|
||||||
if (innerWidth !== clientWidth) {
|
if (timeout) {
|
||||||
$('body').css('padding-right', paddingRight)
|
clearTimeout(timeout)
|
||||||
}
|
timeout = null
|
||||||
}
|
}
|
||||||
|
previous = now
|
||||||
function scrollToDest (name) {
|
func.apply(context, args)
|
||||||
const scrollOffset = $(name).offset().top
|
if (!timeout) context = args = null
|
||||||
let offset
|
} else if (!timeout && options.trailing !== false) {
|
||||||
if ($(window).scrollTop() > scrollOffset) {
|
timeout = setTimeout(later, remaining)
|
||||||
offset = 65
|
|
||||||
} else {
|
|
||||||
offset = 0
|
|
||||||
}
|
|
||||||
$('body,html').animate({
|
|
||||||
scrollTop: scrollOffset - offset
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function snackbarShow (text, showAction, duration) {
|
|
||||||
const sa = (typeof showAction !== 'undefined') ? showAction : false
|
|
||||||
const dur = (typeof duration !== 'undefined') ? duration : 2000
|
|
||||||
const position = GLOBAL_CONFIG.Snackbar.position
|
|
||||||
const bg = document.documentElement.getAttribute('data-theme') === 'light' ? GLOBAL_CONFIG.Snackbar.bgLight : GLOBAL_CONFIG.Snackbar.bgDark
|
|
||||||
Snackbar.show({
|
|
||||||
text: text,
|
|
||||||
backgroundColor: bg,
|
|
||||||
showAction: sa,
|
|
||||||
duration: dur,
|
|
||||||
pos: position
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const initJustifiedGallery = function (selector) {
|
|
||||||
selector.each(function (i, o) {
|
|
||||||
if ($(this).is(':visible')) {
|
|
||||||
$(this).justifiedGallery({
|
|
||||||
rowHeight: 220,
|
|
||||||
margins: 4
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const diffDate = (d, more = false) => {
|
|
||||||
const dateNow = new Date()
|
|
||||||
const datePost = new Date(d)
|
|
||||||
const dateDiff = dateNow.getTime() - datePost.getTime()
|
|
||||||
const dayDiff = Math.floor(dateDiff / (24 * 3600 * 1000))
|
|
||||||
let result
|
|
||||||
if (more) {
|
|
||||||
if (dateDiff <= 3600000) { // < 1 hour
|
|
||||||
result = GLOBAL_CONFIG.date_suffix.one_hour
|
|
||||||
} else if (dateDiff < 3600000 * 24) { // 1 hour < x < 24 hours
|
|
||||||
result = Math.floor(dateDiff / 3600000) + ' ' + GLOBAL_CONFIG.date_suffix.hours
|
|
||||||
} else if (dayDiff >= 1 || dayDiff < 365) { // 1 day < x < 365 days
|
|
||||||
result = dayDiff + ' ' + GLOBAL_CONFIG.date_suffix.day
|
|
||||||
} else { // > 365 days
|
|
||||||
result = d.toLocaleDateString().replace(/\//g, '-')
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
result = dayDiff
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
const loadComment = (dom, callback) => {
|
|
||||||
if ('IntersectionObserver' in window) {
|
|
||||||
const observerItem = new IntersectionObserver((entries) => {
|
|
||||||
if (entries[0].isIntersecting) {
|
|
||||||
callback()
|
|
||||||
observerItem.disconnect()
|
|
||||||
}
|
}
|
||||||
}, { threshold: [0] })
|
}
|
||||||
observerItem.observe(dom)
|
|
||||||
} else {
|
return throttled
|
||||||
callback()
|
},
|
||||||
|
|
||||||
|
sidebarPaddingR: () => {
|
||||||
|
const innerWidth = window.innerWidth
|
||||||
|
const clientWidth = document.body.clientWidth
|
||||||
|
const paddingRight = innerWidth - clientWidth
|
||||||
|
if (innerWidth !== clientWidth) {
|
||||||
|
$('body').css('padding-right', paddingRight)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
scrollToDest: name => {
|
||||||
|
const scrollOffset = $(name).offset().top
|
||||||
|
let offset
|
||||||
|
if ($(window).scrollTop() > scrollOffset) {
|
||||||
|
offset = 65
|
||||||
|
} else {
|
||||||
|
offset = 0
|
||||||
|
}
|
||||||
|
$('body,html').animate({
|
||||||
|
scrollTop: scrollOffset - offset
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
snackbarShow: (text, showAction, duration) => {
|
||||||
|
const sa = (typeof showAction !== 'undefined') ? showAction : false
|
||||||
|
const dur = (typeof duration !== 'undefined') ? duration : 2000
|
||||||
|
const position = GLOBAL_CONFIG.Snackbar.position
|
||||||
|
const bg = document.documentElement.getAttribute('data-theme') === 'light' ? GLOBAL_CONFIG.Snackbar.bgLight : GLOBAL_CONFIG.Snackbar.bgDark
|
||||||
|
Snackbar.show({
|
||||||
|
text: text,
|
||||||
|
backgroundColor: bg,
|
||||||
|
showAction: sa,
|
||||||
|
duration: dur,
|
||||||
|
pos: position
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
initJustifiedGallery: function (selector) {
|
||||||
|
selector.each(function (i, o) {
|
||||||
|
if ($(this).is(':visible')) {
|
||||||
|
$(this).justifiedGallery({
|
||||||
|
rowHeight: 220,
|
||||||
|
margins: 4
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
diffDate: (d, more = false) => {
|
||||||
|
const dateNow = new Date()
|
||||||
|
const datePost = new Date(d)
|
||||||
|
const dateDiff = dateNow.getTime() - datePost.getTime()
|
||||||
|
const dayDiff = Math.floor(dateDiff / (24 * 3600 * 1000))
|
||||||
|
let result
|
||||||
|
if (more) {
|
||||||
|
if (dateDiff <= 3600000) { // < 1 hour
|
||||||
|
result = GLOBAL_CONFIG.date_suffix.one_hour
|
||||||
|
} else if (dateDiff < 3600000 * 24) { // 1 hour < x < 24 hours
|
||||||
|
result = Math.floor(dateDiff / 3600000) + ' ' + GLOBAL_CONFIG.date_suffix.hours
|
||||||
|
} else if (dayDiff >= 1 || dayDiff < 365) { // 1 day < x < 365 days
|
||||||
|
result = dayDiff + ' ' + GLOBAL_CONFIG.date_suffix.day
|
||||||
|
} else { // > 365 days
|
||||||
|
result = d.toLocaleDateString().replace(/\//g, '-')
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
result = dayDiff
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
},
|
||||||
|
|
||||||
|
loadComment: (dom, callback) => {
|
||||||
|
if ('IntersectionObserver' in window) {
|
||||||
|
const observerItem = new IntersectionObserver((entries) => {
|
||||||
|
if (entries[0].isIntersecting) {
|
||||||
|
callback()
|
||||||
|
observerItem.disconnect()
|
||||||
|
}
|
||||||
|
}, { threshold: [0] })
|
||||||
|
observerItem.observe(dom)
|
||||||
|
} else {
|
||||||
|
callback()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user