sabrinaluo / hexo-theme-replica

:octocat:Github style replication for hexo theme
https://sabrinaluo.github.io/tech
MIT License
543 stars 67 forks source link

Errors occurred after run 'hexo s' #10

Closed lonelee-kirsi closed 7 years ago

lonelee-kirsi commented 7 years ago

The Errors

Unhandled rejection TypeError: D:\works\blog\github_pages\themes\replica\layout\index.ejs:1
 >> 1| <%
    2| var posts = page.posts.data;
    3| var oldestPostDate = posts.length ? posts[posts.length - 1].date : {date: moment()};
    4| var startFrom = oldestPostDate.format('MMM D, YYYY');

Cannot read property 'github' of undefined
    at eval (eval at compile (D:\works\blog\github_pages\node_modules\ejs\lib\ejs.js:549:12), <anonymous>:14:27)
    at returnedFn (D:\works\blog\github_pages\node_modules\ejs\lib\ejs.js:580:17)
    at _compiled (D:\works\blog\github_pages\node_modules\hexo\lib\theme\view.js:127:30)
    at View.render (D:\works\blog\github_pages\node_modules\hexo\lib\theme\view.js:29:15)
    at D:\works\blog\github_pages\node_modules\hexo\lib\hexo\index.js:390:25
    at tryCatcher (D:\works\blog\github_pages\node_modules\bluebird\js\release\util.js:16:23)
    at D:\works\blog\github_pages\node_modules\bluebird\js\release\method.js:15:34
    at RouteStream._read (D:\works\blog\github_pages\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)

Questions

sabrinaluo commented 7 years ago

Which version of Hexo did you use? Do you have the required social section in your _config.yml? If you don't have any link, you will still need to put below code snippet in your _config.yml

social:
  github: 
  weibo: 
  linkedin:
lonelee-kirsi commented 7 years ago
sabrinaluo commented 7 years ago

3.3.8 should be compatible. My blog is also using 3.3.8 with this theme, you may take a reference of the config file https://github.com/sabrinaluo/tech/blob/master/_config.yml

Can you provide your _config.yml file?

lonelee-kirsi commented 7 years ago

Should I configure it in root _config.yml instead of theme _config.yml?

I add the following code to root _config.yml and it works:

social:
  github: test
wywncdx commented 7 years ago

I have also found the same error. And I think when genarate the file, hexo read the var in the root _config file, but there is no var 'github'. And the solution is add the var 'github' in root _config as @lonelee-kirsi said.

sabrinaluo commented 7 years ago

@lonelee-kirsi @wywncdx yes, it should be in the root _config.yml file

I will update the template later, to make it work with both theme config and root config.

But please notice that if you have this setting in both theme config and root config, the root config will have higher priority and will override the one in theme config 😅

lonelee-kirsi commented 7 years ago

Thank you for your answer.