refactor(addJs & addCss): forEach()

This commit is contained in:
curben 2019-08-30 07:40:29 +01:00
parent 503584a543
commit c282f06c76
No known key found for this signature in database
GPG Key ID: 5D9DB57A25D34EE3
2 changed files with 4 additions and 4 deletions

View File

@ -21,9 +21,9 @@ hexo.extend.helper.register('addCss', (...args) => {
} else { } else {
// New syntax // New syntax
let tmpResult = '<link rel="stylesheet"' let tmpResult = '<link rel="stylesheet"'
for (const attribute in item) { Object.keys(item).forEach(attribute => {
tmpResult += ` ${attribute}="${item[attribute]}"` tmpResult += ` ${attribute}="${item[attribute]}"`
} })
tmpResult += '>\n' tmpResult += '>\n'
result += tmpResult result += tmpResult
} }

View File

@ -21,10 +21,10 @@ hexo.extend.helper.register('addJs', (...args) => {
} else { } else {
// New syntax // New syntax
let tmpResult = '<script' let tmpResult = '<script'
for (const attribute in item) { Object.keys(item).forEach(attribute => {
if (item[attribute] === true) tmpResult += ' ' + attribute if (item[attribute] === true) tmpResult += ' ' + attribute
else tmpResult += ` ${attribute}="${item[attribute]}"` else tmpResult += ` ${attribute}="${item[attribute]}"`
} })
tmpResult += '></script>\n' tmpResult += '></script>\n'
result += tmpResult result += tmpResult
} }