mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-12 22:17:06 +08:00
🐛 fix: 修復當menu沒設置圖標時,會報Cannot read property 'trim' of undefined 的bug
🐛 fix: 修復meta description 自動生成文章前200文字時部分沒有轉義的bug
This commit is contained in:
@@ -3,17 +3,20 @@
|
|||||||
if !Array.isArray(value)
|
if !Array.isArray(value)
|
||||||
.menus_item
|
.menus_item
|
||||||
a.site-page(href=url_for(trim(value.split('||')[0])))
|
a.site-page(href=url_for(trim(value.split('||')[0])))
|
||||||
i.fa-fw(class=trim(value.split('||')[1]))
|
if value.split('||')[1]
|
||||||
|
i.fa-fw(class=trim(value.split('||')[1]))
|
||||||
span=' '+label
|
span=' '+label
|
||||||
else
|
else
|
||||||
.menus_item
|
.menus_item
|
||||||
a.site-page
|
a.site-page
|
||||||
i.fa-fw(class=trim(label.split('||')[1]) aria-hidden="true")
|
if label.split('||')[1]
|
||||||
|
i.fa-fw(class=trim(label.split('||')[1]) aria-hidden="true")
|
||||||
span=' '+ trim(label.split('||')[0])
|
span=' '+ trim(label.split('||')[0])
|
||||||
i.fa.fa-chevron-down.menus-expand(aria-hidden="true")
|
i.fa.fa-chevron-down.menus-expand(aria-hidden="true")
|
||||||
ul.menus_item_child
|
ul.menus_item_child
|
||||||
each i in value
|
each i in value
|
||||||
li
|
li
|
||||||
a.site-page(href=url_for(trim(i.split('||')[1])))
|
a.site-page(href=url_for(trim(i.split('||')[1])))
|
||||||
i.fa-fw(class=trim(i.split('||')[2]))
|
if i.split('||')[2]
|
||||||
|
i.fa-fw(class=trim(i.split('||')[2]))
|
||||||
span=' '+trim(i.split('||')[0])
|
span=' '+trim(i.split('||')[0])
|
||||||
@@ -8,16 +8,16 @@
|
|||||||
|
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const { stripHTML } = require('hexo-util')
|
const { stripHTML, escapeHTML } = require('hexo-util')
|
||||||
|
|
||||||
hexo.extend.helper.register('page_description', function () {
|
hexo.extend.helper.register('page_description', function () {
|
||||||
const { config, page } = this
|
const { config, page } = this
|
||||||
let description = page.description || page.content || page.title || config.description
|
let description = page.description || page.content || page.title || config.description
|
||||||
|
|
||||||
if (description) {
|
if (description) {
|
||||||
description = stripHTML(description).substring(0, 200)
|
description = escapeHTML(stripHTML(description).substring(0, 200)
|
||||||
.trim()
|
.trim()
|
||||||
.replace(/\n/g, ' ')
|
).replace(/\n/g, ' ')
|
||||||
return description
|
return description
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user