This commit is contained in:
hwy0127@gmail.com
2019-06-17 21:25:18 +08:00
parent 79971d49db
commit 5a3363e0e4
37 changed files with 2955 additions and 418 deletions

View File

@@ -21,19 +21,17 @@ hexo.extend.helper.register('related_posts', function(currentPost, allPosts){
});
});
if (relatedPosts.length == 0) {return ''};
var result = '<div class="relatedPosts_headling"><i class="fa fa-thumbs-up" aria-hidden="true"></i><span>&nbsp;相關文章</span></div><div class="relatedPosts_list">';
var result = "";
var limit_num = hexo.theme.config.related_post.limit || 6
relatedPosts = relatedPosts.sort(compare('weight'));
for (var i = 0; i < Math.min(relatedPosts.length, 6); i++) {
var cover = relatedPosts[i].cover || hexo.theme.config.default_cover || data.melody.default_cover
result += '<div class="relatedPosts_item"><a href="/' + relatedPosts[i].path + '">';
for (var i = 0; i < Math.min(relatedPosts.length, limit_num); i++) {
var cover = relatedPosts[i].cover|| hexo.theme.config.default_cover|| data.butterfly.default_cover
result += '<div class="relatedPosts_item"><a href="/' + relatedPosts[i].path + '" title="' + relatedPosts[i].title +'">';
result += '<img class="relatedPosts_cover lozad" data-src="' + cover + '">';
result += '<div class="relatedPosts_title">' + relatedPosts[i].title + '</div>';
result += '</a></div>'
};
result += '</div>';
result += '<div class="clear_both"></div>';
// console.log(relatedPosts);
}; // console.log(relatedPosts);
return result;
});
hexo.extend.helper.register('echo', function(path){

View File

@@ -1,12 +1,12 @@
/**
* Note: configs in _data/melody.yml will replace configs in hexo.theme.config.
* Note: configs in _data/butterfly.yml will replace configs in hexo.theme.config.
*/
hexo.on('generateBefore', function () {
const rootConfig = hexo.config
if (hexo.locals.get) {
const data = hexo.locals.get('data')
data && data.melody && (hexo.theme.config = data.melody)
data && data.butterfly && (hexo.theme.config = data.butterfly)
}
hexo.theme.config.rootConfig = rootConfig
})