mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-10 21:17:07 +08:00
🐛 fix: 修復當menu沒設置圖標時,會報Cannot read property 'trim' of undefined 的bug
🐛 fix: 修復meta description 自動生成文章前200文字時部分沒有轉義的bug
This commit is contained in:
@@ -8,16 +8,16 @@
|
||||
|
||||
'use strict'
|
||||
|
||||
const { stripHTML } = require('hexo-util')
|
||||
const { stripHTML, escapeHTML } = require('hexo-util')
|
||||
|
||||
hexo.extend.helper.register('page_description', function () {
|
||||
const { config, page } = this
|
||||
let description = page.description || page.content || page.title || config.description
|
||||
|
||||
if (description) {
|
||||
description = stripHTML(description).substring(0, 200)
|
||||
description = escapeHTML(stripHTML(description).substring(0, 200)
|
||||
.trim()
|
||||
.replace(/\n/g, ' ')
|
||||
).replace(/\n/g, ' ')
|
||||
return description
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user