由於整合了多個設定並更改了部分設定名稱,升級到 5.0 版本時,請重新設定 `_config.yml` 文件。
1. 新增 macstyle 設定,取消 mac / mac light 主題設定 2. 整合搜索相關設定 3. 修改程式碼區塊設定 4. 主頁文章新增多種版面配置 5. 新增說說頁面 6. 適配 hexo-blog-encrypt 加密插件 7. 改善手機端目錄的開啟效果 8. 新增平滑滾動功能 9. 支持以程式碼區塊方式撰寫 mermaid 圖表 10. 可自訂文章標題位置 11. 新增程式碼全螢幕按鈕 12. 友情連結頭像改為圓角設計 13. 優化程式碼,使用 hexo-util 的參數和 hexo 內建參數 14. 可自訂搜索框提示文字 15. 未設定選單時,不顯示側邊欄目錄和按鈕 16. 螢幕寬度超過 2000px 時,增加卡片高度 17. 根據語言設定調整字體:簡體中文使用雅黑,其他使用正黑體 18. 更新 plugins.yml 19. 全新的側邊欄界面設計 20. 新增 giscus 的 js 設定 21. 調整 utterances js 的設定位置 22. 新增 utterances option 設定 23. 修改 giscus 的主題設定 24. 多個界面元素改為圓角設計 25. 可選擇圓角或直角界面風格 26. 圖庫加載按鈕新增圖標 27. 改善標籤頁面的滑鼠懸停效果 28. 調整側邊欄的滑鼠懸停效果 29. 微調部分界面元素 1. 修復 Hexo 新版本下 Prism.js 無法正確高亮的問題 2. 修復文章標籤為空時可能出現的錯誤 3. 修正 mermaid 圖表可能出現的錯誤 4. 解決未設定選單時控制台報錯的問題 5. 修復 Algolia 搜索的每頁顯示數量設定無效的問題 6. 解決 Algolia 搜索結果出現滾動條的問題 7. 修正滾動條出現上下按鈕的問題 8. 修復圖庫遠程連結未加前綴的問題 9. 修正 label 標籤外掛右側多餘空格的問題 10. 解決 APlayer 報告內存洩漏的問題 1. 優化 PJAX 下的函數調用 2. 整體代碼優化 3. 提升兼容性 4. 改善 Lighthouse 評分 5. 在 PJAX 關閉時減少不必要的全局變量 6. 優化 Waline 的 import 兼容性 7. 改善頁面進入效果 8. 優化程式碼區塊工具列顯示邏輯 9. 改善不同螢幕寬度下文章標題位置的顯示 10. 優化標籤顏色生成算法,避免過暗或過亮 11. 調整 Artalk 和 Waline 在夜間模式下的字體顏色,與主題保持一致 12. 調整 Algolia 搜索加載動畫位置,避免換行 13. 優化 Algolia 搜索結果為空時的處理 14. 改善系列文章的滑鼠懸停效果 15. 優化 404 頁面代碼 16. 解決搜索和側邊欄開啟時窗口抖動的問題 17. 優化 tabs 標籤外掛的代碼和效能 18. 改善 tabs 中使用 gallery 標籤外掛時的圖片加載邏輯 19. 優化目錄滾動效果,使當前標題保持在中間 20. 調整螢幕寬度超過 1024px 時 gallerygroup 的顯示數量pull/1550/head
parent
0d52505331
commit
06f543ed96
File diff suppressed because it is too large
Load Diff
@ -1,12 +0,0 @@
|
||||
- var top_img_404 = theme.error_404.background || theme.default_top_img
|
||||
|
||||
#body-wrap.error404
|
||||
include ./header/index.pug
|
||||
|
||||
#error-wrap
|
||||
.error-content
|
||||
.error-img
|
||||
img(src=url_for(top_img_404) alt='Page not found')
|
||||
.error-info
|
||||
h1.error_title= '404'
|
||||
.error_subtitle= theme.error_404.subtitle || _p('error404')
|
@ -0,0 +1,125 @@
|
||||
mixin indexPostUI()
|
||||
- let indexLayout = theme.index_layout
|
||||
- let masonryLayoutClass = (indexLayout === 6 || indexLayout === 7) ? 'masonry' : ''
|
||||
#recent-posts.recent-posts.nc(class=masonryLayoutClass)
|
||||
.recent-post-items
|
||||
each article , index in page.posts.data
|
||||
.recent-post-item
|
||||
-
|
||||
let link = article.link || article.path
|
||||
let title = article.title || _p('no_title')
|
||||
let leftOrRight = indexLayout === 3
|
||||
? index%2 == 0 ? 'left' : 'right'
|
||||
: indexLayout === 2 ? 'right' : ''
|
||||
let post_cover = article.cover
|
||||
let no_cover = article.cover === false || !theme.cover.index_enable ? 'no-cover' : ''
|
||||
-
|
||||
if post_cover && theme.cover.index_enable
|
||||
.post_cover(class=leftOrRight)
|
||||
a(href=url_for(link) title=title)
|
||||
if article.cover_type === 'img'
|
||||
img.post-bg(src=url_for(post_cover) onerror=`this.onerror=null;this.src='${url_for(theme.error_img.post_page)}'` alt=title)
|
||||
else
|
||||
div.post-bg(style=`background: ${post_cover}`)
|
||||
.recent-post-info(class=no_cover)
|
||||
a.article-title(href=url_for(link) title=title)
|
||||
if (is_home() && (article.top || article.sticky > 0))
|
||||
i.fas.fa-thumbtack.sticky
|
||||
= title
|
||||
.article-meta-wrap
|
||||
if (theme.post_meta.page.date_type)
|
||||
span.post-meta-date
|
||||
if (theme.post_meta.page.date_type === 'both')
|
||||
i.far.fa-calendar-alt
|
||||
span.article-meta-label=_p('post.created')
|
||||
time.post-meta-date-created(datetime=date_xml(article.date) title=_p('post.created') + ' ' + full_date(article.date))=date(article.date, config.date_format)
|
||||
span.article-meta-separator |
|
||||
i.fas.fa-history
|
||||
span.article-meta-label=_p('post.updated')
|
||||
time.post-meta-date-updated(datetime=date_xml(article.updated) title=_p('post.updated') + ' ' + full_date(article.updated))=date(article.updated, config.date_format)
|
||||
else
|
||||
- let data_type_updated = theme.post_meta.page.date_type === 'updated'
|
||||
- let date_type = data_type_updated ? 'updated' : 'date'
|
||||
- let date_icon = data_type_updated ? 'fas fa-history' :'far fa-calendar-alt'
|
||||
- let date_title = data_type_updated ? _p('post.updated') : _p('post.created')
|
||||
i(class=date_icon)
|
||||
span.article-meta-label=date_title
|
||||
time(datetime=date_xml(article[date_type]) title=date_title + ' ' + full_date(article[date_type]))=date(article[date_type], config.date_format)
|
||||
if (theme.post_meta.page.categories && article.categories.data.length > 0)
|
||||
span.article-meta
|
||||
span.article-meta-separator |
|
||||
each item, index in article.categories.data
|
||||
i.fas.fa-inbox
|
||||
a(href=url_for(item.path)).article-meta__categories #[=item.name]
|
||||
if (index < article.categories.data.length - 1)
|
||||
i.fas.fa-angle-right.article-meta-link
|
||||
if (theme.post_meta.page.tags && article.tags.length > 0)
|
||||
span.article-meta.tags
|
||||
span.article-meta-separator |
|
||||
each item, index in article.tags.data
|
||||
i.fas.fa-tag
|
||||
a(href=url_for(item.path)).article-meta__tags #[=item.name]
|
||||
if (index < article.tags.data.length - 1)
|
||||
span.article-meta-link #[='•']
|
||||
|
||||
mixin countBlockInIndex
|
||||
- needLoadCountJs = true
|
||||
span.article-meta
|
||||
span.article-meta-separator |
|
||||
i.fas.fa-comments
|
||||
if block
|
||||
block
|
||||
span.article-meta-label= ' ' + _p('card_post_count')
|
||||
|
||||
if theme.comments.card_post_count && theme.comments.use
|
||||
case theme.comments.use[0]
|
||||
when 'Disqus'
|
||||
when 'Disqusjs'
|
||||
+countBlockInIndex
|
||||
a.disqus-count(href=full_url_for(link) + '#post-comment')
|
||||
i.fa-solid.fa-spinner.fa-spin
|
||||
when 'Valine'
|
||||
+countBlockInIndex
|
||||
a(href=url_for(link) + '#post-comment')
|
||||
span.valine-comment-count(data-xid=url_for(link))
|
||||
i.fa-solid.fa-spinner.fa-spin
|
||||
when 'Waline'
|
||||
+countBlockInIndex
|
||||
a(href=url_for(link) + '#post-comment')
|
||||
span.waline-comment-count(data-path=url_for(link))
|
||||
i.fa-solid.fa-spinner.fa-spin
|
||||
when 'Twikoo'
|
||||
+countBlockInIndex
|
||||
a.twikoo-count(href=url_for(link) + '#post-comment')
|
||||
i.fa-solid.fa-spinner.fa-spin
|
||||
when 'Facebook Comments'
|
||||
+countBlockInIndex
|
||||
a(href=url_for(link) + '#post-comment')
|
||||
span.fb-comments-count(data-href=urlNoIndex(article.permalink))
|
||||
when 'Remark42'
|
||||
+countBlockInIndex
|
||||
a(href=url_for(link) + '#post-comment')
|
||||
span.remark42__counter(data-url=urlNoIndex(article.permalink))
|
||||
i.fa-solid.fa-spinner.fa-spin
|
||||
when 'Artalk'
|
||||
+countBlockInIndex
|
||||
a(href=url_for(link) + '#post-comment')
|
||||
span.artalk-count(data-page-key=url_for(link))
|
||||
i.fa-solid.fa-spinner.fa-spin
|
||||
|
||||
//- Display the article introduction on homepage
|
||||
case theme.index_post_content.method
|
||||
when false
|
||||
- break
|
||||
when 1
|
||||
.content!= article.description
|
||||
when 2
|
||||
.content!= article.description || truncate(article.content, theme.index_post_content.length)
|
||||
default
|
||||
.content!= truncate(article.content, theme.index_post_content.length)
|
||||
|
||||
if theme.ad && theme.ad.index
|
||||
if (index + 1) % 3 == 0
|
||||
.recent-post-item.ads-wrap!=theme.ad.index
|
||||
|
||||
include ../pagination.pug
|
@ -1,129 +0,0 @@
|
||||
mixin postUI(posts)
|
||||
each article , index in page.posts.data
|
||||
.recent-post-item
|
||||
-
|
||||
let link = article.link || article.path
|
||||
let title = article.title || _p('no_title')
|
||||
const position = theme.cover.position
|
||||
let leftOrRight = position === 'both'
|
||||
? index%2 == 0 ? 'left' : 'right'
|
||||
: position === 'left' ? 'left' : 'right'
|
||||
let post_cover = article.cover
|
||||
let no_cover = article.cover === false || !theme.cover.index_enable ? 'no-cover' : ''
|
||||
-
|
||||
if post_cover && theme.cover.index_enable
|
||||
.post_cover(class=leftOrRight)
|
||||
a(href=url_for(link) title=title)
|
||||
if article.cover_type === 'img'
|
||||
img.post-bg(src=url_for(post_cover) onerror=`this.onerror=null;this.src='${url_for(theme.error_img.post_page)}'` alt=title)
|
||||
else
|
||||
div.post-bg(style=`background: ${post_cover}`)
|
||||
.recent-post-info(class=no_cover)
|
||||
a.article-title(href=url_for(link) title=title)
|
||||
if (is_home() && (article.top || article.sticky > 0))
|
||||
i.fas.fa-thumbtack.sticky
|
||||
= title
|
||||
.article-meta-wrap
|
||||
if (theme.post_meta.page.date_type)
|
||||
span.post-meta-date
|
||||
if (theme.post_meta.page.date_type === 'both')
|
||||
i.far.fa-calendar-alt
|
||||
span.article-meta-label=_p('post.created')
|
||||
time.post-meta-date-created(datetime=date_xml(article.date) title=_p('post.created') + ' ' + full_date(article.date))=date(article.date, config.date_format)
|
||||
span.article-meta-separator |
|
||||
i.fas.fa-history
|
||||
span.article-meta-label=_p('post.updated')
|
||||
time.post-meta-date-updated(datetime=date_xml(article.updated) title=_p('post.updated') + ' ' + full_date(article.updated))=date(article.updated, config.date_format)
|
||||
else
|
||||
- let data_type_updated = theme.post_meta.page.date_type === 'updated'
|
||||
- let date_type = data_type_updated ? 'updated' : 'date'
|
||||
- let date_icon = data_type_updated ? 'fas fa-history' :'far fa-calendar-alt'
|
||||
- let date_title = data_type_updated ? _p('post.updated') : _p('post.created')
|
||||
i(class=date_icon)
|
||||
span.article-meta-label=date_title
|
||||
time(datetime=date_xml(article[date_type]) title=date_title + ' ' + full_date(article[date_type]))=date(article[date_type], config.date_format)
|
||||
if (theme.post_meta.page.categories && article.categories.data.length > 0)
|
||||
span.article-meta
|
||||
span.article-meta-separator |
|
||||
each item, index in article.categories.data
|
||||
i.fas.fa-inbox
|
||||
a(href=url_for(item.path)).article-meta__categories #[=item.name]
|
||||
if (index < article.categories.data.length - 1)
|
||||
i.fas.fa-angle-right.article-meta-link
|
||||
if (theme.post_meta.page.tags && article.tags.data.length > 0)
|
||||
span.article-meta.tags
|
||||
span.article-meta-separator |
|
||||
each item, index in article.tags.data
|
||||
i.fas.fa-tag
|
||||
a(href=url_for(item.path)).article-meta__tags #[=item.name]
|
||||
if (index < article.tags.data.length - 1)
|
||||
span.article-meta-link #[='•']
|
||||
|
||||
mixin countBlockInIndex
|
||||
- needLoadCountJs = true
|
||||
span.article-meta
|
||||
span.article-meta-separator |
|
||||
i.fas.fa-comments
|
||||
if block
|
||||
block
|
||||
span.article-meta-label= ' ' + _p('card_post_count')
|
||||
|
||||
if theme.comments.card_post_count && theme.comments.use
|
||||
case theme.comments.use[0]
|
||||
when 'Disqus'
|
||||
when 'Disqusjs'
|
||||
+countBlockInIndex
|
||||
a.disqus-count(href=full_url_for(link) + '#post-comment')
|
||||
i.fa-solid.fa-spinner.fa-spin
|
||||
when 'Valine'
|
||||
+countBlockInIndex
|
||||
a(href=url_for(link) + '#post-comment')
|
||||
span.valine-comment-count(data-xid=url_for(link))
|
||||
i.fa-solid.fa-spinner.fa-spin
|
||||
when 'Waline'
|
||||
+countBlockInIndex
|
||||
a(href=url_for(link) + '#post-comment')
|
||||
span.waline-comment-count(data-path=url_for(link))
|
||||
i.fa-solid.fa-spinner.fa-spin
|
||||
when 'Twikoo'
|
||||
+countBlockInIndex
|
||||
a.twikoo-count(href=url_for(link) + '#post-comment')
|
||||
i.fa-solid.fa-spinner.fa-spin
|
||||
when 'Facebook Comments'
|
||||
+countBlockInIndex
|
||||
a(href=url_for(link) + '#post-comment')
|
||||
span.fb-comments-count(data-href=urlNoIndex(article.permalink))
|
||||
when 'Remark42'
|
||||
+countBlockInIndex
|
||||
a(href=url_for(link) + '#post-comment')
|
||||
span.remark42__counter(data-url=urlNoIndex(article.permalink))
|
||||
i.fa-solid.fa-spinner.fa-spin
|
||||
when 'Artalk'
|
||||
+countBlockInIndex
|
||||
a(href=url_for(link) + '#post-comment')
|
||||
span.artalk-count(data-page-key=url_for(link))
|
||||
i.fa-solid.fa-spinner.fa-spin
|
||||
|
||||
//- Display the article introduction on homepage
|
||||
case theme.index_post_content.method
|
||||
when false
|
||||
- break
|
||||
when 1
|
||||
.content!= article.description
|
||||
when 2
|
||||
if article.description
|
||||
.content!= article.description
|
||||
else
|
||||
- const content = strip_html(article.content)
|
||||
- let expert = content.substring(0, theme.index_post_content.length)
|
||||
- content.length > theme.index_post_content.length ? expert += ' ...' : ''
|
||||
.content!= expert
|
||||
default
|
||||
- const content = strip_html(article.content)
|
||||
- let expert = content.substring(0, theme.index_post_content.length)
|
||||
- content.length > theme.index_post_content.length ? expert += ' ...' : ''
|
||||
.content!= expert
|
||||
|
||||
if theme.ad && theme.ad.index
|
||||
if (index + 1) % 3 == 0
|
||||
.recent-post-item.ads-wrap!=theme.ad.index
|
@ -0,0 +1,8 @@
|
||||
- var top_img_404 = theme.error_404.background || theme.default_top_img
|
||||
|
||||
.error-content
|
||||
.error-img
|
||||
img(src=url_for(top_img_404) alt='Page not found')
|
||||
.error-info
|
||||
h1.error_title= '404'
|
||||
.error_subtitle= theme.error_404.subtitle || _p('error404')
|
@ -0,0 +1,103 @@
|
||||
//- - author:
|
||||
//- avatar:
|
||||
//- date:
|
||||
//- content:
|
||||
//- tags:
|
||||
//- - tag1
|
||||
//- - tag2
|
||||
|
||||
|
||||
- page.comments = false
|
||||
- page.toc = false
|
||||
#article-container
|
||||
if page.shuoshuo_url
|
||||
script.
|
||||
(() => {
|
||||
const loadShuoshuo = async () => {
|
||||
try {
|
||||
const fetchContent = await fetch('!{url_for(page.shuoshuo_url)}')
|
||||
const shuoshuo = await fetchContent.json()
|
||||
|
||||
let start = 0
|
||||
const container = document.getElementById('article-container')
|
||||
|
||||
const addData = data => {
|
||||
const cLength = data.length
|
||||
const end = start + 10 > cLength ? cLength : start + 10
|
||||
let result = ''
|
||||
data.slice(start, end).forEach((item) => {
|
||||
result += `
|
||||
<div class="shuoshuo-item">
|
||||
<div class="shuoshuo-item-header">
|
||||
<div class="shuoshuo-avatar">
|
||||
<img class="no-lightbox" src="${item.avatar || '!{url_for(theme.avatar.img)}'}">
|
||||
</div>
|
||||
<div class="shuoshuo-info">
|
||||
<div class="shuoshuo-author">${item.author || '!{config.author}'}</div>
|
||||
<div class="shuoshuo-date">${btf.diffDate(item.date, true)}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="shuoshuo-content">
|
||||
${item.content}
|
||||
</div>
|
||||
<div class="shuoshuo-footer">
|
||||
<div class="shuoshuo-tags">
|
||||
${item.tags.map(tag => `<span class="shuoshuo-tag">${tag}</span>`).join('')}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
})
|
||||
|
||||
start = end
|
||||
container.insertAdjacentHTML('beforeend', result)
|
||||
|
||||
if (start >= cLength) {
|
||||
observer.disconnect()
|
||||
} else {
|
||||
setTimeout(() => observer.observe(container.lastElementChild), 100)
|
||||
}
|
||||
|
||||
window.lazyLoadInstance.update()
|
||||
btf.loadLightbox(document.querySelectorAll('#article-container img:not(.no-lightbox)'))
|
||||
}
|
||||
|
||||
addData(shuoshuo)
|
||||
|
||||
const observer = new IntersectionObserver((entries) => {
|
||||
if (entries[0].isIntersecting) {
|
||||
observer.unobserve(entries[0].target)
|
||||
addData(shuoshuo)
|
||||
}
|
||||
}, {
|
||||
root: null,
|
||||
rootMargin: '0px',
|
||||
threshold: 1.0
|
||||
})
|
||||
|
||||
if (container.lastElementChild) {
|
||||
observer.observe(container.lastElementChild)
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
}
|
||||
|
||||
window.pjax ? loadShuoshuo() : window.addEventListener('load', loadShuoshuo)
|
||||
})()
|
||||
else
|
||||
if site.data.shuoshuo
|
||||
each i in site.data.shuoshuo
|
||||
.shuoshuo-item
|
||||
.shuoshuo-item-header
|
||||
.shuoshuo-avatar
|
||||
img.no-lightbox(src=i.avatar || url_for(theme.avatar.img))
|
||||
.shuoshuo-info
|
||||
.shuoshuo-author=i.author || config.author
|
||||
.shuoshuo-date=relative_date(i.date)
|
||||
.shuoshuo-content
|
||||
!=markdown(i.content)
|
||||
.shuoshuo-footer
|
||||
.shuoshuo-tags
|
||||
each tag in i.tags
|
||||
span.shuoshuo-tag=tag
|
@ -1,2 +1,2 @@
|
||||
.tag-cloud-list.is-center
|
||||
!=cloudTags({source: site.tags, orderby: page.orderby || 'random', order: page.order || 1, minfontsize: 1.2, maxfontsize: 2.1, limit: 0, unit: 'em'})
|
||||
!=cloudTags({source: site.tags, orderby: page.orderby || 'random', order: page.order || 1, minfontsize: 1.2, maxfontsize: 1.5, limit: 0, unit: 'em'})
|
@ -1,10 +1,11 @@
|
||||
if theme.chatra && theme.chatra.enable
|
||||
case theme.chat.use
|
||||
when 'chatra'
|
||||
include ./chatra.pug
|
||||
else if theme.tidio && theme.tidio.enable
|
||||
when 'tidio'
|
||||
include ./tidio.pug
|
||||
else if theme.daovoice && theme.daovoice.enable
|
||||
when 'daovoice'
|
||||
include ./daovoice.pug
|
||||
else if theme.crisp && theme.crisp.enable
|
||||
when 'crisp'
|
||||
include ./crisp.pug
|
||||
else if theme.messenger && theme.messenger.enable
|
||||
when 'messenger'
|
||||
include ./messenger.pug
|
@ -1,2 +1,16 @@
|
||||
link(rel="stylesheet" type="text/css" href=url_for(theme.asset.katex))
|
||||
script(src=url_for(theme.asset.katex_copytex))
|
||||
script.
|
||||
(async () => {
|
||||
const showKatex = () => {
|
||||
const mathElements = document.querySelectorAll('#article-container .katex')
|
||||
mathElements.length && mathElements.forEach((el) => {
|
||||
el.classList.add('katex-show')
|
||||
})
|
||||
}
|
||||
if (!window.katex_js_css) {
|
||||
window.katex_js_css = true
|
||||
await btf.getCSS('!{url_for(theme.asset.katex)}')
|
||||
if (!{theme.math.katex.copy_tex}) await btf.getScript('!{url_for(theme.asset.katex_copytex)}')
|
||||
}
|
||||
|
||||
showKatex()
|
||||
})()
|
@ -1,6 +1,7 @@
|
||||
if theme.algolia_search.enable
|
||||
case theme.search.use
|
||||
when 'algolia_search'
|
||||
include ./algolia.pug
|
||||
else if theme.local_search.enable
|
||||
when 'local_search'
|
||||
include ./local-search.pug
|
||||
else if theme.docsearch.enable
|
||||
when 'docsearch'
|
||||
include ./docsearch.pug
|
@ -1,5 +1,9 @@
|
||||
.post_share
|
||||
if theme.sharejs.enable
|
||||
include ./share-js.pug
|
||||
else if theme.addtoany.enable
|
||||
- const { use } = theme.share
|
||||
|
||||
if use
|
||||
.post-share
|
||||
case use
|
||||
when 'addtoany'
|
||||
!=partial('includes/third-party/share/addtoany', {}, {cache: true})
|
||||
when 'sharejs'
|
||||
include ./share-js.pug
|
@ -1,4 +1,4 @@
|
||||
- const coverVal = page.cover_type === 'img' ? page.cover : theme.avatar.img
|
||||
.social-share(data-image=url_for(coverVal) data-sites= theme.sharejs.sites)
|
||||
.social-share(data-image=url_for(coverVal) data-sites= theme.share.sharejs.sites)
|
||||
link(rel='stylesheet' href=url_for(theme.asset.sharejs_css) media="print" onload="this.media='all'")
|
||||
script(src=url_for(theme.asset.sharejs) defer)
|
@ -1,7 +1,5 @@
|
||||
extends includes/layout.pug
|
||||
|
||||
block content
|
||||
include ./includes/mixins/post-ui.pug
|
||||
#recent-posts.recent-posts
|
||||
+postUI
|
||||
include includes/pagination.pug
|
||||
include ./includes/mixins/indexPostUI.pug
|
||||
+indexPostUI
|
@ -1,20 +1,32 @@
|
||||
extends includes/layout.pug
|
||||
|
||||
block content
|
||||
#page
|
||||
if top_img === false
|
||||
- const noCardLayout = ['shuoshuo', '404'].includes(page.type) ? 'nc' : ''
|
||||
- var commentsJsLoad = false
|
||||
|
||||
mixin commentLoad
|
||||
if page.comments !== false && theme.comments.use
|
||||
- commentsJsLoad = true
|
||||
!=partial('includes/third-party/comments/index', {}, {cache: true})
|
||||
|
||||
#page(class=noCardLayout)
|
||||
if top_img === false && page.title
|
||||
h1.page-title= page.title
|
||||
|
||||
case page.type
|
||||
when 'tags'
|
||||
include includes/page/tags.pug
|
||||
+commentLoad
|
||||
when 'link'
|
||||
include includes/page/flink.pug
|
||||
+commentLoad
|
||||
when 'categories'
|
||||
include includes/page/categories.pug
|
||||
+commentLoad
|
||||
when '404'
|
||||
include includes/page/404.pug
|
||||
when 'shuoshuo'
|
||||
include includes/page/shuoshuo.pug
|
||||
default
|
||||
include includes/page/default-page.pug
|
||||
|
||||
if page.comments !== false && theme.comments && theme.comments.use
|
||||
- var commentsJsLoad = true
|
||||
!=partial('includes/third-party/comments/index', {}, {cache: true})
|
||||
+commentLoad
|
@ -1,58 +0,0 @@
|
||||
hexo.extend.helper.register('getArchiveLength', function () {
|
||||
const { archive_generator: archiveGenerator } = hexo.config
|
||||
if (archiveGenerator && archiveGenerator.enable === false) return this.site.posts.length
|
||||
const { yearly, monthly, daily } = archiveGenerator
|
||||
const { year, month, day } = this.page
|
||||
if (yearly === false || !year) return this.site.posts.length
|
||||
|
||||
const posts = this.site.posts.sort('date')
|
||||
|
||||
const compareFunc = (type, y1, m1, d1, y2, m2, d2) => {
|
||||
switch (type) {
|
||||
case 'year':
|
||||
return y1 === y2
|
||||
case 'month':
|
||||
return y1 === y2 && m1 === m2
|
||||
case 'day':
|
||||
return y1 === y2 && m1 === m2 && d1 === d2
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
const generateDateObj = (type) => {
|
||||
return posts.reduce((dateObj, post) => {
|
||||
const date = post.date.clone()
|
||||
const year = date.year()
|
||||
const month = date.month() + 1
|
||||
const day = date.date()
|
||||
const lastData = dateObj[dateObj.length - 1]
|
||||
|
||||
if (!lastData || !compareFunc(type, lastData.year, lastData.month, lastData.day, year, month, day)) {
|
||||
const name = type === 'year' ? year : type === 'month' ? `${year}-${month}` : `${year}-${month}-${day}`
|
||||
dateObj.push({
|
||||
name,
|
||||
year,
|
||||
month,
|
||||
day,
|
||||
count: 1
|
||||
})
|
||||
} else {
|
||||
lastData.count++
|
||||
}
|
||||
|
||||
return dateObj
|
||||
}, [])
|
||||
}
|
||||
|
||||
const data = this.fragment_cache('createArchiveObj', () => {
|
||||
const dateObjs = []
|
||||
if (yearly) dateObjs.push(...generateDateObj('year'))
|
||||
if (monthly) dateObjs.push(...generateDateObj('month'))
|
||||
if (daily) dateObjs.push(...generateDateObj('day'))
|
||||
return dateObjs
|
||||
})
|
||||
|
||||
const name = month ? (day ? `${year}-${month}-${day}` : `${year}-${month}`) : year
|
||||
return data.find(item => item.name === name).count
|
||||
})
|
@ -0,0 +1,45 @@
|
||||
hexo.extend.helper.register('getArchiveLength', function () {
|
||||
const archiveGenerator = hexo.config.archive_generator
|
||||
const posts = this.site.posts
|
||||
|
||||
const { yearly, monthly, daily } = archiveGenerator
|
||||
const { year, month, day } = this.page
|
||||
|
||||
// Archives Page
|
||||
if (!year) return posts.length
|
||||
|
||||
// Function to generate a unique key based on the granularity
|
||||
const getKey = (post, type) => {
|
||||
const date = post.date.clone()
|
||||
const y = date.year()
|
||||
const m = date.month() + 1
|
||||
const d = date.date()
|
||||
if (type === 'year') return `${y}`
|
||||
if (type === 'month') return `${y}-${m}`
|
||||
if (type === 'day') return `${y}-${m}-${d}`
|
||||
}
|
||||
|
||||
// Create a map to count posts per period
|
||||
const mapData = this.fragment_cache('createArchiveObj', () => {
|
||||
const map = new Map()
|
||||
posts.forEach(post => {
|
||||
const keyYear = getKey(post, 'year')
|
||||
const keyMonth = getKey(post, 'month')
|
||||
const keyDay = getKey(post, 'day')
|
||||
|
||||
if (yearly) map.set(keyYear, (map.get(keyYear) || 0) + 1)
|
||||
if (monthly) map.set(keyMonth, (map.get(keyMonth) || 0) + 1)
|
||||
if (daily) map.set(keyDay, (map.get(keyDay) || 0) + 1)
|
||||
})
|
||||
return map
|
||||
})
|
||||
|
||||
// Determine the appropriate key to fetch based on current page context
|
||||
let key
|
||||
if (yearly && year) key = `${year}`
|
||||
if (monthly && month) key = `${year}-${month}`
|
||||
if (daily && day) key = `${year}-${month}-${day}`
|
||||
|
||||
// Return the count for the current period or default to the total posts
|
||||
return mapData.get(key) || posts.length
|
||||
})
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue