Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit problem #1

Open
anonimusprogramus opened this issue Jun 29, 2017 · 1 comment
Open

Limit problem #1

anonimusprogramus opened this issue Jun 29, 2017 · 1 comment

Comments

@anonimusprogramus
Copy link

  1. in _config.yml
jsonFeed:
  limit: 10
  name: 'custom'
  1. run hexo server, it will raise error
INFO  Start processing
FATAL Something's wrong. Maybe you can find the solution ...
TypeError: posts.splice is not a function
  1. what caused error is in index.js line 24
    if (config.limit) posts = posts.splice(0, config.limit);

  2. can be fixed by changing into this
    if (config.limit) posts = posts.limit(config.limit);

  3. run hexo server, now it's OK

Cheers :)

@sbanwart
Copy link

sbanwart commented Sep 1, 2017

I received the same error, but the above change didn't fix it for me. After poking around in the code for a bit, it looks like site.posts isn't an array, but some other type of object. It has a property named data that contains the array of posts. In order to fix the error, I changed line 24 to to this:

if (config.limit) posts = posts.data.splice(0, config.limit);

With this change, the error disappeared and I was able to verify that the JSON Feed file was successfully generated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants