Merge pull request #836 from Android-KitKat/fix-related-post

fix: 标题中带有 HTML 关键字时,会破坏相关推荐的渲染。
pull/858/head
Jerry Wong 3 years ago committed by GitHub
commit ee3c143424
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -54,14 +54,14 @@ hexo.extend.helper.register('related_posts', function (currentPost, allPosts) {
relatedPosts[i].cover === false
? relatedPosts[i].randomcover
: relatedPosts[i].cover
result += `<div><a href="${this.url_for(relatedPosts[i].path)}" title="${relatedPosts[i].title}">`
result += `<div><a href="${this.url_for(relatedPosts[i].path)}" title="${this.escape_html(relatedPosts[i].title)}">`
result += `<img class="cover" src="${this.url_for(cover)}" alt="cover">`
if (dateType === 'created') {
result += `<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)}</div>`
} else {
result += `<div class="content is-center"><div class="date"><i class="fas fa-history fa-fw"></i> ${this.date(relatedPosts[i].updated, hexoConfig.date_format)}</div>`
}
result += `<div class="title">${relatedPosts[i].title}</div>`
result += `<div class="title">${this.escape_html(relatedPosts[i].title)}</div>`
result += '</div></a></div>'
}

Loading…
Cancel
Save