fix: fixed a bug where users could not use their own images

This commit is contained in:
XPoet 2020-11-30 18:25:40 +08:00
parent 12cd54d256
commit 3d47319a94
4 changed files with 8 additions and 21 deletions

View File

@ -14,6 +14,12 @@ style:
# Theme primary color
primary_color: '#0066CC'
# Avatar (You can use local image or image external link)
avatar: images/avatar.png
# Favicon (You can use local image or image external link)
favicon: images/logo.svg
# Image align position, value: left | center
img_position: left

View File

@ -23,7 +23,7 @@
<% } %>
<%= theme.base_info.title || config.title || 'Keep' %>
</title>
<%- __favicon_tag('images/logo.svg') %>
<%- favicon_tag(theme.style.favicon) %>
<%- css('css/style') %>
<%- __css('css/font-awesome.min.css') %>
<%- export_config() %>

View File

@ -8,7 +8,7 @@
<% if (theme.base_info.author || config.author) { %>
<div class="article-header">
<div class="avatar">
<%- __image_tag('images/avatar.png') %>
<%- image_tag(theme.style.avatar) %>
</div>
<div class="info">
<div class="author">

View File

@ -73,22 +73,3 @@ hexo.extend.helper.register('__css', function (path) {
return _css(path);
}
});
hexo.extend.helper.register('__favicon_tag', function (path) {
const _favicon_tag = hexo.extend.helper.get('favicon_tag').bind(hexo);
if (this.theme.cdn.enable) {
return `<link rel="icon" href="//cdn.jsdelivr.net/npm/hexo-theme-keep@${this.theme.version}/source/${path}">`
} else {
return _favicon_tag(path);
}
});
hexo.extend.helper.register('__image_tag', function (path) {
const _image_tag = hexo.extend.helper.get('image_tag').bind(hexo);
if (this.theme.cdn.enable) {
return `<img src="//cdn.jsdelivr.net/npm/hexo-theme-keep@${this.theme.version}/source/${path}">`
} else {
return _image_tag(path);
}
});