wingjay / wingjay.github.io

blog for wingjay.
16 stars 12 forks source link

这个相关文章推荐板块有问题 #29

Open hoochanlon opened 6 years ago

hoochanlon commented 6 years ago

ERROR Cannot read property 'forEach' of undefined TypeError: Cannot read property 'forEach' of undefined at Object. (H:\blog\themes\next\scripts\related_posts.js:4:22)


hexo.extend.helper.register('related_posts', function(currentPost, allPosts){
    var relatedPosts = [];
    currentPost.tags.forEach(function (tag) {
        allPosts.forEach(function (post) {
            if (isTagRelated(tag.name, post.tags)) {
                var relatedPost = {
                    title: post.title,
                    path: post.path,
                    weight: 1
                };