要設置場景,我的作者信息存儲在我的Jekyll _data文件夾內的directory.json中。比較來自不同Jekyll_data文件的數據
"name": "Brandon Bellew",
"bio": "Brandon Bellew is a great writer.",
"email": "[email protected]",
"specialties": "introspection, ventilation systems, memorization, post-prandial revelry",
"photo": "http://www.tpgweb2.net/headshots/thumbs/brandon-b-thumb-2.jpg"
我也存儲在catalogue.json文章,也是我的化身內_data文件夾
"name": "Beginner's Guide to Google Analytics",
"author": "Brandon Bellew",
"date": "May 18 2016",
"description": "The Google Analytics (GA) dashboard is quite intuitive, and it's easy to collect basic information (number of users on the site, average time spent on site, etc.) without having a deep background in analytics. But what about specifics?",
"category": "Analytics"
我通過我的catalogue.json文件,並顯示所有的文章試圖週期中文章信息,但從我的directory.json文件中的正確作者拉照片。
實質上,我試圖做的是:如果目錄中文章的「作者」與目錄項中作者的「名稱」匹配,則顯示與該作者相關的照片。這樣我就不必爲他們寫的每篇文章都將作者的照片另存爲一個單獨的項目。
這是我在目錄從正確的作者拉動照片失敗的嘗試:
<h4>Articles</h4>
{% for item in site.data.catalogue %}
{% for item in site.data.directory %}
{% if item.name == page.author %}
<img src="{{ item.photo }}" >
{% endif %}
{% endfor %}
{% endfor %}
使用傑基爾這是可能的,或者是有不同的方式,我需要構建呢?