直接打出类型是 function没问题。
就算出错了,静态文件也都正常生成了,不影响。
3| <body>
4| <%- partial('_chips/header') %>
>> 5| <% page.posts.each(function(item){ if(item.top){ %>
6| <div><%- item.title %></div>
7| <% }}); %>
8| <% page.posts.each(function(item){ if(!item.top){ %>
Cannot read property 'each' of undefined
所以應該先檢查一下page.posts吧
<%- typeof page.posts %>
<%- page.posts.length %>
object 10
检查过的
page.posts貌似是warehouse object, 試試
page.posts.toArray().each()
https://github.com/tommy351/warehouse/blob/master/test/scripts/document.js#L128-L145
1| <div id="container">
>> 2| <% page.posts.toArray().each(function(item){ if(item.top){ %>
3| <%- partial('_partial/archive', { item: item }) %>
4| <% }}); %>
5| <% page.posts.toArray().each(function(item){ if(!item.top){ %>
Cannot read property 'toArray' of undefined
toArray 之后还是有问题。
把基础ejs文件都加上就好了,ths
你好,我这边也遇到这个问题,在使用tag.ejs,categories的时候,也是报同样的错误,而且我打印出来,page.posts也是一个空值,目前我的解决方案是site.posts来调用全部文章,这是个什么情况啊??能问一下基础ejs是什么东西吗?
创建博客项目之后,里边默认的那些。好像有 archive.ejs, category.ejs, index.ejs, layout.ejs, page, post.ejs。不知道记得对不对。就是需要的全部弄好了之后,再去修改代码。开发哪个页面,再加会遇到上面的问题。
someone can speak english pls
@xuanvan229
I have a page "source/about/index.md" with "layout: index", and it is the cause. I can resolve the issue by removing the page or using the following setting
_config.yml
index_generator:
- path: ''
+ path: 'about'
If you still having the issue, can you attach your theme? Also do you have any page with layout: index or layout: archive?
Most helpful comment
someone can speak english pls