【发布时间】:2019-06-04 13:27:55
【问题描述】:
我正在尝试根据使用 where_exp 的 id 从名为“内容”的集合中获取特定项目,但对于我来说,我无法让它工作。代码如下:
过滤器:
{% assign var = site.content | where_exp:"content", "content.id == 'testId'" | first %}
收藏中帖子的主要内容:
---
layout: content
title: "This is the title"
image: "assets/photos/image.jpg"
id: "testId"
---
html:
<img class="full-width-poto" src="{{ var.image }}">
我不知道我做错了什么。
注意,我一直在参考这篇文章:Getting a specific item from a collection in Jekyll 和 https://riptutorial.com/jekyll/example/28446/accessing-a-specific-collection-item
【问题讨论】: