在Jekyll 3.1.2(和3.1.1)上,在post.html布局中,我想在子类别中为其上一个/下一个链接创建一个排序的帖子列表。当我知道类别的名称时,我在其他地方工作,但在导出类别名称时,我在将帖子附加到数组时遇到问题。
给出一组帖子:
categories:
- topics
- my-vacation
我正在post.html
布局中尝试创建排序列表:
{% if page.categories.first == 'topics' and page.categories.last != 'topics'
%}{% assign sorted_list = site.empty_array
%}{% for topic in site.categories.topics
%}{% if topic.categories.last == page.categories.last
%}{% assign sorted_list = sorted_list | push: topic
%}{% endif
%}{% endfor
%}{% assign sorted_list = sorted_list | sort
%}{% endif
%}
(配置中empty_array: []
)
但是我收到了这个错误:
Liquid Exception: Liquid error (line 16): comparison of Jekyll::Drops::DocumentDrop with Jekyll::Drops::DocumentDrop failed in _layouts/post.html
jekyll 3.1.2 | Error: Liquid error (line 16): comparison of Jekyll::Drops::DocumentDrop with Jekyll::Drops::DocumentDrop failed
第16行是推送到sorted_list
。如果我使用push: 'foo'
或push: page
我没有收到错误,但当然,这不是我想要的。当我尝试检查sorted_list时,出现inspected result must be ASCII
错误。
感谢您的帮助;我不知所措。堆栈跟踪中的第一行指向liquid\strainer.rb
方法中的invoke
。
编辑,更多信息:
可能是它试图推送对象而不是引用它吗?或者是预期的......
答案 0 :(得分:0)
解决:错误实际上是排序中的两行。修理, 将要排序的属性添加到此类列表中:
assign sorted_list = sorted_list | sort: 'date'
parkr considered this a bug。 所以在Jekyll 3.2中,DocumentDrops默认按日期排序。