如果我指定并插入页面的frontmatter,则可以显示数据。如果我指定它不会循环{% assign member = site.data.members[page.author] %}
author: valuehere
{% for member in site.data.members %} ~~~ {{ member.name }} ~~~ {% endfor %}
==成员.yml
attorney1:
birth_country: "United States of America"
birth_city: "Paso Robles"
birth_region: CA
birth_zip: 93446
birth_date: "05/1968"
education: "Southeastern University: B.A. History – 2008, University of Florida Levin College of Law: Juris Doctor – 2001"
image: attorney1.jpg
nationality: "United States of America"
name: "Attorney One Esq"
first_name: "Attorney"
last_name: "One"
honorary: Esquire
email: email@example.com
home_country: "United States of America"
home_city: "Ocala"
home_region: "FL"
home_zip: "34482"
gender: Male
permalink: "/lawyers/attorney1.html"
ext: "02"
practices: "Personal Injury · Insurance Litigation"
web: "Lawyer One Esq is a past member of the Hillsborough County Bar Association and Young Lawyers Division, the Lakeland Bar Association, and Emerge. Jon was also served on the Board of Directors for Tri-County Human services, which serves Polk, Hardee, and Highlands counties. Lawyer One Esq is currently a member of the Jacksonville Bar Association."
我试过像这样重新格式化数据文件:
- author: attorney1
name: "Attorney One"
~~~
然后像这样重新编码作者页面:
---
layout: attorney
title: "Attorney One"
crumbtitle: "Attorney One"
permalink: "/lawyers/attorney1.html"
jsontype: lawyer
genre: Law
headline: "Affordable Marion County Legal Representation"
author: attorney1
---
{% assign author = site.data.members | where: "author", "{{page.author}}" %}
<!-- Main -->
<article id="main">
<header class="special container">
<span class="icon fas fa-user-circle"></span>
<h2>About {{ author.name }}</h2>
{{ author.web | markdownify }}
</header>
<!-- One -->
目标是能够使用 for 循环并为作者页面提取数据。如果我像这样格式化数据文件:
attorney1:
name: "Attorney one"
作者页面使用{% assign author = site.data.members[page.author] %}
并打破了for循环。