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 {
|
} 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
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue