2024-01-19 13:51:55 +08:00
|
|
|
'use strict';
|
|
|
|
|
2024-01-20 13:35:43 +08:00
|
|
|
hexo.extend.helper.register('icon', function(key) {
|
2024-01-19 13:51:55 +08:00
|
|
|
const { icons } = hexo.theme.config
|
|
|
|
var result = ''
|
2024-01-20 13:35:43 +08:00
|
|
|
if (icons[key]) {
|
|
|
|
result = icons[key]
|
2024-01-19 13:51:55 +08:00
|
|
|
} else {
|
2024-01-20 13:35:43 +08:00
|
|
|
result = key
|
2024-01-19 13:51:55 +08:00
|
|
|
}
|
|
|
|
if (result.startsWith('/') || result.startsWith('https://') || result.startsWith('http://')) {
|
|
|
|
return `<img src="${result}" />`
|
|
|
|
} else {
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
})
|