This commit is contained in:
xaoxuu 2024-01-30 18:08:47 +08:00
parent a2f429a4e9
commit 48afb63f4c
3 changed files with 4 additions and 10 deletions

View File

@ -115,7 +115,7 @@ function layoutFooterDiv() {
el += ' onclick="' + item.onclick + '"';
}
el += '>';
el += item.icon;
el += icon(item.icon, 'no-lazy')
el += '</a>';
}
}

View File

@ -12,13 +12,7 @@ function layoutDiv() {
}
el += `>`
if (item.icon?.length > 0) {
if (item.icon.startsWith('<')) {
el += item.icon
} else if (theme.icons[item.icon]) {
el += theme.icons[item.icon]
} else {
el += `<img no-lazy src="${item.icon}">`
}
el += icon(item.icon, 'no-lazy')
} else {
el += `<span>${__(item.title)}</span>`
}

View File

@ -1,6 +1,6 @@
'use strict';
hexo.extend.helper.register('icon', function(key) {
hexo.extend.helper.register('icon', function(key, args) {
const { icons } = hexo.theme.config
var result = ''
if (icons[key]) {
@ -9,7 +9,7 @@ hexo.extend.helper.register('icon', function(key) {
result = key
}
if (result.startsWith('/') || result.startsWith('https://') || result.startsWith('http://')) {
return `<img src="${result}" />`
return `<img ${args?.length > 0 ? args : ''} src="${result}" />`
} else {
return result
}