Merge pull request #18 from Core00077/master

确保了cheerio返回非html实体编码,同时修复了hexo主页上emoji不能正常显示的问题
This commit is contained in:
CRIMX 2019-04-12 14:35:05 +08:00 committed by GitHub
commit 222ea40102
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -29,7 +29,8 @@ if (options.enable !== false) {
hexo.extend.filter.register('after_post_render', data => {
if (!options.inject && data['no-emoji']) { return data }
const $ = cheerio.load(data.content)
const $ = cheerio.load(data.content, {decodeEntities: false})
const excerpt = cheerio.load(data.excerpt,{decodeEntities: false})
if (options.inject) {
$('body').append(`<script>
@ -55,9 +56,11 @@ if (options.enable !== false) {
if (!data['no-emoji']) {
replaceColons($('body')[0], $, emojis)
replaceColons(excerpt('body')[0], excerpt, emojis)
}
data.content = $('body').html()
data.excerpt = excerpt('body').html()
return data
})