hexo-theme-stellar/scripts/helpers/icon.js

17 lines
407 B
JavaScript
Raw Normal View History

2024-01-19 13:51:55 +08:00
'use strict';
2024-01-30 18:08:47 +08:00
hexo.extend.helper.register('icon', function(key, args) {
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://')) {
2024-01-30 18:08:47 +08:00
return `<img ${args?.length > 0 ? args : ''} src="${result}" />`
2024-01-19 13:51:55 +08:00
} else {
return result
}
})