mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-08-08 19:48:42 +08:00
update
This commit is contained in:
@@ -23,7 +23,6 @@ hexo.extend.helper.register('related_posts', function (currentPost) {
|
||||
if (relatedPosts.has(post.path)) {
|
||||
relatedPosts.get(post.path).weight += 1
|
||||
} else {
|
||||
const getPostDesc = post.postDesc || postDesc(post, hexo)
|
||||
relatedPosts.set(post.path, {
|
||||
title: post.title,
|
||||
path: post.path,
|
||||
@@ -32,7 +31,7 @@ hexo.extend.helper.register('related_posts', function (currentPost) {
|
||||
weight: 1,
|
||||
updated: post.updated,
|
||||
created: post.date,
|
||||
postDesc: getPostDesc,
|
||||
post,
|
||||
random: Math.random()
|
||||
})
|
||||
}
|
||||
@@ -61,12 +60,15 @@ hexo.extend.helper.register('related_posts', function (currentPost) {
|
||||
result += `<div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>${headlineLang}</span></div>`
|
||||
result += '<div class="relatedPosts-list">'
|
||||
|
||||
for (let i = 0; i < Math.min(relatedPostsList.length, limitNum); i++) {
|
||||
let { cover, title, path, cover_type, created, updated, postDesc } = relatedPostsList[i]
|
||||
const max = Math.min(relatedPostsList.length, limitNum)
|
||||
for (let i = 0; i < max; i++) {
|
||||
const item = relatedPostsList[i]
|
||||
let { cover, title, path, cover_type, created, updated, post } = item
|
||||
const { escape_html, url_for, date } = this
|
||||
cover = cover || 'var(--default-bg-color)'
|
||||
title = escape_html(title)
|
||||
const className = postDesc ? 'pagination-related' : 'pagination-related no-desc'
|
||||
const desc = post.postDesc || postDesc(post, hexo)
|
||||
const className = desc ? 'pagination-related' : 'pagination-related no-desc'
|
||||
result += `<a class="${className}" href="${url_for(path)}" title="${title}">`
|
||||
if (cover_type === 'img') {
|
||||
result += `<img class="cover" src="${url_for(cover)}" alt="cover">`
|
||||
@@ -80,8 +82,8 @@ hexo.extend.helper.register('related_posts', function (currentPost) {
|
||||
}
|
||||
result += `<div class="info-item-2">${title}</div></div>`
|
||||
|
||||
if (postDesc) {
|
||||
result += `<div class="info-2"><div class="info-item-1">${postDesc}</div></div>`
|
||||
if (desc) {
|
||||
result += `<div class="info-2"><div class="info-item-1">${desc}</div></div>`
|
||||
}
|
||||
result += '</div></a>'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user