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
109 stars 14 forks source link

I am using next-theme, it is swig, how could i use your code into it? #4

Closed myjeshurun closed 6 years ago

myjeshurun commented 6 years ago

And could you please help me to find the right swig file i need to change? Thank you.

Before you submit your issue, please tell me your environment info. Also , if you occur ERROR Plugin load failed: , please reinstall hexo and npm as follows, for example.

$ nvm install v6.10.1
$ nvm use v6.10.1
$ npm install -g npm
$ npm install -g hexo-cli
$ hexo init hexo6101
$ cd hexo6101
$ npm install
$ npm install hexo-related-popular-posts --save

Also , if you occur DTraceProviderBindings.node error , please see issue#1. https://github.com/tea3/hexo-related-popular-posts/issues/1

For BUG

For question

just push question

For feature request

just push feature request

Environment Info

OS version

Node version(node -v)

v6.10.1

Your site _config.yml

# Hexo Configuration
...

Your theme _config.yml

# Hexo Configuration
...

Plugin version(npm ls --depth 0)

hexo-vanilla-site@0.0.0 ~/hexo-vanilla-site
├── hexo@3.1.1
├── hexo-generator-archive@0.1.4
├── hexo-generator-category@0.1.3
├── hexo-generator-index@0.2.0
├── hexo-generator-tag@0.2.0
├── hexo-renderer-ejs@0.1.1
├── hexo-renderer-marked@0.2.10
├── hexo-renderer-stylus@0.3.1
└── hexo-server@0.1.3
tea3 commented 6 years ago

@myjeshurun Hi , Thank you for using this plugin . Could you add code as follow ?

https://github.com/iissnan/hexo-theme-next/blob/master/layout/_macro/post.swig#L313

...
</div>

{{ popular_posts() }}

{#####################}
{### END POST BODY ###}
{#####################}
...

Please tell me whether this issue can be solved .

myjeshurun commented 6 years ago

Hello,

thank you for your help. I did as you told me. But an error occurs, here is the msg:

Unhandled rejection TypeError: Cannot read property 'tags' of undefined

at Object.module.exports.getList

(/Users/jeshurun/docs/hexo/node_modules/hexo-related-popular-posts/lib/list-json.js:127:22)

at module.exports

(/Users/jeshurun/docs/hexo/node_modules/hexo-related-popular-posts/lib/helper.js:7:31)

at Object.<anonymous>

(/Users/jeshurun/docs/hexo/node_modules/hexo-related-popular-posts/index.js:170:32)

at wrapper

(/Users/jeshurun/docs/hexo/node_modules/lodash/lodash.js:4968:19)

at Object._ctx.post_template.render (eval at <anonymous>

(/Users/jeshurun/docs/hexo/node_modules/swig/lib/swig.js:498:13),

:422:143) at Object.eval [as tpl] (eval at (/Users/jeshurun/docs/hexo/node_modules/swig/lib/swig.js:498:13), :821:1078) at compiled (/Users/jeshurun/docs/hexo/node_modules/swig/lib/swig.js:619:18) at _compiled (/Users/jeshurun/docs/hexo/node_modules/hexo/lib/theme/view.js:127:30) at View.render (/Users/jeshurun/docs/hexo/node_modules/hexo/lib/theme/view.js:29:15) at /Users/jeshurun/docs/hexo/node_modules/hexo/lib/hexo/index.js:390:25 at tryCatcher (/Users/jeshurun/docs/hexo/node_modules/bluebird/js/release/util.js:16:23) at /Users/jeshurun/docs/hexo/node_modules/bluebird/js/release/method.js:15:34 at RouteStream._read (/Users/jeshurun/docs/hexo/node_modules/hexo/lib/hexo/router.js:134:3) at RouteStream.Readable.read (_stream_readable.js:348:10) at resume_ (_stream_readable.js:737:12) at _combinedTickCallback (internal/process/next_tick.js:80:11) at process._tickCallback (internal/process/next_tick.js:104:9) Blessings in Christ, *Jeshurun* *我的仆人雅各,我所拣选的耶书崙哪,不要害怕!* *Don’t be afraid, Jacob my servant; and you, Jeshurun, whom I have chosen.* On Mon, Aug 7, 2017 at 3:46 AM, tea wrote: > Hi , Thank you for using this plugin . Could you add code as follow ? > > https://github.com/iissnan/hexo-theme-next/blob/master/ > layout/_macro/post.swig#L313 > > ... >
> > {{ popular_posts() }} > > {#####################} > {### END POST BODY ###} > {#####################} > ... > > Please tell me whether this issue can be solved . > > — > You are receiving this because you authored the thread. > Reply to this email directly, view it on GitHub > , > or mute the thread > > . >
tea3 commented 6 years ago

@myjeshurun I tried this plugin in the hexo-theme-next. hexo-theme-next and Swig seems to be a special case. In the new plug-in version, it have supported to hexo-theme-next. Please update this plugin and add the following code to the template.

  1. Update version
$ npm uninstall hexo-related-popular-posts --save
$ npm install hexo-related-popular-posts --save
  1. Add code

For example , Add popular_posts( {} , post ) to the following location. https://github.com/iissnan/hexo-theme-next/blob/master/layout/_macro/post.swig#L313

...
</div>

{{ popular_posts( {} , post ) }}

{#####################}
{### END POST BODY ###}
{#####################}
...

Please tell me whether this issue can be solved .

tea3 commented 6 years ago

@myjeshurun Sory , I forget to update npm version. I have updated 2.0.0 to 2.0.1 just before.

myjeshurun commented 6 years ago

yes. I did try. And it works:) Thank you so much! It is a great plugin.

Blessings in Christ,

Jeshurun 我的仆人雅各,我所拣选的耶书崙哪,不要害怕! Don’t be afraid, Jacob my servant; and you, Jeshurun, whom I have chosen.

On Tue, Aug 8, 2017 at 10:58 AM, tea notifications@github.com wrote:

@myjeshurun https://github.com/myjeshurun Sory , I forget to update npm version. I have updated 2.0.0 to 2.0.1 just before.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tea3/hexo-related-popular-posts/issues/4#issuecomment-320982655, or mute the thread https://github.com/notifications/unsubscribe-auth/AVdc3H2-e14VChul2IF2J6sX7-RpUcLwks5sWHejgaJpZM4OvBef .

swordspoet commented 6 years ago

It seems doesn't work on next themes

swordspoet commented 6 years ago

@myjeshurun Hi, I just visited your blog and there was not plugin, it doesn't work now?

myjeshurun commented 6 years ago

@swordspoet It works. But I chose another way :)

On Fri, Oct 27, 2017, 08:02 swordspoet notifications@github.com wrote:

@myjeshurun https://github.com/myjeshurun Hi, I just visited your blog and there was not plugin, it doesn't work now?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tea3/hexo-related-popular-posts/issues/4#issuecomment-339952476, or mute the thread https://github.com/notifications/unsubscribe-auth/AVdc3LVNINdSMzjtcZEBRjZqhzSJeKV5ks5swcZdgaJpZM4OvBef .

swordspoet commented 6 years ago

@myjeshurun I have followed your steps in next theme, it might miss some information or something else.