mirror of https://gitlab.com/curben/blog
refactor(addJs & addCss): forEach()
This commit is contained in:
parent
503584a543
commit
c282f06c76
|
@ -21,9 +21,9 @@ hexo.extend.helper.register('addCss', (...args) => {
|
|||
} else {
|
||||
// New syntax
|
||||
let tmpResult = '<link rel="stylesheet"'
|
||||
for (const attribute in item) {
|
||||
Object.keys(item).forEach(attribute => {
|
||||
tmpResult += ` ${attribute}="${item[attribute]}"`
|
||||
}
|
||||
})
|
||||
tmpResult += '>\n'
|
||||
result += tmpResult
|
||||
}
|
||||
|
|
|
@ -21,10 +21,10 @@ hexo.extend.helper.register('addJs', (...args) => {
|
|||
} else {
|
||||
// New syntax
|
||||
let tmpResult = '<script'
|
||||
for (const attribute in item) {
|
||||
Object.keys(item).forEach(attribute => {
|
||||
if (item[attribute] === true) tmpResult += ' ' + attribute
|
||||
else tmpResult += ` ${attribute}="${item[attribute]}"`
|
||||
}
|
||||
})
|
||||
tmpResult += '></script>\n'
|
||||
result += tmpResult
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue