在Jekyll 3.1.2 (和3.1.1)中,在post.html layout中,我想为上一个/下一个链接创建一个子类别中的帖子排序列表。当我知道类别的名称时,我让它在其他地方工作,但在派生类别名称时,我在将post附加到数组时遇到了问题。
给定一组包含以下内容的帖子:
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错误。
谢谢你的帮助,我不知所措。堆栈跟踪的第一行指向invoke方法中的liquid\strainer.rb。
编辑,更多信息:
会不会是它试图推送对象,而不是对它的引用?或者这是意料之中的..

发布于 2016-04-01 10:30:05
解决:错误实际上是排序中的几行。要修复此问题,请将要作为排序依据的属性添加到此类列表中:
assign sorted_list = sorted_list | sort: 'date'parkr considered this a bug。因此,在Jekyll 3.2中,DocumentDrops将默认按日期排序。
https://stackoverflow.com/questions/36217943
复制相似问题