无法在 Jekyll 模板中分配工作位置
Cannot get assign where working in Jekyll template
我用 Jekyll 建立了我的网站。
数据文件在别处解析时工作正常,但当我尝试使用 where
子句访问特定记录时,我没有得到任何结果。
在 https://github.com/ohiweb/ohiweb.github.io
查看项目
麻烦的页面在portfolio\betimca\index.html
下
portfolio.yml
projects:
- name: "betimca"
title: "Betimca Subdivision Project"
description: "These beautiful houses in Betimca feature classical elements with modern conveniences. Brick facades are crafted with accents tht stand out for maximum curb appeal. Gables with generous windows allow maximum light to upstairs rooms and add to their distinguished character."
feature: "betimca_1a.jpg"
media: "portfolio/betimca"
images: [betimca_1a.jpg,betimca_1b.jpg,betimca_1c.jpg,betimca_2a.jpg,betimca_2b.jpg,betimca_3a.jpg,betimca_3b.jpg]
tags: ["portfolio", "new construction", "residential", "subdivision"]
index.html
{% assign project = site.data.portfolio.projects | where: "name", "betimca" %}
<section>
<div class="row">
<div class="col col-md-4">
<header class="page-header">
<h1>
{{project.title}}
</h1>
</header>
<p>{{project.description}}</p>
</div>
<div class="col col-md-6 col-md-offset-2">
<img src="/media/{{project.media}}/{{project.feature}}" class="img-responsive img-thumbnail">
</div>
</div>
<hr>
<div class="row">
{% for image in project.images %}
<div class="col col-xs-6 col-sm-4 col-lg-3">
<span class="thumbnail">
<img src="/media/{{project.media}}/{{image}}" alt="{{project.title}} {{image}}">
</span>
</div>
{% endfor %}
</div>
</section>
{% assign project = site.data.portfolio.projects | where: "name", "betimca" %}
这个 returns 一个只有一个元素的数组。
如果你想获取项目中的元素,你可以这样做:
{% assign project = site.data.portfolio.projects | where: "name", "betimca" | first %}
现在您的页面可以正常工作了。
我用 Jekyll 建立了我的网站。
数据文件在别处解析时工作正常,但当我尝试使用 where
子句访问特定记录时,我没有得到任何结果。
在 https://github.com/ohiweb/ohiweb.github.io
查看项目麻烦的页面在portfolio\betimca\index.html
下portfolio.yml
projects:
- name: "betimca"
title: "Betimca Subdivision Project"
description: "These beautiful houses in Betimca feature classical elements with modern conveniences. Brick facades are crafted with accents tht stand out for maximum curb appeal. Gables with generous windows allow maximum light to upstairs rooms and add to their distinguished character."
feature: "betimca_1a.jpg"
media: "portfolio/betimca"
images: [betimca_1a.jpg,betimca_1b.jpg,betimca_1c.jpg,betimca_2a.jpg,betimca_2b.jpg,betimca_3a.jpg,betimca_3b.jpg]
tags: ["portfolio", "new construction", "residential", "subdivision"]
index.html
{% assign project = site.data.portfolio.projects | where: "name", "betimca" %}
<section>
<div class="row">
<div class="col col-md-4">
<header class="page-header">
<h1>
{{project.title}}
</h1>
</header>
<p>{{project.description}}</p>
</div>
<div class="col col-md-6 col-md-offset-2">
<img src="/media/{{project.media}}/{{project.feature}}" class="img-responsive img-thumbnail">
</div>
</div>
<hr>
<div class="row">
{% for image in project.images %}
<div class="col col-xs-6 col-sm-4 col-lg-3">
<span class="thumbnail">
<img src="/media/{{project.media}}/{{image}}" alt="{{project.title}} {{image}}">
</span>
</div>
{% endfor %}
</div>
</section>
{% assign project = site.data.portfolio.projects | where: "name", "betimca" %}
这个 returns 一个只有一个元素的数组。
如果你想获取项目中的元素,你可以这样做:
{% assign project = site.data.portfolio.projects | where: "name", "betimca" | first %}
现在您的页面可以正常工作了。