tea3 / hexo-related-popular-posts

A hexo plugin that generates a list of links to related posts and popular posts. Also , this plugin can get Visitor Counts (PV) on posts.
MIT License
111 stars 15 forks source link

Cannot read property 'tags' of undefined #6

Closed ghostssura closed 7 years ago

ghostssura commented 7 years ago

I'm trying to use this with the Hexo Theme Phantom but this error keeps appearing.

Unhandled rejection TypeError: /Users/jackiechong/Garden/business/test/themes/phantom/layout/post.ejs:1
 >> 1| <%- partial('_partial/article-full', {item: page}) %>

/Users/jackiechong/Garden/business/test/themes/phantom/layout/_partial/article-full.ejs:22
    20| <%- item.content %>
    21|
 >> 22| <%- popular_posts() %>
    23|
    24| <!-- Tags -->
    25| <%- partial('article-tags') %>

Cannot read property 'tags' of undefined
    at Object.module.exports.getList (/Users/jackiechong/Garden/business/test/node_modules/hexo-related-popular-posts/lib/list-json.js:129:20)
    at module.exports (/Users/jackiechong/Garden/business/test/node_modules/hexo-related-popular-posts/lib/helper.js:7:31)
    at Object.<anonymous> (/Users/jackiechong/Garden/business/test/node_modules/hexo-related-popular-posts/index.js:170:32)
    at Object.wrapper [as popular_posts] (/Users/jackiechong/Garden/business/test/node_modules/lodash/lodash.js:4968:19)
    at eval (eval at compile (/Users/jackiechong/Garden/business/test/node_modules/ejs/lib/ejs.js:549:12), <anonymous>:50:17)
    at returnedFn (/Users/jackiechong/Garden/business/test/node_modules/ejs/lib/ejs.js:580:17)
    at Theme._View.View._compiledSync (/Users/jackiechong/Garden/business/test/node_modules/hexo/lib/theme/view.js:122:20)
    at Theme._View.View.View.renderSync (/Users/jackiechong/Garden/business/test/node_modules/hexo/lib/theme/view.js:50:21)
    at Object.partial (/Users/jackiechong/Garden/business/test/node_modules/hexo/lib/plugins/helper/partial.js:42:17)
    at Object.wrapper [as partial] (/Users/jackiechong/Garden/business/test/node_modules/lodash/lodash.js:4968:19)
    at eval (eval at compile (/Users/jackiechong/Garden/business/test/node_modules/ejs/lib/ejs.js:549:12), <anonymous>:9:17)
    at returnedFn (/Users/jackiechong/Garden/business/test/node_modules/ejs/lib/ejs.js:580:17)
    at Theme._View.View._compiled (/Users/jackiechong/Garden/business/test/node_modules/hexo/lib/theme/view.js:127:30)
    at Theme._View.View.View.render (/Users/jackiechong/Garden/business/test/node_modules/hexo/lib/theme/view.js:29:15)
    at /Users/jackiechong/Garden/business/test/node_modules/hexo/lib/hexo/index.js:390:25
    at tryCatcher (/Users/jackiechong/Garden/business/test/node_modules/bluebird/js/release/util.js:16:23)
    at /Users/jackiechong/Garden/business/test/node_modules/bluebird/js/release/method.js:15:34
    at RouteStream._read (/Users/jackiechong/Garden/business/test/node_modules/hexo/lib/hexo/router.js:134:3)
    at RouteStream.Readable.read (_stream_readable.js:445:10)
    at resume_ (_stream_readable.js:825:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)

Is there something I'm missing or am I placing it in the wrong file? Can't find anything on the error.

tea3 commented 7 years ago

@ghostssura hexo-theme-phantom seems to have the same issue as #4 . Please change the following code to the themes/hexo-theme-phantom/layout/_partial/article-full.ejs.

...
<!-- Content -->
<%- item.content %>

<%- popular_posts( {} , item ) %>

<!-- Tags -->
<%- partial('article-tags') %>
...
ghostssura commented 7 years ago

That did it! Thanks @tea3.