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

hexo g 命令出现 page.tags.forEach is not a function #187

Closed
JerrySheh opened this issue Sep 23, 2019 · 5 comments
Closed

hexo g 命令出现 page.tags.forEach is not a function #187

JerrySheh opened this issue Sep 23, 2019 · 5 comments

Comments

@JerrySheh
Copy link

Hi,我拉了 master 分支,当执行 hexo g 命令时发现以下错误。我查阅了 issue 历史,发现 #100 有类似的错误,但 #100 把 each 改成 forEach ,似乎 forEach 也有问题。

我对前端不太熟悉,能帮忙看一下吗? 非常感谢。

ERROR E:\blog\themes\hexo-theme-matery\layout\post.ejs:26
    24|
    25|     <% if (isTocEnable) { %>
 >> 26|     <%- partial('_partial/post-detail-toc.ejs') %>
    27|     <% } else { %>
    28|     <%- partial('_partial/post-detail.ejs') %>
    29|     <% } %>

E:\blog\themes\hexo-theme-matery\layout\_partial\post-detail-toc.ejs:90
    88| <div class="row">
    89|     <div id="main-content" class="col s12 m12 l9">
 >> 90|         <%- partial('_partial/post-detail.ejs') %>
    91|     </div>
    92|     <div id="toc-aside" class="expanded col l3 hide-on-med-and-down">
    93|         <div class="toc-widget">

E:\blog\themes\hexo-theme-matery\layout\_partial\post-detail.ejs:9
    7|                     <% if (page.tags && page.tags.length) { %>
    8|                     <div class="article-tag">
 >> 9|                         <% page.tags.forEach(function(tag) { %>
    10|                             <a href="<%- url_for(tag.path) %>" target="_blank">
    11|                                 <span class="chip bg-color"><%= tag.name %></span>
    12|                             </a>

page.tags.forEach is not a function
TypeError: E:\blog\themes\hexo-theme-matery\layout\post.ejs:26
    24|
    25|     <% if (isTocEnable) { %>
 >> 26|     <%- partial('_partial/post-detail-toc.ejs') %>
    27|     <% } else { %>
    28|     <%- partial('_partial/post-detail.ejs') %>
    29|     <% } %>

E:\blog\themes\hexo-theme-matery\layout\_partial\post-detail-toc.ejs:90
    88| <div class="row">
    89|     <div id="main-content" class="col s12 m12 l9">
 >> 90|         <%- partial('_partial/post-detail.ejs') %>
    91|     </div>
    92|     <div id="toc-aside" class="expanded col l3 hide-on-med-and-down">
    93|         <div class="toc-widget">

E:\blog\themes\hexo-theme-matery\layout\_partial\post-detail.ejs:9
    7|                     <% if (page.tags && page.tags.length) { %>
    8|                     <div class="article-tag">
 >> 9|                         <% page.tags.forEach(function(tag) { %>
    10|                             <a href="<%- url_for(tag.path) %>" target="_blank">
    11|                                 <span class="chip bg-color"><%= tag.name %></span>
    12|                             </a>

page.tags.forEach is not a function
    at eval (eval at compile (E:\blog\node_modules\ejs\lib\ejs.js:618:12), <anonymous>:14:18)
    at returnedFn (E:\blog\node_modules\ejs\lib\ejs.js:653:17)
    at Theme._View.View._compiledSync.locals [as _compiledSync] (E:\blog\node_modules\hexo\lib\theme\view.js:119:22)
    at Theme._View.View.View.renderSync (E:\blog\node_modules\hexo\lib\theme\view.js:48:23)
    at Object.partial (E:\blog\node_modules\hexo\lib\plugins\helper\partial.js:34:15)
    at eval (eval at compile (E:\blog\node_modules\ejs\lib\ejs.js:618:12), <anonymous>:13:17)
    at returnedFn (E:\blog\node_modules\ejs\lib\ejs.js:653:17)
    at Theme._View.View._compiledSync.locals [as _compiledSync] (E:\blog\node_modules\hexo\lib\theme\view.js:119:22)
    at Theme._View.View.View.renderSync (E:\blog\node_modules\hexo\lib\theme\view.js:48:23)
    at Object.partial (E:\blog\node_modules\hexo\lib\plugins\helper\partial.js:34:15)
    at eval (eval at compile (E:\blog\node_modules\ejs\lib\ejs.js:618:12), <anonymous>:46:17)
    at returnedFn (E:\blog\node_modules\ejs\lib\ejs.js:653:17)
    at Theme._View.View._compiled.locals [as _compiled] (E:\blog\node_modules\hexo\lib\theme\view.js:123:48)
    at Theme._View.View.View.render (E:\blog\node_modules\hexo\lib\theme\view.js:29:15)
    at E:\blog\node_modules\hexo\lib\hexo\index.js:349:21
    at tryCatcher (E:\blog\node_modules\hexo\node_modules\bluebird\js\release\util.js:16:23)
    at E:\blog\node_modules\hexo\node_modules\bluebird\js\release\method.js:15:34
    at RouteStream._read (E:\blog\node_modules\hexo\lib\hexo\router.js:123:3)
    at RouteStream.Readable.read (_stream_readable.js:457:10)
    at resume_ (_stream_readable.js:933:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)
@blinkfox
Copy link
Owner

应该是你 Nodejs 版本比较低引起的吧。

@JerrySheh
Copy link
Author

升级了最新的 hexo 和 Nodejs,还是会报这个错。但是不影响使用,暂时先忽略了。感谢。

@JerrySheh
Copy link
Author

补充:最后我发现是 source 目录下, _post 目录之外的 page 文章不能有 tag 标签,去除后问题得到解决。

@LiZeC123
Copy link

补充:最后我发现是 source 目录下, _post 目录之外的 page 文章不能有 tag 标签,去除后问题得到解决。

感谢老哥提供的线索, 不然用二分法不知道调试到什么时候去了

@silencieuxzero
Copy link

我也遇到了这个问题,在删除tag之后恢复了,感谢老哥提供的帮助

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

4 participants