feat: add CDN to load image resources

This commit is contained in:
XPoet 2020-11-27 09:31:10 +08:00
parent 6fc57659cb
commit 81a3cbea2a
2 changed files with 10 additions and 3 deletions

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('images/avatar.png') %>
</div>
<div class="info">
<div class="author">

View File

@ -72,7 +72,6 @@ hexo.extend.helper.register('__css', function (path) {
} else {
return _css(path);
}
});
hexo.extend.helper.register('__favicon_tag', function (path) {
@ -82,6 +81,14 @@ hexo.extend.helper.register('__favicon_tag', function (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);
}
});