huytd / azeroth-js

:beer: Yet another Static blog engine. Built with :heart: for Github
216 stars 52 forks source link

"node generator.js" encounter error,how to fix it? #3

Open luckypoem opened 8 years ago

luckypoem commented 8 years ago

hi.

root@AR:/usr/local/azeroth-js-site# node generator.js /usr/local/azeroth-js-site/generator.js:29 if (lines[lines.length - 6].indexOf('<meta') == 0) { ^

TypeError: Cannot read property 'indexOf' of undefined at /usr/local/azeroth-js-site/generator.js:29:35 at FSReqWrap.readFileAfterClose as oncomplete root@AR:/usr/local/azeroth-js-site#

thanks

huytd commented 8 years ago

Hi @luckypoem

Could you show me what's inside your posts folder? And what is the content of each files in it? A post should has the minimum format of:

# title

and the content
luckypoem commented 8 years ago

hi.

root@AR:/usr/local/azeroth-js-site# node generator.js /usr/local/azeroth-js-site/generator.js:29 if (lines[lines.length - 6].indexOf('<meta') == 0) { ^

TypeError: Cannot read property 'indexOf' of undefined at /usr/local/azeroth-js-site/generator.js:29:35 at FSReqWrap.readFileAfterClose as oncomplete root@AR:/usr/local/azeroth-js-site# cd posts root@AR:/usr/local/azeroth-js-site/posts# ls home.html home.md lorem-ipsum.html lorem-ipsum.md test-1.md root@AR:/usr/local/azeroth-js-site/posts# cat test-1.md

test1

this is test1. root@AR:/usr/local/azeroth-js-site/posts#

is the format of test-1.md not correct?

luckypoem commented 8 years ago

or my nodejs version is not ok?

root@AR:/usr/local/azeroth-js-site/posts# node -v v5.3.0 root@AR:/usr/local/azeroth-js-site/posts#

huytd commented 8 years ago

No 😄 your nodejs is ok.

The issue is what it say:

Cannot read property 'indexOf' of undefined

In this code:

if (lines[lines.length - 6].indexOf('<meta') == 0) {

Your file is just two lines, less than 6 lines, so the statement lines[lines.length - 6] should be lines[-4], and of course it's doesn't exist :D

We should have a null check for this one.

huytd commented 8 years ago

And the solution for you at this time is your post should be longer than 6 lines 😅

luckypoem commented 8 years ago

hi. it's ok now. and pagination is feasible?

huytd commented 8 years ago

We have to add the posts to home page manually at this time (by editting home.md). It's possible to generate the home page dynamically but I need to find sometime do do it :D

juancuiule commented 7 years ago

Hi, I'm willing to help, what do you actually wanna do?

huytd commented 7 years ago

Hi @juancuiule, thanks for interesting on this.

I think what need to be done here is:

This can be submitted as 2 separated Pull Request.

P/S: And if you gonna submit it before Monday, don't forget to put the hacktoberfest label to the pull request, heheh

juancuiule commented 7 years ago

Working on the second one

juancuiule commented 7 years ago

Partially done in PR #9