From 92111f3c324e83edba545bca42d3a661905697d7 Mon Sep 17 00:00:00 2001 From: Jerry <16351105+jerryc127@users.noreply.github.com> Date: Mon, 27 Apr 2020 02:37:20 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20fix:=20=E4=BF=AE=E5=BE=A9=E7=95=B6menu?= =?UTF-8?q?=E6=B2=92=E8=A8=AD=E7=BD=AE=E5=9C=96=E6=A8=99=E6=99=82=EF=BC=8C?= =?UTF-8?q?=E6=9C=83=E5=A0=B1Cannot=20read=20property=20'trim'=20of=20unde?= =?UTF-8?q?fined=20=E7=9A=84bug=20:bug:=20fix:=20=E4=BF=AE=E5=BE=A9meta=20?= =?UTF-8?q?description=20=E8=87=AA=E5=8B=95=E7=94=9F=E6=88=90=E6=96=87?= =?UTF-8?q?=E7=AB=A0=E5=89=8D200=E6=96=87=E5=AD=97=E6=99=82=E9=83=A8?= =?UTF-8?q?=E5=88=86=E6=B2=92=E6=9C=89=E8=BD=89=E7=BE=A9=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- layout/includes/header/menu_item.pug | 9 ++++++--- scripts/helpers/page.js | 6 +++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/layout/includes/header/menu_item.pug b/layout/includes/header/menu_item.pug index 81c6f6c..983bcec 100644 --- a/layout/includes/header/menu_item.pug +++ b/layout/includes/header/menu_item.pug @@ -3,17 +3,20 @@ if !Array.isArray(value) .menus_item 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 else .menus_item 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]) i.fa.fa-chevron-down.menus-expand(aria-hidden="true") ul.menus_item_child each i in value li 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]) \ No newline at end of file diff --git a/scripts/helpers/page.js b/scripts/helpers/page.js index c6360d5..d877e28 100644 --- a/scripts/helpers/page.js +++ b/scripts/helpers/page.js @@ -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 } })